Newbi init and stops working after a while

Posted on
  • The code "works" ie it give me some nice LED's
    The problem is, it stops working after a time.

    // our main function
    function puckLeds(){
      let leds= 0;
      let timerId = null;
    
      digitalWrite([LED3,LED2,LED1], leds);
    
      // watch for the Big Red Button
      setWatch(function() {
        if ( timerId !== null){
          clearTimeout(timerId);
        } 
        leds = (leds + 1)%7;
        digitalWrite([LED3,LED2,LED1], leds);
        timerId = setTimeout(function () {
        digitalWrite([LED3,LED2,LED1], 0);
        }, 10000);
      }, BTN, {edge:"falling", debounce:100, repeat:true}); 
    }
    
    // ensure that the code is available after reload or whatever
    E.on('init', function() {
      console.log("hello");
      puckLeds();
    });
    
    save();
    

    Edit after input below.
    Placement of pulldown did not seem to work
    pinMode(BTN,"input_pulldown");

    function puckLeds(){
      let leds= 0;
      let timerId = null;
    
      digitalWrite([LED3,LED2,LED1], leds);
    
      setWatch(function() {
        // pinMode(BTN,"input_pulldown");
        if ( timerId !== null){
          clearTimeout(timerId);
        } 
        leds = (leds + 1)%7;
        digitalWrite([LED3,LED2,LED1], leds);
        timerId = setTimeout(function () {
        digitalWrite([LED3,LED2,LED1], 0);
        }, 10000);
      }, BTN, {edge:"falling", debounce:100, repeat:true}); 
      pinMode(BTN,"input_pulldown");
    }
    
    E.on('init', function() {
      console.log("hello");
      puckLeds();
    });
    
    save();
    
  • Have you updated your firmware? As it comes the Puck.js firmware had some issues keeping the pulldown resistor on the button.

  • No update: as supplied to ensure I know what gets supplied to my friends if they order one :)
    I update it via the GUI.

  • Or RTFM and find it is not via GUI :)
    And find that "FIRMWARE UPDATES" has no info for windows (I create PR if wished).

    "FIRMWARE UPDATES" could do with a quick link instead of reading down the page.

    I use the already installed sw for windows and give it a go.

  • OK: you are going to love this ...
    I only have a Windows mobile and a Windows PC.
    nRF Connect v1.1 for Windows needs to be googled more: doesn't seem to have bluetooth, just usb

    I get back on this one.

    • nRF Connect v1.1 for windows does not allow me to use "Start Scan"
    • the puck.js apears as DfuTarg on Windows when put into the correct mode.

    I try and do forum scans at nordic/google.

    devzone.nordicsemi.com/question/­94468/nrf-connect-for-windows-10/
    Evidence of problems before the so called anniversity version of windows 10

    devzone.nordicsemi.com/question/­95258/nrf-toolbox-doesnt-work-properly-o­n-windows-phone/
    Funny how windows phone turns people off

    my case at nordicsemi
    nordicsemi.com/index.php/eng­/supportcase/view/34266

  • As a newbie, I presumed the GUI would update the device, clearer indication that the puck.js is not flasher-able: so very easy as the receiver of a puck.js just to look thru the GUI and think "great, flasher" (until one reads what is clearly written)

    Better yet, use the info from "Request board details on connect" and allow for specific menu/dialogs in question with Flasher. (I will remember to make an issue of this)

  • I presumed the GUI would update the device

    It will do eventually - however I'm waiting for:

    • Chrome to implement Web Bluetooth for Windows (which they will do soon hopefully)
    • Nordic to implement a Secure Firmware update for Web Bluetooth - which they also say they're doing

    I don't mention Windows because I don't believe the Nordic tools offer it for Windows yet - at least not unless you have an nRF-DK. I did ask them if it were possible and they said they might look into it.

    use the info from "Request board details on connect" and allow for specific menu/dialogs in question with Flasher.

    This is exactly what the IDE does for other boards, but I've turned it off for now because it'll just annoy everyone if they can't update with the IDE.

    If you want to fix it without a firmware update, just add pinMode(BTN,"input_pulldown") after setWatch

  • nRF Connect v1.1 is available for windows but seems not to support bluetooth
    nordicsemi.com/eng/Products/­Bluetooth-low-energy/nRF-Connect-for-des­ktop (anyone can download)
    infocenter.nordicsemi.com/index.j­sp?topic=%2Fcom.nordic.infocenter.tools%­2Fdita%2Ftools%2FnRF_Connect%2FnRF_Conne­ct_intro.html&cp=4_2
    It is not possible to click "Start Scan" on my machine :(

    I have made a case at nordicsemi
    nordicsemi.com/index.php/eng­/supportcase/view/34266

  • nRF Connect v1.1: no support for Windows 10 without a dongle
    so looks like I have to find an android or iThingy in the cupboard: no problem

    Hi,

    Yes, nRF Connect v1.1 does support connection to BLE devices on
    Windows 10, but it does require a nRF51/52 DK/dongle for
    communication. Built-in BLE HW will not work as nRF Connect relies on
    serialized softdevice commands and not HCI.

    Look at the documentation in our inforcenter.

    Best Regards,

    Martin

    Edit:
    Probably something like this infocenter.nordicsemi.com/index.­jsp?topic=%2Fcom.nordic.infocenter.sdk5.­v12.0.0%2Flib_serialization.html

  • but it does require a nRF51/52 DK/dongle for communication

    Since you have an nRF52DK you could just use that?

  • Yep: that was what I was thinking (also thinking of comments concerning uses of a nRF52X PCB :) from Espurino)

  • And that it looks like the nRF Connect is a node product with an nRF core js

  • I can confirm nordicsemi.com/eng/Products/­Bluetooth-low-energy/nRF-Connect-for-des­ktop :

    • on windows, the nRF connect is an electron app, asar package
    • on ubuntu/linux, the nRF connect is an electron app, luckly not asar: pack out and cherry pick js
    • on OS X, I have not enough money for an apple :)

    It seems the techy aspects of bluetooth with browser is Wait for Chrome but does that give the techy "serialized softdevice commands" with two outcomes:

    1. puck.js can only be updated by an android/iPhone app that is not within Espruino control (no windows possible)
    2. something may work in windows os: but don't hold yr breath timeframes and possibilities are unknown

    Roll on Windows Desktop on Canonical Ubuntu: Xenix returns, with possible internal MS project name "Phoenix": but this is outside of the problem at hand.

    Edit: package.json

    "author": "Nordic Semiconductor ASA",
      "license": "Proprietary",
    

    Edit:
    A lot of code on Nordics github and unknown if "what is needed" is there.

    Edit:
    DFU seems to be github.com/NordicSemiconductor/s­ecure-dfu-web-bluetooth
    with a keyword Esruino in the package.json


    3 Attachments

    • electron app.PNG
    • unix-not-asar-but-electron.PNG
    • license and blobs.PNG
  • Breadcrumbs
    github.com/NordicSemiconductor/s­ecure-dfu-web-bluetooth with Espruino as a package.json keyword leads to a

    Error: No compatible USB Bluetooth 4.0 device found!
        at BluetoothHciSocket.bindUser (C:\Users\owen\source\repos\github\Nordi­cSemiconductor\secure-dfu-web-bluetooth\­node_modules\bluetooth-hci-socket\lib\us­b.js:70:11)
    

    A google on bluetooth-hci-socket gives a github.com/sandeepmistry/node-bl­uetooth-hci-socket

    And a WIP which does not need any comments: I just edit this post to document for myself where the trail lead on Windows 10

    Edit
    The bluetooth in my device is supported:

    Intel Wireless Bluetooth 7265   0x8087  0x0a2a
    

    Edit:
    zadig did it's work: bluetooth not available to Windows 10, and hoping available for the node of things

    Edit:
    Don't skip steps, go thru the doc and examples to make sure the base of DFU works when there, even if unnessary (DFU could work) time well spent
    github.com/sandeepmistry/node-bl­uetooth-hci-socket

    Edit:
    Ensure pre-req for node-bluetooth-hci-socket by doing github.com/nodejs/node-gyp#insta­llation for Windows

    Edit:
    "Waiting for installers..." and have done for a long time. May have to bail out and cross fingers.

    Microsoft Windows [Version 10.0.14393]
    (c) 2016 Microsoft Corporation. All rights reserved.
    
    C:\WINDOWS\system32>npm install --global --production windows-build-tools
    
    > windows-build-tools@1.1.0 postinstall C:\Users\owen\AppData\Roaming\npm\node_m­odules\windows-build-tools
    > node ./lib/index.js
    
    Downloading BuildTools_Full.exe
    Downloading python-2.7.11.msi
    [=======================================­=====>] 100.0% of 18.64 MB (2.87 MB/s)
    Downloaded python-2.7.11.msi. Saved to C:\Users\owen\.windows-build-tools\pytho­n-2.7.11.msi.
    Starting installation...
    Launched installers, now waiting for them to finish.
    This will likely take some time - please be patient!
    Waiting for installers... \Successfully installed Visual Studio Build Tools.
    Waiting for installers...
    

    Edit:
    Bailed out but the following gave something I have to understand:

    owen@DESKTOP-O5H58VV MINGW64 /c/source/repos/github/sandeepmistry/nod­e-bluetooth-hci-socket (master)
    $ node examples/le-connection-test.js
    data: 040e0402030c00, 7 bytes
    data: 040f0400020d20, 7 bytes
    
    owen@DESKTOP-O5H58VV MINGW64 /c/source/repos/github/sandeepmistry/nod­e-bluetooth-hci-socket (master)
    $ node examples/le-scan-test.js
    data: 040e04000c200c
    data: 040e04000b2000
    LE Scan Parameters Set
    data: 040e0402030c00
    data: 040e04020c2000
    LE Scan Enable Set
    
    owen@DESKTOP-O5H58VV MINGW64 
    /c/source/repos/github/sandeepmistry/nod­e-bluetooth-hci-socket (master)
    $ node examples/le-advertisement-test.js
    isDevUp = false
    write: 010a200100
    write: 0106200fa000a0000000000000000000000700
    write: 01092020190909657374696d6f74650e160a182e­b8855fb5ddb601000200000000000000
    write: 010820201e0201061aff4c000215b9407f30f5f8­466eaff925556b57fe6d00010002b600
    write: 010a200101
    data:  040e04000a200c
    data:  040e0400062000
    LE Advertising Parameters Set
    data:  040e0401092000
    LE Scan Response Data Set
    data:  040e0400082000
    LE Advertising Data Set
    data:  040e0402030c00
    data:  040e04020a2000
    LE Advertise Enable Set
    

    Edit:

    owen@DESKTOP-O5H58VV MINGW64 /c/source/repos/github/NordicSemiconduct­or/secure-dfu-web-bluetooth (master)
    $ npm install ../../sandeepmistry/node-bluetooth-hci-s­ocket/
    $ npm install
    

    Edit:
    Coffee time and find out what it all means
    Although, I could maybe use an nRF52-DK to solve my case, it requires the device and no "solution" for others that do not have a device to use.

    owen@DESKTOP-O5H58VV MINGW64 /c/source/repos/github/NordicSemiconduct­or/secure-d                                                                                            fu-web-bluetooth (master)
    $ npm test
    
    > secure-dfu@0.0.0 test C:\source\repos\github\NordicSemiconduct­or\secure-dfu-web-bluetooth
    > mocha --reporter spec
    
    
    
    (node:10904) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): requestDevice error: adapter not enabled
      [#file_utils](http://forum.espruino.com/­search/?q=%23file_utils)
        1) should un-zip test_resources/dfu_test_app_hrm_s132.zip­ and print it's contents.
        2) should parse the manifest.json file passed to it and return a json object.
    (node:10904) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 3): Error: ENOENT: no such file or directory, open 'C:\source\repos\github\NordicSemiconduc­tor\secure-dfu-web-bluetooth\tmp\manifes­t.json'
    (node:10904) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 4): Error: ENOENT: no such file or directory, open 'C:\source\repos\github\NordicSemiconduc­tor\secure-dfu-web-bluetooth\tmp\nrf5283­2_xxaa.dat'
        3) should parse a .bin / .dat file into an array of bytes. Checks that the first and last bytes are correct.
    
      [#index](http://forum.espruino.com/searc­h/?q=%23index) -- NOTE: requires nRF52 device running secure_dfu_secure_dfu_ble_s132_pca10040_­debug.hex in range of computer.
        4) should test littleEndian.
        √ should test littleEndianUInt32.
    (node:10904) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 6): requestDevice error: adapter not enabled
        5) should succesfully scan for, connect to, and discover the services/characteristics of the DFU target device.
        6) should succesfully enable notifications on the control point characteristic.
        7) should send create command.
    
    
      1 passing (4s)
      7 failing
    
      1) [#file_utils](http://forum.espruino.com/­search/?q=%23file_utils) should un-zip test_resources/dfu_test_app_hrm_s132.zip­ and print it's contents.:
         Error: ENOENT: no such file or directory, lstat 'C:\source\repos\github\NordicSemiconduc­tor\secure-dfu-web-bluetooth\tmp'
          at Error (native)
          at Object.fs.lstatSync (fs.js:982:18)
          at Context.it (test\test.js:16:15)
    
      2) [#file_utils](http://forum.espruino.com/­search/?q=%23file_utils) should parse the manifest.json file passed to it and return a json object.:
         Uncaught SyntaxError: Unexpected token u in JSON at position 0
          at Object.parse (native)
          at ReadFileContext.fs.readFile [as callback] (utils\file_utils.js:37:20)
          at FSReqWrap.readFileAfterOpen [as oncomplete] (fs.js:365:13)
    
      3) [#file_utils](http://forum.espruino.com/­search/?q=%23file_utils) should parse a .bin / .dat file into an array of bytes. Checks that the first and last bytes are correct.:
         Error: Timeout of 2000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves.
    
    
      4) [#index](http://forum.espruino.com/searc­h/?q=%23index) -- NOTE: requires nRF52 device running secure_dfu_secure_dfu_ble_s132_pca10040_­debug.hex in range of computer. should test littleEndian.:
    
          AssertionError: expected '0,1,2,3' to equal '3,2,1,0'
          + expected - actual
    
          -0,1,2,3
          +3,2,1,0
    
          at Context.it (test\test.js:47:31)
    
      5) [#index](http://forum.espruino.com/searc­h/?q=%23index) -- NOTE: requires nRF52 device running secure_dfu_secure_dfu_ble_s132_pca10040_­debug.hex in range of computer. should succesfully scan for, connect to, and discover the services/characteristics of the DFU target device.:
         Error: Timeout of 2000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves.
    
    
      6) [#index](http://forum.espruino.com/searc­h/?q=%23index) -- NOTE: requires nRF52 device running secure_dfu_secure_dfu_ble_s132_pca10040_­debug.hex in range of computer. should succesfully enable notifications on the control point characteristic.:
         TypeError: Cannot read property 'controlPointCharacteristic' of undefined
          at Context.it (test\test.js:106:41)
    
      7) [#index](http://forum.espruino.com/searc­h/?q=%23index) -- NOTE: requires nRF52 device running secure_dfu_secure_dfu_ble_s132_pca10040_­debug.hex in range of computer. should send create command.:
         TypeError: Cannot read property 'controlPointCharacteristic' of undefined
          at Context.it (test\test.js:120:30)
    
    
    
    npm ERR! Test failed.  See above for more details.
    

    Edit
    puck.js DF:F5:A5:EC:43:1B Returning to Zadig and waiting for a system restoration point

    Edit:
    github.com/sandeepmistry/node-bl­uetooth-hci-socket/pull/54

    Edit:
    Getting to nobel, and make sure one see's a video
    youtube.com/watch?v=mL9B8wuE­dms

    Edit:
    All pre-req met and using Zadig (again)
    github.com/nodejs/node-gyp#insta­llation
    github.com/sandeepmistry/noble

    Edit:
    noble failure, no adapter, regress to github.com/sandeepmistry/node-bl­uetooth-hci-socket and ensure simple steps

    Edit:
    noble

    rm -fr npm_modules
    npm install <path to hci>
    npm install
    

    And ....

    C:\source\repos\github\sandeepmistry\nob­le>node examples\advertisement-discovery.js
    peripheral discovered (dff5a5ec431b with address <df:f5:a5:ec:43:1b, random>, connectable true, RSSI -70:
            hello my local name is:
                    Puck.js 431b
            can I interest you in any of the following advertised services:
                    ["6e400001b5a3f393e0a9e50e24dcca9e"]
    

    Edit:
    This is probably bad and I have to find a way to update the puck.js (where I started)

    C:\source\repos\github\sandeepmistry\nob­le>node examples\advertisement-discovery.js
    (no reply with battery off, button, battery on, green, release button, red)
    
  • Chrome for windows has web ble http://forum.espruino.com/conversations/­299715/

    Except, it doesn't seem to work, so I need a reference machine.
    Virtual Box Ubuntu. Ensure that the host Windows 10 is NOT using bluetooth, Devices->uninstall driver for bluetooth device and delete files.

    Then make sure that Virtual Box has Devices->USB->enable access to bluetooth adapter

    However, nRF needs a certain type of adapter on all platforms it seems, not only windows.
    So only supported on iPhone and Android as low energy and then it will work


    2 Attachments

    • hmmm.PNG
    • has to be a certain type of bluetooth.PNG
  • Thank you puck, yes, I am VERY intrested

    C:\source\repos\github\sandeepmistry\nob­le>node examples\advertisement-discovery.js
    peripheral discovered (dff5a5ec431b with address <df:f5:a5:ec:43:1b, random>, connectable true, RSSI -70:
            hello my local name is:
                    Puck.js 431b
            can I interest you in any of the following advertised services:
                    ["6e400001b5a3f393e0a9e50e24dcca9e"]
    
  • Using the nRF52-DK as a bluetooth "proxy" from Windows 10.
    puck.js now works with init and leds
    Only problem now is my 8yr old daughter keeps steeling puck to play with


    1 Attachment

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

Newbi init and stops working after a while

Posted by Avatar for OwenBrotherwood @OwenBrotherwood

Actions