Implementation of the CellularInterface for u-blox C027 and C030 (non-N2xx flavour) modems that uses the IP stack on-board the cellular modem, hence not requiring LWIP (and so less RAM) and allowing any AT command exchanges to be carried out at the same time as data transfers (since the modem remains in AT mode all the time). This library may be used from mbed 5.5 onwards. If you need to use SMS, USSD or access the modem file system at the same time as using the CellularInterface then use ublox-at-cellular-interface-ext instead.

Dependents:   example-ublox-cellular-interface example-ublox-cellular-interface_r410M example-ublox-mbed-client example-ublox-cellular-interface ... more

Files at this revision

API Documentation at this revision

Comitter:
fahimalavi
Date:
Thu Aug 01 18:06:44 2019 +0500
Parent:
29:773cfb0fe56c
Child:
31:07c9c5c3fb88
Child:
32:cba63ca70edc
Commit message:
edrx test case added and UPSND support added in disconnect modem stack

Changed in this revision

TESTS/unit_tests/default/main.cpp Show annotated file Show diff for this revision Revisions of this file
UbloxATCellularInterface.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/TESTS/unit_tests/default/main.cpp	Mon Jul 29 14:49:01 2019 +0500
+++ b/TESTS/unit_tests/default/main.cpp	Thu Aug 01 18:06:44 2019 +0500
@@ -1153,7 +1153,7 @@
     int previous_profile, current_profile;
 
     // Power-up the modem
-    TEST_ASSERT(interface->init());
+    TEST_ASSERT(interface->init(MBED_CONF_APP_DEFAULT_PIN));
 
     // Check if modem is registered with network
     if (interface->is_registered_csd() || interface->is_registered_psd() || interface->is_registered_eps()) {
@@ -1184,20 +1184,64 @@
     TEST_ASSERT(interface->connect(MBED_CONF_APP_DEFAULT_PIN, MBED_CONF_APP_APN,
                                    MBED_CONF_APP_USERNAME, MBED_CONF_APP_PASSWORD) == 0);
 
+    interface->get_receive_period();
+
     drop_connection(interface);
+}
+
+void test_edrx() {
+    const int c_edrx_value = 2;
+
+    // Power-up the modem
+    TEST_ASSERT(interface->init(MBED_CONF_APP_DEFAULT_PIN));
 
-    // Restore MNO profile to previous settings
-    TEST_ASSERT(interface->set_mno_profile((UbloxATCellularInterface::MNOProfile)previous_profile));
-    tr_debug("Previous MNO configured\n");
+    // Check if modem is registered with network
+    if (interface->is_registered_csd() || interface->is_registered_psd() || interface->is_registered_eps()) {
+        tr_error("set edrx in detached state");
+        // Deregister from Network
+        drop_connection(interface);
+    }
+    // Set MNO profile
+    TEST_ASSERT(interface->set_mno_profile((UbloxATCellularInterface::MNOProfile)MBED_CONF_UBLOX_CELL_DEFAULT_MNO_PROFILE));
+    tr_debug("MNO configured\n");
+
+    interface->set_receive_period(2, UbloxCellularBase::EDRXEUTRAN_WB_S1_mode, c_edrx_value);
+    interface->set_receive_period(2, UbloxCellularBase::EDRXEUTRAN_NB_S1_mode, c_edrx_value);
 
     // Rebooting modem for settings to take effect
-	TEST_ASSERT(interface->reboot_modem());
-	tr_debug("Reboot successful\n");
-	wait_ms(5000);
+    TEST_ASSERT(interface->reboot_modem());
+    tr_debug("Reboot successful\n");
+    wait_ms(5000);
+
+    //TEST_ASSERT(interface->get_receive_period() == c_edrx_value);
+
+    TEST_ASSERT(interface->connect(MBED_CONF_APP_DEFAULT_PIN, MBED_CONF_APP_APN,
+                                       MBED_CONF_APP_USERNAME, MBED_CONF_APP_PASSWORD) == 0);
+
+    TEST_ASSERT(interface->get_receive_period() == c_edrx_value);
+
+    drop_connection(interface);
+
+    interface->set_receive_period(3, UbloxCellularBase::EDRXEUTRAN_WB_S1_mode);
+    interface->set_receive_period(3, UbloxCellularBase::EDRXEUTRAN_NB_S1_mode);
 
-    // Check MNO profile configured correctly
-    TEST_ASSERT(interface->get_mno_profile(&current_profile));
-    TEST_ASSERT((current_profile == previous_profile));
+    // Set MNO profile
+    TEST_ASSERT(interface->set_mno_profile((UbloxATCellularInterface::MNOProfile)(MBED_CONF_UBLOX_CELL_DEFAULT_MNO_PROFILE+1)));
+    tr_debug("MNO configured\n");
+
+    // Rebooting modem for settings to take effect
+    TEST_ASSERT(interface->reboot_modem());
+    tr_debug("Reboot successful\n");
+    wait_ms(5000);
+
+    // Set MNO profile
+    TEST_ASSERT(interface->set_mno_profile((UbloxATCellularInterface::MNOProfile)MBED_CONF_UBLOX_CELL_DEFAULT_MNO_PROFILE));
+    tr_debug("MNO configured\n");
+
+    // Rebooting modem for settings to take effect
+    TEST_ASSERT(interface->reboot_modem());
+    tr_debug("Reboot successful\n");
+    wait_ms(5000);
 }
 #endif
 
@@ -1218,6 +1262,10 @@
 
 // Test cases
 Case cases[] = {
+#ifdef TARGET_UBLOX_C030_R41XM
+    Case("MNO profile test", test_mno_profile),
+    Case("edrx test", test_edrx),
+#endif
     Case("Base class tests", test_base_class),
     Case("Set randomise", test_set_randomise),
 #ifdef MBED_CONF_APP_ECHO_SERVER
@@ -1246,9 +1294,6 @@
     Case("Register with network test", test_registration),
     Case("Set previous RAT test", test_set_previous_rat),
 #endif
-#ifdef TARGET_UBLOX_C030_R41XM
-    Case("MNO profile test", test_mno_profile),
-#endif
 #ifndef TARGET_UBLOX_C027 // Not enough RAM on little 'ole C027 for this
     Case("Connect using local instance, must be last test", test_connect_local_instance_last_test)
 #endif
--- a/UbloxATCellularInterface.cpp	Mon Jul 29 14:49:01 2019 +0500
+++ b/UbloxATCellularInterface.cpp	Thu Aug 01 18:06:44 2019 +0500
@@ -467,6 +467,8 @@
 bool UbloxATCellularInterface::disconnect_modem_stack()
 {
     bool success = false;
+    int active;
+    Timer t1;
     LOCK();
 
     if (get_ip_address() != NULL) {
@@ -477,6 +479,21 @@
             }
         }
     }
+    t1.start();
+    while (!(t1.read() >= 180)) {
+        if (_at->send("AT+UPSND=" PROFILE ",8") && _at->recv("+UPSND: %*d,%*d,%d\n", &active) && _at->recv("OK")) {
+
+            if (active == 0) {  //If context is deactivated, exit while loop and return status
+                tr_debug("Profile deactivated successfully");
+                break;
+            }
+            else {
+                tr_error("Profile still active");
+                rtos::ThisThread::sleep_for(5000); //Wait for 5 seconds and then try again
+            }
+        }
+    }
+    t1.stop();
 
     UNLOCK();
     return success;