-
-
Notifications
You must be signed in to change notification settings - Fork 203
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
236 additions
and
0 deletions.
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
patches/0223-CellularDevice-avoid-callback-data-is-changed-before.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
From 0611201dfb21fcc36e0d37e283a7e8bb44664ec8 Mon Sep 17 00:00:00 2001 | ||
From: pennam <[email protected]> | ||
Date: Fri, 17 Nov 2023 17:25:50 +0100 | ||
Subject: [PATCH 223/226] CellularDevice: avoid callback data is changed before | ||
attached callback is changed | ||
|
||
--- | ||
.../source/framework/device/CellularDevice.cpp | 10 +++++----- | ||
1 file changed, 5 insertions(+), 5 deletions(-) | ||
|
||
diff --git a/connectivity/cellular/source/framework/device/CellularDevice.cpp b/connectivity/cellular/source/framework/device/CellularDevice.cpp | ||
index 50d900e14a..1f53b33e61 100644 | ||
--- a/connectivity/cellular/source/framework/device/CellularDevice.cpp | ||
+++ b/connectivity/cellular/source/framework/device/CellularDevice.cpp | ||
@@ -180,6 +180,11 @@ void CellularDevice::stm_callback(nsapi_event_t ev, intptr_t ptr) | ||
|
||
void CellularDevice::cellular_callback(nsapi_event_t ev, intptr_t ptr, CellularContext *ctx) | ||
{ | ||
+ // forward to callback function if set by attach(...). | ||
+ if (_status_cb) { | ||
+ _status_cb(ev, ptr); | ||
+ } | ||
+ | ||
if (ev >= NSAPI_EVENT_CELLULAR_STATUS_BASE && ev <= NSAPI_EVENT_CELLULAR_STATUS_END) { | ||
cellular_connection_status_t cell_ev = (cellular_connection_status_t)ev; | ||
cell_callback_data_t *ptr_data = (cell_callback_data_t *)ptr; | ||
@@ -220,11 +225,6 @@ void CellularDevice::cellular_callback(nsapi_event_t ev, intptr_t ptr, CellularC | ||
} | ||
curr = curr->_next; | ||
} | ||
- | ||
- // forward to callback function if set by attach(...). | ||
- if (_status_cb) { | ||
- _status_cb(ev, ptr); | ||
- } | ||
} | ||
|
||
nsapi_error_t CellularDevice::shutdown() | ||
-- | ||
2.42.0 | ||
|
30 changes: 30 additions & 0 deletions
30
patches/0224-ATHandler-do-not-temporarily-change-debug-options-to.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
From 973a19b25200a2d11746ea8196a8403f189e13a7 Mon Sep 17 00:00:00 2001 | ||
From: pennam <[email protected]> | ||
Date: Fri, 17 Nov 2023 17:29:39 +0100 | ||
Subject: [PATCH 224/226] ATHandler: do not temporarily change debug options to | ||
partially trace AT commands | ||
|
||
--- | ||
connectivity/cellular/source/framework/device/ATHandler.cpp | 5 ----- | ||
1 file changed, 5 deletions(-) | ||
|
||
diff --git a/connectivity/cellular/source/framework/device/ATHandler.cpp b/connectivity/cellular/source/framework/device/ATHandler.cpp | ||
index f305fd8af5..36d21243f8 100644 | ||
--- a/connectivity/cellular/source/framework/device/ATHandler.cpp | ||
+++ b/connectivity/cellular/source/framework/device/ATHandler.cpp | ||
@@ -1244,12 +1244,7 @@ void ATHandler::handle_start(const char *cmd, const char *cmd_chr) | ||
} | ||
_cmd_buffer[len] = '\0'; | ||
|
||
- const bool temp_state = get_debug(); | ||
- set_debug(true); | ||
- | ||
cmd_start(_cmd_buffer); | ||
- | ||
- set_debug(temp_state); | ||
} | ||
|
||
void ATHandler::cmd_start_stop(const char *cmd, const char *cmd_chr, const char *format, ...) | ||
-- | ||
2.42.0 | ||
|
97 changes: 97 additions & 0 deletions
97
patches/0225-CellularStateMachine-add-state-data-to-timeout-and-r.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
From 1e2795ce9a47146d8c87e4ff957ac3784482e075 Mon Sep 17 00:00:00 2001 | ||
From: pennam <[email protected]> | ||
Date: Fri, 17 Nov 2023 17:57:49 +0100 | ||
Subject: [PATCH 225/226] CellularStateMachine: add state data to timeout and | ||
retry callbacks | ||
|
||
--- | ||
.../framework/common/CellularCommon.h | 20 +++++++++++++++++++ | ||
.../framework/device/CellularStateMachine.h | 2 ++ | ||
.../framework/device/CellularStateMachine.cpp | 11 +++++++--- | ||
3 files changed, 30 insertions(+), 3 deletions(-) | ||
|
||
diff --git a/connectivity/cellular/include/cellular/framework/common/CellularCommon.h b/connectivity/cellular/include/cellular/framework/common/CellularCommon.h | ||
index f0466e88cf..96e25dc991 100644 | ||
--- a/connectivity/cellular/include/cellular/framework/common/CellularCommon.h | ||
+++ b/connectivity/cellular/include/cellular/framework/common/CellularCommon.h | ||
@@ -47,6 +47,26 @@ struct cell_signal_quality_t { | ||
} | ||
}; | ||
|
||
+struct cell_timeout_cb_t { | ||
+ int timeout; /* configured timeout */ | ||
+ int state; /* cellular state */ | ||
+ cell_timeout_cb_t() | ||
+ { | ||
+ timeout = -1; | ||
+ state = -1; | ||
+ } | ||
+}; | ||
+ | ||
+struct cell_retry_cb_t { | ||
+ int retry_count; /* retry count */ | ||
+ int state; /* cellular state */ | ||
+ cell_retry_cb_t() | ||
+ { | ||
+ retry_count = -1; | ||
+ state = -1; | ||
+ } | ||
+}; | ||
+ | ||
/** | ||
* Cellular specific event changes. | ||
* Connect and disconnect are handled via NSAPI_EVENT_CONNECTION_STATUS_CHANGE | ||
diff --git a/connectivity/cellular/include/cellular/framework/device/CellularStateMachine.h b/connectivity/cellular/include/cellular/framework/device/CellularStateMachine.h | ||
index 67912e463c..aed9d615ce 100644 | ||
--- a/connectivity/cellular/include/cellular/framework/device/CellularStateMachine.h | ||
+++ b/connectivity/cellular/include/cellular/framework/device/CellularStateMachine.h | ||
@@ -189,6 +189,8 @@ private: | ||
bool _command_success; | ||
bool _is_retry; | ||
cell_callback_data_t _cb_data; | ||
+ cell_timeout_cb_t _timeout_cb_data; | ||
+ cell_retry_cb_t _retry_cb_data; | ||
cellular_connection_status_t _current_event; | ||
int _status; | ||
PlatformMutex _mutex; | ||
diff --git a/connectivity/cellular/source/framework/device/CellularStateMachine.cpp b/connectivity/cellular/source/framework/device/CellularStateMachine.cpp | ||
index 833f1d2239..37416ca72e 100644 | ||
--- a/connectivity/cellular/source/framework/device/CellularStateMachine.cpp | ||
+++ b/connectivity/cellular/source/framework/device/CellularStateMachine.cpp | ||
@@ -61,7 +61,7 @@ CellularStateMachine::CellularStateMachine(CellularDevice &device, events::Event | ||
_start_time(rand() % (MBED_CONF_CELLULAR_RANDOM_MAX_START_DELAY)), | ||
#endif // MBED_CONF_CELLULAR_RANDOM_MAX_START_DELAY | ||
_event_timeout(-1s), _event_id(-1), _plmn(0), _command_success(false), | ||
- _is_retry(false), _cb_data(), _current_event(CellularDeviceReady), _status(0) | ||
+ _is_retry(false), _cb_data(), _timeout_cb_data(), _retry_cb_data(), _current_event(CellularDeviceReady), _status(0) | ||
{ | ||
|
||
// set initial retry values in seconds | ||
@@ -289,8 +289,10 @@ void CellularStateMachine::retry_state_or_fail() | ||
if (_retry_count < _retry_array_length) { | ||
tr_debug("%s: retry %d/%d", get_state_string(_state), _retry_count, _retry_array_length); | ||
// send info to application/driver about error logic so it can implement proper error logic | ||
+ _retry_cb_data.retry_count = _retry_count; | ||
+ _retry_cb_data.state = _state; | ||
_cb_data.status_data = _current_event; | ||
- _cb_data.data = &_retry_count; | ||
+ _cb_data.data = &_retry_cb_data; | ||
_cb_data.error = NSAPI_ERROR_OK; | ||
send_event_cb(CellularStateRetryEvent); | ||
|
||
@@ -680,8 +682,11 @@ void CellularStateMachine::send_event_cb(cellular_connection_status_t status) | ||
|
||
void CellularStateMachine::change_timeout(const std::chrono::duration<int, std::milli> &timeout) | ||
{ | ||
+ _timeout_cb_data.timeout = timeout.count(); | ||
+ _timeout_cb_data.state = _state; | ||
+ | ||
_cb_data.status_data = _current_event; | ||
- _cb_data.data = &timeout; | ||
+ _cb_data.data = &_timeout_cb_data; | ||
_cb_data.error = NSAPI_ERROR_OK; | ||
// event callback is a preferred method to communicate to CellularDevice, | ||
// for example calling CellularDevice::set_timeout would call back to this class | ||
-- | ||
2.42.0 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
From aa22f048ae886adcc032ba2fefc7e1f90aa2b693 Mon Sep 17 00:00:00 2001 | ||
From: pennam <[email protected]> | ||
Date: Tue, 21 Nov 2023 14:50:08 +0100 | ||
Subject: [PATCH 226/226] Gemalto Cinterion: improve trace output | ||
|
||
* Do not flood serial monitor with tr_info prints | ||
* Align usage of "\n" | ||
--- | ||
.../CINTERION/GEMALTO_CINTERION_CellularContext.cpp | 2 +- | ||
.../GEMALTO/CINTERION/GEMALTO_CINTERION_CellularStack.cpp | 8 ++++---- | ||
2 files changed, 5 insertions(+), 5 deletions(-) | ||
|
||
diff --git a/connectivity/drivers/cellular/GEMALTO/CINTERION/GEMALTO_CINTERION_CellularContext.cpp b/connectivity/drivers/cellular/GEMALTO/CINTERION/GEMALTO_CINTERION_CellularContext.cpp | ||
index 7ee2c8e53c..d4ae578f09 100644 | ||
--- a/connectivity/drivers/cellular/GEMALTO/CINTERION/GEMALTO_CINTERION_CellularContext.cpp | ||
+++ b/connectivity/drivers/cellular/GEMALTO/CINTERION/GEMALTO_CINTERION_CellularContext.cpp | ||
@@ -122,7 +122,7 @@ nsapi_error_t GEMALTO_CINTERION_CellularContext::do_user_authentication() | ||
return NSAPI_ERROR_AUTH_FAILURE; | ||
} | ||
} else { | ||
- tr_info("Empty pwd and username fields: no need for authentication\n"); | ||
+ tr_info("Empty pwd and username fields: no need for authentication"); | ||
} | ||
|
||
return NSAPI_ERROR_OK; | ||
diff --git a/connectivity/drivers/cellular/GEMALTO/CINTERION/GEMALTO_CINTERION_CellularStack.cpp b/connectivity/drivers/cellular/GEMALTO/CINTERION/GEMALTO_CINTERION_CellularStack.cpp | ||
index fc2e8985d7..ac2a54282a 100644 | ||
--- a/connectivity/drivers/cellular/GEMALTO/CINTERION/GEMALTO_CINTERION_CellularStack.cpp | ||
+++ b/connectivity/drivers/cellular/GEMALTO/CINTERION/GEMALTO_CINTERION_CellularStack.cpp | ||
@@ -284,7 +284,7 @@ nsapi_error_t GEMALTO_CINTERION_CellularStack::gethostbyname(const char *host, S | ||
_at.resp_stop(); | ||
if (size > 0) { | ||
//Valid string received | ||
- tr_info("Read %d bytes. Valid string: %s\n", size, ipAddress); | ||
+ tr_info("Read %d bytes. Valid string: %s", size, ipAddress); | ||
// _at.restore_at_timeout(); | ||
if (!address->set_ip_address(ipAddress)) { | ||
_at.unlock(); | ||
@@ -292,7 +292,7 @@ nsapi_error_t GEMALTO_CINTERION_CellularStack::gethostbyname(const char *host, S | ||
} | ||
} else { | ||
//Null string received | ||
- tr_info("Read %d bytes. Null string\n", size); | ||
+ tr_info("Read %d bytes. Null string", size); | ||
return NSAPI_ERROR_NO_ADDRESS; | ||
} | ||
} | ||
@@ -550,7 +550,7 @@ nsapi_size_or_error_t GEMALTO_CINTERION_CellularStack::socket_recvfrom_impl(Cell | ||
size = UDP_PACKET_SIZE; | ||
} | ||
|
||
- tr_info("requesting %d bytes\n", size); | ||
+ tr_debug("requesting %d bytes\n", size); | ||
_at.cmd_start_stop("^SISR", "=", "%d%d", socket->id, size); | ||
|
||
sisr_retry: | ||
@@ -574,7 +574,7 @@ sisr_retry: | ||
|
||
nsapi_size_or_error_t len = _at.read_int(); | ||
if (len == 0) { | ||
- tr_warn("Socket %d no data", socket->id); | ||
+ tr_debug("Socket %d no data", socket->id); | ||
_at.resp_stop(); | ||
RESTORE_URCs_AND_RETURN(NSAPI_ERROR_WOULD_BLOCK); | ||
} | ||
-- | ||
2.42.0 | ||
|