I'm working on Android/iOS apps for an IOT peripheral that is sending BLE data. Both apps are actually working quite nicely with the physical peripheral device (which is using the Texas Instrument's BLE library).
Now that the actual peripherals are working, I'm trying to write an emulator with Bleno so the dev team can be more efficient, but am running into issues transmitting a static string value for a characteristic.
I'm setting up my characteristic like this:
var bleCharacteristic = function() {
bleCharacteristic.super_.call(this, {
uuid: '0321',
properties: ['read'],
value: new Buffer('12345'),
});
};
Bleno says that I have to use a node.js buffer to send string data, but on both Android and IOS, the received data is not 12345
, but rather something like this:
{
value: '3031333031383133303630303864666234643030323030333065303332656530313330313831333036303,
}
Thoughts on why this might be happening? Is there some other advertisement data that I'm forgetting to set in the emulator so that the value comes back as expected?
Here's an example of how I am reading the payload value. This is from our Android app:
@Override
public void onCharacteristicRead(final BluetoothGatt gatt, final BluetoothGattCharacteristic characteristic, int status) {
...
String payload = bytesToHex(characteristic.getValue());
...
}
NOTE: Let me know if there is any other relevant code that I can post.
Your characteristic setup looks fine. Although I know nothing about Android, in iOS, you should be able to get the value by calling this.
You can also use BLE utility apps like LightBlue to explore your characteristics.