Beispiel #1
0
    def __init__(self):

        # variables
        self.guiLock = threading.Lock()
        self.apiDef = IpMoteDefinition.IpMoteDefinition()

        # initialize GUI window
        self.window = dustWindow.dustWindow('Upstream', self._windowCb_close)

        # create a sensor frame (don't show yet)
        self.sensorFrame = dustFrameSensorTx.dustFrameSensorTx(
            self.window,
            self.guiLock,
            frameName="sensor data to send",
            row=0,
            column=0)
        self.sensorFrame.show()

        # create a table frame
        self.tableFrame = dustFrameTable.dustFrameTable(
            self.window,
            self.guiLock,
            frameName="join state machine",
            row=1,
            column=0)

        # add a connection frame
        self.connectionFrame = dustFrameConnection.dustFrameConnection(
            self.window,
            self.guiLock,
            self._connectionFrameCb_connected,
            frameName="mote connection",
            row=2,
            column=0)
        self.connectionFrame.apiLoaded(self.apiDef)
        self.connectionFrame.show()

        # create a table frame
        self.textFrame = dustFrameText.dustFrameText(self.window,
                                                     self.guiLock,
                                                     frameName="tip",
                                                     row=3,
                                                     column=0)
        self.textFrame.setWrapLength(400)
        self.textFrame.show()
        output = []
        output += [
            'Remember to reset your mote before starting this application.'
        ]
        output += [
            'The fields in the "sensor data to send" frame are preset with IPv6 address of the motedata.dustnetworks.com server, and the UDP port it is listening on. You can change this IPv6 address and UDP port to if you wish to send to a different server. Per the 6LoWPAN standard, a UDP port chosen between 61616 (0xF0B0) and 61631 (0xF0BF) results in the best compression, thus largest payload. See the mote API guide for further information.'
        ]
        output += [
            'Note: The "send to manager" and "send to host" button become active only once the mote has reached the READYTOSEND state.'
        ]
        self.textFrame.write('\n\n'.join(output))

        # update in GUI elements
        self._updateGui()
 def __init__(self):
     self.window = dustWindow("dustFrameConnection", self._closeCb)
     self.guiLock = threading.Lock()
     self.frame = dustFrameConnection(self.window,
                                      self.guiLock,
                                      self._connectCb,
                                      row=0,
                                      column=0)
     self.apidef = IpMoteDefinition.IpMoteDefinition()
     self.frame.apiLoaded(self.apidef)
     self.frame.show()
     self.window.mainloop()
Beispiel #3
0
    def _loadApi(self):
        '''
        \brief Called when pressing the 'load' button.
        '''

        # read the configuration entered in the GUI
        self.guiLock.acquire()
        temp_networkType = self.networkTypeString.get()
        if not self.deviceType:
            self.deviceType = self.deviceTypeString.get()
        self.guiLock.release()

        # load the API definition
        try:
            if temp_networkType == self.IP and self.deviceType == self.MANAGER:
                self.apiDef = IpMgrDefinition.IpMgrDefinition()
            elif temp_networkType == self.IP and self.deviceType == self.MOTE:
                self.apiDef = IpMoteDefinition.IpMoteDefinition()
            elif temp_networkType == self.WHART and self.deviceType == self.MANAGER:
                self.apiDef = HartMgrDefinition.HartMgrDefinition()
            elif temp_networkType == self.WHART and self.deviceType == self.MOTE:
                self.apiDef = HartMoteDefinition.HartMoteDefinition()
            else:
                raise SystemError("wrong combination "+\
                                  " temp_networkType="+str(temp_networkType)+\
                                  " self.deviceType="+str(self.deviceType))
        except NotImplementedError as err:
            print str(err)
            return

        # freeze the form frame
        self.guiLock.acquire()
        self.networkTypeMenu.config(state=Tkinter.DISABLED)
        self.deviceTypeMenu.config(state=Tkinter.DISABLED)
        self.loadButton.config(state=Tkinter.DISABLED)
        self.guiLock.release()

        # call the callback
        self.cbApiLoaded(self.apiDef)
Beispiel #4
0
#============================ imports =========================================

from SmartMeshSDK.ApiDefinition   import ApiDefinition,    \
                                         IpMoteDefinition
from SmartMeshSDK.IpMoteConnector import IpMoteConnector
from SmartMeshSDK.ApiException    import CommandError,     \
                                         ConnectionError

#============================ main ============================================

print 'Simple Application which interacts with the IP mote - (c) Dust Networks'

print '\n\n================== Step 1. API exploration ========================'

print '\n=====\nLoad the API definition of the IP mote'
apidef = IpMoteDefinition.IpMoteDefinition()
print 'done.'

print '\n=====\nList all the defined command IDs:'
print apidef.getIds(ApiDefinition.ApiDefinition.COMMAND)

print '\n=====\nList all the defined command names:'
print apidef.getNames(ApiDefinition.ApiDefinition.COMMAND)

print '\n=====\nGet the command name of command ID 2:'
print apidef.idToName(ApiDefinition.ApiDefinition.COMMAND, 2)

print '\n=====\nGet the command ID of command name \'getParameter\':'
print apidef.nameToId(ApiDefinition.ApiDefinition.COMMAND, ['getParameter'])

print '\n=====\nList the subcommand of command \'getParameter\':'
Beispiel #5
0
 def __init__(self, maxQSize=100):
     api_def = IpMoteDefinition.IpMoteDefinition()
     SerialConnector.SerialConnector.__init__(self, api_def, maxQSize)