Avatar for user113948


Member since Jun 2020 • Last active Aug 2020
  • 2 conversations

Most recent activity

  • in Puck.js, Pixl.js and MDBT42
    Avatar for user113948

    Has anyone been successful in detecting specific gestures using the accelerometer on the Puck.js v2?

    I know the Bangle.js seems to use Tensorflow Lite to recognize certain gestures, if you create a model to train them. Does the Puck.js v2 have the ability to load and recognize the same gesture model?

    I'm looking for something where I can train a model to recognize simple gestures (forward, left, right, up, down, draw a Z, draw a circle) and then load it onto the Puck.

    It looks like the Puck.js v2 has similar specs to the Bangle.js

    64MHz nRF52832 ARM Cortex-M4
    64kB RAM 512kB on-chip flash, 4MB external flash

    Puck.js v2
    64MHz nRF52832 ARM Cortex-M4
    64kB RAM, 512kB Flash

    If that isn't possible, what's the best way to go about this just using the built in accelerometer? (I've been playing with require("puckjsv2-accel-movement").on();­ )

  • in Puck.js, Pixl.js and MDBT42
    Avatar for user113948

    So to work around it, I'm afraid you'll have to manually specify the advertising data:

    Thank you, that was the missing piece I needed to figure out the rest, and I got it working now!

    Thanks for all your help so far! I'm learning a lot!

    If I have any other questions on this I'll follow up here.

  • in Puck.js, Pixl.js and MDBT42
    Avatar for user113948

    Yes, that looks spot on. Espruino will advertise that in the Scan Response packet, but that should be totally fine for most things.

    So I feel like I'm very close, but not quite there. I've been successful in switching between UART being set true and false, so I can test my custom advertisement, and then switch back to the default Nordic UART service to reprogram wirelessly, without having to reset the Puck.

    I don't know if my service UUID is being "advertised" correctly though. I've been using the iOS versions of nRF Connect (by Nordic Semiconductor) and BlueSee BLE Debugger (by Synapse), and I see both the custom Name and the custom Service UUID advertised from the Puck, and appearing exactly like the thing I'm trying to mimic (the phone advertisement). Meaning from both of those apps, the name and UUID appear to be advertised identically between the Puck and what I'm trying to mimic, using the code snippet below:

    NRF.setServices(undefined, {
          uart : false, 
          advertise: [ 'ABCDABCD-ABCD-ABCD-ABCD-ABCDABCDABCD' ]  
    NRF.setAdvertising({}, {name:"Puck.js"}); 

    However, on the custom hardware I'm trying to communicate to, the Puck isn't being picked up at all. Let's say the custom name I'm advertising is "Puck.js" and the service UUID is "ABCDABCD-ABCD-ABCD-ABCD-ABCDABCDABCD"

    Looking into the RAW BLE packet from NRF Connect, the Puck looks like it's advertising this:


    Which looks like 2 advertisements in 1 BLE packet.

    Adv 1:
    Length: 0x02
    Type: 0x01 (Flag)
    Value: 0x06

    Adv 2:
    Length: 0x08
    Type: 0x09 (Complete Local Name)
    Value: 0x5075636b2e6a73 ("Puck.js" in hex, using ASCII table)

    However what I'm wanting to see, is 3 advertisements in the packet, the missing one being the service UUID. Something like

    Adv 3:
    Length: 0x11 (17 in hex, 1 for the type, 16 for the UUID itself)
    Type: 0x07 (Complete List of 128-bit Service Class UUIDs)
    Value: 0xabcdabcdabcdabcdabcdabcdabcdabcd (the service UUID)

    So the overall RAW BLE packet looking something like this:


    What am I potentially doing wrong to where the service UUID isn't being brodcast in the RAW BLE packet?

  • in Puck.js, Pixl.js and MDBT42
    Avatar for user113948

    There are quite a few Bluetooth LE tutorials listed at https://www.espruino.com/Tutorials
    As for basics check this one: https://www.espruino.com/About+Bluetooth­+LE

    @fanoush I looked through a couple of these but didn't find anything exactly like what I'm trying to do.

    Not at all. However the Espruino tools tend to look for devices with a certain name or an advertised Nordic UART service. If you change the name and remove the UART service then they will no longer be able to find the device to connect.

    As @fanoush says you shouldn't really need to advertise a custom service UUID unless you've got some other thing you're trying to fool/connect to. All they're for is as a way to 'find' a device but if you have the device name then that'd be enough

    @Gordon Got it. I do have something I'm trying to fool/connect to. I have a mobile app that broadcasts a specific BLE UUID and I'm trying to mimic that with the puck. Both the Advertised Service and the Name need to be something different than the default Nordic UART service the puck advertises.

    I'm thinking of using the push button to alternate between programming mode and service advertising mode. So for programming, I would have this code:

    NRF.setServices(undefined, {
          uart : true

    but then when I want to advertise my custom service UUID I could run this code, disabling the Nordic UART service, and advertise my own:

    NRF.setServices(undefined, {
          uart : false
    //run function that advertises my custom service UUID

    Would that work, so I don't have to completely reset the Puck every time I want to test advertising this custom service UUID?

    To advertise a 128 bit service UUID (without data) you can use the second argument of setServices - but as you note if you want to do it easily you'll have to disable the UART. Perhaps that's not such a big deal for you though - develop without the service being advertised, then when you're done you can add the line, remove the UART and advertise your custom service.

    So for the second argument in setServices, do you mean something like this?

    NRF.setServices(undefined, {
      uart : false, // optional, default is true. Enable BLE UART support
      advertise: [ 'ABCDABCD-ABCD-ABCD-ABCD-ABCDABCDABCD' ] // optional, list of service UUIDs to advertise

    As NRF.setServices(data, options)
    data - The service (and characteristics) to advertise
    options - Optional object containing options

    So I don't need to add the UUID in data, only the options portion under advertise?

  • in Puck.js, Pixl.js and MDBT42
    Avatar for user113948

    It says by default, Puck.js has a Nordic UART service (UUID 6e400001-b5a3-f393-e0a9-e50e24dcca9e) that allows us to communicate with the JS interpreter, as well as a TX and RX characteristic of this service.

    Is there any way to advertise a custom UUID from the Puck.js, or will we only ever be able to advertise that default Nordic UART service? Would advertising a different service break the Web Bluetooth, and ability to program wirelessly?

    If we can advertise a custom one, how would I go about doing so? I've been playing around with NRF.setAdvertising but haven't been getting anywhere. Should I be using NRF.setServices instead?

    I'm trying to advertise a UUID in the form "ABCDABCD-ABCD-ABCD-ABCD-ABCDABCDABCD". http://www.espruino.com/Reference#t_l_NR­F_setServices says a UUID can be of that form, but says unless I disable the UART UUID, I can't advertise due to a size limitation. But that breaks the web bluetooth, so how would I program the Puck?

    Code examples would be appreciated!