• As a follow on from a previous post( Espruino Hub and BLE) I am trying to connect a raspberrypi to the bangle and send from the pi a short message or two digit code.
    I have researched the espruino ref https://www.espruino.com/Interfacing#blu­etooth-le, and in so doing came across a ble wrapper called bleak.
    This seems suited to my purpose but whilst it will connect and appear to send data it the data does not show on the bangle.
    I also do not know what ref I would need for these to entries (UUID_NORDIC_TX = ""
    UUID_NORDIC_RX = ""
    If it helps this is the shell output

    Connecting...
    Connected
    Writing command
    RX> bytearray(b"E.showMessage(\'Hello")
    RX> bytearray(b"\',\'A")
    RX> bytearray(b" Title\')/n")
    Waiting for data
    Done!

    and this is the python code

    e#!/usr/bin/env python3
    
    import asyncio
    import array
    from bleak import discover
    from bleak import BleakClient
    
    address = "D8:AB:E0:B7:F5:AE"
    UUID_NORDIC_TX = "6e400002-b5a3-f393-e0a9-e50e24dcca9e"
    UUID_NORDIC_RX = "6e400003-b5a3-f393-e0a9-e50e24dcca9e"
    command = b"E.showMessage('Hello','A Title')/n"
    
    def uart_data_received(sender, data):
        print("RX> {0}".format(data))
    
    # You can scan for devices with:
    [#async](http://forum.espruino.com/searc­h/?q=%23async) 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!")
    
    
    
    

    Any guidance appreciated.

About

Avatar for user118216 @user118216 started