#.... def main(): #Initialize LoRa control ports (M0-M1, AUX) GPIO.setmode(GPIO.BOARD) GPIO.setwarnings(False) GPIO.setup(PIN_LORA_M0, GPIO.OUT) GPIO.setup(PIN_LORA_M1, GPIO.OUT) GPIO.setup(PIN_LORA_AUX, GPIO.IN, pull_up_down = GPIO.PUD_UP) #Wait until AUX is high (Module is ready) if not wait_until_pin(PIN_LORA_AUX, GPIO.HIGH, 1.0): raise_error("LoRa module is busy!", -1, cleanup()) else: print("LoRa module is available") #Set module mode (11) sleep GPIO.output(PIN_LORA_M0, GPIO.HIGH) GPIO.output(PIN_LORA_M1, GPIO.HIGH) if not wait_until_pin(PIN_LORA_AUX, GPIO.HIGH, 1.0): raise_error("Cannot set parameters", -1, cleanup()) else: print("Parameters are set") #Send lora configuration parameters uart.reset_input_buffer() print("TX:", lora_params.hex(" ")) uart.write(lora_params) uart.flush() time.sleep(0.1) #Validate lora configuration parameters uart.reset_input_buffer() print("TX:", cmd_params.hex(" ")) uart.write(cmd_params) uart.flush() rx = uart.read(6) if rx != lora_params: raise_error("Unable to validate configuration parameters", -1, cleanup()) else: print("Config parameters:", rx.hex(" ")) time.sleep(0.1) #Set module mode (00) transceiver if not wait_until_pin(PIN_LORA_AUX, GPIO.HIGH, 1.0): raise_error("LoRa module is busy!", -1, cleanup()) else: print("LoRa module is available to transmit") GPIO.output(PIN_LORA_M0, GPIO.LOW) GPIO.output(PIN_LORA_M1, GPIO.LOW) time.sleep(0.01) #.... main() if _name_ == "__main__": main()