@@ -71,6 +71,9 @@ License: Revised BSD License, see LICENSE.TXT file include in the project
71
71
#include "py/obj.h"
72
72
#include "py/mpprint.h"
73
73
#include "modmachine.h"
74
+ #include "machpin.h"
75
+ #include "pins.h"
76
+ #include "sx1308-config.h"
74
77
75
78
/* -------------------------------------------------------------------------- */
76
79
/* --- PRIVATE MACROS ------------------------------------------------------- */
@@ -903,6 +906,38 @@ void lora_gw_init(const char* global_conf) {
903
906
MSG_INFO ("lora_gw_init() done fh=%u high=%u\n" , xPortGetFreeHeapSize (), uxTaskGetStackHighWaterMark (NULL ));
904
907
}
905
908
909
+ void pygate_reset () {
910
+ MSG_INFO ("pygate_reset\n" );
911
+
912
+ // pull sx1257 and sx1308 reset high, the PIC FW should power cycle the ESP32 as a result
913
+ pin_obj_t * sx1308_rst = SX1308_RST_PIN ;
914
+ pin_config (sx1308_rst , -1 , -1 , GPIO_MODE_OUTPUT , MACHPIN_PULL_NONE , 0 );
915
+ pin_obj_t * sx1257_rst = (& PIN_MODULE_P8 );
916
+ pin_config (sx1257_rst , -1 , -1 , GPIO_MODE_OUTPUT , MACHPIN_PULL_NONE , 0 );
917
+
918
+ sx1308_rst -> value = 1 ;
919
+ sx1257_rst -> value = 1 ;
920
+
921
+ pin_set_value (sx1308_rst );
922
+ pin_set_value (sx1257_rst );
923
+
924
+ vTaskDelay (5000 / portTICK_PERIOD_MS );
925
+
926
+ // if this is still being executed, then it seems the ESP32 reset did not take place
927
+ // set the two reset lines low again and stop the lora gw task, to make sure we return to a defined state
928
+ MSG_ERROR ("pygate_reset failed to reset\n" );
929
+ sx1308_rst -> value = 0 ;
930
+ sx1257_rst -> value = 0 ;
931
+ pin_set_value (sx1308_rst );
932
+ pin_set_value (sx1257_rst );
933
+
934
+ if (xLoraGwTaskHndl ){
935
+ vTaskDelete (xLoraGwTaskHndl );
936
+ xLoraGwTaskHndl = NULL ;
937
+ }
938
+
939
+ }
940
+
906
941
int lora_gw_get_debug_level (){
907
942
return debug_level ;
908
943
}
0 commit comments