Avatar for Gordon

Gordon

Member since Sep 2013 • Last active Jul 2021

Most recent activity

  • in Bangle.js
    Avatar for Gordon

    Just a quick note to say the developer edition is now on the shop: https://shop.espruino.com/banglejs2-dev

    It's a bit pricey but that's just because it was pretty painful for me to get this first set (high postage/customs), I think there will be a bunch of questions about how to use it, and I also only think you should get this if you're really desperate :)

    It won't be long to wait until I'm ready to ship a proper device that's a lot quicker to get started with!

  • in Bangle.js
    Avatar for Gordon

    Just a quick note to say the developer edition is now on the shop: https://shop.espruino.com/banglejs2-dev

    It's a bit pricey but that's just because it was pretty painful for me to get this first set (high postage/customs), I think there will be a bunch of questions about how to use it, and I also only think you should get this if you're really desperate :)

    It won't be long to wait until I'm ready to ship a proper device that's a lot quicker to get started with!

  • in General
    Avatar for Gordon

    That's odd - You do have to send the 'keyup' event as well, so:

    NRF.sendHIDReport([0,0,0x92,0,0,0,0,0]);­
    setTimeout(function() {
      NRF.sendHIDReport([0,0,0,0,0,0,0,0]);
    }, 100);
    

    Might do it?

    However, in the 'HID Report' you have to give a 'logical maximum', which is the maximum keycode value you intend to send. In http://www.espruino.com/modules/ble_hid_­keyboard.js you can see 0x25, 0x73, // Logical Maximum (115 - include F13, etc) and again a few lines later

    So if the above doesn't work, you could try copying the hid_keyboard code into your project, and changing 0x25, 0x73, to 0x25, 0x93, (as well as the line below)

  • in Bangle.js
    Avatar for Gordon

    Hi,

    Which firmware version do you have on the Bangle? This may actually be unrelated to pairing.

    On 2v09 I added increased MTUs, but those require some negotiating and we found that when both devices support larger MTUs you actually needed a delay to let them finish.

    I think Cutting Edge firmwares have this fixed, but maybe the code below will work for you? It just adds a setTimeout

    scan = ()=>{
      NRF.findDevices(devices => {
        for (let device of devices) {
          // Only display devices that advertise a name
            if (device.name) {
              addMenuItem(device);
            }
        }
      }, {timeout:3000,active: true });
    };
    
    addMenuItem = (device)=>{
      console.log(device);
    
      //first attemp of sending the password
      /*device.on('passkeyRequest', function() {
        console.log("passKeyRequested");
        device.sendPasskey("012034");
      });
      */
      //adding a item to the menu, trying to connect when item is pressed
      scanMenu[device.name]= ()=>{
        console.log(device); // is displayed the device
        NRF.connect(device.id)
          .then((g)=>{
            console.log("NRF connection ok!");//is displayed
            var gatt = g;
            console.log(gatt);
            var device = g.device;
            //Second attempt of sending password
            device.on('passkeyRequest', function() {
              console.log("passKeyRequested");
              device.sendPasskey("012034");
            });
    
          gatt.startBonding()
          .then(()=>{
            console.log("bonded", gatt.getSecurityStatus()); //displays : bonded { "connected": true, "encrypted": false, "mitm_protected": false, "bonded": true }
            return new Promise(resolve => setTimeout(resolve, 1000)); // wait 1 sec
         }).then(() => {
            return gatt.getPrimaryService("00000000-3608-4b­ee-bb82-4d09b486bc1f"); //also tried getPrimaryServices()
        //console.log(services);
          })
          .then( (services)=>{
            console.log(services); //
            return services.getCharacteristics();
          })
          .then((chars)=>{
            console.log(chars);
          })
        })
        .catch((error)=>{
          console.log(error);
        });
      };
    
  • in Puck.js, Pixl.js and MDBT42
    Avatar for Gordon

    I have just discovered an issue while working on something else...

    If you manage to completely fill up Storage, the next time you reboot, Storage is read as invalid and is automatically erased!

    It's actually surprisingly hard to do that...

    s=require("Storage");s.write("test","Hel­lo",0,s.getFree()-40)
    

    It only happens with values between s.getFree()-32 and s.getFree()-64. Everything else is fine!

    However it's entirely likely that with repeated small writes and frequent resets, you could actually hit this issue.

    Cutting edge builds now have this fixed, as will 2v10 when released!

  • in Bangle.js
    Avatar for Gordon

    Is there an easy way to simulate the pedometer movement?

    You can just move the bangle up and down at a regular rate...

    Or, you can just do something like this in code:

    var n = 1;
    setInterval(function() {
      Bangle.emit("step", n++);
    }, 1000);
    
  • in Bangle.js
    Avatar for Gordon

    Wow, that is a strange one...

    Is there a way to hard reset bangle?

    Yes - try https://www.espruino.com/Bangle.js#reset­ting-without-loading-any-code and then https://www.espruino.com/Bangle.js#delet­ing-all-code

    That could be a good start in case there's something strange going on with your watch's config. I definitely haven't seen this behaviour on any other devices.

  • in JavaScript
    Avatar for Gordon

    What Espruino device are you running this on? I guess maybe converting the data to the newBinary string in one go is causing it to use a lot of memory, since each bit turns into 2 characters.

    While what you're doing seems possible, I think using setInterval isn't really going to work for you, since the JS execution speed may not be fast enough, and any extra code that runs will delay execution.

    However, you do have some other options:

    • You can pass an array into digitalPulse - it should work fine but creating the array will be a bit fiddly since you need to specify the time between pulses, not the actual pulse values
    • Use SPI with the right baud rate (but just the MOSI - output - pin). You just need to ensure that newBinary is a Uint8Array of binary data rather than a string (so effectively 4 bits of actual homebus data go to 1 byte of data in newBinary).

    Hardware SPI probably won't run at exactly the right baud rate (depending on the board you're using) but software SPI should be fine

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

    That'd odd - you could check global["\xff"].watches and see if that shows anything different between button presses?

    Could you try and get this down to a super basic example that has the same problem, using setWatch and not much else?

    On nRF52, 2v09 did switch to using low lower watches on pins - but I haven't personally seen any issues with doing that here.

  • in Bangle.js
    Avatar for Gordon

    "press btn 3 to reload"

    How long do you hold btn3 for? You need to hold it for ~2 seconds to trigger the reload.

    You mean the "2x3 Pixel Clock"? I just tried it here, but it seems ok for me.

Actions