• Hi!
    I have uploaded a script which set data on button click.
    Here is the code :

    echo(0);\n
    clearInterval();
    clearWatch();
    var presses = 0;\n
    setWatch(function () {\n
        if(presses > 100) {
            presses = 0;
        }\n
        presses++;\n
        LED2.reset();\n
        LED3.reset();\n
        NRF.setAdvertising({}, {
            interval: 200,
            manufacturer: 0x0590,
            manufacturerData: [presses]
        });\n
    }, BTN, {
        edge: 'falling',
        repeat: 1,
        debounce: 0
    })\n
    LED1.set()\n
    setTimeout(function () {
        LED1.reset()
    }, 2000)\n
    save();
    
    

    It works fine but sometimes when i click the button.. noble.js does not scan any changed data.
    However the data value has changed but not advertised. ( it means the setWatch function is working )
    I think it's a problem in puck.js script updated.. maybe NRF.setAdvertising ?

    It is a major problem for our application. Do you have any idea of what could cause this issue ?
    Thank you !

  • Are those \n part of your code, or just a copy/paste issue?

    One thing that might be worth trying is debounce:20 just in case something odd is happening caused by the button contacts bouncing and queuing up lots of changes?

    Could you also add something like LED.set() at the beginning of the setWatch and LED.reset() at the end? The LED should flicker on if everything has worked, but if for whatever reason there was an error executing to the end of the code then the LED will stay on

  • OK thank you i'll try with "debounce:20" and the "LED.set() / LED.reset()" at the beginning / end of setWatch.
    If i remove the "/n" the code does not work, must i remove it ?

  • Forget about the "\n" problem i have write it a te end of the code only and it works.
    I keep you inform if the "advertising" data problem is not resolved.
    Thank you !

  • Ahh - how are you uploading the code? I guess it's not from the IDE, but from your own Node.js app?

    Could you try uploading the code in the Espruino Web IDE and see if it works? It could be that if you're uploading via your own app then there may be issues with flow control which mean that the code doesn't get uploaded correctly.

    It can be easy enough to fix, but for now, to help track down the problem, uploading via the IDE would be worth trying.

  • Yes i upload it from node.js app.
    I have tested with the flicker LED and it does not stuck ( when advertising data not working ).
    The setWatch function seem to works fine, but the NRF.setAdvertising inside sometimes is not triggered..

    Thank you

  • Could you try checking with the nRF connect app on a phone?

    It is possible it's something to do with your computer actually cacheing the manufacturerdata.

    I just tried this here and your code works fine for me - albeit with huge amounts of extra counting because you don't have any debounce

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

Puck.js advertising data - manufacturerData - button click

Posted by Avatar for Christof550 @Christof550

Actions