10000 esp32: Improvement to LTE attach and PSM disabling. · pycom/pycom-micropython-sigfox@4481a1c · GitHub
[go: up one dir, main page]

Skip to content
This repository was archived by the owner on Sep 16, 2024. It is now read-only.

Commit 4481a1c

Browse files
author
Daniel Campora
committed
esp32: Improvement to LTE attach and PSM disabling.
1 parent 046b350 commit 4481a1c

File tree

3 files changed

+14
-8
lines changed

3 files changed

+14
-8
lines changed

esp32/lte/lteppp.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,8 +286,8 @@ static void TASK_LTE (void *pvParameters) {
286286

287287
// enable PSM if not already enabled
288288
lteppp_send_at_cmd("AT+CPSMS?", LTE_RX_TIMEOUT_MAX_MS);
289-
if (!strstr(lteppp_trx_buffer, "+CPSMS: 1")) {
290-
lteppp_send_at_cmd("AT+CPSMS=1", LTE_RX_TIMEOUT_MIN_MS);
289+
if (!strstr(lteppp_trx_buffer, "+CPSMS: 0")) {
290+
lteppp_send_at_cmd("AT+CPSMS=0", LTE_RX_TIMEOUT_MIN_MS);
291291
}
292292
// enable low power mode
293293
lteppp_send_at_cmd("AT!=\"setlpm airplane=1 enable=1\"", LTE_RX_TIMEOUT_MAX_MS);

esp32/mods/modlte.c

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -207,10 +207,13 @@ static mp_obj_t lte_init_helper(lte_obj_t *self, const mp_arg_val_t *args) {
207207
lte_push_at_command("AT+CFUN?", LTE_RX_TIMEOUT_MIN_MS);
208208
if (strstr(modlte_rsp.data, "+CFUN: 0")) {
209209
const char *carrier = "standard";
210+
lte_obj.carrier = false;
210211
if (args[0].u_obj != mp_const_none) {
211212
carrier = mp_obj_str_get_str(args[0].u_obj);
212213
if ((!strstr(carrier, "standard")) && (!strstr(carrier, "verizon")) && (!strstr(carrier, "at&t"))) {
213214
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError, "invalid carrier %s", carrier));
215+
} else if (!strstr(carrier, "standard")) {
216+
lte_obj.carrier = true;
214217
}
215218
}
216219

@@ -313,12 +316,14 @@ STATIC mp_obj_t lte_attach(mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t
313316
// configuring scanning in all 6 bands
314317
lte_push_at_command("AT!=\"clearscanconfig\"", LTE_RX_TIMEOUT_MIN_MS);
315318
if (args[0].u_obj == mp_const_none) {
316-
lte_push_at_command("AT!=\"RRC::addScanBand band=3\"", LTE_RX_TIMEOUT_MIN_MS);
317-
lte_push_at_command("AT!=\"RRC::addScanBand band=4\"", LTE_RX_TIMEOUT_MIN_MS);
318-
lte_push_at_command("AT!=\"RRC::addScanBand band=12\"", LTE_RX_TIMEOUT_MIN_MS);
319-
lte_push_at_command("AT!=\"RRC::addScanBand band=13\"", LTE_RX_TIMEOUT_MIN_MS);
320-
lte_push_at_command("AT!=\"RRC::addScanBand band=20\"", LTE_RX_TIMEOUT_MIN_MS);
321-
lte_push_at_command("AT!=\"RRC::addScanBand band=28\"", LTE_RX_TIMEOUT_MIN_MS);
319+
if (!lte_obj.carrier) {
320+
lte_push_at_command("AT!=\"RRC::addScanBand band=3\"", LTE_RX_TIMEOUT_MIN_MS);
321+
lte_push_at_command("AT!=\"RRC::addScanBand band=4\"", LTE_RX_TIMEOUT_MIN_MS);
322+
lte_push_at_command("AT!=\"RRC::addScanBand band=12\"", LTE_RX_TIMEOUT_MIN_MS);
323+
lte_push_at_command("AT!=\"RRC::addScanBand band=13\"", LTE_RX_TIMEOUT_MIN_MS);
324+
lte_push_at_command("AT!=\"RRC::addScanBand band=20\"", LTE_RX_TIMEOUT_MIN_MS);
325+
lte_push_at_command("AT!=\"RRC::addScanBand band=28\"", LTE_RX_TIMEOUT_MIN_MS);
326+
}
322327
} else {
323328
uint32_t band = mp_obj_get_int(args[0].u_obj);
324329
if (band == 3) {

esp32/mods/modlte.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ typedef struct _lte_obj_t {
2222
uint32_t ip4;
2323
uint8_t cid;
2424
bool init;
25+
bool carrier;
2526
} lte_obj_t;
2627

2728

0 commit comments

Comments
 (0)
0