Most recent activity
-
Your new firmware exhibits broadly the same behaviour. It disconnects after just under a second (about 0.93 seconds now, but I'm not sure if that's because of the new firmware or because I was messing with
NRF.setConnectionInterval()
earlier).I let it try over 100 times and it didn't work even once.
-
Thanks @fanoush I will give that a go.
For now I have found the most success by writing the sensor values into the "manufacturer data" field, and using
NRF.findDevices
to discover the manufacturer data. Since I only need one-way communication this will probably be good enough for me, but I'll give the firmware a try as it would obviously be better if it worked properly. -
Thanks for the suggestion. I tried
NRF.setConnectionInterval(50)
on both the Bangle.js 1 and 2 and it didn't make any obvious improvement.I have had some success in making the ESP32 connect to the Bangle.js and draw the sensor readings on the screen. This seems more reliable than the other way around, but still quite unreliable. It does seem to work well once it's connected, but getting it connected can take a minute or 2. And again it's much worse on Bangle.js 2 than on the original Bangle.js, I haven't got it to work at all with the Bangle.js 2.
-
Aha,
service.startNotifications()
was helpful, thanks.Sadly I've already built the device that has an ESP32-C3 potted inside it so it's inconvenient to change. Since it was working with
gatttool
I assumed it wouldn't be too much trouble to use it with a Bangle.js.I wrote a Bangle.js program that keeps retrying to connect until it works, but sometimes it takes several minutes to get a working connection even with the original Bangle.js (and it has still not worked even once on the Bangle.js 2). But it does work once it's connected.
I'm thinking of inverting the "client" and "server" to see if that works any better. I.e. make the ESP32 connect to the Bangle.js and send readings that way instead. Slightly inconvenient that you can't use the Web IDE console while something else is connected to the Bangle.js though.
-
OK, some progress on the original Bangle.js. It very rarely works (maybe 1 in 30 times), but I have observed it working and successfully reading out data from the characteristic:
NRF.connect("34:85:18:00:38:8e").then(function(gatt) { console.log(gatt); console.log("connected"); var t = getTime(); gatt.device.on('gattserverdisconnected', function(reason) { console.log("disconnected (" + reason + ") after " + (getTime()-t) + " secs"); }); return gatt.getPrimaryService("4fafc201-1fb5-459e-8fcc-c5c9c331914b"); }).then(function(service) { console.log("got service: "); console.log(service); return service.getCharacteristic("beb5483e-36e1-4688-b7f5-ea07361b26a8"); }).then(function(characteristic) { console.log("got characteristic, value = "); characteristic.readValue().then(function(v) { console.log(v); }); characteristic.on('characteristicvaluechanged', function() { console.log("characteristicvaluechanged: "); characteristic.readValue().then(function(v) { console.log(v); }); }); }).catch(function(e) { console.log("error: " + e); });
gives:
BluetoothRemoteGATTServer: { "device": BluetoothDevice: { "id": "34:85:18:00:38:8e", "gatt": ... }, "connected": true } connected got service: BluetoothRemoteGATTService: { "uuid": "4fafc201-1fb5-459e-8fcc-c5c9c331914b", "isPrimary": true, "start_handle": 40, "end_handle": 65535 } got characteristic, value = DataView: { "buffer": new Uint8Array([4, 0, 0, 0]).buffer, "byteOffset": 0, "byteLength": 4 }
However you'll notice that the "characteristicvaluechanged" callback is not firing. I left it running for several minutes and it didn't fire even once, so I think the "notify" response is not working. But this is progress, at least, and in the worst case I can probably read out the characteristic value on a timer, so there is light at the end of the tunnel!
It would still be better if it worked on Bangle.js 2, and if it worked every time instead of only 1/30 times.
(The MAC address is different because I'm using a different ESP32C3, but that's just an accident - it still doesn't work on the Bangle.js 2).
-
I don't have any ESP32 that's not a C3, so I'd have to wait for one to arrive. Can you suggest what I should buy?
I am now finding that it doesn't work at all even on the original Bangle.js. In fact in total I think it only worked once, and it's not obvious to me whether it actually worked, or just didn't notice that it didn't work.
I know it says "connected", but it's not obvious to me that that callback runs after it actually connected, compared to when it merely thinks it was connected. The "connection failed to be established" error suggests it was never connected in the first place.
-
-
I didn't know about the "core debug level" option. I just tried it with Verbose, and I see a bunch of stuff at startup, and a bunch of stuff when I connect using gatttool, but indeed nothing at all when the Bangle.js 2 tries to connect.
So are we saying that the Bangle.js 2 is just (sometimes, in your case, and always, in my case) not sending the connection request?
I wonder if I could try connecting it to some other type of device to see if that works, I'll try to think of something. Obviously Web Bluetooth works for the IDE so it's not like Bluetooth is completely non-functional.
I tried putting
BLEDevice::setMTU(131)
(and also 23) just before and just afterBLEDevice::startAdvertising()
in my Arduino code from the first post in this thread. No change, the Bangle.js 2 still says it was disconnected after ~1.0 seconds.My immediate problem is solved anyway, because I can just report my sensor readings in the "manufacturer data" field, and grab it with
NRF.findDevices()
.