puck.js: advertisement not working !!! Need help

Posted on
  • 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

    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']});
    
  • 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?

  • 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

  • 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 service

    Then 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 Name

    I suspect an issue somewhere or an error in the doc or a wrong usage ?

    Any idea and help ?

    Thanks a lot

    Vpl

  • 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%20Advertising

    or 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.

  • Hi

    Thanks very much for your answer
    I've tested different things

    My firmware is 2v04
    I've tested a simple advertisement using the setAdvertising like that

    NRF.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. THanks

    Nevertheless 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 code

    setInterval(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

  • 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?

    http://www.espruino.com/MDBT42Q

  • 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 here

    Just 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

  • 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 using console.log instead of attempting to drive the (non-existent in this case) servo.

    http://www.espruino.com/BLE+Communications

    Forum post example

    Puck.js advertising data - manufacturerData - button click

  • 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 temperature

    What is wrong ? is there an error in the doc and the "advertise" option does not work this way ?

    Thanks for your answer

    Regards
    Vpl

  • Fri 2019.07.19

    Are the results similar, as in this working example that @user101905 just posted:

    Puck Advertising Private Characteristic and r/w



    Just reviewed the example at:

    https://www.espruino.com/Reference#l_NRF_setServices

    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.

  • 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_IND
    • NRF.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!

  • Hi
    Yes this helps and clarify a lot

    Thanks very much for your support and help

    Regards
    Vpl

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

puck.js: advertisement not working !!! Need help

Posted by Avatar for user94148 @user94148

Actions