Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issues related to st_conn_cleanup(iot_ctx, false) function #144

Open
KIMSUNIK opened this issue Jan 17, 2024 · 1 comment
Open

Issues related to st_conn_cleanup(iot_ctx, false) function #144

KIMSUNIK opened this issue Jan 17, 2024 · 1 comment

Comments

@KIMSUNIK
Copy link

KIMSUNIK commented Jan 17, 2024

When I press the reset button for 5 seconds to initialize the device, factory reset function is executed. Because the AP has not started, onboarding can no longer proceed. AP mode is activated only when the power is reconnected.

static void connection_start(void) {
    iot_pin_t *pin_num = NULL;
    int err;
    err = st_conn_start(iot_ctx, (st_status_cb)&iot_status_cb, IOT_STATUS_ALL, NULL, pin_num);
    if (err) {
        printf("fail to start connection. err:%d\n", err);
    }
    if (pin_num) {
        free(pin_num);
    }
}

static void connection_start_task(void *arg) {
    connection_start();
    vTaskDelete(NULL);
}

void button_event(IOT_CAP_HANDLE *handle, int type, int count) {
...
    } else if (type == BUTTON_LONG_PRESS) {
        st_conn_cleanup(iot_ctx, false);
        xTaskCreate(connection_start_task, "connection_task", 2048, NULL, 10, NULL);
    }
}

I (185053) button_event(): button, clean-up provisioning & data without reboot
I (185053) [IoT]: st_conn_cleanup(1305) > st_conn_cleanup start (0)
D (185053) [IoT]: iot_dump_log(346) > LOG : 30000000 65a71b9a 0000051a 00000000
D (185063) [IoT]: _iot_net_tls_write(614) > 24@0x3ffd0450
D (185773) [IoT]: _iot_net_tls_read(575) > 1@0x3ffbc604
D (185773) [IoT]: _iot_net_tls_read(575) > 1@0x3ffbc605
D (185773) [IoT]: _iot_net_tls_read(575) > 2@0x3ffcf35e
D (185773) [IoT]: iot_dump_log(346) > LOG : 3000010a 65a71b9b 00000000 00000000
D (188833) [IoT]: _iot_net_tls_read(575) > 1@0x3ffcb094
D (188833) [IoT]: _iot_net_tls_read(575) > 1@0x3ffcb095
D (188833) [IoT]: _iot_net_tls_read(575) > 1@0x3ffcb096
D (188833) [IoT]: _iot_net_tls_read(575) > 139@0x3ffda67f
D (188843) [IoT]: _iot_mqtt_signin_client_callback(424) > raw msg : {"target":"99edeb78-df98-4439-8c59-4cce23830ad8","event":"device.deleted"}
D (188853) [IoT]: iot_dump_log(346) > LOG : 30000204 65a71b9e 00000000 00000000
I (188863) [IoT]: _iot_parse_noti_data(650) > payload : {"target":"99edeb78-df98-4439-8c59-4cce23830ad8","event":"device.deleted"}
D (188873) [IoT]: iot_dump_log(346) > LOG : 30000205 65a71b9e 00000000 00000000
D (188883) [IoT]: _iot_main_task(902) > cmd: 4

I (188883) [IoT]: _do_iot_main_command(586) > curr_main_cmd:4, curr_main_state:6
D (188893) [IoT]: iot_dump_log(346) > LOG : 30000000 65a71b9e 000002e8 00000000
I (188903) [IoT]: _do_iot_main_command(748) > Device-card deleting is done
D (188903) [IoT]: iot_dump_log(346) > LOG : 20000000 65a71b9e 000002ed c1eac1eb
D (188913) [IoT]: _iot_net_tls_write(614) > 4@0x3ffd0460
I (188923) [IoT]: iot_device_cleanup(1023) > start to erase device information
D (188923) [IoT]: iot_nv_erase_prov_data(303) > >>>HIT<<<
D (188933) [IoT]: _iot_nv_io_storage(104) > id = 1, mode = 2
D (188943) [IoT]: iot_security_be_init(2283) > security backend is 'software'
D (188943) [IoT]: iot_security_storage_write(155) > id:1
D (188953) [IoT]: _iot_security_be_bsp_fs_store(262) > id = 1
D (188963) [IoT]: iot_bsp_nv_get_data_path(25) > >>>HIT<<<
D (188963) [IoT]: _iot_security_be_bsp_fs_storage_id2filename(85) > storage file = 'WifiProvStatus'ty_be_init(2283) > snvs_open_from_partition stdk 1
D (188983) nvs: nvs_set_str WifiProvStatus NONE
D (188993) nvs: nv13) [IoT]iot_security_be_bsp_fs_store(262) > id = 6
D (1890) > id:1 written 4@0x3f400764
D (188993) [IoT]: _iot_nv_io_storage(104) > id = 6, mode = 2
D (189003) [IoT]: iot_security_be_init(2283) > security backend is 'software'
D (18900loudProvStatus NONE
D (189053) nvs: nvs_d:6
D (189013)13) [IoT]: iot_bsp_nv_get_data_path(25) > >>>HIT<<<T<<<0m
D (189053) [IoT]: iot_nv_erase(1136) > >>>Hme(85) > storage file = 'CloudProvStatus'
D (189033) nvs: nvs_open_from_partition stdk 1
D (189043) nvs: nvs_set_str CloudProvStatus NONE
D (189053) nvs: nvs_close 40
D (18_bsp__be_bsp_fs_remove(315) > id = 10
D (189083) [IoT]: iotIT<<<
D (189063) [IoT]: _iot_nv_io_storage(104) > id =n stdk 1
D (189103) nvs: nvs_erase_key Device_from_partitio> security backend is 'software'
D (189073) [IoT]: iot_secuect it first.

D (189123re is previous connecting, disconn_bsp_nv_get_data_path(25) > >>>HIT<<<
D (189093IoT]: _ionect(1434) > mqtt disconnect 0
I (189143) [n stdk 1
D (189103) nvs: nvs_erase_key DeviceID

D (000 00000000
I (189163) [IoT]: st_conn_cle1b9e 00000ect it first.

D (189123) [IoT]: iot_es_disconnect(1300) >)
D (189183) [IoT]: iot_dump_ > st_conn_start start (no-pinIoT]: _iot_net_show_status(92) > [1705450398] network socket stae 000004cb 0000[IoT]: iot_dump_log(346) > LOG : 20000000 65a71b9000 00000000
I (189163) [IoT]: st_conn_cleanup(1324) > st_conn_cleanup done (0)
D (189173) [IoT]: iot_dump_log()
D (189183) [IoT]: iot_dump_log(346) > LOG : 30000000 65a71b9e 000004c7 00000000
W (189193) [IoT]: st_conn_stae 000004cb 00000006
D (189213) [IoT]: iot_dump_log(346) > LOG : 20000104 65a71b9e fffffff5 00000000
D (189213) [IoT]: iot_nv_get_misc_info(1071) > >>>HIT<<<
D (189223) [IoT]: _iot_nv_io_storage(104) > id = 11, mode = 1
D (189233) [IoT]: iot_security_be_init(2283) > security backend is 'sfo'
bsp_fs_storage_id2filename(85) > storage file = 'MiscIn id:11
D (189243) [IoT]: _iot_security_be_bsp_fs_load(193) > id = 11
D (189243) [IoT]: _iot_security_be_bsp_fs_load_from_nv(100) > id = 11
D (189253) [IoT]: iot_bsp_nv_get_data_path(25) > >>>HIT<<<
D (189263) [IoT]: _iot_secfo'
D (189273) nvs: nvs_open_from_partition stdk 0
D (f-3001f7caa49a4","maj":0,"min":1},"loId":"0ee68f6a-656c-4dbc-a1cvs_get_str_or_blob MiscInfo
D (189283) nvs: nvs_close 42
D (189283) [IoT]: iot_security_storage_read(146) > id:11 read 133@0x3ffcf7dc
D (189293) [IoT]: iot_misc_info_store(1378)onnecting failed(-2) fostr : {"dip":{"id":"292bfe28-dc57-4c27-b1f-3001f7caa4ee","prevErr":"CE32"}
D (189313) [IoT]: iot_misc_info_store(1387) > Same misc_info, skip NV update
E (189313) [IoT]: iot_es_disconnect(1294) > There is no mqtt_ctx!!
W (189323) [IoT]: _iot_main_task(980) > COMM disconnecting failed(-2) for mqtt_yield
D (189333) [IoT]: iot_dump_log(346) > LOG : 20000000 65a71b9f 000003d5 fffffffe

@junyoun-kim
Copy link
Collaborator

@KIMSUNIK You can apply below patch in iot-core.

diff --git a/src/iot_api.c b/src/iot_api.c
index 1a0aecf..ab0c0c0 100644
--- a/src/iot_api.c
+++ b/src/iot_api.c
@@ -1614,6 +1614,8 @@ iot_error_t iot_cleanup(struct iot_context *ctx, bool reboot)
if (reboot) {
IOT_REBOOT();
+ } else {
+ ctx->curr_state = IOT_STATE_INITIALIZED;
}
return IOT_ERROR_NONE;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants