I was successful in sending ASCII chars from the Evothings app to the Microduino-BT/HM-10 with the
Arduino LED On/Off BLE example. I had to first change the code of
index.html starting at line 92 so that it would connect specifically to my BLE device. Just FYI, the default name of the HM-10 is "HMSoft" but I changed that to "HMSoft531" to indicate this particular device has been flashed with the latest firmware, v5.31.
Code: Select all
evothings.arduinoble.connect(
'HMSoft531', // Name of BLE shield. << was 'arduinoble'
function(device)
{
app.device = device;
app.showMessage('Connected! Touch buttons to turn LED on/off.');
},
function(errorCode)
{
app.showMessage('Connect error: ' + errorCode + '.');
});
Next, I needed to edit
arduinoble.js to write to the proper characteristic of the HM-10 (
0xffe1), starting at line 97,
Code: Select all
device.writeDataArray = function(uint8array)
{
device.writeCharacteristic(
'0000ffe1-0000-1000-8000-00805f9b34fb', // << was '713d0003-503e-4c75-ba94-3148f18d941e'
uint8array,
function()
{
console.log('writeCharacteristic success');
},
function(errorCode)
{
console.log('writeCharacteristic error: ' + errorCode);
});
};
Lastly, I had to change the write command to send the specific value I wanted to send. Starting from line 66 of
index.html,
Code: Select all
app.ledOn = function()
{
app.device && app.device.writeDataArray(new Uint8Array([102])); // '102' is ASCII char 'f', value was '1'
}
I also figured out I could transmit multiple chars/bytes at once since the HM-10 can send up to 20 bytes at a time (per the BLE specification). I simply separated the bytes in the array by commas. For example to send the ASCII string 'fgh' I would send
Uint8Array([102,103,104]).
I am now trying to set up bi-directional communication between the app and the peripheral. However, in the
Arduino BLE example, specifically
app.js, it is written based on the peripheral having separate characteristics for write and read, whereas the HM-10 seems to only have one for both (
0xffe1 is the only characteristic of service 0xffe0 advertised). I will continue to work on that but, again, any hints would be most appreciated.
Thanks,
Don