-
Thank you @Gordon!! That was it! And thanks for forwarding the other issue, I did a search on the forums for BLE Error 11 and I get no hits (not even this post).
And @fanoush... thank you too! You have inspired me to order both an F07 and a DK08 to flash into Espruinos. I'm trying to work up the courage to make a build for PineTime. It's been a LONG time since i've worked at device level (hence my preference for JS on MCUs) but you've done considerable heavy lifting already. I've learned a lot from you both!
-
Hey all, I'm a little lost here. My Bangle is running a watchface that is listening on a specific UUID for short strings to act as notifications (not BLE notifications, just messages). The Bangle code works fine, and I can access it from both a Web Bluetooth page and a DroidScript app. However, I can't get my puck to send the message properly. Here is the Bangle (peripheral) code snippet:
var BLEMessage = ""; NRF.setServices({ "feb10001-f00d-ea75-7192-abbadabadebb": { "feb10002-f00d-ea75-7192-abbadabadebb": { value : [0], maxLen : 20, writable : true, onWrite : function(evt) { let str = stringFromArray(evt.data); if(str === "__EOM__") { if(BLEMessage) { showMsg('Message',BLEMessage); } else { reload(); scheduleAlarms(); showMsg('', 'Reloading...'); } BLEMessage = ''; } else { BLEMessage += str; } } } } }, { });
The showMsg() function is defined and works fine (just draws a dialog box and writes the string to screen).
Here is the Puck code (mostly thanks to Gordon's BLE example):
const primaryServiceUuid = 'feb10001-f00d-ea75-7192-abbadabadebb'; const sendCharUuid = 'feb10002-f00d-ea75-7192-abbadabadebb'; let device, sendCharacteristic; const split20 = (msg) => { let chunks = []; while(msg.length > 20) { chunks.push(msg.substr(0, 20)); msg = msg.substr(20); } if(msg.length) chunks.push(msg); return chunks; }; var msgToSend = "FOO!"; var logMsg = ''; function logD() { require("Storage").write('logMsg.txt', logMsg); } function sendMsg() { var gatt; NRF.requestDevice({ filters: [{ namePrefix: 'Bangle' }] }) .then(function(device) { logMsg += "Found\n"; digitalPulse(LED2,1,10); return device.gatt.connect(); }).then(function(g) { logMsg += "Connected\n"; digitalPulse(LED3,1,10); gatt = g; return g.getPrimaryService(primaryServiceUuid); }).then(function(service) { logMsg += "got PS\n"; return service.getCharacteristic(sendCharUuid); }).then(function(characteristic) { logMsg += "Got char\n"; sendCharacteristic = characteristic; return sendCharacteristic.writeValue(toArrBuf(myMessage)); }).then(function() { logMsg += "Sending: " + JSON.stringify(toArrBuf(myMessage)); return sendCharacteristic.writeValue( toArrBuf('__EOM__')); }).then(function() { digitalPulse(LED2,1,[10,200,10,200,10]); gatt.disconnect(); logMsg += "Done!\n"; logD(); busy=false; }).catch(function(e) { digitalPulse(LED1,1,10); logMsg += e.toString()+"\n"; busy=false; logD(); }); } setWatch(sendMsg, BTN, {edge:"rising", debounce:50, repeat:true});
Which works fine in an HTML page using "let NRF = navigator.bluetooth;"
I'm writing my log to a file since console is disabled when I run this, and the file reads:Found Connected BLE error 0x11 (BUSY)
As i said, I know the Bangle code works, been using it for weeks. The Puck code runs in a browser just fine. Which device is "BUSY"?? Any help appreciated!
Hope someone is still checking this thread. I am considering ordering two of these (https://smartcare.en.alibaba.com/product/60602047741-819857284/Special_Memory_Lcd_Smart_Watch_Heart_Rate_Fitness_Wristband_Ios_wholesales_Fitness_Tracker_Touch_Screen_Sleep_Tracker.html?spm=a2700.shop_plgr.41413.10.2f735091VSZpkM), but I'm not 100% sure it's the same device! My questions are:
I am a long time tech guy, but haven't done a cross-compile in eons.