Send raw byte array over BLE

Posted on
  • I'm using a MDBT42.

    I have an iphone app which connects over BLE and can receive data from the MDBT42 over UART.
    On the MDBT42 I use the print statement to send a load of byte in ASCII format, i.e. I send literal 'FF' for 255. In the iphone app I have to decode the ASCII characters received to generate a byte array which is then decoded again into a set of glucose readings.

    This all works fine, but there must be a better way to send just a big byte array without having to decode ASCII characeters in the iphone app.

    Any ideas? I'm sure I've missed something obvious here.

    Thanks,
    Marco

  • Sun 2019.06.16

    Hello @user97106,

    'I send literal 'FF' for 255'

    Besides Octal, Hex is the next step up from just sending Binary! Not sure I really understand where the connection is missed? BCD - Binary Coded Decimal?

    Javascript is on the send side, whereas Java in on the receive side. So sending hex data as you are, seems the best route for language compatibility. Isn't sending a lightweight payload a goal here?



    There are many excellent tutorials within the MDBT42Q web page:

    http://www.espruino.com/MDBT42Q
    http://www.espruino.com/BLE+Communications

    Short of that I used our old friend Google with the 'site:' keyword qualifier:

    Google:    how to send an array of data over ble site:espruino.com

    https://www.espruino.com/Reference#t_l_NRF_setAdvertising

    and an example that was posted in the forum with corresponding source code:

    http://forum.espruino.com/conversations/306687/


    re: 'without having to decode ASCII characeters (sic) in the iphone app'

    Consider sending an encoded Json packet?    Base64 encoding?


    As a suggestion, post both sides of the communication as it exists now, so that we may better understand where the current thinking is.

  • You might find that Bluetooth.write([33,34,35,etc]) is what you want? That skips out any of the 'string handling' and REPL stuff that print does.

  • Aha, that's what I was looking for. Thanks.

  • Mon 2019.06.17

    'You might find that Bluetooth.write([33,34,35,etc]) is what you want? '

    Good afternoon @Gordon,

    Where are the Espruino Bluetooth class function definitions or Espruino master class (sub class?) references, so that one may discover the allowable function signatures? Is this documentation in process perhaps?

    http://www.espruino.com/Reference#Bluetooth

    The only reference I found to Bluetooth.println() is in

    https://www.espruino.com/Web%20Bluetooth

  • If you type 'Bluetooth' into the search box you get the bluetooth global: http://www.espruino.com/Reference#l__global_Bluetooth

    It says Instance of Serial and if you click that you get http://www.espruino.com/Reference#Serial which shows you all the stuff you can do with it

  • Thanks for that tidbit @Gordon.

    While I'll agree the text 'Instance of Serial' is there, one has to 'actually' get there in the first place.

    For what it's worth, I was searching down the left side 'Contents' hyperlinks and never saw the link for (only) 'Bluetooth'. Making the connection for 'global Bluetooth' in the search box isn't that intuitive, for me anyway.

  • I was searching down the left side 'Contents' hyperlinks

    I know, but if I put all the global variables in there the list would be so long you wouldn't find anything!

    Basically there's just too much information in that one file now - I don't see much of a way around it apart from using the search box.

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

Send raw byte array over BLE

Posted by Avatar for user97106 @user97106

Actions