diff --git a/README.md b/README.md index de7ff45..b5a630f 100644 --- a/README.md +++ b/README.md @@ -393,6 +393,8 @@ param **`networkConnectionCB`** The function that handles the network connection param **`networkStatusCB`** The function that handle the network connection status acknowledgement. +Due to the client pointer is assigned, to avoid dangling pointer, client should be existed as long as it was used for transportation. + ```cpp void setExternalClient(Client *client, ESP_Signer_NetworkConnectionRequestCallback networkConnectionCB, ESP_Signer_NetworkStatusRequestCallback networkStatusCB); @@ -413,6 +415,8 @@ param **`user`** The GPRS user. param **`password`** The GPRS password. +Due to the client and modem pointers are assigned, to avoid dangling pointer, client should be existed as long as it was used for transportation. + ```cpp void setGSMClient(Client *client, void *modem, const char *pin, const char *apn, const char *user, const char *password); ``` diff --git a/examples/Ethernet/Pico/Pico.ino b/examples/Ethernet/Pico/Pico.ino index ef2c3f4..a27fdb7 100644 --- a/examples/Ethernet/Pico/Pico.ino +++ b/examples/Ethernet/Pico/Pico.ino @@ -179,6 +179,8 @@ void begin() config.signer.tokens.scope = "https://www.googleapis.com/auth/spreadsheets,https://www.googleapis.com/auth/drive,https://www.googleapis.com/auth/drive.file"; /* Assign the pointer to global defined external Client object and required callback functions */ + // Due to the client (eth) pointer is assigned, to avoid dangling pointer, + // client should be existed as long as it was used for transportation. Signer.setExternalClient(ð, networkConnection, networkStatusRequestCallback); Signer.begin(&config); diff --git a/examples/GSM/GSM.ino b/examples/GSM/GSM.ino index da218c6..a014802 100644 --- a/examples/GSM/GSM.ino +++ b/examples/GSM/GSM.ino @@ -165,7 +165,9 @@ void setup() config.token_status_callback = tokenStatusCallback; config.signer.tokens.scope = "https://www.googleapis.com/auth/spreadsheets,https://www.googleapis.com/auth/drive,https://www.googleapis.com/auth/drive.file"; - + + // Due to the gsm_client and modem pointers are assigned, to avoid dangling pointer, + // gsm_client and modem should be existed as long as it was used for transportation. Signer.setGSMClient(&gsm_client, &modem, GSM_PIN, apn, gprsUser, gprsPass); Signer.begin(&config); diff --git a/src/ESP_Signer.h b/src/ESP_Signer.h index 37d14e3..daf52dc 100644 --- a/src/ESP_Signer.h +++ b/src/ESP_Signer.h @@ -51,6 +51,9 @@ class ESP_Signer * @param client The pointer to Arduino Client derived class of SSL Client. * @param networkConnectionCB The function that handles the network connection. * @param networkStatusCB The function that handle the network connection status acknowledgement. + * + * Due to the client pointer is assigned, to avoid dangling pointer, + * client should be existed as long as it was used for transportation. */ void setExternalClient(Client *client, ESP_Signer_NetworkConnectionRequestCallback networkConnectionCB, ESP_Signer_NetworkStatusRequestCallback networkStatusCB) @@ -66,6 +69,9 @@ class ESP_Signer * @param apn The GPRS APN (Access Point Name). * @param user The GPRS user. * @param password The GPRS password. + * + * Due to the client and modem pointers are assigned, to avoid dangling pointer, + * client and modem should be existed as long as it was used for transportation. */ void setGSMClient(Client *client, void *modem = nullptr, const char *pin = nullptr, const char *apn = nullptr, const char *user = nullptr, const char *password = nullptr) {