• I am following along with the video:
    Puck.js Bluetooth with the Graphical Editor

    My puck shows up in the Nordic nRF Connect on my iPhone, but it only show the default UART Service, not the service I created and deployed by following the video.

    The IDE show this message:
    BLE connected, queueing BLE restart for later

    I disconnected and reconnected many times.

    version: 1v91

    Any Ideas?
    Thank you.

  • The cause of your problems is most likely the iPhone. They're not expecting Bluetooth devices to actually change, so often don't update the list of services.

    Could you try turning Bluetooth off on the iPhone, then back on? You'd have to do that every time the services change I'm afraid.

  • Yes, that was the problem, I am now able to see the new Service.
    Thank you.

    My IOS nRF app does not allow me to change the data type, I only have a text box with 0x preceding it. Could you tell me is it asking for hex?
    I type in 1 and hit send and the box turns red, so it must not like it. The write types are Command and Request, both choke on me entering 1

  • Honestly I'm not sure what happens in the iOS version - it would appear to be a recent change. You could try 01 or 0x01?

    Also the `Lightblue explorer' app could be worth a try - it's a similar app that might be easier to use

  • Thank you Gordon, I will give those suggestions a try.

  • Hi, sorry for hijacking the thread, but..

    I am having similar problem with the BLE, where i have disconnected from the puck, removed the battery and inserted it again, etc.

    What i'm basically is trying to do is a hold-button and release after ½ second.
    Since this isnt inlcuded in the "ble_hid_keyboard" library, i created my own based upon "tap" function in said library.(1)

    
    var keydown = function(keyCode, modifiers, callback) {
      NRF.sendHIDReport([modifiers,0,keyCode,0,0,0,0,0], function() {
        if (callback) callback();
      });
    };
    
    var keyrelease = function(keyCode, modifiers, callback) {
      NRF.sendHIDReport([0,0,0,0,0,0,0,0], function() {
        if (callback) callback();
      });
    };
    // ......
    
    var kb = require("ble_hid_keyboard");
    NRF.setServices(undefined, { hid : kb.report });
    
    function btnPressed() {
      ledBlink();
    //  kb.tap(kb.KEY.A, 0, function() {});
      keydown(kb.KEY.F12);
    }
    
    // trigger btnPressed whenever the button is pressed
    setWatch(btnPressed, BTN, {edge:"rising",repeat:true,debounce:50});
    
    function ledBlink() {
      LED1.write(true);
      setTimeout(function() {
        LED1.write(false);
        keyrelease();
      }, 500);
    
    }
    enter code here
    

    the error i get back is "Uncaught Error: BLE HID not enabled"
    is there a way to check if it is in BLE HID mode before trying to do anything, so ie. i can restart the puck or light up a led to tell me that it isnt ready (besides catching said error in a try-catch)?

    [1]

  • Are you using the 1v92 firmware? I know there was an issue where trying to send a HID packet before HID was initialised (eg the device had been disconnected and reconnected) would leave it in a state where it wouldn't work until after a reboot, but I'm pretty sure I fixed that in 1v92.

    In 1v92 I think it's safest just to try...catch the error when you make the call though. It shouldn't do any harm.

  • Yes, i am using the latest, 1v92 firmware.
    I haven't been keeping up with the updates so i flashed it before doing this.

  • @Gordon what does

    BLE Connected, queueing BLE restart for later
    actually entail? How does one restart BLE? reconnect from the computer? pull the battery?

    I'm having issues with getting it back into the right "mode" for the keyboard to do something other then throwing exceptions with the code above. with or without kb.tap().

  • @Gordon what does BLE Connected, queueing BLE restart for later actually entail?

    The bluetooth stack on Puck.js's chip was never designed for devices that modified their services on the fly, and as a result it can only ever add services to the end of the list of services.

    So when you enable bluetooth HID, which requires a bunch of changes, Puck.js has to actually restart the bluetooth stack to wipe out all existing services so it can then start again and re-add them in the right order. If it did that when you were connected then the connection would drop - hence the message.

    All you need to do is disconnect BLE from the IDE and the BLE stack will restart, then when you reconnect everything will be sorted.

    So usually you'd do:

    • Connect with the IDE
    • Upload HID code (possibly save it if you want to so it'll work again at power-on)
    • Disconnect
    • Now Pair/connect using your operating system's Bluetooth menu

    And you're sorted. I think that you can then also connect with the IDE while it's a bluetooth HID device, but I'm not sure if that works on all platforms yet.

  • Hmm.. I'm not entirely sure the keyboard library works now.
    I am having no luck with getting even the bluetooth keyboard example to run.

    However the media controls works instantiations after reconnecting.

  • I'm pretty sure it does work fine - others have had it going. Which device are you trying to use it as a keyboard for?

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

BLE connected, queueing BLE restart for later (Solved)

Posted by Avatar for Terrence @Terrence

Actions