ArduinoCore-arc32 icon indicating copy to clipboard operation
ArduinoCore-arc32 copied to clipboard

Sketch where Read characteristics don't work

Open crfrancis opened this issue 8 years ago • 2 comments

I've attached a sketch, which is a cut-down version of one I'm working on. It sets one service with 5 characteristics: one write, 2 notify and 2 read. The write and notify ones work as expected, but not the reads. If I upload this to a fresh Arduino 101, with the "101 Firmware Updater" programmer, it flashes the new firmware (with the 2.0.2 board manager). Then with LightBlue on the iPhone I can see the device, the service and the characteristics, but I can't read the 2 read values. The same with my own C++ code on an R-Pi (BlueZ 5.46 installed). I have another sketch with 3 characteristics, and that works properly. cheers, Richard

LasersRemote30debug.zip

crfrancis avatar Aug 20 '17 10:08 crfrancis

I've been working on this issue for weeks now, but today made a breakthrough, with a reproducible cause.

It's the analogRead() which is to blame. I tried all 6 pins and the result is the same. Reading the characteristic doesn't work.

But if you comment out the call to readLaserVoltage() in the example I posted, the problem goes away.

cheers, Richard

crfrancis avatar Aug 20 '17 17:08 crfrancis

Here is an update to the sketch which demonstrates the problem. It has 37 lines. Using, for example, LightBlue on an iPhone reveals the problem. Commenting out line 35 laserVolts = analogRead(VOLTS_PIN); // try commentinng out this line will stop the error.

cheers, Richard

crfrancis avatar Nov 03 '17 13:11 crfrancis