-
• #2
Hi - is your firmware up to date?
The code looks fine to me - I just ran it and I see the 0x181A service using nRF connect. It's possible that significantly older firmwares didn't have that code implemented and ignored the
advertise
field.However it may also be because I believe Espruino tends to put advertised services in the scan response packet - so if you're just looking at ADV_IND you may not see the service?
-
• #3
Hi
Thanks very much for this quick answer. My firmware is 1.99 so a bit old but not so much.
I'm going to update the firmware first to check this option
Thanks again
Regards
Vpl -
• #4
Hi
I've updated the firmware to the latest version 2.v04
Then I've reloaded the service as above.
Connecting with Nrf Connect (android) I can see as you the 0x181A sensing serviceThen in the documentation they mention that the advertisement cannot be seen outside of a connection
So running my sniffer I've connected to the puck.js from NrfConnect
I can see The CONNECT_REQ then various Read-by-group req to discover the GATT characteristiques
then a bunch of empty PDU to maintain the connection open I guess.
But no adverstisement at all
At the end I get again the ADV_IND with just the device NameI suspect an issue somewhere or an error in the doc or a wrong usage ?
Any idea and help ?
Thanks a lot
Vpl
-
• #5
Thr 2019.07.18
What are the results when connecting using the WebIDE as a monitoring tool?
http://www.espruino.com/About+Bluetooth+LE
https://www.espruino.com/BLE%20Advertisingor from a web page
https://www.espruino.com/Quick+Start+BLE#puckjs
https://www.puck-js.com/go'I suspect an issue . . . or a wrong usage'
Posting the entire code block would greatly assist here.
-
• #6
Hi
Thanks very much for your answer
I've tested different thingsMy firmware is 2v04
I've tested a simple advertisement using the setAdvertising like thatNRF.setAdvertising( [ {0x180F : new Int16Array([E.getTemperature() * 100]).buffer} ], { interval:300 } );
I get ADV_IND as expected with period SCAN_REQ/SCAN_RESP.
Perfect this is what I was looking for. THanksNevertheless in the puck documentation it is written that we should get a similar behavior with the following code
NRF.setServices({ // Configuring the Envrionmental Sensing Service 0x181A: { // Configure Temperature Characteristics 0x2A6E: { readable: true, notify: true, writeable: false, value: new Int16Array([E.getTemperature() * 100]).buffer } } // Make Envrionmental Sensing Service known }, {advertise: ['0x181A']});
I've tested but DO NOT get any advertising. It is mentioned to be connected to the device. I've tried with the NRF Tool (android) to connect but no advertisement
Is it a bug or a wrong coding ?
By the way (not a priority but questioning)
The only thing I've noticed is that the battery level does not change .. A bit surprised as when I run this codesetInterval(function() { print (E.getBattery()); }, 500);
I get a variable battery level with 5/10% change at each sample
I've tried to change in the SetAdvertising with
Puck.getBatteryPercentage()
But same problem.
Thanks for your support and help
I'm developing labs for students and this puck.js is really a nice piece of Hw for training !!Regards
Vpl -
• #7
Fri 2019.07.19
'in the puck documentation'
Would you post the link please. There is plenty of documentation. ;-)
Line #9 looks iffy, re: use of Uint16Array
http://www.espruino.com/Reference#t_l_Uint16Array_Uint16Array
'I get a variable battery level with 5/10% change at each sample'
Could you estimate please, an approximate date the Puck was first powered up, e.g. the plastic tab was removed?
Then, roughly how many hours the device remains powered up, executing Javascript? e.g. compared to number of hours the battery remained removed
Has any attempt been made to make use of sleep mode?
'I'm developing labs for students and this puck.js is really a nice piece of Hw for training'
Have you considered the MDBT42Q breakout board to be able to attach sensors, such as temperature, humidity, rain gage or even a GPS unit?
-
• #8
Hi,
Regarding this advertising behavior that does not work for me, I'm refering to this part of the documentation https://www.espruino.com/Reference#l_NRF_setServices
It is said hereJust creating a service doesn't mean that the service will be advertised. It will only be available after a device connects. To advertise, specify the UUIDs you wish to advertise in the advertise field of the second options argument. For example this will create and advertise a heart rate service:
NRF.setServices({ 0x180D: { // heart_rate 0x2A37: { // heart_rate_measurement notify: true, value : [0x06, heartrate], } } }, { advertise: [ '180D' ] })
In my code (provided earlier in this post) I'm replicating exactly the same things but does not work
What do I do wrongly ?
Regards
Vpl -
• #9
Fri 2019.07.19
Thank you for the link, now we are all on the same page.
I inquired about the battery. A possible area of concern.
What is the percentage that is being reported?
@Gordon pointed out in #2
'so if you're just looking at ADV_IND you may not see the service?'
Without all the code, it's difficult to determine a potential cause.
As the firmware is up to date,
What PC and OS are being used to view the error(s)?
Please upload the error results from the WebIDE left-hand side.
What other tutorials have been attempted? Those results?As a suggestion, try this tutorial. To make things easier, modify the
flag()
function to output to the WebIDE usingconsole.log
instead of attempting to drive the (non-existent in this case) servo.Forum post example
-
• #10
Hi
For the Advertising issue I recap from the begining with the code such as we are on the same page:
Here is the code that I've loaded on my puck (latest version)NRF.setServices({ // Configuring the Envrionmental Sensing Service 0x181A: { // Configure Temperature Characteristics 0x2A6E: { readable: true, notify: true, writeable: false, value: new Int16Array([E.getTemperature() * 100]).buffer } } // Make Envrionmental Sensing Service known }, {advertise: ['0x181A']});
The puck.js documentation (https://www.espruino.com/Reference#l_NRFÂ_setServices) states that a connection is required to get the ADV_IND.
So I used the NRF connect Android App (latest version), activated my BLE sniffer and connected to the puck
On the trace I see the CONNECT_REQ but no ADV_IND with the temperatureWhat is wrong ? is there an error in the doc and the "advertise" option does not work this way ?
Thanks for your answer
Regards
Vpl -
• #11
Fri 2019.07.19
Are the results similar, as in this working example that @user101905 just posted:
Just reviewed the example at:See the fourth code block there. The issue seems to be in the argument of the advertise property. The format is a Json object, with the argument represented as a string. In Line #13 of the snippet shown in #10 above, indicates a string representation, for base clarification to humans, of the desired hex value and not the string for valid Json syntax that is that numerical hex value.
-
• #12
I don't know if this is any help? http://www.espruino.com/About+Bluetooth+LE
Basically Bluetooth LE is a bit confusing in that 'Services' can be used for Advertising OR as something that holds a characteristic when the device is connected.
NRF.setServices({}, {advertise: ['0x181A']});
advertises the service 0x181A - but as I said in my reply at the top, that will likely be in a scan respose packet, NOT ADV_INDNRF.setAdvertising({0x180F:[1]});
advertises service data 0x180F. That'll go in ADV_IND but I believe is actually a different type of data to the first option.NRF.setServices({0x181A: { 0x2A6E: { ...
sets services and characteristics, and these are only available when connected.
The first 2 options only transmit data when you're not connected, and only the second option will use ADV_IND. The first uses scan response packets.
Hope that's some help!
-
• #13
Hi
Yes this helps and clarify a lotThanks very much for your support and help
Regards
Vpl
Hi,
I've created the following service on my puck and asked for advertisement
I'm using the NRFsniffer to look at the trace. When I connect to the puck using the sniffer the only ADV_IND I get are only about the Device Name & Type. I never get the 0x181A service as expected.
In the doc it is mentioned that the master must connect to get these advertisement. But I don't get anything ?
Did I missed something ?
Thanks for your help and support
Vpl