Android Question Writing hex bytes to DSD relay board via BLE

air cover

Member
Licensed User
This example code: https://www.b4x.com/android/forum/threads/ble-2-bluetooth-low-energy.59937/#content
successfully scans for BLE devices and finds my DSD relay board, then successfully connects to it.

That code then fails when writing to the DSD board via BLE.

Understanding that sample program is taking some effort. An Index is being passed to some routines wherein a .get function is used, but it isn't intuitively obvious why copying that code to a new subroutine generates compile errors for an object not being initiated, but that's not really my question.

What I'd love to know is how to make a Button_click write a hex byte to my DSD relay board via BLE. Something extraordinarily simple, one would hope.

I did extensive forum searches and they all came back to that BLE2 sample code or bluetooth chat code (obviously I need BLE).

What I was hoping to find was a simple program that wrote hex bytes via BLE so that I could just tweak that code. Oy vey. Search after search.
 

air cover

Member
Licensed User
Nevermind. I got it. Not pretty, but the answer is to write a byte array to the DSD board. If you are using the BLE coding example from the b4x forum, then:

manager.WriteData("0000ffe0-0000-1000-8000-00805f9b34fb","0000ffe1-0000-1000-8000-00805f9b34fb", Array As Byte(0xA0, 0x01, 0x00, 0xA1)) 'Turns off DSD Relay #1


Also, a few points because we are dealing with BLE:
My T-Mobile Android 9 Samsung a10e phone had to do a T-Mobile software update and power-off reboot before the BLE sample program would connect with it to the DSD board via BLE.

Well, actually, it connected 1 time, then never again... until the upgrade and reboot.

Oh, and it wouldn't do BLE when the phone was below 30% charged.

Each of the above generated errors.
 
Last edited:
Upvote 0
Top