Commit d702b611 authored by Qasim's avatar Qasim

no message

parent fe6817bc
......@@ -23,8 +23,7 @@ class LoraModule(wishful_module.AgentModule):
# bytesize= serial.EIGHTBITS,parity = serial.PARITY_NONE,
# stopbits=serial.STOPBITS_ONE, timeout=10)
#self.node = dev
@wishful_module.bind_function(upis.lora.radio.set_dev_eui)
def set_dev_eui(self, deveui):
self.log.info("Set Parameters called".format())
......@@ -93,7 +92,7 @@ class LoraModule(wishful_module.AgentModule):
time.sleep(0.2) # wait
dev.close()
return 1
@wishful_module.bind_function(upis.lora.radio.set_adr)
def set_adr(self, adr):
self.log.info("Set Parameters called".format())
......@@ -118,8 +117,6 @@ class LoraModule(wishful_module.AgentModule):
dev.close()
return 1
@wishful_module.bind_function(upis.lora.radio.set_dr)
def set_dr(self, dr):
self.log.info("Set Parameters called".format())
......@@ -185,13 +182,84 @@ class LoraModule(wishful_module.AgentModule):
@wishful_module.bind_function(upis.radio.set_tx_power)
def set_tx_power(self, power):
if 2 <= power <= 14:
dev = serial.Serial('/dev/ttyACM0', baudrate=115200,
bytesize=serial.EIGHTBITS, parity=serial.PARITY_NONE,
stopbits=serial.STOPBITS_ONE, timeout=10)
data = '^tx0{}$000000000000000000000000000000'.format(str(power).zfill(2))
self.log.info("Data sent by controller is: {}".format(data))
dev.write(data.encode('utf-8'))
dev.flush()
rec_data = dev.readline().strip().decode('utf-8', errors='ignore')
self.log.info("Recieved data from Lora {}: Data sent to Lora Board{}".format(rec_data, data))
time.sleep(0.2) # wait
dev.close()
return 1
else:
return 0
@wishful_module.bind_function(upis.radio.get_tx_power)
def get_tx_power(self):
dev = serial.Serial('/dev/ttyACM0', baudrate=115200,bytesize=serial.EIGHTBITS, parity=serial.PARITY_NONE,stopbits=serial.STOPBITS_ONE, timeout=10)
data = '^gt01$000000000000000000000000000000'
self.log.info("Get Tx power ")
dev.write(data.encode('utf-8'))
dev.flush()
rec_data = dev.readline().strip().decode('utf-8', errors='ignore')
self.log.info("Recieved data from Lora, TX power is {}:".format(rec_data))
time.sleep(0.2) # wait
dev.close()
return 1
@wishful_module.bind_function(upis.radio.get_dr)
def get_dr(self):
dev = serial.Serial('/dev/ttyACM0', baudrate=115200,bytesize=serial.EIGHTBITS, parity=serial.PARITY_NONE,stopbits=serial.STOPBITS_ONE, timeout=10)
data = '^gt02$000000000000000000000000000000'
self.log.info("Get Tx power ")
dev.write(data.encode('utf-8'))
dev.flush()
rec_data = dev.readline().strip().decode('utf-8', errors='ignore')
self.log.info("Recieved data from Lora, dr is {}:".format(rec_data))
time.sleep(0.2) # wait
dev.close()
return 1
@wishful_module.bind_function(upis.radio.get_dev_eui)
def get_dev_eui(self):
dev = serial.Serial('/dev/ttyACM0', baudrate=115200,bytesize=serial.EIGHTBITS, parity=serial.PARITY_NONE,stopbits=serial.STOPBITS_ONE, timeout=10)
data = '^gt03$000000000000000000000000000000'
dev.write(data.encode('utf-8'))
dev.flush()
rec_data = dev.readline().strip().decode('utf-8', errors='ignore')
self.log.info("Recieved data from Lora, dev eui is {}:".format(rec_data))
time.sleep(0.2) # wait
dev.close()
return 1
@wishful_module.bind_function(upis.radio.get_app_eui)
def get_app_eui(self):
dev = serial.Serial('/dev/ttyACM0', baudrate=115200,bytesize=serial.EIGHTBITS, parity=serial.PARITY_NONE,stopbits=serial.STOPBITS_ONE, timeout=10)
data = '^gt04$000000000000000000000000000000'
dev.write(data.encode('utf-8'))
dev.flush()
rec_data = dev.readline().strip().decode('utf-8', errors='ignore')
self.log.info("Recieved data from Lora, app eui is {}:".format(rec_data))
time.sleep(0.2) # wait
dev.close()
return 1
@wishful_module.bind_function(upis.radio.get_app_key)
def get_app_key(self):
dev = serial.Serial('/dev/ttyACM0', baudrate=115200,bytesize=serial.EIGHTBITS, parity=serial.PARITY_NONE,stopbits=serial.STOPBITS_ONE, timeout=10)
data = '^gt05$000000000000000000000000000000'
dev.write(data.encode('utf-8'))
dev.flush()
rec_data = dev.readline().strip().decode('utf-8', errors='ignore')
self.log.info("Recieved data from Lora, app key is {}:".format(rec_data))
time.sleep(0.2) # wait
dev.close()
return 1
# @wishful_module.bind_function(upis.radio.set_parameters)
# def set_parameters(self, params):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment