I’m working on a project that counts the number of times a wheel spins in a complete circle using a proximity sensor controlled by UART, and sends that data to an application on a phone or computer via BLE. The device should be counting the data regardless of whether or not a central device is connected, but should be able to connect to said central device at any time to show the current data.
I’m constantly running into an error that’s really hard to diagnose since I can’t tell for sure when it’s occurring, only that it at some point happened. Basically, after several minutes of running the device perfectly fine, I write to a characteristic to update the number of rotations, and after that the connection is terminated and the device becomes undiscoverable. I’ve checked with nRF Connect on Android and Apple devices, and it happens on both. The Artemis Nano isn’t showing a hard-fault, so my best guess is that it’s still running fine and thinks that it’s still connected to a central device, even though the connection dropped out prior to or at the exact moment I wrote to that characteristic.
I don’t have a lot to go on right now, so I’ll come back with more information as I keep troubleshooting. That said, I wanted to know if anyone had any similar experiences and/or possible solutions.
paulvha:
do you restart advertising when a central disconnects?
I did some testing and it doesn’t even seem to realize that it has been disconnected. I put in code to toggle an LED based on whether or it was connected or not, and once the connection dies the LED stays lit. Apparently this was a known bug with the ArduinoBLE library, but it supposedly got patched out. Also unfortunately, when I go to update the library from 1.2.2 to 1.3.0 or beyond, it breaks completely (at least for the Sparkfun Nano).
What’s weird to me is that I don’t have this problem with other BLE programs I’ve written for the Artemis, but I can’t find what’s specifically different here to cause this problem. Hardware-wise, the only difference between the other projects I’ve worked on is that I’m using a prefab Nano instead of directly attaching an Artemis to a PCB.
Not sure what a "prefab Nano " is, but what if you run the program on another Artemis?
can you share the code so I can have a look and maybe give it try.
The arrduinoBLE had/is having several issues. Some solutions are known, but not applied to the source code. Now with the lounge of UNOR4 the source code has been changing on-the-fly and the downloaded library-zip does not look completely in sync with the source code files on git-hub.
instead of directly attaching an Artemis to a PCB.
Not sure what a "prefab Nano " is, but what if you run the program on another Artemis?
can you share the code so I can have a look and maybe give it try.
The arrduinoBLE had/is having several issues. Some solutions are known, but not applied to the source code. Now with the lounge of UNOR4 the source code has been changing on-the-fly and the downloaded library-zip does not look completely in sync with the source code files on git-hub.
instead of directly attaching an Artemis to a PCB.
I’ll see what I can do. The basic gist is that I’m polling a sensor on UART and updating a few different variables based on its responses. Those variables get loaded into a BLE characteristic when I ask it to. It works for the most part, but then the connection drops and I can’t get it back because the Artemis doesn’t realize the central device is gone
Not sure what a "prefab Nano " is, but what if you run the program on another Artemis?
can you share the code so I can have a look and maybe give it try.
The arrduinoBLE had/is having several issues. Some solutions are known, but not applied to the source code. Now with the lounge of UNOR4 the source code has been changing on-the-fly and the downloaded library-zip does not look completely in sync with the source code files on git-hub.
instead of directly attaching an Artemis to a PCB.
I figured it out. I made a mistake in the code I wrote to make sure the UART wouldn’t get stuck if a character went missing. Basically, check if a character has arrived on the UART and if it hasn’t, count up by one. If the count reaches X, abort and increment another count, then try the UART instruction again from scratch. If it fails three times, throw an error on BLE. The mistake I made was making that X value something in the thousands while the count variable was a uint8_t. The original X value was 255, but I changed stuff around when trying to troubleshoot something else and it seems I forgot to revert all the changes when I found the real cause of the other error(s)