@@ -95,6 +95,7 @@ uart_config_t lte_uart_config0;
9595uart_config_t lte_uart_config1 ;
9696
9797static bool lte_legacyattach_flag = true;
98+ static bool lte_debug = false;
9899
99100static bool lte_ue_is_out_of_coverage = false;
100101
@@ -175,13 +176,16 @@ static void lte_callback_handler(void* arg)
175176static bool lte_push_at_command_ext (char * cmd_str , uint32_t timeout , const char * expected_rsp , size_t len ) {
176177 lte_task_cmd_data_t cmd = { .timeout = timeout , .dataLen = len };
177178 memcpy (cmd .data , cmd_str , len );
178- //printf("[CMD] %s\n", cmd_str);
179+ if (lte_debug )
180+ printf ("[AT] %s\n" , cmd_str );
179181 lteppp_send_at_command (& cmd , & modlte_rsp );
180182 if ((expected_rsp == NULL ) || (strstr (modlte_rsp .data , expected_rsp ) != NULL )) {
181- //printf("[OK] %s\n", modlte_rsp.data);
183+ if (lte_debug )
184+ printf ("[AT-OK] %s\n" , modlte_rsp .data );
182185 return true;
183186 }
184- //printf("[FAIL] %s\n", modlte_rsp.data);
187+ if (lte_debug )
188+ printf ("[AT-FAIL] %s\n" , modlte_rsp .data );
185189 return false;
186190}
187191
@@ -494,7 +498,8 @@ static const mp_arg_t lte_init_args[] = {
494498 { MP_QSTR_id , MP_ARG_INT , {.u_int = 0 } },
495499 { MP_QSTR_carrier , MP_ARG_KW_ONLY | MP_ARG_OBJ , {.u_obj = mp_const_none } },
496500 { MP_QSTR_cid , MP_ARG_KW_ONLY | MP_ARG_INT , {.u_int = 1 } },
497- { MP_QSTR_legacyattach , MP_ARG_KW_ONLY | MP_ARG_BOOL , {.u_bool = true} }
501+ { MP_QSTR_legacyattach , MP_ARG_KW_ONLY | MP_ARG_BOOL , {.u_bool = true} },
502+ { MP_QSTR_debug , MP_ARG_KW_ONLY | MP_ARG_BOOL , {.u_bool = false} },
498503};
499504
500505static mp_obj_t lte_make_new (const mp_obj_type_t * type , mp_uint_t n_args , mp_uint_t n_kw , const mp_obj_t * all_args ) {
@@ -504,6 +509,8 @@ static mp_obj_t lte_make_new(const mp_obj_type_t *type, mp_uint_t n_args, mp_uin
504509 // parse args
505510 mp_arg_val_t args [MP_ARRAY_SIZE (lte_init_args )];
506511 mp_arg_parse_all (n_args , all_args , & kw_args , MP_ARRAY_SIZE (args ), lte_init_args , args );
512+ if (args [4 ].u_bool )
513+ lte_debug = true;
507514
508515 // setup the object
509516 lte_obj_t * self = & lte_obj ;
@@ -524,6 +531,8 @@ STATIC mp_obj_t lte_init(mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t *k
524531 // parse args
525532 mp_arg_val_t args [MP_ARRAY_SIZE (lte_init_args ) - 1 ];
526533 mp_arg_parse_all (n_args - 1 , pos_args + 1 , kw_args , MP_ARRAY_SIZE (args ), & lte_init_args [1 ], args );
534+ if (args [3 ].u_bool )
535+ lte_debug = true;
527536 return lte_init_helper (pos_args [0 ], args );
528537}
529538STATIC MP_DEFINE_CONST_FUN_OBJ_KW (lte_init_obj , 1 , lte_init );
0 commit comments