Avatar for PiOfThings

PiOfThings

Member since Dec 2019 • Last active Jan 2020
  • 5 conversations
  • 27 comments

IoT bungler ;-)

Most recent activity

    • 14 comments
    • 563 views
  • in Bangle.js
    Avatar for PiOfThings

    @Gordon thanks... works perfectly with StorageFile. Silly me 🥴, I was trying to use Storage.read or something.

  • in Bangle.js
    Avatar for PiOfThings

    @Gordon just to clarify, once the file increases in size and starts getting the shard marker in the end we have to use the shard marker in the name when we do a read, correct?

    // say I have written a big file called 'myfile'
    var s = require("Storage");
    // print(s.read("myfile")); // would return undefined
    print(s.read("myfile\1")); // returns the first block of the file.
    

    I am getting this behaviour, I am still on the default beta version firmware that came with my KS Beta unit.

  • in Bangle.js
    Avatar for PiOfThings

    Okay, as per this example from bleak, Darwin aka OSX doesn't work with MAC address, it needs the funky string ID of the device.

  • in Bangle.js
    Avatar for PiOfThings

    Brilliant! Finally got something to work... bleak works on my laptop.

    The example gives the impression that the mac address of the BangleJS is good enough to connect to it, but that didn't work. So instead I commented out the command run and used the discover run to first get the address. It came out as a long set of strings for all the nearby BLE devices, thankfully it identified Bangle as follows (I've mangled the last 5 characters).

    0DB07D6F-8F0F-4CB3-A801-0D9A868XX9XX: Bangle.js ed8a
    

    I then used this as the address and the following code came back with a list of files though it is still a bit mangled, but it's a start.

    import asyncio
    import array
    from bleak import discover
    from bleak import BleakClient
    
    address = "0DB07D6F-8F0F-4CB3-A801-0D9A868XX9XX"
    UUID_NORDIC_TX = "6e400002-b5a3-f393-e0a9-e50e24dcca9e"
    UUID_NORDIC_RX = "6e400003-b5a3-f393-e0a9-e50e24dcca9e"
    command = b"\x03\x10var f = require('Storage')\n\x10 print(f.list())\n\x10print('Hello World')\n"
    
    def uart_data_received(sender, data):
        print("RX> {0}".format(data))
    
     # You can scan for devices with:
     # async def run():
     #    devices = await discover()
     #    for d in devices:
     #        print(d)
    
    print("Connecting...")
    async def run(address, loop):
        async with BleakClient(address, loop=loop) as client:
            print("Connected")
            await client.start_notify(UUID_NORDIC_RX, uart_data_received)
            print("Writing command")
            c=command
            while len(c)>0:
              await client.write_gatt_char(UUID_NORDIC_TX, bytearray(c[0:20]), True)
              c = c[20:]
            print("Waiting for data")
            await asyncio.sleep(1.0, loop=loop) # wait for a response
            print("Done!")
    
    
    loop = asyncio.get_event_loop()
    loop.run_until_complete(run(address, loop))
     # loop.run_until_complete(run())
    
  • in Bangle.js
    Avatar for PiOfThings

    @ConorONeill Thanks... and @Gordon woah... how did I miss that... Thanks a ton... Given noble is unhappy on my laptop, I'll give Python a go...

  • in Bangle.js
    Avatar for PiOfThings

    @ConorONeill thanks for the heads up... I was having trouble with my dev environment, first OSX baulked, but I don't have full XCode (only bare minimum) installed, so I thought I would try Linux.

    Then my linux box baulked, someone has messed the apt-repository index files and it won't install anything.

    So my third step was to setup a Pi... This is where I had left it until I saw your note. Will proceed with caution.

    Any alternates you know of?

    @AkosLukacs yeah I think all I need to do it stick the self signed cert into the Trusted Keystore, now if I could only find a reliable documentation on how to do that on OSX. The cert generated by OSX Keystore isn't accepted by http-server (node app) and the one generated by openssl isn't accepted into the Keystore atm.

    Might come back to this if Noble fails.

  • in Bangle.js
    Avatar for PiOfThings

    Just after posting, I find this... https://github.com/noble/noble

    I am going to see if I can connect to my Bangle using this and build a nice bridge.

  • in Bangle.js
    Avatar for PiOfThings

    While Web BLE is simply genius when it comes to ease of using pre-built development tools, I want to build a 'server' side app/tool to suck up all data from my Bangle watch. Web BLE's valid https cert requirement is really getting in the way at the moment for me.

    I just want a Node console application that connects to my Bangle JS and pulls existing files (created by my BangleJS App on the watch).

    I saw the example of using Puck.js over Web BLE, can I do something like that without Web BLE? Say I pair my watch with my laptop, can I use simple NodeJS to pull files over Bluetooth? Any guidance is appreciated. It need not be Bangle JS specific, any Espruino sample will do.

    Cheers

Actions