drx

Revision:
26:7a05f60319bc
Parent:
25:e67d3d9d2e7e
Child:
27:bea0391bb075
--- a/UbloxCellularBase.cpp	Wed May 29 12:39:28 2019 +0500
+++ b/UbloxCellularBase.cpp	Fri Jul 26 15:32:42 2019 +0500
@@ -1,4 +1,4 @@
-/* Copyright (c) 2017 ublox Limited
+/* Copyright (c) 2019 ublox Limited
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -499,6 +499,9 @@
     _cb_param_psm_coming_out = NULL;
     _func_psm_coming_out = NULL;
 #endif
+#ifdef TARGET_UBLOX_C030_R41XM
+    _edrx_configured = false;
+#endif
 }
 
 // Destructor.
@@ -822,6 +825,15 @@
                     if (_at->is_idle_mode_enabled() == false) {
                         set_idle_mode(false); //disable idle mode at start up
                     }
+                    if(_edrx_configured == false) {
+                        // A special form of the command can be given as +CEDRXS=3.
+                        // In this form, eDRX will be disabled and data for all parameters in the command +CEDRXS will be removed or,
+                        // if available, set to the manufacturer specific default values.
+                        set_receive_period(3,UbloxCellularBase::EDRXGSM_A_Gb_mode);
+                        set_receive_period(3,UbloxCellularBase::EDRXEUTRAN_WB_S1_mode);
+                        set_receive_period(3,UbloxCellularBase::EDRXEUTRAN_NB_S1_mode);
+                    }
+                    get_receive_period();
 #endif
                     if (set_device_identity(&_dev_info.dev) && // Set up device identity
                         device_init(_dev_info.dev)) {// Initialise this device
@@ -840,6 +852,7 @@
                                     set_sms()) { // And set up SMS
                                     // The modem is initialised.
                                     _modem_initialised = true;
+                                    tr_info("Modem initialized");
                                 }
                             }
                         }
@@ -1635,6 +1648,84 @@
   return (_dev_info.modem_psm_state == AWAKE);
 }
 
+#ifdef TARGET_UBLOX_C030_R41XM
+int UbloxCellularBase::set_receive_period(int mode, tEDRXAccessTechnology act_type, uint8_t edrx_value) {
+    char edrx[5];
+    uint_to_binary_str(edrx_value, edrx, 5, 4);
+    edrx[4] = '\0';
+    int status = 1;
+
+    LOCK();
+
+    if (_at->send("AT+CEDRXS=%d,%d,\"%s\"", mode, act_type, edrx) && _at->recv("OK")) {
+        _edrx_configured = true;
+        status = 0;
+    }
+    else {
+        status = 1;
+    }
+
+
+    UNLOCK();
+
+    return status;
+}
+
+int UbloxCellularBase::set_receive_period(int mode, tEDRXAccessTechnology act_type) {
+    int status = 1;
+
+    LOCK();
+
+    if (_at->send("AT+CEDRXS=%d,%d", mode, act_type) && _at->recv("OK")) {
+
+        status = 0;
+    }
+    else {
+        status = 1;
+    }
+
+    UNLOCK();
+
+    return status;
+}
+
+int UbloxCellularBase::set_receive_period(int mode) {
+    int status = 1;
+
+    LOCK();
+
+    if (_at->send("AT+CEDRXS=%d", mode) && _at->recv("OK")) {
+
+        status = 0;
+    }
+    else {
+        status = 1;
+    }
+
+    UNLOCK();
+
+    return status;
+}
+
+bool UbloxCellularBase::get_receive_period() {
+    bool success = false;
+    char buf[24] = {0x00};
+    uint8_t edrx_val[5];
+    tEDRXAccessTechnology act_type;
+
+    LOCK();
+
+    if (_at->send("AT+CEDRXS?") && _at->recv("%23[^\n]\nOK\n", buf)) {
+        if (sscanf(buf, "+CEDRXS: %d,%s", (int *)act_type, edrx_val) == 2) {
+            success = true;
+        }
+    }
+
+    UNLOCK();
+    return success;
+}
+#endif //TARGET_UBLOX_C030_R41XM
+
 //application should call init() or connect() in order to initialize the modem
 void UbloxCellularBase::wakeup_modem()
 {