With the standard TI demo firmware running in my Sensortag, and running the Evothings demo app for Sensortag Sensors, everything is working fine. But for my project I need to slow down the rate at which Sensortag advertises itself, and how often it converts its sensor values (also, I only need the temperature sensor, not the others).
So I have modified the TI firmware to advertise and convert less often, and to ignore converting other sensors except for the temperature sensor. But now the Evothings app finds it very difficult to work with the Sensortag. It always reports 'connected' but often then stops, or sometimes reports 'sensors online' but doesn't actually show any data. Sometimes it works but then it will stop and it seems to require the phone to be rebooted to get it working again.
It would seem (to someone reading this) that I have done something wrong in the modification of the Sensortag firmware, but here's the strange thing: after making my timing adjustments in the firmware, the Sensortag Android app supplied by TI (written in Java and not a Cordova app) still works perfectly and sees the Sensortag data consistently (every ten seconds as my tag updates values). I can switch between the TI app and the Evothings app on my phone; the TI one works while the Evothings one doesn't. So is there something wrong with the Cordova BLE plugin?
TI Sensortag advertising and conversion periods
Re: TI Sensortag advertising and conversion periods
I have evaluated this issue further and decided that the advertising / conversion periods aren't the problem, but extending them just make an existing problem worse. The connection success using an Evothings app is not reliable, even with fast advertising. It seems the more I use the device, the worse it Is getting. But still the TI android app (downloaded from Google Play) always connects perfectly, so I can't really put the blame on the tag itself.
Re: TI Sensortag advertising and conversion periods
Code: Select all
sensortag
.statusCallback(statusHandler)
.errorCallback(errorHandler)
.keypressCallback(keypressHandler)
.irTemperatureCallback(irTemperatureHandler, 500)
.humidityCallback(humidityHandler)
.barometerCallback(barometerHandler, 500)
.accelerometerCallback(accelerometerHandler, 200)
.magnetometerCallback(magnetometerHandler, 200)
.gyroscopeCallback(gyroscopeHandler, 200, 7) // 7 = enable all axes.
.connectToClosestDevice()
the second parameter in each of the callbacks is the period of refresh rate in milliseconds (where we can control them) - thats one half of your question answered. there is a known problem with the reliability of the BLE connection on android which our team is looking into in more detail - we are not exactly sure where the problem lies, could be specific to various models of android devices.. further testing is required to squish this bug / issue - any additional insights from users would be good to receive and help resolve the problems.
Re: TI Sensortag advertising and conversion periods
Thanks Ardiri.
I have already tried various refresh rates but seems to make no difference.
One *very* interesting thing I have now noticed as that, while an Evothings app is running (either my own code or the demo app) and failing to properly connect, if I then run the TI app at the same time, as soon as the TI app connects (or tries to) the Evothings connection starts working. This observation is very repeatable; I can be waiting for an Evothings connection for 30 seconds or more, then as soon as I start the TI app concurrently the Evothing app starts working. So the TI app is doing something important in the background.
After some Googling I found this:https://stackoverflow.com/questions/22596951/how-to-programmatically-force-bluetooth-low-energy-service-discovery-on-android which may be a solution but I don't know how to include this Java code in the Cordova plugin.
Regards
Chris
I have already tried various refresh rates but seems to make no difference.
One *very* interesting thing I have now noticed as that, while an Evothings app is running (either my own code or the demo app) and failing to properly connect, if I then run the TI app at the same time, as soon as the TI app connects (or tries to) the Evothings connection starts working. This observation is very repeatable; I can be waiting for an Evothings connection for 30 seconds or more, then as soon as I start the TI app concurrently the Evothing app starts working. So the TI app is doing something important in the background.
After some Googling I found this:https://stackoverflow.com/questions/22596951/how-to-programmatically-force-bluetooth-low-energy-service-discovery-on-android which may be a solution but I don't know how to include this Java code in the Cordova plugin.
Regards
Chris
Re: TI Sensortag advertising and conversion periods
Hi quilkin,
We should look into the Cordova BLE plugin to investigate further. There is a problem on some Android devices that scanning does not report same device multiple times, and the plugin does not rescan or anything to work around this. Perhaps the problem you see is somehow related to this issue?
Have you tried the BLE Scan app on your device? Does it report your customized SensorTag? Does it update RSSI readings?
Please use Evothings 1.0.0 as some bugs related to BLE Scan were fixed in this release.
Best regards, Mikael
We should look into the Cordova BLE plugin to investigate further. There is a problem on some Android devices that scanning does not report same device multiple times, and the plugin does not rescan or anything to work around this. Perhaps the problem you see is somehow related to this issue?
Have you tried the BLE Scan app on your device? Does it report your customized SensorTag? Does it update RSSI readings?
Please use Evothings 1.0.0 as some bugs related to BLE Scan were fixed in this release.
Best regards, Mikael
Re: TI Sensortag advertising and conversion periods
Hi Mikael,
Thanks for the quick response.
The BLE Scan app connects OK, with an RSSI of -58 or -61. The problem I am seeing is not that it won't connect; it always connects but then the services are not found correctly, so the status may report, for example, 'sensors online' but no data is transferred.
However if the TI app is running at the same time, and I use the 'Scan' button on that while the Evothings app is trying to connect, the Evothings connects properly and all the services work.
I'm already using 1.0.0, I only downloaded a few days ago.
The problem seems to be getting worse, the Evothings connection hardly ever works now without a kick from the TI app. I will try to get hold of another Android device that has BLE, to see if there's any difference.
By the way, I really appreciate the fast turnaround for developing with this, compared with having to make and upload the Cordova code every time. But I can't make the command "<script>console.log = hyper.log</script>" work and if I just use 'hyper.log' then I can't debug using Chrome 'Inspect' because it fails on trying to find 'hyper'.
Also, if there's any chance in a future release to add breakpoints and variable values in the workbench tools (as I can do with Chrome) that would be great!
Regards
Chris
Thanks for the quick response.
The BLE Scan app connects OK, with an RSSI of -58 or -61. The problem I am seeing is not that it won't connect; it always connects but then the services are not found correctly, so the status may report, for example, 'sensors online' but no data is transferred.
However if the TI app is running at the same time, and I use the 'Scan' button on that while the Evothings app is trying to connect, the Evothings connects properly and all the services work.
I'm already using 1.0.0, I only downloaded a few days ago.
The problem seems to be getting worse, the Evothings connection hardly ever works now without a kick from the TI app. I will try to get hold of another Android device that has BLE, to see if there's any difference.
By the way, I really appreciate the fast turnaround for developing with this, compared with having to make and upload the Cordova code every time. But I can't make the command "<script>console.log = hyper.log</script>" work and if I just use 'hyper.log' then I can't debug using Chrome 'Inspect' because it fails on trying to find 'hyper'.
Also, if there's any chance in a future release to add breakpoints and variable values in the workbench tools (as I can do with Chrome) that would be great!
Regards
Chris
Re: TI Sensortag advertising and conversion periods
quilkin wrote:By the way, I really appreciate the fast turnaround for developing with this, compared with having to make and upload the Cordova code every time. But I can't make the command "<script>console.log = hyper.log</script>" work and if I just use 'hyper.log' then I can't debug using Chrome 'Inspect' because it fails on trying to find 'hyper'.
have you tried using the JavaScript workbench in the Evothings Workbench (click on tools). the hyper.log() calls are written to the console there and you can do debugging directly on your device by writing out to the console.. you may also have a bunch of related error messages which could be telling us of the exact problem you are having as well.
Re: TI Sensortag advertising and conversion periods
have you tried using the JavaScript workbench in the Evothings Workbench (click on tools). the hyper.log() calls are written to the console there and you can do debugging directly on your device by writing out to the console.. you may also have a bunch of related error messages which could be telling us of the exact problem you are having as well.
Yes, I have used the workbench tools. I'm having to manually convert all references to 'console.log' to 'hyper.log' to get any output, because I cannot get any results from the suggestion to use "<script>console.log = hyper.log</script>" . I have tried to catch an error message to see what the problem is, and I will try some more but I feel as though it's deep in the cordova ble plugin and not accessible at the javascript level.
I won't be able to do any more on this now until Tuesday. Thanks for your help so far.
Regards
Chris
Re: TI Sensortag advertising and conversion periods
Hi again,
Just to let you know that I have now tried the BLE plugin by Rand Dusing https://github.com/randdusing/BluetoothLE and it connects and works (i.e. reading the services) correctly first time. Same Sensortag, same firmware, same Android device. Then switched back to Evothings and immediately got this error from the Chrome::/inspect console:
... so it is finding a 'null' device at an inappropriate spot. (the relevant line is " // Set sensor configuration to ON..... configUUID && instance.device.writeCharacteristic(".....)
The Rand Dusing example code isn't as high-level as the Evothings one, so I need to write some extra code to fill the gaps but it does look more stable.
Regards
Chris
Just to let you know that I have now tried the BLE plugin by Rand Dusing https://github.com/randdusing/BluetoothLE and it connects and works (i.e. reading the services) correctly first time. Same Sensortag, same firmware, same Android device. Then switched back to Evothings and immediately got this error from the Chrome::/inspect console:
Code: Select all
processMessage failed: Error: TypeError: Cannot call method 'writeCharacteristic' of null cordova.js:1044
processMessage failed: Stack: TypeError: Cannot call method 'writeCharacteristic' of null
at Object.instance.sensorOn (file:///android_asset/www/js/ti-sensortag.js:366:43)
at Object.instance.irTemperatureOn (file:///android_asset/www/js/ti-sensortag.js:278:22)
at instance.activateSensors (file:///android_asset/www/js/ti-sensortag.js:267:22)
... so it is finding a 'null' device at an inappropriate spot. (the relevant line is " // Set sensor configuration to ON..... configUUID && instance.device.writeCharacteristic(".....)
The Rand Dusing example code isn't as high-level as the Evothings one, so I need to write some extra code to fill the gaps but it does look more stable.
Regards
Chris
Re: TI Sensortag advertising and conversion periods
Hi Chris,
Regarding the issue with hyper.log, try using this function for your logging:
Best regards, Mikael
Regarding the issue with hyper.log, try using this function for your logging:
Code: Select all
<script>
function mylog(message) {
if (window.hyper && window.hyper.log) {
hyper.log(message);
// If you also want it to log to console.log uncomment this line:
//console.log(message);
} else {
console.log(message);
}
}
</script>
Best regards, Mikael
Who is online
Users browsing this forum: No registered users and 15 guests