J JTolhurst Member Licensed User Longtime User May 3, 2016 #1 Hi, I have been having a play with the B4A BLE example. I can connect to my bluetooth device and see some basic information about numerous services and characteristics. I have a service which I am interested in: 0000ffe0-0000-1000-8000-00805f9b34fb which has a characteristic: 0000ffe1-0000-1000-8000-00805f9b34fb which has attributes: read, write without response, notify. The protocol I am interested in requires that communication is always started by the Android device writing to the characteristic. The answers are "notified" by the bluetooth device varying the value of the characteristic. The commands and answers are packets with the following structure: x55 xAA len x09 x01 com ... ck0 ck1 where: ... Are a UInt8 array of l-2 elements ck0, ck1 are a checksum computed from the elements from l to the last of ... x55 and xAA are fixed and are Beggining of buffer len is the size of ... + 2 x09 and x01 are fixed com is a command or variable. How would I go about writing this kind of packet to the characteristic, and then receiving the response (which can sometimes be spread over more than one packet)? Many Thanks
Hi, I have been having a play with the B4A BLE example. I can connect to my bluetooth device and see some basic information about numerous services and characteristics. I have a service which I am interested in: 0000ffe0-0000-1000-8000-00805f9b34fb which has a characteristic: 0000ffe1-0000-1000-8000-00805f9b34fb which has attributes: read, write without response, notify. The protocol I am interested in requires that communication is always started by the Android device writing to the characteristic. The answers are "notified" by the bluetooth device varying the value of the characteristic. The commands and answers are packets with the following structure: x55 xAA len x09 x01 com ... ck0 ck1 where: ... Are a UInt8 array of l-2 elements ck0, ck1 are a checksum computed from the elements from l to the last of ... x55 and xAA are fixed and are Beggining of buffer len is the size of ... + 2 x09 and x01 are fixed com is a command or variable. How would I go about writing this kind of packet to the characteristic, and then receiving the response (which can sometimes be spread over more than one packet)? Many Thanks
Erel B4X founder Staff member Licensed User Longtime User May 4, 2016 #2 Start with: Code: Copy Dim b() As Byte = Array As Byte(0x55, 0xAA, 3, 0x09, 0x01, com, 1, 2, 3, ck0, ck1) [code] Which type of checksum is used? You should call Write and then call Read in the WriteCompleted event. Upvote 0
Start with: Code: Copy Dim b() As Byte = Array As Byte(0x55, 0xAA, 3, 0x09, 0x01, com, 1, 2, 3, ck0, ck1) [code] Which type of checksum is used? You should call Write and then call Read in the WriteCompleted event.