• Thanks Gordon,
    So I now have double quotes back in and I have tested the connection and it has worked ok so far in terms of not giving the connection error.However the console output looks werid and the watch display is blank.
    So I will post the complete code.

    ``
    #!/usr/bin/env python3

    import asyncio
    import array
    from bleak import discover
    from bleak import BleakClient
    import json

    #create dictionary for the data to be sent
    dict = {'Code': '10'}

    address = "D8:AB:E0:B7:F5:AE"
    UUID_NORDIC_TX = "6e400002-b5a3-f393-e0a9-e50e24dcca9e"
    UUID_NORDIC_RX = "6e400003-b5a3-f393-e0a9-e50e24dcca9e"
    #command = "X("+json.dumps(dict)+")\n"
    #command = b"E.showMessage('Hello','A Title')/n"
    command = "Y("+json.dumps(dict)+")\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]),'utf-8') , 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))

    My app. Note function is now Y.
    
    

    E.showMessage("Hello Code");

    function Y(dict) {
    E.showMessage(dict);

    }

    and the console
    
    
    

    Connecting...
    Connected
    Writing command
    Waiting for data
    RX> bytearray(b'Y({"Code": "10"})\r\n')
    RX> bytearray(b'Y({"Code": "10"})\r\n')
    RX> bytearray(b'Uncaught Error: Func')
    RX> bytearray(b'Uncaught Error: Func')
    RX> bytearray(b'tion "split" not fou')
    RX> bytearray(b'tion "split" not fou')
    RX> bytearray(b'nd!\r\n at line 1 col ')
    RX> bytearray(b'nd!\r\n at line 1 col ')
    RX> bytearray(b'250\r\n...ect(c/2-b,44')
    RX> bytearray(b'250\r\n...ect(c/2-b,44')
    RX> bytearray(b',c/2+b,45)}b=e.split')
    RX> bytearray(b',c/2+b,45)}b=e.split')
    RX> bytearray(b'("\n");var h=(f-16*b')
    RX> bytearray(b'("\n");var h=(f-16*b')
    RX> bytearray(b'.length)...\r\n ')
    RX> bytearray(b'.length)...\r\n ')
    RX> bytearray(b' ')
    RX> bytearray(b' ')
    RX> bytearray(b' ^\r\nin function ca')
    RX> bytearray(b' ^\r\nin function ca')
    RX> bytearray(b'lled from line 1 col')
    RX> bytearray(b'lled from line 1 col')
    RX> bytearray(b' 19\r\nE.showMessage(d')
    RX> bytearray(b' 19\r\nE.showMessage(d')
    RX> bytearray(b'ict);\r\n ')
    RX> bytearray(b'ict);\r\n ')
    RX> bytearray(b' ^\r\nat line 1 co')
    RX> bytearray(b' ^\r\nat line 1 co')
    RX> bytearray(b'l 19\r\nE.showMessage(')
    RX> bytearray(b'l 19\r\nE.showMessage(')
    RX> bytearray(b'dict);\r\n ')
    RX> bytearray(b'dict);\r\n ')
    RX> bytearray(b' ^\r\nin function')
    RX> bytearray(b' ^\r\nin function')
    RX> bytearray(b' "Y" called from lin')
    RX> bytearray(b' "Y" called from lin')
    RX> bytearray(b'e 1 col 17\r\nY({"Code')
    RX> bytearray(b'e 1 col 17\r\nY({"Code')
    RX> bytearray(b'": "10"})\r\n ')
    RX> bytearray(b'": "10"})\r\n ')
    RX> bytearray(b' ^\r\n>')
    RX> bytearray(b' ^\r\n>')
    Done!

    ```
    Any help most appreciated.

About

Avatar for user118216 @user118216 started