How to handle Data from Bluetooth in Console application

I have a C# console application that I want to use to read data from the Meadow microcontroller.

I followed these instructions from Microsoft: Bluetooth GATT-Client - UWP applications | Microsoft Docs

I have everything working from connecting to the device to getting all services and characteristics only until I need to process the received data / value of my characteristic. Currently I want to read only one Int32.

This is my Bluetooth characteristic:

intCharacteristic = new CharacteristicInt32(
                name: "My Number",
                uuid: "017e99d6-8a61-11eb-8dcd-0242ac1300bb",
                permissions: CharacteristicPermission.Write | CharacteristicPermission.Read,
                properties: CharacteristicProperty.Write | CharacteristicProperty.Read
                );

How i set its value:

int testInt = 111;
intCharacteristic.SetValue(testInt);

Part of my console application where i am stuck:

GattReadResult result = await selectedCharacteristic.ReadValueAsync();
if (result.Status == GattCommunicationStatus.Success)
{
    var reader = DataReader.FromBuffer(result.Value);
    byte[] input = new byte[reader.UnconsumedBufferLength];
    reader.ReadBytes(input);
    
    //This is where i am stuck, I tried the following but it does not return my actual integer
    int i = BitConverter.ToInt32(input, 0);
    Console.WriteLine("int: {0}", i);
}

input array includes the following:

[0] = 248
[1] = 255
[2] = 253
[3] = 63

I don´t really understand how those values are sent by the Meadow.

I think I understand your use case - give me a little time and I’ll create a more complete BLE sample app that covers this usage.

Hey Chris, thanks for your answer. All the current examples regarding Bluetooth are Xamarin apps that use the BLE Plugin/Nuget packed for communication with the device. I don´t want to use this plugin but rather the “plain” c# like in the microsoft documentation.