bt_nus_send data type

I'm sending a short data string from a NUS application. For some reason I cannot read the data as bytes, only string, even if the sent array is uint8_t.

Is there a specifier for the service as to what data type it sends? I couldn't find anything.

Cheers

Parents Reply
  • That's what I did at first. Sent a char array buffer. But it can only be received as string, not as bytes.

    Now, I'm trying to receive the bytes with MITs  app inventor, and there I need to resister to a certain data type. For some reason only registering for strings works. If I register for bytes I get nothing. This made me wonder if the NUS service tells the master "hey, I'm sending a string" and If so, how to change it

Children
  • Dear.

    For me it hard to understand what is wrong. When you send data there are no String, no char, no int etc... There are numbers from 0 to 255. And recieve side decide how to parse this number data

    Please share your code for understanding

  • I also cannot understand what's wrong. I am now suspecting that something's wrong with MIT's App Inventor API. I can register and receive data as string, and as shorts (16bit), but cannot get the data as byte or integers.

    Whatever. I'm receiving the data as 16bit shorts and compose from two short a long if needed, or decompose to two bytes.

    Unless someone knows of a type that BLE advertises for master, I don't think there's anything to ask here.

    Thanks!

  • Hello matangk,

    I am not familiar with the MIT Inventor App myself, but I too would find it strange if it was only able to display data received as strings.

    matangk said:
    Unless someone knows of a type that BLE advertises for master, I don't think there's anything to ask here.

    I am not sure what you are asking about here, but as qwertynoon said it is all just bytes being transferred which will depend on the receiver to decode them correctly.
    There is also no advertising going on from the central device (if this is what you meant by 'master') - they only scan for advertisements sent by peripheral devices.
    You phone would be the central device in the case you describe, most likely.

    Best regards,
    Karl

Related