Bluz Noble Communication


#1

I am trying to build a gateway on pi using the noble libraries. I intend to have the Bluz chip send three digits representing temperature data to the gateway. Right now I am testing communication by having the Bluz chip just sending out a two byte array (uint8_t rsp[2] = {‘H’,‘i’}) in its loop without a callback and I am trying to read this data and print it out on the PI. I am currently able to connect and read data from the chip via its TX characteristic but I am not sure if its the right data being read. My question put simply in two parts are: 1) How do I send out a simple array of bytes without a callback on the Bluz chip? 2) How do I read the data back to it’s original format on js using the noble library? Any help will be appreciated thanks.


#2

Following up on this. I somehow managed to get it to send the characters by reading data from the other characteristic
’871e022538ff77b1ed419fb3aa142db2’ and also I changed the array to (uint8_t rsp[3] = {‘H’,‘i’,‘t’}). I will now try to transmit more complex data to see if it still works.


#3

Are you basing this off the gateway that @mumblepins wrote? It is here: https://github.com/mumblepins/bluz-gateway

I think this handles most of the cases you are looking at, so perhaps there is already the answer in there


#4

Thank you for the reply. Yeah I have looked at his but it goes beyond the scope of what I wish to implement. I do not want cloud connection. I just wish to receive and read bytes from the Bluz chip sort of like a Bluetooth serial monitor system. I think my problem (for now) was that I used the wrong characteristic.


#5

There are two characteristics, one for sending data down and one for receiving data up. So yes, it is easy to confuse the two.


#6

Hi continuing this thread, I am trying to get noble to talk back to the bluz chip. I am writing one byte of data ([0x01]) to on the write characteristic (‘871e022538ff77b1ed419fb3aa142db2’) via noble and noble confirms this is successful. I set the bluz chip to flash the led on D7 whenever it receives any data from noble but it does not work. I am using the example code provided in the bluz documentation for the data callback handler but instead of setting the ‘sendData’ variable and sending ‘HI’ to true it should just flash the LED on D7. Can I please get some help on this? I can post my codes if needed. Thanks.


#7

Sending raw Bluetooth data requires a bit more. Every stream of data that goes to bluz has to start with a basic header and end with a single packet that denotes end of stream.

So what you need to do is add the header for custom data service, which is 0x04, to the data you are sending, and then send a second packet of [0x03, 0x04].

So you should send two packets, the first should be [0x04, 0x01] and then follow that with [0x03, 0x04].


#8

That worked perfectly. Thank you very much.