Beispiel #1
0
def connect_clicb(params):
    
    # filter params
    port = params[0]
    
    try:
        AppData().get('connector')
    except KeyError:
        pass
    else:
        print 'already connected.'
        return
    
    # create a connector
    AppData().set('connector',IpMgrConnectorSerial.IpMgrConnectorSerial())
    
    # connect to the manager
    try:
        AppData().get('connector').connect({
            'port': port,
        })
    except ConnectionError as err:
        print 'Could not connect to {0}: {1}'.format(
            port,
            err,
        )
        AppData().delete('connector')
        return
    
    # start threads
    AppData().set('manager',Manager())
Beispiel #2
0
def disconnectManagers(port):
    pm = portsManagerDict[port]
    try:
        pm['manager'].disconnect()
        pm['manager'] = IpMgrConnectorSerial.IpMgrConnectorSerial()
    except Exception as e:
        print e
Beispiel #3
0
 def __init__(self):
     self.fileLock = threading.RLock()
     self.hdlc = OpenHdlc.OpenHdlc()
     self.hrParser = HrParser.HrParser()
     self.api = IpMgrDefinition.IpMgrDefinition()
     self.connSerial = IpMgrConnectorSerial.IpMgrConnectorSerial()
     self.oapLock = threading.RLock()
     self.oap = OAPDispatcher.OAPDispatcher()
     self.oap.register_notif_handler(self._handle_oap_notif)
Beispiel #4
0
def main():
    global frontendName

    # Parse CLI arguments
    parser = argparse.ArgumentParser(prog='rfid-cli',
                                     description='RFID command line client')
    parser.add_argument('-p',
                        '--port',
                        help='SmartMesh manager serial port',
                        required=True)
    parser.add_argument('-f',
                        '--frontend',
                        help='The web frontend to display',
                        required=True)
    args = parser.parse_args()

    # Fetch user defined COM port
    port = args.port
    frontendName = args.frontend

    # Create serial connection to manager
    print('Connecting to {0}'.format(port))
    connector = IpMgrConnectorSerial.IpMgrConnectorSerial()
    try:
        connector.connect({'port': port})
    except ConnectionError as err:
        print('Could not connect to {0}: {1}'.format(port, err))
        connector.disconnect()
        sys.exit(1)

    # Hook program exits and perform cleanup
    def cleanup(signum, frame):
        # Disconnect the serial connection on exit
        # NOTE: Failure to disconnect the connector will mean the
        #       program will not exit due to still running threads
        print('Disconnecting from {0}...'.format(port))
        connector.disconnect()
        print('Disconnection successful')
        sys.exit(0)

    signal.signal(signal.SIGINT, cleanup)

    # Create SmartMesh subscriber
    print('Connection successful.')
    print('Subscribing to SmartMesh notifications...')
    subscriber = IpMgrSubscribe.IpMgrSubscribe(connector)
    subscriber.start()
    subscriber.subscribe(
        notifTypes=[IpMgrSubscribe.IpMgrSubscribe.NOTIFDATA],
        fun=meshNotificationHandler,
        isRlbl=False,
    )

    # Start web server
    print('Running web server: http://127.0.0.1:5000')
    socketio.run(app, host='127.0.0.1', port='5000')
Beispiel #5
0
 def run(self):
     
     # connect to manager
     self.mgr = IpMgrConnectorSerial.IpMgrConnectorSerial()
     self.mgr.connect({'port': SERIALPORT_MGR})
     
     # connect to tag
     self.tag = IpMoteConnector.IpMoteConnector()
     self.tag.connect({'port': SERIALPORT_TAG})
     
     for networksize in range(5,46,5):
         self.runExperimentForSize(networksize)
Beispiel #6
0
def connect_clicb(params):
    global connector
    global oapTxRx

    # filter params
    port = params[0]

    # create a coonnector
    connector = IpMgrConnectorSerial.IpMgrConnectorSerial()

    # connect to the manager
    try:
        connector.connect({
            'port': port,
        })
    except ConnectionError as err:
        printExcAndQuit(err)

    # create main object
    oapTxRx = OapTxRx(connector)
    def run(self):

        while self.goOn:

            try:
                print 'Connecting to {0}...'.format(self.serialPort),
                self.connector = IpMgrConnectorSerial.IpMgrConnectorSerial()
                self.connector.connect({'port': self.serialPort})
                subscriber = IpMgrSubscribe.IpMgrSubscribe(self.connector)
                subscriber.start()
                subscriber.subscribe(
                    notifTypes=[
                        IpMgrSubscribe.IpMgrSubscribe.ERROR,
                        IpMgrSubscribe.IpMgrSubscribe.FINISH,
                    ],
                    fun=self._handle_ErrorFinish,
                    isRlbl=True,
                )
                subscriber.subscribe(
                    notifTypes=[
                        IpMgrSubscribe.IpMgrSubscribe.NOTIFDATA,
                    ],
                    fun=self._handle_data,
                    isRlbl=False,
                )
                self.oap_dispatch = OAPDispatcher.OAPDispatcher()
                self.oap_dispatch.register_notif_handler(self._handle_oap)
                AppData().setConnector(self.connector)
            except Exception as err:
                print 'FAIL:'
                print err
                time.sleep(1)
            else:
                print 'PASS.'
                self.reconnectEvent.clear()
                self.reconnectEvent.wait()
            finally:
                try:
                    self.connector.disconnect()
                except:
                    pass
def connect_clicb(params):
    global connector
    global notifThread
    global snapshotThread

    # filter params
    port = params[0]

    # create a coonnector
    connector = IpMgrConnectorSerial.IpMgrConnectorSerial()

    # connect to the manager
    try:
        connector.connect({
            'port': port,
        })
    except ConnectionError as err:
        printExcAndQuit(err)

    # start threads
    notifThread = NotifThread(connector)
    snapshotThread = SnapshotThread(connector)
Beispiel #9
0
def createManagers(ports):
    global mymanagers
    mymanagers = []

    for p in ports:
        mymanagers.append(IpMgrConnectorSerial.IpMgrConnectorSerial())
Beispiel #10
0
DEFAULT_MgrSERIALPORT = '/dev/ttyUSB3'
NUMBER_OF_NETWORKS = 3

#============================ Global Variables ================================

networkIds = []
reportQueue = Queue.Queue(maxsize=0)
errorQueue = Queue.Queue(maxsize=0)
queueReady = True
queueBusy = False
session = requests.Session()
database_session = dict()
mymanagers = []
moteDict = {}
mymanager = IpMgrConnectorSerial.IpMgrConnectorSerial()
portsManagerDict = {}
indexPortsDict = {}
globalmacAddress = [0, 0, 0, 0, 0, 0, 0, 0]
managerAddress = []

#============================ functions =======================================


#----------------------------------------------------
# find_connected_devices(mymanager):
#     - The point of this function is to scan for
#       all connected USB devices and recognize the
#       Dust Managers
#     - This should be platform independent
#     - TODO: Scanning should be implemented by
Beispiel #11
0
    def run(self):

        with self.dataLock:
            self.isReconnecting = True

        while (True):

            try:

                #==== wait for an order to (re)connect

                self.reconnectSem.acquire()

                with self.dataLock:
                    assert self.isReconnecting == True

                #==== connect to serial port

                if isinstance(self.connection_details, str):
                    # connecting to a serial port

                    self.connector = IpMgrConnectorSerial.IpMgrConnectorSerial(
                    )
                    self.connector.connect({
                        'port': self.connection_details,
                    })
                else:
                    # connecting to the serialMux

                    self.connector = IpMgrConnectorMux.IpMgrConnectorMux()
                    self.connector.connect({
                        'host': self.connection_details[0],
                        'port': self.connection_details[1],
                    })

                #==== getTime

                temp = self.connector.dn_getTime()
                managerTime = float(temp.utcSecs) + float(
                    temp.utcUsecs / 1000000.0)
                self.csvLogger.managerTime(managerTime)

                #==== subscribe

                self.subscriber = IpMgrSubscribe.IpMgrSubscribe(self.connector)
                self.subscriber.start()

                self.subscriber.subscribe(
                    notifTypes=[
                        IpMgrSubscribe.IpMgrSubscribe.NOTIFDATA,
                    ],
                    fun=self._subs_notifData,
                    isRlbl=False,
                )

                self.subscriber.subscribe(
                    notifTypes=[
                        IpMgrSubscribe.IpMgrSubscribe.FINISH,
                        IpMgrSubscribe.IpMgrSubscribe.ERROR,
                    ],
                    fun=self._subs_finishOrError,
                    isRlbl=True,
                )

                #==== log

                self.csvLogger.log(CsvLogger.EVENT_CONNECTED)
                log.info(CsvLogger.EVENT_CONNECTED)

            except ConnectionError as err:

                # log
                log.warning(err)

                # schedule reconnection
                self._reconnect()

                # wait before attempting to reconnect
                time.sleep(1)

            else:

                with self.dataLock:
                    # remember I'm not connecting anymore
                    self.isReconnecting = False
Beispiel #12
0
 def _addManagerConnection(self,connectParam):
     dld = DustLinkData.DustLinkData()
     with dld.dataLock:
         
         assert(connectParam not in self.apiconnectors)
         assert(connectParam not in self.listeners)
         assert(connectParam not in self.netstate)
         assert(connectParam not in self.analyzers)
         assert(connectParam not in self.publishers)
         
         try:
             
             #===== self.apiconnectors
             
             if isinstance(connectParam,str):
                 # connecting to a serial port
                 
                 newConnector = IpMgrConnectorSerial.IpMgrConnectorSerial()
                 newConnector.connect({
                     'port': connectParam,
                 })
             else:
                 # connecting to the serialMux
                 
                 newConnector = IpMgrConnectorMux.IpMgrConnectorMux()
                 newConnector.connect({
                     'host': connectParam[0],
                     'port': connectParam[1],
                 })
         
             # log
             log.info('added apiconnectors {0}'.format(connectParam))
             
             self.apiconnectors[connectParam] = newConnector
             
             dld.updateManagerConnectionState(
                 connectParam,
                 DustLinkData.DustLinkData.MANAGERCONNECTION_STATE_ACTIVE
             )
             
             #===== delete network
             
             try:
                 dld.deleteNetwork(FormatUtils.formatConnectionParams(connectParam))
             except ValueError:
                 pass # happens if network doesn't exist
             
             #===== add network
             
             try:
                 dld.addNetwork(FormatUtils.formatConnectionParams(connectParam))
             except ValueError:
                 pass # happens if network already exists from previous connection
             
             #===== self.listeners
             
             assert(connectParam not in self.listeners)
             self.listeners[connectParam]   = GatewayListener.GatewayListener(
                 self.apiconnectors[connectParam],
                 connectParam,
             )
             log.info('added listener {0}'.format(connectParam))
             
             #===== self.netstate
             
             assert(connectParam not in self.netstate)
             self.netstate[connectParam]   = NetworkState.NetworkState(connectParam)
             log.info('added netstate {0}'.format(connectParam))
             
             #===== self.analyzers
             
             assert(connectParam not in self.analyzers)
             self.analyzers[connectParam]   = NetworkStateAnalyzer.NetworkStateAnalyzer(connectParam)
             log.info('added analyzer {0}'.format(connectParam))
             
             #===== self.publishers
             
             assert(connectParam not in self.publishers)
             self.publishers[connectParam]   = NetworkStatePublisher.NetworkStatePublisher(connectParam)
             log.info('added publisher {0}'.format(connectParam))
         
         except Exception as err:
             
             # log
             log.warning('could not add apiconnectors {0}: {1}'.format(connectParam, err))
             
             # update state
             dld.updateManagerConnectionState(
                 connectParam,
                 DustLinkData.DustLinkData.MANAGERCONNECTION_STATE_FAIL,
                 reason = str(err),
             )
             
             # detelete the connection to the manager
             self._deleteManagerConnection(connectParam)
Beispiel #13
0
    def run(self):

        try:

            dld = DustLinkData.DustLinkData()
            dld._resetScratchpad()

            dld._addScratchpad(
                "<p class=\"doc-header\">Resetting manager.</p>")

            #===== connecting to manager

            dld._addScratchpad("<p>connecting to manager at {0}.</p>".format(
                self.connectionParams))
            try:
                if isinstance(self.connectionParams, tuple):
                    # over serialMux
                    connector = IpMgrConnectorMux.IpMgrConnectorMux()
                    connector.connect({
                        'host': self.connectionParams[0],
                        'port': self.connectionParams[1],
                    })
                else:
                    # over serial
                    connector = IpMgrConnectorSerial.IpMgrConnectorSerial()
                    connector.connect({
                        'port': self.connectionParams,
                    })
            except Exception as err:
                dld._addScratchpad(
                    "<p class=\"doc-warning\">connection failed: {0}.</p>".
                    format(err))
                return
            else:
                dld._addScratchpad(
                    "<p class=\"doc-success\">connection successful.</p>")

            try:

                #===== issuing dn_getNetworkConfig()

                dld._addScratchpad("<p>issuing dn_getNetworkConfig()</p>")
                try:
                    oldconf = connector.dn_getNetworkConfig()
                except Exception as err:
                    dld._addScratchpad(
                        "<p class=\"doc-warning\">failed issuing dn_getNetworkConfig(): {0}.</p>"
                        .format(err))
                    return
                else:
                    output = []
                    output += [
                        "<p class=\"doc-success\">issued dn_getNetworkConfig() succesfully.</p>"
                    ]
                    output += ["<p>Received the following fields:</p>"]
                    output += ["<table>"]
                    output += [
                        "<tr><td>{0}</td><td>{1}</td></tr>".format(
                            k, getattr(oldconf, k)) for k in oldconf._fields
                    ]
                    output += ["</table>"]
                    output = ''.join(output)
                    dld._addScratchpad(output)

                #===== issuing dn_setNetworkConfig()

                newconf = {
                    'networkId': oldconf.networkId,
                    'apTxPower': 8,
                    'frameProfile': 1,
                    'maxMotes': 33,
                    'baseBandwidth': 9000,
                    'downFrameMultVal': 1,
                    'numParents': 2,
                    'ccaMode': 0,
                    'channelList': 32767,
                    'autoStartNetwork': 1,
                    'locMode': 0,
                    'bbMode': 0,
                    'bbSize': 1,
                    'isRadioTest': 0,
                    'bwMult': 300,
                    'oneChannel': 255,
                }

                output = []
                output += [
                    "<p>issuing dn_setNetworkConfig() with the following parameters</p>"
                ]
                output += ["<table>"]
                output += [
                    "<tr><td>{0}</td><td>{1}</td></tr>".format(k, v)
                    for (k, v) in newconf.items()
                ]
                output += ["</table>"]
                output = ''.join(output)
                dld._addScratchpad(output)

                try:
                    connector.dn_setNetworkConfig(**newconf)
                except Exception as err:
                    dld._addScratchpad(
                        "<p class=\"doc-warning\">failed issuing dn_setNetworkConfig(): {0}.</p>"
                        .format(err))
                    return
                else:
                    dld._addScratchpad(
                        "<p class=\"doc-success\">issued dn_setNetworkConfig() succesfully.</p>"
                    )

                #===== issuing dn_reset()

                dld._addScratchpad("<p>issuing dn_reset()</p>")
                try:
                    connector.dn_reset(
                        type=0,  # 0 = resetSystem
                        macAddress=[0] *
                        8,  # this field is not used when resetting the system
                    )
                except Exception as err:
                    pass  # happens since receiving no ACK from manager which is resetting

            finally:
                #===== disconnect and delete connector

                dld._addScratchpad(
                    "<p>disconnecting from manager at {0}.</p>".format(
                        self.connectionParams))
                try:
                    connector.disconnect()
                except Exception as err:
                    dld._addScratchpad(
                        "<p class=\"doc-warning\">disconnection failed: {0}.</p>"
                        .format(err))
                else:
                    dld._addScratchpad(
                        "<p class=\"doc-success\">disconnection successful.</p>"
                    )
                del connector

            dld._addScratchpad("<p class=\"doc-header\">done.</p>")

        except Exception as err:
            output = []
            output += ['===== crash in thread {0} ====='.format(self.name)]
            output += ['\nerror:\n']
            output += [str(err)]
            output += ['\ncall stack:\n']
            output += [traceback.format_exc()]
            output = '\n'.join(output)
            print output  # critical error
            log.critical(output)
            raise
 def _connectSerial(self):
     '''
     \brief Connect through the serial port.
     '''
    
     # initialize the connector
     try:
         if   isinstance(self.apiDef,IpMgrDefinition.IpMgrDefinition):
             self.connector = IpMgrConnectorSerial.IpMgrConnectorSerial()
         elif isinstance(self.apiDef,IpMoteDefinition.IpMoteDefinition):
             self.connector = IpMoteConnector.IpMoteConnector()
         elif isinstance(self.apiDef,HartMoteDefinition.HartMoteDefinition):
             self.connector = HartMoteConnector.HartMoteConnector()
         else:
             raise SystemError
     except NotImplementedError as err:
         self.guiLock.acquire()
         self.tipLabel.configure(text=str(err))
         self.guiLock.release()
         return
     
     # read connection params from GUI
     self.guiLock.acquire()
     connectParams = {
         'port': self.serialPortText.get(1.0,Tkinter.END).strip(),
     }
     self.guiLock.release()
     
     # connect to the serial port
     try:
         self.connector.connect(connectParams)
     except ConnectionError as err:
         self.guiLock.acquire()
         self.serialPortText.configure(bg=dustStyle.COLOR_ERROR)
         self.tipLabel.configure(text=str(err))
         self.guiLock.release()
         return
         
     # if you get here, the connector could connect, i.e. the COM port is available
     
     # make sure that the device attached to the serial port is really the mote we expect
     if   isinstance(self.apiDef,IpMgrDefinition.IpMgrDefinition):
         # nothing to do, since connecting to a manager includes a handshake
         pass
     
     elif isinstance(self.apiDef,IpMoteDefinition.IpMoteDefinition):
         try:
             res = self.connector.dn_getParameter_moteInfo()
         except (ConnectionError,CommandError) as err:
             
             # disconnect the connector
             self.connector.disconnect()
             
             # print error text
             output  = []
             output += ["Could open the COM port, but issuing dn_getParameter_moteInfo() failed."]
             output += ["Exact error received: {0}".format(err)]
             output += ["Please verify that the device connected to {0} is a SmartMesh IP mote.".format(connectParams['port'])]
             output += ["Please verify that the SmartMesh IP mote is configured in slave mode."]
             output  = '\n'.join(output)
             self.guiLock.acquire()
             self.serialPortText.configure(bg=dustStyle.COLOR_WARNING_NOTWORKING)
             self.tipLabel.configure(text=output)
             self.guiLock.release()
             return
         
     elif isinstance(self.apiDef,HartMoteDefinition.HartMoteDefinition):
         
         try:
             res = self.connector.dn_getParameter_moteInfo()
         except (ConnectionError,CommandError) as err:
             
             # disconnect the connector
             self.connector.disconnect()
             
             # print error text
             output  = []
             output += ["Could open the COM port, but issuing dn_getParameter_moteInfo() failed."]
             output += ["Exact error received: {0}".format(err)]
             output += ["Please verify that the device connected to {0} is a SmartMesh WirelessHART mote.".format(connectParams['port'])]
             output += ["Please verify that the SmartMesh WirelessHART mote is configured in slave mode."]
             output  = '\n'.join(output)
             self.guiLock.acquire()
             self.serialPortText.configure(bg=dustStyle.COLOR_WARNING_NOTWORKING)
             self.tipLabel.configure(text=output)
             self.guiLock.release()
             return
     else:
         raise SystemError
     
     # if you get here, the connection has succeeded
     self.guiLock.acquire()
     self.serialPortText.configure(bg=dustStyle.COLOR_NOERROR)
     self.tipLabel.configure(text="Connection successful.")
     self.guiLock.release()
     
     # hide other connectFrames
     self.guiLock.acquire()
     self.serialMuxFrame.grid_forget()
     self.xmlFrame.grid_forget()
     self.guiLock.release()
     
     # update the button
     self.guiLock.acquire()
     self.serialButton.configure(text='disconnect', command=self._disconnect)
     self.guiLock.release()
     
     # common connect routing
     self._connect()
Beispiel #15
0
    def run(self):
        try:
            while self.goOn:
                try:

                    # connect to the manager
                    self.connector = IpMgrConnectorSerial.IpMgrConnectorSerial(
                    )
                    self.connector.connect({
                        'port': self.serialport,
                    })

                    # subscribe to notifications
                    self.subscriber = IpMgrSubscribe.IpMgrSubscribe(
                        self.connector)
                    self.subscriber.start()
                    self.subscriber.subscribe(
                        notifTypes=[
                            IpMgrSubscribe.IpMgrSubscribe.NOTIFDATA,
                        ],
                        fun=self._notifAll,
                        isRlbl=False,
                    )
                    self.subscriber.subscribe(
                        notifTypes=[
                            IpMgrSubscribe.IpMgrSubscribe.NOTIFEVENT,
                            IpMgrSubscribe.IpMgrSubscribe.NOTIFHEALTHREPORT,
                            IpMgrSubscribe.IpMgrSubscribe.NOTIFIPDATA,
                            IpMgrSubscribe.IpMgrSubscribe.NOTIFLOG,
                        ],
                        fun=self._notifAll,
                        isRlbl=True,
                    )
                    self.subscriber.subscribe(
                        notifTypes=[
                            IpMgrSubscribe.IpMgrSubscribe.ERROR,
                            IpMgrSubscribe.IpMgrSubscribe.FINISH,
                        ],
                        fun=self._notifErrorFinish,
                        isRlbl=True,
                    )

                except Exception as err:

                    try:
                        self.connector.disconnect()
                    except Exception:
                        pass

                    # wait to reconnect
                    time.sleep(1)

                else:
                    self.reconnectEvent.clear()
                    self.reconnectEvent.wait()

                    try:
                        self.connector.disconnect()
                    except Exception:
                        pass

        except Exception as err:
            logCrash(self.name, err)
Beispiel #16
0
UDP_PORT_NUMBER = 60000
STRING_TO_PUBLISH = "Hello, World!"
PUBLISH_RATE_SEC = 5

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

try:
    print 'SimpleIPDownstreamMgr (c) Dust Networks'
    print 'SmartMesh SDK {0}\n'.format('.'.join(
        [str(b) for b in sdk_version.VERSION]))
    print 'Note: Use with SimpleIPDownstreamMote\n'

    #=====
    print "- create the variable 'mgrconnector'"

    mgrconnector = IpMgrConnectorSerial.IpMgrConnectorSerial()

    #=====
    print "- connect to the manager's serial port"

    serialport = raw_input(
        "Enter the serial API port of SmartMesh IP Manager (e.g. COM7): ")
    mgrconnector.connect({'port': serialport})

    #=====
    print "- retrieve the list of all connected motes"

    operationalMacs = []
    currentMac = (0, 0, 0, 0, 0, 0, 0, 0
                  )  # start getMoteConfig() iteration with the 0 MAC address
    continueAsking = True
Beispiel #17
0
def connect(params):
    # filter params
    #port = params[0]
    port = params

    try:
        AppData().get('connector')
    except KeyError:
        pass
    else:
        print 'already connected.'
        return

    # create a connector
    AppData().set('connector', IpMgrConnectorSerial.IpMgrConnectorSerial())

    # connect to the manager
    try:
        AppData().get('connector').connect({
            'port': port,
        })
    except ConnectionError as err:
        print 'Could not connect to {0}: {1}'.format(
            port,
            err,
        )
        AppData().delete('connector')
        return

    # Set ACL's
    joinKey = [
        0x44, 0x55, 0x53, 0x54, 0x4E, 0x45, 0x54, 0x57, 0x4F, 0x52, 0x4B, 0x53,
        0x52, 0x4F, 0x43, 0x4B
    ]
    mac = [0x00, 0x17, 0x0d, 0x00, 0x00, 0x30, 0xb3, 0x5c]
    print "Setting ACL for {0} to {1}".format(FormatUtils.formatBuffer(mac),
                                              joinKey)
    AppData().get('connector').dn_setACLEntry(macAddress=mac, joinKey=joinKey)

    joinKey = [
        0x44, 0x55, 0x53, 0x54, 0x4E, 0x45, 0x54, 0x57, 0x4F, 0x52, 0x4B, 0x53,
        0x52, 0x4F, 0x43, 0x4B
    ]
    mac = [0x00, 0x17, 0x0d, 0x00, 0x00, 0x30, 0xb6, 0x81]
    print "Setting ACL for {0} to {1}".format(FormatUtils.formatBuffer(mac),
                                              joinKey)
    AppData().get('connector').dn_setACLEntry(macAddress=mac, joinKey=joinKey)

    joinKey = [
        0x44, 0x55, 0x53, 0x54, 0x4E, 0x45, 0x54, 0x57, 0x4F, 0x52, 0x4B, 0x53,
        0x52, 0x4F, 0x43, 0x4B
    ]
    print "Setting common join key to {0}".format(
        FormatUtils.formatBuffer(joinKey))
    AppData().get('connector').dn_setCommonJoinKey(joinKey)

    networkId = 1337
    apTxPower = 8  # TX power 8
    frameProfile = 1  # Frame profile 1
    maxMotes = 33
    baseBandwidth = 9000
    downFrameMultVal = 1
    numParents = 2
    ccaMode = 0  # off
    channelList = 32767
    autoStartNetwork = True
    locMode = 0
    bbMode = 0  # off
    bbSize = 1
    isRadioTest = 0
    bwMult = 300
    oneChannel = 255

    print "Setting network ID to {0}".format(networkId)
    AppData().get('connector').dn_setNetworkConfig(
        networkId=networkId,
        apTxPower=apTxPower,
        frameProfile=frameProfile,
        maxMotes=maxMotes,
        baseBandwidth=baseBandwidth,
        downFrameMultVal=downFrameMultVal,
        numParents=numParents,
        ccaMode=ccaMode,
        channelList=channelList,
        autoStartNetwork=autoStartNetwork,
        locMode=locMode,
        bbMode=bbMode,
        bbSize=bbSize,
        isRadioTest=isRadioTest,
        bwMult=bwMult,
        oneChannel=oneChannel)

    print "Resetting manager"
    mac = [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]
    AppData().get('connector').dn_reset(0, mac)  # System Reset

    # start threads
    AppData().set('manager', Manager())