Sending ASCII from lopy4
I am trying to send the ascii from the lopy4 to the gateway. First the ascii.txt will be converted to the binary bits and then divided into the lora packets and the packets will be sent with delayed time. If any one of you have completed similar task or have any idea, I would appreciate your help. I am new to the micropython codings.
I have also tried to program the following code;
import binascii import struct ascii = 'SIGN.txt' with open(ascii, 'rb') as f: content = f.read() data = binascii.hexlify(content) print(binascii.hexlify(content)) print(content) print(data) l = len(data) print (l) hex_string = binascii.unhexlify(data) print (hex_string) print (len (hex_string)) for l in range (0, l, 10): package = data[1:l+10] print (package)
Your help will be highly appreciated.
This post is deleted!
@phusy012 Assuming that you node and server are close-by, packet loss due to poor reception is unlikely. So it might still be, that the channel configuration of node and server do not match, and sometimes the node uses channels at which the server does not listen.
Hi. Thank you for the comment. I set the s.setblocking(True) and could see the lora built-in server receiving the packets. But after some time, some packets are lost in the middle while the others are received continuously. I also tried to put the lopy into sleep for some seconds in a loop to enable the delay between two packets but even then some packets are lost in the middle (could see from the device data in application section of the lora builtin server).
for l in range (0, l, 20):
package = content[l:l+20]
Wondering what could have gone wrong in this.
Will appreciate your advice again.
@phusy012 After a few packets there is an overflow in sending. You should set s.setblocking(True), to ensure, that the next transmission is not requested before the previous has been completed.
@robert-hh and any other experts
Thank you for the response.
The "gateway" I meant was my own Lora Built in Server. I am using the RAK831 Pilot Gateway and I have developed my own Built in Server.
I took note of having no need to convert ascii to hex and wrote the new program code attached below;
When I run the program on the Lopy4 board, it though sends some part of the ascii (I confirm since I receive some data in the node applications device data of LoRa Built in Server) but comes with the following error attached below:
I tried to browse for error nature and reasons but could not get the clear picture. Please advise and will appreciate your help in advance.
@phusy012 Assuming that what you call "gateway" is not a TTN gateway, you can get some hints from the Lora-Lora example in the documentation: https://docs.pycom.io/tutorials/lora/module-module/
Also, for transmission you do not have to convert your data to a hex_string. That only doubles the data size and transmission time = air time, which is limited in LoRa.