def register_device(addr): if (csmapi.ENDPOINT == None): detect_local_ec() global MAC if addr != None: MAC=addr global profile if profile['d_name'] == None: profile['d_name']= str(int(random.uniform(1, 100)))+'.'+ profile['dm_name'] global timestamp for i in profile['df_list']: timestamp[i]= '' print('IoTtalk Server = {}'.format(csmapi.ENDPOINT)) if csmapi.register(MAC,profile): print ('This device has successfully registered.') print ('Device name = ' + profile['d_name']) csmapi.push(MAC,'__Ctl_I__',['SET_DF_STATUS_RSP',{'cmd_params':[]}]) return True else: print ('Registration failed.') return False
def register_device(addr): if (csmapi.ENDPOINT == None): detect_local_ec() global MAC if addr != None: MAC = addr global profile if profile['d_name'] == None: profile['d_name'] = str(int(random.uniform( 1, 100))) + '.' + profile['dm_name'] global timestamp for i in profile['df_list']: timestamp[i] = '' print('IoTtalk Server = {}'.format(csmapi.ENDPOINT)) if csmapi.register(MAC, profile): print('This device has successfully registered.') print('Device name = ' + profile['d_name']) csmapi.push(MAC, '__Ctl_I__', ['SET_DF_STATUS_RSP', { 'cmd_params': [] }]) return True else: print('Registration failed.') return False
def register_device(addr): global MAC, profile, timestamp, thx if csmapi.ENDPOINT == None: detect_local_ec() if addr != None: MAC = addr if profile['d_name'] == None: profile['d_name'] = str(int(random.uniform( 1, 100))) + '.' + profile['dm_name'] for i in profile['df_list']: timestamp[i] = '' print('IoTtalk Server = {}'.format(csmapi.ENDPOINT)) if csmapi.register(MAC, profile): print('This device has successfully registered.') print('Device name = ' + profile['d_name']) if thx == None: print('Create control threading') thx = threading.Thread(target=ControlChannel) #for control channel thx.daemon = True #for control channel thx.start() #for control channel return True else: print('Registration failed.') return False
def register_device(addr): global MAC, profile, timestamp if csmapi.ENDPOINT == None: detect_local_ec() if addr != None: MAC = addr if profile['d_name'] == None: profile['d_name'] = profile['dm_name'] + '.' + (get_mac_addr()[-4:]) for i in profile['df_list']: timestamp[i] = '' print('IoTtalk Server = {}'.format(csmapi.ENDPOINT)) if csmapi.register(MAC, profile): print('This device has successfully registered.') print('Device name = ' + profile['d_name']) #thx=threading.Thread(target=ControlChannel) #thx.daemon = True #thx.start() return True else: print('Registration failed.') return False
def register(endpoint, profile): global _profile global _registered global _df_list global _df_selected global _df_is_odf global _df_timestamp if endpoint is not None: csmapi.ENDPOINT = endpoint if csmapi.ENDPOINT is None: return False _profile = profile _profile['d_name'] = profile['dm_name'] + _mac_addr[-4:] for i in range(RETRY_COUNT): try: if csmapi.register(_mac_addr, profile): logging('init(): Register succeed: {}', csmapi.ENDPOINT) _df_list = [df_name for df_name in profile['df_list']] _df_selected = {odf_name: False for odf_name in _df_list} _df_is_odf = {odf_name: True for odf_name in _df_list} _df_timestamp = {odf_name: '' for odf_name in _df_list} _ctl_timestamp = '' _suspended = True if not _registered: _registered = True t = Thread(target=main_loop) t.daemon = True t.start() _deregister_lock.acquire() return True except csmapi.CSMError as e: logging('init(): Register: CSMError({})', e) logging('init(): Register failed, wait {} seconds before retry', RETRY_INTERVAL) time.sleep(RETRY_INTERVAL) return False
def register_device(addr): global MAC, profile, timestamp, thx if csmapi.ENDPOINT == None: detect_local_ec() if addr != None: MAC = addr for i in profile['df_list']: timestamp[i] = '' print('IoTtalk Server = {}'.format(csmapi.ENDPOINT)) profile['d_name'] = csmapi.register(MAC,profile) print ('This device has successfully registered.') print ('Device name = ' + profile['d_name']) if thx == None: print ('Create control threading') thx=threading.Thread(target=ControlChannel) #for control channel thx.daemon = True #for control channel thx.start() #for control channel
def register_device(self, addr): if csmapi.ENDPOINT == None: detect_local_ec() if addr != None: self.MAC = addr for i in self.profile['df_list']: self.timestamp[i] = '' print('IoTtalk Server = {}'.format(csmapi.ENDPOINT)) self.profile['d_name'] = csmapi.register(self.MAC, self.profile) print('This device has successfully registered.') print('Device name = ' + self.profile['d_name']) if self.thx == None: print('Create control threading') self.thx = threading.Thread( target=self.ControlChannel) #for control channel self.thx.daemon = True #for control channel self.thx.start() #for control channel