Skip to content

I can not send data with writeCharacteristics #149

@ltobiomynuvola

Description

@ltobiomynuvola

Hello everybody,

I have a bluethooth device (HM10) that receives an 'a' as a test, but I do not know how to send this string as an array buffer.

The device connects, the problem is the sending of this data

This is my code:

`
var service = evothings.ble.getService(app.device, app.SERVICE_UUID);
var characteristic = evothings.ble.getCharacteristic(service, app.CHARACTERISTIC_UUID);
app.display(JSON.stringify(characteristic));

    var data = new Uint8Array(1);
    data[0] = 'a';
    evothings.ble.writeCharacteristic(
    app.device,
    characteristic,
    data, // Buffer view with data to write
    function()
    {
        app.display('characteristic written');
    },
    function(errorCode)
    {
        app.display('writeCharacteristic error: ' + errorCode);
    });

`

NOTE:

I have also sent:

'a' binary
var data = new Uint8Array(8);
data[0] = '0';
data[1] = '1';
data[2] = '1';
data[3] = '0';
data[4] = '0';
data[5] = '0';
data[6] = '0';
data[7] = '1';

'a' Hexa
var data = new Uint8Array(2);
data[0] = '6';
data[1] = '1';

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions