-
Notifications
You must be signed in to change notification settings - Fork 3k
UBLOX cellular api's for UDP and TCP #7619
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks quite good. Description could tell TCP is client only.
@@ -98,6 +98,7 @@ class AT_CellularStack : public NetworkStack, public AT_CellularBase | |||
bool started; // socket has been opened on modem stack | |||
bool tx_ready; // socket is ready for sending on modem stack | |||
bool rx_avail; // socket has data for reading on modem stack | |||
volatile nsapi_size_t pending_bytes; // The number of received bytes pending |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could probably use rx_avail
flag here just to indicate that some data is available because you always read how much data really is available when recveiving? If not then you could change type of rx_avail
and use it instead of new pending_bytes
variable.
There is no need to use volatile here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If rx_avail is unused and nobody else is using it then we can change its type and use it as well.
@@ -0,0 +1,59 @@ | |||
/* | |||
* Copyright (c) 2017, Arm Limited and affiliates. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Years are passing so fast, it's already 2018 :) See also the other files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated.
{ | ||
|
||
public: | ||
UBLOX_AT(events::EventQueue &queue); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please run astyle.exe -n --options=.astylerc <file>
for coding guidelines.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated all files.
|
||
bool UBLOX_AT_CellularNetwork::has_registration(RegistrationType reg_type) | ||
{ | ||
return (reg_type == C_REG || reg_type == C_GREG); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LTE / NB-IoT should be C_EREG
instead of C_GREG
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is not LTE or NB-Iot module so no need to add 'C_EREG '.
|
||
nsapi_error_t UBLOX_AT_CellularNetwork::detach() | ||
{ | ||
_at.lock(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could call parent implementation AT_CellularNetwork::detach();
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After detach we are receiving two urc's, '+CGREG' and '+UUPSDD', to process these urc's we have added 50 ms wait here otherwise "CellularNetwork test detach" fails.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add wait just before when "test detach" is called?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you suggesting to add wait in CellularNetwork test detach
test case?
if yes then I can remove my detach()
function and will use parent implementation.
_at.resp_start(); | ||
_at.resp_stop(); | ||
_at.unlock(); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
get_last_error()
before unlocking.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated.
return NSAPI_ERROR_DEVICE_ERROR; | ||
} | ||
|
||
_at.lock(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lock
not needed due to socket_sendto_impl
has locks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated.
CellularSocket *socket = NULL; | ||
|
||
for (unsigned int x = 0; (socket == NULL) && (x < UBLOX_MAX_SOCKET); x++) { | ||
if (_socket) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If _socket is NULL then we probably want to assert :)
_at.resp_start("+UDNSRN:"); | ||
if (_at.info_resp()) { | ||
_at.read_string(ipAddress, sizeof(ipAddress)); | ||
_at.resp_stop(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't change anything here but logically resp_stop
would be in the same scope with resp_start
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated.
#endif | ||
/* wait for modem to power off properly*/ | ||
wait(10); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this really needed here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated.
0fa9e3a
to
cd7dc50
Compare
cd7dc50
to
ffb4f92
Compare
@AriParkkila please review again. Do you have any other queries? |
uint8_t ch = 0; | ||
int port = 0; | ||
Timer timer; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An application may call recvfrom
even when there is no incoming data. In these cases function should return immediately with NSAPI_ERROR_WOULD_BLOCK (async) instead of waiting for timer.read_ms() < SOCKET_TIMEOUT)
.
_at.write_int(address.get_port()); | ||
_at.write_int(size); | ||
_at.cmd_stop(); | ||
wait_ms(50); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mbed_poll
is a better way to wait for an input
|
||
nsapi_error_t UBLOX_AT_CellularNetwork::detach() | ||
{ | ||
_at.lock(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add wait just before when "test detach" is called?
@AriParkkila In reference to those linked issues, would it be possible for this PR to continue if those are left open, or are those issues blocking basic functionality and/or would they cause tests to fail? |
+UDNSRN will be supported in later modem firmware versions of R410M variant. This pull request was generated after all tests getting passed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you should still fix async socket reading. If recv
waits for an second that causes unnecessary unresponsiveness and battery consumption.
uint8_t ch = 0; | ||
int port = 0; | ||
Timer timer; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can always return NSAPI_ERROR_WOULD_BLOCK
:
In blocking mode Mbed OS socket layer waits for a message until socket-timeout and if one is received via URC then socket layer calls recvfrom
again to actually read the message.
In non-blocking mode control returns immediately to a calling application. When message is received via URC it issues callback on an application, then the application needs to call recvfrom
again to actually read the message.
@@ -275,6 +273,13 @@ nsapi_size_or_error_t UBLOX_AT_CellularStack::socket_recvfrom_impl(CellularSocke | |||
int port = 0; | |||
Timer timer; | |||
|
|||
if (!socket->rx_avail) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think rx_avail
should not be cleared in sendto
, you need to set it in URC and reset after all is read in recvfrom.
Because you are now updating pending_bytes
in URC, you could use that as well and remove rx_avail
completely, and then check for if (socket->pending_bytes > 0)
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you saying that remove rx_avail
from my class completely and use pending_bytes
only, for checking availability of data as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please fix rx_avail
and it looks good to me.
Updated and removed |
/morph build |
Build : SUCCESSBuild number : 2823 Triggering tests/morph test |
Exporter Build : FAILUREBuild number : 2453 |
Export failure does not appear related to PR. |
/morph mbed2-build |
Test : SUCCESSBuild number : 2573 |
/morph export-build |
Jenkins machine fail, restarting /morph export-build |
@ARMmbed/mbed-os-test Can you review the above exporter failure (IllegalStateException) |
@0xc0170 Seems to be jenkins failure. Please rerun export job |
Exporter Build : SUCCESSBuild number : 2478 |
Exporter Build : SUCCESSBuild number : 2479 |
UBLOX cellular api's for UDP and TCP
Description
This PR updates the cellular API's for the u-blox targets. Some u-blox targets must use an internal IP stack while others can use both internal and external IP stacks. This PR introduces support for the internal IP stack; a new cellular target type, called UBLOX_AT, is added in "CellularTargets.h" and AT classes are added in targets/UBLOX. The API to the internal IP stack supports both UDP and TCP socket operations.
Supported Targets: UBLOX_C030_U201
Tool Chains: ARM, GCC_ARM, IAR
ARM_Build.txt
GCC_ARM_Build.txt
IAR_Build.txt
Pull request type