@@ -1236,8 +1236,8 @@ STATIC mp_obj_t lte_send_at_cmd(mp_uint_t n_args, const mp_obj_t *pos_args, mp_m
1236
1236
lte_check_init ();
1237
1237
lte_check_inppp ();
1238
1238
STATIC const mp_arg_t allowed_args [] = {
1239
- { MP_QSTR_cmd , MP_ARG_REQUIRED | MP_ARG_OBJ , {.u_obj = mp_const_none } },
1240
- { MP_QSTR_delay , MP_ARG_INT , {.u_int = LTE_RX_TIMEOUT_MAX_MS } }
1239
+ { MP_QSTR_cmd , MP_ARG_OBJ , {.u_obj = mp_const_none } },
1240
+ { MP_QSTR_timeout , MP_ARG_KW_ONLY | MP_ARG_INT , {.u_int = LTE_RX_TIMEOUT_MAX_MS } },
1241
1241
};
1242
1242
// parse args
1243
1243
uint32_t argLength = MP_ARRAY_SIZE (allowed_args );
@@ -1246,34 +1246,10 @@ STATIC mp_obj_t lte_send_at_cmd(mp_uint_t n_args, const mp_obj_t *pos_args, mp_m
1246
1246
if (args [0 ].u_obj == mp_const_none ) {
1247
1247
nlr_raise (mp_obj_new_exception_msg_varg (& mp_type_ValueError , "the command must be specified!" ));
1248
1248
}
1249
- uint32_t timeout = LTE_RX_TIMEOUT_MAX_MS ;
1250
1249
if (MP_OBJ_IS_STR_OR_BYTES (args [0 ].u_obj ))
1251
1250
{
1252
1251
size_t len ;
1253
- char * command = (char * )(mp_obj_str_get_data (args [0 ].u_obj , & len ));
1254
-
1255
- if (argLength > 1 ) {
1256
- timeout = args [1 ].u_int ;
1257
- }
1258
-
1259
- if (len <= LTE_AT_CMD_DATA_SIZE_MAX ) {
1260
- lte_push_at_command_ext_cont (command , timeout , NULL , len , false);
1261
- } else {
1262
- size_t chunk_count = len / LTE_AT_CMD_DATA_SIZE_MAX ;
1263
- size_t remaining_bytes = len % LTE_AT_CMD_DATA_SIZE_MAX ;
1264
-
1265
- bool expect_continuation = false;
1266
- char * chunk_start = command ;
1267
- for (size_t i = 0 ; i < chunk_count ; ++ i ) {
1268
- expect_continuation = (i < (chunk_count - 1 )) || remaining_bytes ;
1269
- lte_push_at_command_ext_cont (chunk_start , timeout , NULL , LTE_AT_CMD_DATA_SIZE_MAX , expect_continuation );
1270
- chunk_start += LTE_AT_CMD_DATA_SIZE_MAX ;
1271
- }
1272
-
1273
- if (remaining_bytes ) {
1274
- lte_push_at_command_ext_cont (chunk_start , timeout , NULL , remaining_bytes , false);
1275
- }
1276
- }
1252
+ lte_push_at_command_ext ((char * )(mp_obj_str_get_data (args [0 ].u_obj , & len )), args [1 ].u_int , NULL , len );
1277
1253
}
1278
1254
else
1279
1255
{
@@ -1285,7 +1261,7 @@ STATIC mp_obj_t lte_send_at_cmd(mp_uint_t n_args, const mp_obj_t *pos_args, mp_m
1285
1261
vstr_add_str (& vstr , modlte_rsp .data );
1286
1262
while (modlte_rsp .data_remaining )
1287
1263
{
1288
- lte_push_at_command_ext ("Pycom_Dummy" , LTE_RX_TIMEOUT_MAX_MS , NULL , strlen ("Pycom_Dummy" ) );
1264
+ lte_push_at_command_ext ("Pycom_Dummy" , args [ 1 ]. u_int , NULL , strlen ("Pycom_Dummy" ) );
1289
1265
vstr_add_str (& vstr , modlte_rsp .data );
1290
1266
}
1291
1267
return mp_obj_new_str_from_vstr (& mp_type_str , & vstr );
0 commit comments