コード例 #1
0
def temperature(params):

    moteSelected = macToMoteId(params[0])
    if moteSelected < 0:
        print 'moteId invalid'
        return
    # filter params
    try:
        moteId = moteSelected
        isBcast = False
    except:
        isBcast = True
    tempOn = int(params[1])
    pktPeriod = int(params[2])

    if moteId > len(AppData().get('operationalmotes')):
        print 'moteId {0} impossible, there are only {1} motes'.format(
            moteId,
            len(AppData().get('operationalmotes')),
        )
        return

    # send OAP command ... single or all broadcast
    if not isBcast:
        AppData().get('oap_clients')[AppData().get('operationalmotes')
                                     [moteId]].send(
                                         cmd_type=OAPMessage.CmdType.PUT,
                                         addr=[5],
                                         data_tags=[
                                             OAPMessage.TLVByte(t=0, v=tempOn),
                                             OAPMessage.TLVLong(t=1,
                                                                v=pktPeriod),
                                         ],
                                     )
    else:
        # build OAP message
        oap_msg = OAPMessage.build_oap(
            seq=0,
            sid=0,
            cmd=OAPMessage.CmdType.PUT,
            addr=[5],
            tags=[
                OAPMessage.TLVByte(t=0, v=tempOn),
                OAPMessage.TLVLong(t=1, v=pktPeriod),
            ],
            sync=True,
        )
        oap_msg = [ord(b) for b in oap_msg]

        # send OAP message broadcast NUM_BCAST_TO_SEND times
        for i in range(NUM_BCAST_TO_SEND):
            AppData().get('connector').dn_sendData(
                macAddress=[0xff] * 8,
                priority=0,
                srcPort=OAPMessage.OAP_PORT,
                dstPort=OAPMessage.OAP_PORT,
                options=0x00,
                data=oap_msg,
            )
コード例 #2
0
ファイル: OapClient.py プロジェクト: dustcloud/smartmeshsdk
def temp_clicb(params):
    
    # filter params
    try:
        moteId    = int(params[0])
        isBcast   = False
    except:
        isBcast   = True 
    tempOn      = int(params[1])
    pktPeriod   = int(params[2])
    
    if moteId>len(AppData().get('operationalmotes')):
        print 'moteId {0} impossible, there are only {1} motes'.format(
            moteId,
            len(AppData().get('operationalmotes')),
        )
        return
    
    # send OAP command ... single or all broadcast
    if not isBcast:
        AppData().get('oap_clients')[AppData().get('operationalmotes')[moteId]].send(
            cmd_type   = OAPMessage.CmdType.PUT,
            addr       = [5],
            data_tags  = [
                OAPMessage.TLVByte(t=0,v=tempOn),
                OAPMessage.TLVLong(t=1,v=pktPeriod),
            ],
        )
    else:
        # build OAP message
        oap_msg = OAPMessage.build_oap(
            seq          = 0,
            sid          = 0,
            cmd          = OAPMessage.CmdType.PUT,
            addr         = [5],
            tags         = [
                OAPMessage.TLVByte(t=0,v=tempOn),
                OAPMessage.TLVLong(t=1,v=pktPeriod),
            ],
            sync         = True,
        )
        oap_msg = [ord(b) for b in oap_msg]
        
        # send OAP message broadcast NUM_BCAST_TO_SEND times
        for i in range (NUM_BCAST_TO_SEND):
            AppData().get('connector').dn_sendData(
                macAddress   = [0xff]*8,
                priority     = 0,
                srcPort      = OAPMessage.OAP_PORT,
                dstPort      = OAPMessage.OAP_PORT,
                options      = 0x00,
                data         = oap_msg,
            )
コード例 #3
0
ファイル: OapClient.py プロジェクト: ddidiy/smartmeshsdk
def led_clicb(params):
    
    # filter params
    try:
        moteId    = int(params[0])
        isBcast   = False
    except:
        isBcast   = True
    ledState  = params[1]
    
    if moteId>len(AppData().get('operationalmotes')):
        print 'moteId {0} impossible, there are only {1} motes'.format(
            moteId,
            len(AppData().get('operationalmotes')),
        )
        return
    
    if ledState=="0":
        ledVal = 0
    else:
        ledVal = 1
    
    # send OAP command ... single or all broadcast
    if not isBcast:
        AppData().get('oap_clients')[AppData().get('operationalmotes')[moteId]].send(
            cmd_type   = OAPMessage.CmdType.PUT,
            addr       = [3,2],
            data_tags  = [OAPMessage.TLVByte(t=0,v=ledVal)],
            cb         = _respPoipoi,
        )
    else:
        # build OAP message
        oap_msg = OAPMessage.build_oap(
            seq          = 0,
            sid          = 0,
            cmd          = OAPMessage.CmdType.PUT,
            addr         = [3,2],
            tags         = [OAPMessage.TLVByte(t=0,v=ledVal)],
            sync         = True,
        )
        oap_msg = [ord(b) for b in oap_msg]
        
        # send OAP message broadcast NUM_BCAST_TO_SEND times
        for i in range (NUM_BCAST_TO_SEND):
            AppData().get('connector').dn_sendData(
                macAddress   = [0xff]*8,
                priority     = 0,
                srcPort      = OAPMessage.OAP_PORT,
                dstPort      = OAPMessage.OAP_PORT,
                options      = 0x00,
                data         = oap_msg,
            )
コード例 #4
0
    def _sendOap(self, macToSendTo):

        with self.dataLock:

            # build OAP message
            oap_msg = OAPMessage.build_oap(
                seq=0,
                sid=0,
                cmd=OAPMessage.CmdType.PUT,
                addr=[3, 2],
                tags=[OAPMessage.TLVByte(t=0, v=self.ledVal)],
                sync=True,
            )
            oap_msg = [ord(b) for b in oap_msg]

            # send OAP message
            connector.dn_sendData(
                macAddress=macToSendTo,
                priority=0,
                srcPort=OAPMessage.OAP_PORT,
                dstPort=OAPMessage.OAP_PORT,
                options=0x00,
                data=oap_msg,
            )
コード例 #5
0
 def _sendOap(self,macToSendTo):
     
     with self.dataLock:
         
         # build OAP message
         oap_msg = OAPMessage.build_oap(
             seq          = 0,
             sid          = 0,
             cmd          = OAPMessage.CmdType.PUT,
             addr         = [3,2],
             tags         = [OAPMessage.TLVByte(t=0,v=self.ledVal)],
             sync         = True,
         )
         oap_msg = [ord(b) for b in oap_msg]
         
         # send OAP message
         connector.dn_sendData(
             macAddress   = macToSendTo,
             priority     = 0,
             srcPort      = OAPMessage.OAP_PORT,
             dstPort      = OAPMessage.OAP_PORT,
             options      = 0x00,
             data         = oap_msg,
         )
コード例 #6
0
    config.verify_ssl = False

    if os.path.isfile(certifi.where()):
        config.ssl_ca_cert = certifi.where()
    else:
        config.ssl_ca_cert = os.path.join(os.path.dirname(sys.executable),
                                          "cacert.pem")

    # initialize the VManager Python library
    voyager = VManagerApi(host=mgrhost)

    # build OAP message
    oap_msg = OAPMessage.build_oap(
        seq=0,
        sid=0,
        cmd=OAPMessage.CmdType.PUT,
        addr=[3, 2],
        tags=[OAPMessage.TLVByte(t=0, v=ledVal)],
        sync=True,
    )
    oap_msg_b64 = base64.b64encode(oap_msg)  # Convert from bin to base64

    # send the packet, once if to one mote, 4 times if Broadcast
    if macaddr == "FF-FF-FF-FF-FF-FF-FF-FF":
        loop = 3
    else:
        loop = 1
    for x in xrange(loop):
        sendapacket(macaddr, oap_msg_b64)
        time.sleep(2)

    print 'Script ended normally'
コード例 #7
0
    def _sendOapCommand(self, targetNet, targetMac, oapAddress, oapTags):

        #===== send

        dataToSend = OAPMessage.build_oap(
            0,  # seq_num
            0,  # session_id
            OAPMessage.CmdType.PUT,  # command
            oapAddress,  # address 254=pkgen
            tags=oapTags,  # parameters,
            sync=True,
        )

        dataToSend = [ord(b) for b in dataToSend]

        # dispatch
        dispatcher.send(
            signal='dataToMesh_{0}'.format(targetNet),
            data={
                'mac': targetMac,
                'priority': 0,
                'srcPort': DustLinkData.DustLinkData.WKP_OAP,
                'dstPort': DustLinkData.DustLinkData.WKP_OAP,
                'options': 0,
                'data': dataToSend,
            },
        )

        #===== compute expected ACK

        expectedAck = [0x02, 0x00, 0xff, len(oapAddress)] + oapAddress

        #===== wait for ACK

        waitStartTime = time.time()
        self.waitForResponseEvent.clear()

        while True:

            # calculate how much time left to wait for response
            timeToWait = self.MAXWAITFOROAPRESPONSE - (time.time() -
                                                       waitStartTime)
            if timeToWait < 0:
                timeToWait = None

            # wait for a response
            if self.waitForResponseEvent.wait(timeToWait):
                # I received a response

                self.waitForResponseEvent.clear()

                with self.responseBufLock:

                    if (self.reponseBuf['mac'] == targetMac and
                            self.reponseBuf['srcPort'] == OAPMessage.OAP_PORT
                            and self.reponseBuf['destPort']
                            == OAPMessage.OAP_PORT
                            and len(self.reponseBuf['payload'])
                            == len(expectedAck) + 2
                            and self.reponseBuf['payload'][-len(expectedAck):]
                            == expectedAck):
                        return

            else:
                # timeout
                raise SystemError(
                    "OAP Timeout: no ACK received after {0}s".format(
                        self.MAXWAITFOROAPRESPONSE))
コード例 #8
0
    config.password     = '******'
    config.verify_ssl   = False
    
    if os.path.isfile(certifi.where()):
        config.ssl_ca_cert  = certifi.where()
    else:
        config.ssl_ca_cert = os.path.join(os.path.dirname(sys.executable), "cacert.pem")
    
    # initialize the VManager Python library
    voyager = VManagerApi(host=mgrhost)
    
    # build OAP message
    oap_msg = OAPMessage.build_oap(
        seq             = 0,
        sid             = 0,
        cmd             = OAPMessage.CmdType.PUT,
        addr            = [3,2],
        tags            = [OAPMessage.TLVByte(t=0,v=ledVal)],
        sync           = True,
    )
    oap_msg_b64 = base64.b64encode(oap_msg)   # Convert from bin to base64

    # send the packet, once if to one mote, 4 times if Broadcast
    if macaddr == "FF-FF-FF-FF-FF-FF-FF-FF":
        loop = 3
    else:
        loop = 1
    for x in xrange(loop):
        sendapacket(macaddr, oap_msg_b64)
        time.sleep(2)

    print 'Script ended normally'
コード例 #9
0
ファイル: OapClient.py プロジェクト: ddidiy/smartmeshsdk
def pkgen_clicb(params):
    
    # filter params
    try:
        moteId    = int(params[0])
        isBcast   = False
    except:
        isBcast   = True 
    numPkt      = int(params[1])
    pktPeriod   = int(params[2])
    pktSize     = int(params[3])
    pktstartPID = 0
    
    if moteId>len(AppData().get('operationalmotes')):
        print 'moteId {0} impossible, there are only {1} motes'.format(
            moteId,
            len(AppData().get('operationalmotes')),
        )
        return
    
    # send OAP command ... single mote, or all unicast, or all broadcast
    if isBcast == False:
        AppData().get('oap_clients')[AppData().get('operationalmotes')[moteId]].send(
            cmd_type   = OAPMessage.CmdType.PUT,
            addr       = [254],
            data_tags  = [
                OAPMessage.TLVLong(t=0,v=1),
                OAPMessage.TLVLong(t=1,v=numPkt),
                OAPMessage.TLVLong(t=2,v=pktPeriod),
                OAPMessage.TLVByte(t=3,v=pktSize),
                OAPMessage.TLVByte(t=4,v=pktstartPID),
            ],
        )
    elif params[0] == "allu":
        print " Sending Unicast command to all motes\n"
        for mote_mac in AppData().get('operationalmotes'):
            AppData().get('oap_clients')[mote_mac].send(
                cmd_type   = OAPMessage.CmdType.PUT,
                addr       = [254],
                data_tags  = [
                    OAPMessage.TLVLong(t=0,v=1),
                    OAPMessage.TLVLong(t=1,v=numPkt),
                    OAPMessage.TLVLong(t=2,v=pktPeriod),
                    OAPMessage.TLVByte(t=3,v=pktSize),
                    OAPMessage.TLVByte(t=4,v=pktstartPID),
                ],
            )
            time.sleep(.25)
    elif params[0] == "allb":
        print " Sending Broadcast command to all motes\n"
        # build OAP message
        oap_msg = OAPMessage.build_oap(
            seq          = 0,
            sid          = 0,
            cmd          = OAPMessage.CmdType.PUT,
            addr         = [254],
            tags         = [
                OAPMessage.TLVLong(t=0,v=1),
                OAPMessage.TLVLong(t=1,v=numPkt),
                OAPMessage.TLVLong(t=2,v=pktPeriod),
                OAPMessage.TLVByte(t=3,v=pktSize),
                OAPMessage.TLVByte(t=4,v=pktstartPID),
            ],
            sync         = True,
        )
        oap_msg = [ord(b) for b in oap_msg]
                
        # send OAP message broadcast NUM_BCAST_TO_SEND times
        for i in range (NUM_BCAST_TO_SEND):
            AppData().get('connector').dn_sendData(
                macAddress   = [0xff]*8,
                priority     = 0,
                srcPort      = OAPMessage.OAP_PORT,
                dstPort      = OAPMessage.OAP_PORT,
                options      = 0x00,
                data         = oap_msg,
            )
    else:
        print (' unknown paramater ... {0}'.format(params[0]))
コード例 #10
0
 def _sendOapCommand(self,targetNet,targetMac,oapAddress,oapTags):
     
     #===== send
     
     dataToSend =    OAPMessage.build_oap(
                                         0,                       # seq_num
                                         0,                       # session_id
                                         OAPMessage.CmdType.PUT,  # command
                                         oapAddress,              # address 254=pkgen
                                         tags=oapTags,            # parameters,
                                         sync=True,
                                     )
     
     dataToSend = [ord(b) for b in dataToSend]
                     
     # dispatch
     dispatcher.send (
         signal        = 'dataToMesh_{0}'.format(targetNet),
         data          = {
             'mac':         targetMac,
             'priority':    0,
             'srcPort':     DustLinkData.DustLinkData.WKP_OAP,
             'dstPort':     DustLinkData.DustLinkData.WKP_OAP,
             'options':     0,
             'data':        dataToSend,
         },
     )
     
     #===== compute expected ACK
     
     expectedAck = [0x02,0x00,0xff,len(oapAddress)]+oapAddress
     
     #===== wait for ACK
     
     waitStartTime   = time.time()
     self.waitForResponseEvent.clear()
     
     while True:
         
         # calculate how much time left to wait for response
         timeToWait = self.MAXWAITFOROAPRESPONSE - (time.time()-waitStartTime)
         if timeToWait<0:
             timeToWait = None
         
         # wait for a response
         if self.waitForResponseEvent.wait(timeToWait):
             # I received a response
             
             self.waitForResponseEvent.clear()
             
             with self.responseBufLock:
                 
                 if (self.reponseBuf['mac']==targetMac                      and
                     self.reponseBuf['srcPort']==OAPMessage.OAP_PORT        and 
                     self.reponseBuf['destPort']==OAPMessage.OAP_PORT       and
                     len(self.reponseBuf['payload'])==len(expectedAck)+2    and
                     self.reponseBuf['payload'][-len(expectedAck):]==expectedAck
                     ):
                     return
             
         else:
             # timeout
             raise SystemError("OAP Timeout: no ACK received after {0}s".format(self.MAXWAITFOROAPRESPONSE))
コード例 #11
0
            tempOn = 1
            userinput = raw_input('\nEnter the desired publish rate in ms (e.g. {0} ):'.format(DFLT_RATE))
            if userinput == "":
                pktPeriod = DFLT_RATE
            else:
                pktPeriod = int(userinput)
        else:
            tempOn = 0
            pktPeriod = DFLT_RATE

        oap_msg = OAPMessage.build_oap(
            seq          = 0,
            sid          = 0,
            cmd          = OAPMessage.CmdType.PUT,
            addr         = [5],
            tags         = [
                OAPMessage.TLVByte(t=0,v=tempOn),
                OAPMessage.TLVLong(t=1,v=pktPeriod),
            ],
            sync         = True,
        )
    elif userinput == "2":
        # '2=PKGen ON/OFF or service only
        
        userinput = raw_input(
            '\nEnter the desired PKGen mode;\n'
            '1=Turn PKGen ON\n'
            '2=Turn PKGen OFF\n'
            '3=PKGen service Bandwidth request only - no publishing\n'
        )
コード例 #12
0
 def _injectData(self,sender,signal,data):
     
     try:
         
         # log
         if log.isEnabledFor(logging.DEBUG):
             log.debug('_injectData {0}'.format(data))
         
         dld = DustLinkData.DustLinkData()
         with dld.dataLock:
             (transport,resource) = dld.getAppTransport(self._appName)
             
             if   transport == DustLinkData.DustLinkData.APP_TRANSPORT_UDP:
                 
                 raise NotImplementedError()
             
             elif transport == DustLinkData.DustLinkData.APP_TRANSPORT_OAP:
                 
                 # TODO: handle seq_num and session_id
                 
                 # format data to send
                 if   self._appName=='OAPLED':
                     dataToSend =    OAPMessage.build_oap(
                                         0,                                   # seq_num
                                         0,                                   # session_id
                                         OAPMessage.CmdType.PUT,              # command
                                         [3,2],                               # address
                                         tags=[OAPMessage.TLVByte(t=0,v=data['fields']['status'])],
                                         sync=True
                                     )
                 
                 elif self._appName=='OAPsound':
                     dataToSend =    OAPMessage.build_oap(
                                         0,                                   # seq_num
                                         0,                                   # session_id
                                         OAPMessage.CmdType.PUT,              # command
                                         [3,0],                               # address
                                         tags=[OAPMessage.TLVByte(t=0,v=data['fields']['status'])],
                                         sync=True
                                     )
                 
                 elif self._appName=='OAPTemperature':
                     dataToSend =    OAPMessage.build_oap(
                                         0,                                   # seq_num
                                         0,                                   # session_id
                                         OAPMessage.CmdType.PUT,              # command
                                         [5],                                 # address
                                         tags=[OAPMessage.TLVByte(t=0,v=1),
                                               OAPMessage.TLVLong(t=1,v=data['fields']['rate']),],# parameters,
                                         sync=True
                                     )
                 
                 else:
                     raise NotImplementedError()
                 
                 dataToSend = [ord(b) for b in dataToSend]
                 
                 # find netname
                 targetNetname = None
                 for netname in dld.getNetnames():
                     if data['mac'] in dld.getNetworkMotes(netname):
                         targetNetname = netname
                         break
                 
                 if not targetNetname:
                     raise SystemError('no network found which contains {0}'.format(data['mac']))
                 
                 # dispatch
                 self._dispatch (
                     signal        = 'dataToMesh_{0}'.format(targetNetname),
                     data          = {
                         'mac':         data['mac'],
                         'priority':    0,
                         'srcPort':     DustLinkData.DustLinkData.WKP_OAP,
                         'dstPort':     DustLinkData.DustLinkData.WKP_OAP,
                         'options':     0,
                         'data':        dataToSend,
                     },
                 )
             
             elif transport == DustLinkData.DustLinkData.APP_TRANSPORT_COAP:
                 
                 raise NotImplementedError()
                 
             elif transport == DustLinkData.DustLinkData.APP_TRANSPORT_MOTERUNNER:
                 
                 raise NotImplementedError()
                 
             else:
                 
                 raise ValueError('unexpected transport={0}'.format(transport))
     
     except Exception as err:
         import traceback
         traceback.print_exc()
         print err
コード例 #13
0
                '\nEnter the desired publish rate in ms (e.g. {0} ):'.format(
                    DFLT_RATE))
            if userinput == "":
                pktPeriod = DFLT_RATE
            else:
                pktPeriod = int(userinput)
        else:
            tempOn = 0
            pktPeriod = DFLT_RATE

        oap_msg = OAPMessage.build_oap(
            seq=0,
            sid=0,
            cmd=OAPMessage.CmdType.PUT,
            addr=[5],
            tags=[
                OAPMessage.TLVByte(t=0, v=tempOn),
                OAPMessage.TLVLong(t=1, v=pktPeriod),
            ],
            sync=True,
        )
    elif userinput == "2":
        # '2=PKGen ON/OFF or service only

        userinput = raw_input(
            '\nEnter the desired PKGen mode;\n'
            '1=Turn PKGen ON\n'
            '2=Turn PKGen OFF\n'
            '3=PKGen service Bandwidth request only - no publishing\n')

        numPkt = 30000
コード例 #14
0
ファイル: OapClient.py プロジェクト: dustcloud/smartmeshsdk
def pkgen_clicb(params):
    
    # filter params
    try:
        moteId    = int(params[0])
        isBcast   = False
    except:
        isBcast   = True 
    numPkt      = int(params[1])
    pktPeriod   = int(params[2])
    pktSize     = int(params[3])
    pktstartPID = 0
    
    if moteId>len(AppData().get('operationalmotes')):
        print 'moteId {0} impossible, there are only {1} motes'.format(
            moteId,
            len(AppData().get('operationalmotes')),
        )
        return
    
    # send OAP command ... single mote, or all unicast, or all broadcast
    if isBcast == False:
        AppData().get('oap_clients')[AppData().get('operationalmotes')[moteId]].send(
            cmd_type   = OAPMessage.CmdType.PUT,
            addr       = [254],
            data_tags  = [
                OAPMessage.TLVLong(t=0,v=1),
                OAPMessage.TLVLong(t=1,v=numPkt),
                OAPMessage.TLVLong(t=2,v=pktPeriod),
                OAPMessage.TLVByte(t=3,v=pktSize),
                OAPMessage.TLVByte(t=4,v=pktstartPID),
            ],
        )
    elif params[0] == "allu":
        print " Sending Unicast command to all motes\n"
        for mote_mac in AppData().get('operationalmotes'):
            AppData().get('oap_clients')[mote_mac].send(
                cmd_type   = OAPMessage.CmdType.PUT,
                addr       = [254],
                data_tags  = [
                    OAPMessage.TLVLong(t=0,v=1),
                    OAPMessage.TLVLong(t=1,v=numPkt),
                    OAPMessage.TLVLong(t=2,v=pktPeriod),
                    OAPMessage.TLVByte(t=3,v=pktSize),
                    OAPMessage.TLVByte(t=4,v=pktstartPID),
                ],
            )
            time.sleep(.25)
    elif params[0] == "allb":
        print " Sending Broadcast command to all motes\n"
        # build OAP message
        oap_msg = OAPMessage.build_oap(
            seq          = 0,
            sid          = 0,
            cmd          = OAPMessage.CmdType.PUT,
            addr         = [254],
            tags         = [
                OAPMessage.TLVLong(t=0,v=1),
                OAPMessage.TLVLong(t=1,v=numPkt),
                OAPMessage.TLVLong(t=2,v=pktPeriod),
                OAPMessage.TLVByte(t=3,v=pktSize),
                OAPMessage.TLVByte(t=4,v=pktstartPID),
            ],
            sync         = True,
        )
        oap_msg = [ord(b) for b in oap_msg]
                
        # send OAP message broadcast NUM_BCAST_TO_SEND times
        for i in range (NUM_BCAST_TO_SEND):
            AppData().get('connector').dn_sendData(
                macAddress   = [0xff]*8,
                priority     = 0,
                srcPort      = OAPMessage.OAP_PORT,
                dstPort      = OAPMessage.OAP_PORT,
                options      = 0x00,
                data         = oap_msg,
            )
    else:
        print (' unknown paramater ... {0}'.format(params[0]))
コード例 #15
0
    def _injectData(self, sender, signal, data):

        try:

            # log
            if log.isEnabledFor(logging.DEBUG):
                log.debug('_injectData {0}'.format(data))

            dld = DustLinkData.DustLinkData()
            with dld.dataLock:
                (transport, resource) = dld.getAppTransport(self._appName)

                if transport == DustLinkData.DustLinkData.APP_TRANSPORT_UDP:

                    raise NotImplementedError()

                elif transport == DustLinkData.DustLinkData.APP_TRANSPORT_OAP:

                    # TODO: handle seq_num and session_id

                    # format data to send
                    if self._appName == 'OAPLED':
                        dataToSend = OAPMessage.build_oap(
                            0,  # seq_num
                            0,  # session_id
                            OAPMessage.CmdType.PUT,  # command
                            [3, 2],  # address
                            tags=[
                                OAPMessage.TLVByte(t=0,
                                                   v=data['fields']['status'])
                            ],
                            sync=True)

                    elif self._appName == 'OAPTemperature':
                        dataToSend = OAPMessage.build_oap(
                            0,  # seq_num
                            0,  # session_id
                            OAPMessage.CmdType.PUT,  # command
                            [5],  # address
                            tags=[
                                OAPMessage.TLVByte(t=0, v=1),
                                OAPMessage.TLVLong(t=1,
                                                   v=data['fields']['rate']),
                            ],  # parameters,
                            sync=True)

                    else:
                        raise NotImplementedError()

                    dataToSend = [ord(b) for b in dataToSend]

                    # find netname
                    targetNetname = None
                    for netname in dld.getNetnames():
                        if data['mac'] in dld.getNetworkMotes(netname):
                            targetNetname = netname
                            break

                    if not targetNetname:
                        raise SystemError(
                            'no network found which contains {0}'.format(
                                data['mac']))

                    # dispatch
                    self._dispatch(
                        signal='dataToMesh_{0}'.format(targetNetname),
                        data={
                            'mac': data['mac'],
                            'priority': 0,
                            'srcPort': DustLinkData.DustLinkData.WKP_OAP,
                            'dstPort': DustLinkData.DustLinkData.WKP_OAP,
                            'options': 0,
                            'data': dataToSend,
                        },
                    )

                elif transport == DustLinkData.DustLinkData.APP_TRANSPORT_COAP:

                    raise NotImplementedError()

                elif transport == DustLinkData.DustLinkData.APP_TRANSPORT_MOTERUNNER:

                    raise NotImplementedError()

                else:

                    raise ValueError(
                        'unexpected transport={0}'.format(transport))

        except Exception as err:
            import traceback
            traceback.print_exc()
            print err