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

Cellular: UBLOX_C030_N211 Cellular API's #9637

Merged
merged 5 commits into from Mar 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 10 additions & 10 deletions features/cellular/TESTS/api/cellular_sms/main.cpp
Expand Up @@ -110,21 +110,21 @@ static void test_sms_initialize_text_mode()
static void test_sms_initialize_pdu_mode()
{
nsapi_error_t err = sms->initialize(CellularSMS::CellularSMSMmodePDU);
TEST_ASSERT(err == NSAPI_ERROR_OK || (err == NSAPI_ERROR_DEVICE_ERROR &&
((AT_CellularSMS *)sms)->get_device_error().errCode == SIM_BUSY));
TEST_ASSERT(err == NSAPI_ERROR_OK || err == NSAPI_ERROR_UNSUPPORTED || (err == NSAPI_ERROR_DEVICE_ERROR &&
((AT_CellularSMS *)sms)->get_device_error().errCode == SIM_BUSY));
}

static void test_set_cscs()
{
nsapi_error_t err = sms->set_cscs("IRA");
TEST_ASSERT(err == NSAPI_ERROR_OK || (err == NSAPI_ERROR_DEVICE_ERROR &&
((AT_CellularSMS *)sms)->get_device_error().errCode == SIM_BUSY));
TEST_ASSERT(err == NSAPI_ERROR_OK || err == NSAPI_ERROR_UNSUPPORTED || (err == NSAPI_ERROR_DEVICE_ERROR &&
((AT_CellularSMS *)sms)->get_device_error().errCode == SIM_BUSY));
err = sms->set_cscs("UCS2");
TEST_ASSERT(err == NSAPI_ERROR_OK || (err == NSAPI_ERROR_DEVICE_ERROR &&
((AT_CellularSMS *)sms)->get_device_error().errCode == SIM_BUSY));
TEST_ASSERT(err == NSAPI_ERROR_OK || err == NSAPI_ERROR_UNSUPPORTED || (err == NSAPI_ERROR_DEVICE_ERROR &&
((AT_CellularSMS *)sms)->get_device_error().errCode == SIM_BUSY));
err = sms->set_cscs("GSM");
TEST_ASSERT(err == NSAPI_ERROR_OK || (err == NSAPI_ERROR_DEVICE_ERROR &&
((AT_CellularSMS *)sms)->get_device_error().errCode == SIM_BUSY));
TEST_ASSERT(err == NSAPI_ERROR_OK || err == NSAPI_ERROR_UNSUPPORTED || (err == NSAPI_ERROR_DEVICE_ERROR &&
((AT_CellularSMS *)sms)->get_device_error().errCode == SIM_BUSY));
}

static void test_set_csca()
Expand All @@ -143,8 +143,8 @@ static void test_set_csca()
static void test_set_cpms_me()
{
nsapi_error_t err = sms->set_cpms("ME", "ME", "ME");
TEST_ASSERT(err == NSAPI_ERROR_OK || (err == NSAPI_ERROR_DEVICE_ERROR &&
((AT_CellularSMS *)sms)->get_device_error().errCode == SIM_BUSY));
TEST_ASSERT(err == NSAPI_ERROR_OK || err == NSAPI_ERROR_UNSUPPORTED || (err == NSAPI_ERROR_DEVICE_ERROR &&
((AT_CellularSMS *)sms)->get_device_error().errCode == SIM_BUSY));
}

#ifdef MBED_CONF_APP_CELLULAR_PHONE_NUMBER
Expand Down
4 changes: 4 additions & 0 deletions features/cellular/framework/AT/AT_CellularBase.h
Expand Up @@ -49,6 +49,10 @@ class AT_CellularBase {
PROPERTY_AT_CGSN_WITH_TYPE, // 0 = not supported, 1 = supported. AT+CGSN without type is likely always supported similar to AT+GSN.
PROPERTY_AT_CGDATA, // 0 = not supported, 1 = supported. Alternative is to support only ATD*99***<cid>#
PROPERTY_AT_CGAUTH, // 0 = not supported, 1 = supported. APN authentication AT commands supported
PROPERTY_AT_CNMI, // 0 = not supported, 1 = supported. New message (SMS) indication AT command
PROPERTY_AT_CSMP, // 0 = not supported, 1 = supported. Set text mode AT command
PROPERTY_AT_CMGF, // 0 = not supported, 1 = supported. Set preferred message format AT command
PROPERTY_AT_CSDH, // 0 = not supported, 1 = supported. Show text mode AT command
PROPERTY_IPV4_PDP_TYPE, // 0 = not supported, 1 = supported. Does modem support IPV4?
PROPERTY_IPV6_PDP_TYPE, // 0 = not supported, 1 = supported. Does modem support IPV6?
PROPERTY_IPV4V6_PDP_TYPE, // 0 = not supported, 1 = supported. Does modem support dual stack IPV4V6?
Expand Down
12 changes: 12 additions & 0 deletions features/cellular/framework/AT/AT_CellularSMS.cpp
Expand Up @@ -210,6 +210,9 @@ void AT_CellularSMS::cmti_urc()

nsapi_error_t AT_CellularSMS::set_cnmi()
{
if (!get_property(PROPERTY_AT_CNMI)) {
return NSAPI_ERROR_UNSUPPORTED;
}
_at.lock();
_at.cmd_start("AT+CNMI=2,1");
_at.cmd_stop_read_resp();
Expand All @@ -218,6 +221,9 @@ nsapi_error_t AT_CellularSMS::set_cnmi()

nsapi_error_t AT_CellularSMS::set_cmgf(int msg_format)
{
if (!get_property(PROPERTY_AT_CMGF)) {
return NSAPI_ERROR_UNSUPPORTED;
}
_at.lock();
_at.cmd_start("AT+CMGF=");
_at.write_int(msg_format);
Expand All @@ -227,6 +233,9 @@ nsapi_error_t AT_CellularSMS::set_cmgf(int msg_format)

nsapi_error_t AT_CellularSMS::set_csmp(int fo, int vp, int pid, int dcs)
{
if (!get_property(PROPERTY_AT_CSMP)) {
return NSAPI_ERROR_UNSUPPORTED;
}
_at.lock();
_at.cmd_start("AT+CSMP=");
_at.write_int(fo);
Expand All @@ -239,6 +248,9 @@ nsapi_error_t AT_CellularSMS::set_csmp(int fo, int vp, int pid, int dcs)

nsapi_error_t AT_CellularSMS::set_csdh(int show_header)
{
if (!get_property(PROPERTY_AT_CSDH)) {
return NSAPI_ERROR_UNSUPPORTED;
}
_at.lock();
_at.cmd_start("AT+CSDH=");
_at.write_int(show_header);
Expand Down
4 changes: 1 addition & 3 deletions features/cellular/framework/AT/AT_CellularStack.cpp
Expand Up @@ -132,9 +132,7 @@ nsapi_error_t AT_CellularStack::socket_open(nsapi_socket_t *handle, nsapi_protoc
tr_info("Socket %d open", index);
// create local socket structure, socket on modem is created when app calls sendto/recvfrom
_socket[index] = new CellularSocket;
CellularSocket *psock;
psock = _socket[index];
memset(psock, 0, sizeof(CellularSocket));
CellularSocket *psock = _socket[index];
SocketAddress addr(0, get_dynamic_ip_port());
psock->id = index;
psock->localAddress = addr;
Expand Down
4 changes: 3 additions & 1 deletion features/cellular/framework/common/CellularTargets.h
Expand Up @@ -32,8 +32,10 @@ namespace mbed {
#elif TARGET_MTB_MTS_DRAGONFLY
#define CELLULAR_DEVICE TELIT_HE910
#elif TARGET_UBLOX_C030
#if defined(TARGET_UBLOX_C030_N211) || defined(TARGET_UBLOX_C030_R41XM)
#if defined(TARGET_UBLOX_C030_R41XM)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CellularTargets.h is to be removed, no changes here but instead define UBLOX/N2XX/mbed_lib.json, copy a template e.g. from GENERIC_AT3GPP/mbed_lib.json.

#define CELLULAR_DEVICE UBLOX_AT
#elif defined(TARGET_UBLOX_C030_N211)
#define CELLULAR_DEVICE UBLOX_N2XX
#else
#define CELLULAR_DEVICE UBLOX_PPP
#endif
Expand Down
Expand Up @@ -99,6 +99,10 @@ void GEMALTO_CINTERION::init_module_bgs2()
0, // AT_CGSN_WITH_TYPE
1, // AT_CGDATA
1, // AT_CGAUTH
1, // AT_CNMI
1, // AT_CSMP
1, // AT_CMGF
1, // AT_CSDH
1, // PROPERTY_IPV4_STACK
0, // PROPERTY_IPV6_STACK
0, // PROPERTY_IPV4V6_STACK
Expand Down
Expand Up @@ -28,6 +28,10 @@ static const intptr_t cellular_properties[AT_CellularBase::PROPERTY_MAX] = {
1, // AT_CGSN_WITH_TYPE
1, // AT_CGDATA
1, // AT_CGAUTH
1, // AT_CNMI
1, // AT_CSMP
1, // AT_CMGF
1, // AT_CSDH
1, // PROPERTY_IPV4_STACK
1, // PROPERTY_IPV6_STACK
1, // PROPERTY_IPV4V6_STACK
Expand Down
Expand Up @@ -28,6 +28,10 @@ static const intptr_t cellular_properties[AT_CellularBase::PROPERTY_MAX] = {
0, // AT_CGSN_WITH_TYPE
0, // AT_CGDATA
1, // AT_CGAUTH
1, // AT_CNMI
1, // AT_CSMP
1, // AT_CMGF
1, // AT_CSDH
1, // PROPERTY_IPV4_STACK
0, // PROPERTY_IPV6_STACK
0, // PROPERTY_IPV4V6_STACK
Expand Down
Expand Up @@ -35,6 +35,10 @@ static const intptr_t cellular_properties[AT_CellularBase::PROPERTY_MAX] = {
1, // AT_CGSN_WITH_TYPE
1, // AT_CGDATA
0, // AT_CGAUTH, BC95_AT_Commands_Manual_V1.9
1, // AT_CNMI
1, // AT_CSMP
1, // AT_CMGF
1, // AT_CSDH
1, // PROPERTY_IPV4_STACK
0, // PROPERTY_IPV6_STACK
0, // PROPERTY_IPV4V6_STACK
Expand Down
Expand Up @@ -37,6 +37,10 @@ static const intptr_t cellular_properties[AT_CellularBase::PROPERTY_MAX] = {
0, // AT_CGSN_WITH_TYPE
0, // AT_CGDATA
1, // AT_CGAUTH
1, // AT_CNMI
1, // AT_CSMP
1, // AT_CMGF
1, // AT_CSDH
1, // PROPERTY_IPV4_STACK
0, // PROPERTY_IPV6_STACK
0, // PROPERTY_IPV4V6_STACK
Expand Down
Expand Up @@ -31,6 +31,10 @@ static const intptr_t cellular_properties[AT_CellularBase::PROPERTY_MAX] = {
0, // AT_CGSN_WITH_TYPE
1, // AT_CGDATA
0, // AT_CGAUTH
1, // AT_CNMI
1, // AT_CSMP
1, // AT_CMGF
1, // AT_CSDH
1, // PROPERTY_IPV4_STACK
0, // PROPERTY_IPV6_STACK
0, // PROPERTY_IPV4V6_STACK
Expand Down
Expand Up @@ -34,6 +34,10 @@ static const intptr_t cellular_properties[AT_CellularBase::PROPERTY_MAX] = {
1, // AT_CGSN_WITH_TYPE
1, // AT_CGDATA
1, // AT_CGAUTH
1, // AT_CNMI
1, // AT_CSMP
1, // AT_CMGF
1, // AT_CSDH
1, // PROPERTY_IPV4_STACK
0, // PROPERTY_IPV6_STACK
0, // PROPERTY_IPV4V6_STACK
Expand Down
Expand Up @@ -28,6 +28,10 @@ static const intptr_t cellular_properties[AT_CellularBase::PROPERTY_MAX] = {
0, // AT_CGSN_WITH_TYPE
1, // AT_CGDATA
0, // AT_CGAUTH
1, // AT_CNMI
1, // AT_CSMP
1, // AT_CMGF
1, // AT_CSDH
1, // PROPERTY_IPV4_STACK
0, // PROPERTY_IPV6_STACK
0, // PROPERTY_IPV4V6_STACK
Expand Down
10 changes: 9 additions & 1 deletion features/cellular/framework/targets/UBLOX/AT/UBLOX_AT.cpp
Expand Up @@ -29,7 +29,11 @@ static const intptr_t cellular_properties[AT_CellularBase::PROPERTY_MAX] = {
AT_CellularNetwork::RegistrationModeLAC, // C_REG
0, // AT_CGSN_WITH_TYPE
1, // AT_CGDATA
1, // AT_CGAUTH,
1, // AT_CGAUTH
1, // AT_CNMI
1, // AT_CSMP
1, // AT_CMGF
1, // AT_CSDH
1, // PROPERTY_IPV4_STACK
0, // PROPERTY_IPV6_STACK
0, // PROPERTY_IPV4V6_STACK
Expand All @@ -42,6 +46,10 @@ static const intptr_t cellular_properties[AT_CellularBase::PROPERTY_MAX] = {
1, // AT_CGSN_WITH_TYPE
1, // AT_CGDATA
1, // AT_CGAUTH
1, // AT_CNMI
1, // AT_CSMP
1, // AT_CMGF
1, // AT_CSDH
1, // PROPERTY_IPV4_STACK
0, // PROPERTY_IPV6_STACK
0, // PROPERTY_IPV4V6_STACK
Expand Down
Expand Up @@ -296,6 +296,12 @@ nsapi_size_or_error_t UBLOX_AT_CellularStack::socket_recvfrom_impl(CellularSocke
_at.read_string(ipAddress, sizeof(ipAddress));
port = _at.read_int();
usorf_sz = _at.read_int();
if (usorf_sz > size) {
usorf_sz = size;
}
_at.read_bytes(&ch, 1);
_at.read_bytes((uint8_t *)buffer + count, usorf_sz);
_at.resp_stop();

// Must use what +USORF returns here as it may be less or more than we asked for
if (usorf_sz > socket->pending_bytes) {
Expand All @@ -304,13 +310,6 @@ nsapi_size_or_error_t UBLOX_AT_CellularStack::socket_recvfrom_impl(CellularSocke
socket->pending_bytes -= usorf_sz;
}

if (usorf_sz > size) {
usorf_sz = size;
}
_at.read_bytes(&ch, 1);
_at.read_bytes((uint8_t *)buffer + count, usorf_sz);
_at.resp_stop();

if (usorf_sz > 0) {
count += usorf_sz;
size -= usorf_sz;
Expand Down Expand Up @@ -345,6 +344,12 @@ nsapi_size_or_error_t UBLOX_AT_CellularStack::socket_recvfrom_impl(CellularSocke
_at.resp_start("+USORD:");
_at.skip_param(); // receiving socket id
usorf_sz = _at.read_int();
if (usorf_sz > size) {
usorf_sz = size;
}
_at.read_bytes(&ch, 1);
_at.read_bytes((uint8_t *)buffer + count, usorf_sz);
_at.resp_stop();

// Must use what +USORD returns here as it may be less or more than we asked for
if (usorf_sz > socket->pending_bytes) {
Expand All @@ -353,13 +358,6 @@ nsapi_size_or_error_t UBLOX_AT_CellularStack::socket_recvfrom_impl(CellularSocke
socket->pending_bytes -= usorf_sz;
}

if (usorf_sz > size) {
usorf_sz = size;
}
_at.read_bytes(&ch, 1);
_at.read_bytes((uint8_t *)buffer + count, usorf_sz);
_at.resp_stop();

if (usorf_sz > 0) {
count += usorf_sz;
size -= usorf_sz;
Expand Down