Published a Web Bluetooth JS app for anyone to use

Posted on
  • I just published a Github repo of a basic template for creating a Web Bluetooth js app to interact with a Puck.js in a browser...

    https://github.com/cmenscher/puckWebBlue­toothTemplate

    It uses Bootstrap and jQuery, but you can easily rip those out. I've tested it on Chrome Desktop (OSX) and Android Chrome. I hope it's useful!

  • Nice, thanks! It'd be well worth adding it to GitHub pages and providing a link in the Readme - then we could hopefully try it out just by clicking on it!

  • Oops! It was already being hosted at https://cmenscher.github.io/puckWebBluet­oothTemplate/, but you're totally right so I added a link to the README. 👌

  • Nice! Thanks for sharing @cmensche.

  • re "If the Puck never gets found, you may have to power cycle the Puck by taking the battery out. If you know of a way around this, please tell me!" I've found that as long as I make sure all other sessions have disconnected from the puck then it goes back into discovery mode, but does not advertise itself if it's currently connected

  • Is there a way to force a disconnect? I've found that to be true as well but closing browser windows doesn't seem to do it. I suppose there's some kind of timeout but I'd be happy to put a disconnect button somewhere.

  • It's not done by default, but uploading setWatch(function(){NRF.disconnect()},BT­N,{edge:"rising",repeat:true,debounce:50­}) should force a disconnect when the button is pressed.

  • I actually send

    connection.write("NRF.on('disconnect', function() { reset(); });"); 
    

    when the app initially connects to the puck, but when watching the IDE it doesn't ever seem to run. I updated the NRF.disconnect() to the resetPuck function, but on testing it doesn't seem to do much either. But I could be missing something. ;-) I don't think it's a major issue, but my biggest concern is to prevent the puck from continuously running the code/send data and burn the battery. I assume calling reset() is enough to terminate most CPU and radio activity.

  • If you add NRF.on('disconnect', function() { digitalPulse(LED3,1,1000); setTimeout("reset()",1500);}); you'll see the LED flash, which would tell you if it was resetting.

    I think your problem might just be that you haven't put a newline at the end of the write command?

  • Ah! Duh. Thanks I'll try adding the newline.

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

Published a Web Bluetooth JS app for anyone to use

Posted by Avatar for cmenscher @cmenscher

Actions