Avatar for Ossama

Ossama

Member since Oct 2018 • Last active Jan 2019
  • 5 conversations
  • 33 comments

Most recent activity

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

    the following seems to works. all good thanks

    \x10Bluetooth.println(beam(mycool))\n

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

    thanks, so i have tried the following and it works but i do receive an echo of the input command. so i tried with the \x10, but this does not work, however i receive the following echoed back.

    when issuing the following command

    "beam(sleep)\n"
    

    i get

    {"topic":"/ble/data/d8:19:e7:5b:3a:57/nu­s/nus_rx","payload":"beam(sleep)\r\n","q­os":0,"retain":false,"_msgid":"2846d788.­245218"}

    and

    {"topic":"/ble/data/d8:19:e7:5b:3a:57/nu­s/nus_rx","payload":"=\"testing\"\r\n>",­"qos":0,"retain":false,"_msgid":"3714119­6.ec66fe"}

    however when issuing the following command to rid of the echoed command

    "\x10beam(sleep)\n"
    

    i only get

    {"topic":"/ble/data/d8:19:e7:5b:3a:57/nu­s/nus_rx","payload":"\"\x10beam(sleep)\n­\"","qos":0,"retain":false,"_msgid":"721­7a5c4.d44c8c"}

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

    Could i use a puck.js to detect another puck presence, i.e. have one in the car and another in the garrage, and use the one in the garrage to detect the one in the car, i.e. rssi level and act when rssi level is at certain value?

    Thanks

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

    maybe i should rephrase my last message,

    what is the best way to execute a function within the puck and get a response

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

    what about the result from the function, i.e i want to send ack back .

    also i am having issue publishing on the nodered from another lan machine

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

    i really appreciate your help...
    i have reverted to the hub and mqtt. and can send commands, but how am i able to receive a function response from the puck.

    Many thanks

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

    This my code so far on the puck , and I am able to connect using the python code below and send commands, but I am unable to return a value back, actually I do receive something, such as

    <type 'str'>
    <- Serial1
    >
    

    but it should be temperature reading of the puck. any help please

    Puck Code:

    function beam(ircode)
    {
      Puck.IR(require("pronto").decode(ircode)­);
      digitalWrite(LED2,1);
      setTimeout(function() 
      {
        digitalWrite(LED2,0);
      }, delayInMilliseconds);
      return E.getTemperature();
    }
    

    Python:

    import sys
    from bluepy.btle import UUID, Peripheral
    import time
    import binascii
    from bluepy import btle
    
    command = "\x03\x10beam(" +sys.argv[2]+ ");\n"
    
    class MyDelegate(btle.DefaultDelegate):
        def __init__(self):
            btle.DefaultDelegate.__init__(self)
    
        def handleNotification(self, cHandle, data):
            print("A notification was received: %s" %data)
            
    p = Peripheral(sys.argv[1], 'random')
    p.setDelegate(MyDelegate())
    try:
            UartService=p.getServiceByUUID(UUID("6E4­00001-B5A3-F393-E0A9-E50E24DCCA9E"))
            ch = UartService.getCharacteristics(UUID("6E4­00002-B5A3-F393-E0A9-E50E24DCCA9E"))[0]
    
            while len(command)>0:
                    ch.write(command[0:20]);
                    command = command[20:];
    
            
            p.writeCharacteristic(ch.valHandle+1, "\x02\x00")
    
            while True:
                if p.waitForNotifications(1.0):
                    # handleNotification() was called
                    continue
    
                print("Waiting...")
                # Perhaps do something else here
            [#rx](http://forum.espruino.com/search/?­q=%23rx) = UartService.getCharacteristics(UUID("6E4­00003-B5A3-F393-E0A9-E50E24DCCA9E"))[0]
            [#val](http://forum.espruino.com/search/­?q=%23val) = rx.read()
            [#print](http://forum.espruino.com/searc­h/?q=%23print) val
        
    
            p.disconnect()
    finally:
            p.disconnect()
    
  • in Puck.js, Pixl.js and MDBT42
    Avatar for Ossama

    Thanks

    this is such an example, so i need to setup anything on the puck.js side?

    while True:

        if p.waitForNotifications(1.0):
            print("Notification trigger")
            continue
    print("Waiting")
    

    is

    return E.getTemperature();

    sufficient

Actions