• Hi

    I'm testing the ADV_IND associated to a sensing service definition as follow

    NRF.setServices({
    	// Configuring the Envrionmental Sensing Service
    	0x181A: {
    		// Configure Temperature Characteristics
    		0x2A6E: {
    			readable: true,
    			notify: true,
    			writeable: false,
    		}
    	}
    });
    NRF.setAdvertising(
       [
    	{0x181A : [Puck.light()]}], 
       {interval:500}
    );
    

    I've controlled that the service is well defined into the GATT
    I receive ADV_IND perdiodically as expected

    My problem is that the Service Data value does not change at all. Egal to 0 !!
    I've check several things

    The Puck.light() is Ok as the following code works fine

    setInterval(function() {
      print (Puck.light());
    }, 500);
    

    I've tried to replace the Puck.light() by

    - new Float32Array([Puck.light() * 100]).buffer or
     - new Int16Array([E.getTemperature() * 100]).buffer
    

    The value is not = 0 but does not change neither ..

    Any idea ?
    Other option to get this sensing value ?

  • I guess it's because you're just running the code once, and also you're trying to output a value between 0 and 1 as an integer?

    What about:

    setInterval(function() {  
      NRF.setAdvertising([
        {0x181A : [Puck.light()*100]}], 
       {interval:500}
      );
    }, 500);
    

    The example code on http://www.espruino.com/Reference#l_NRF_setAdvertising shows how you could report the temperature using setInterval as well.

  • Hi gordon

    Thanks for your answer
    I don't follow you. I've tried also to use the

    Float32Array([Puck.light() * 100]).buffer
    

    to eliminate this question of value between 0 à 1 as an integer. But the value I get, in the ADV_IND does not change neither !!

    I've looked again at the http://www.espruino.com/Reference#l_NRF_­setAdvertising but do no see really what is wrong in my code.
    By the way I've not used the following code that is proposed in the puck.js API documentation because to me, the setInterval is redundant to the setAdvertising. The NRF.setAdvertising is already arming the advertising mechanism and their is no way to use a setInterval() to do the same again ...
    I Am wrong ?

    setInterval(function() {
      NRF.setAdvertising({
        0x1809 : [Math.round(E.getTemperature())]
      });
    }, 30000);
    

    Vpl

  • to me, the setInterval is redundant to the setAdvertising

    This is your problem.

    Try the code I gave you or the code in the example, and see if it works.

    If you call setAdvertising once then advertising data will be set, but it'll be set just once so the value will not change until you call it again. Hence the need for setInterval to update the advertising with new light values.

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

Puck.js ADV_IND does not contain the sensor value

Posted by Avatar for user94148 @user94148

Actions