Revision 26:e4e444cc7b14, committed 2019-08-01
- Comitter:
- fahimalavi
- Date:
- Thu Aug 01 18:57:01 2019 +0500
- Parent:
- 25:e67d3d9d2e7e
- Commit message:
- edrx support added
Changed in this revision
diff -r e67d3d9d2e7e -r e4e444cc7b14 UbloxCellularBase.cpp
--- a/UbloxCellularBase.cpp Wed May 29 12:39:28 2019 +0500
+++ b/UbloxCellularBase.cpp Thu Aug 01 18:57:01 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.
@@ -813,6 +816,8 @@
if (set_functionality_mode(FUNC_AIRPLANE)) {
#endif
if (initialise_sim_card()) {
+ int mno_profile;
+
#ifdef TARGET_UBLOX_C030_R412M
if (_psm_status == false) { //psm is not enabled by application yet so disable it at start-up
set_power_saving_mode(0, 0);
@@ -822,6 +827,18 @@
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();
+
+ if (get_mno_profile(&mno_profile))
+ tr_info("Current MNO profile is: %d", mno_profile);
#endif
if (set_device_identity(&_dev_info.dev) && // Set up device identity
device_init(_dev_info.dev)) {// Initialise this device
@@ -840,6 +857,7 @@
set_sms()) { // And set up SMS
// The modem is initialised.
_modem_initialised = true;
+ tr_info("Modem initialized");
}
}
}
@@ -956,6 +974,8 @@
MBED_ASSERT(_at != NULL);
+ at_set_timeout(3*60*1000); //command has 3 minutes timeout
+
if (_at->send("AT+COPS=2") && _at->recv("OK")) {
_dev_info.reg_status_csd = CSD_NOT_REGISTERED_NOT_SEARCHING;
_dev_info.reg_status_psd = PSD_NOT_REGISTERED_NOT_SEARCHING;
@@ -1630,11 +1650,112 @@
}
}
+uint32_t UbloxCellularBase::binary_str_to_uint(const char *binary_string, int binary_string_length)
+{
+ if (!binary_string || !binary_string_length) {
+ return 0;
+ }
+
+ int integer_output = 0, base_exp = 1;
+
+ for (int i = binary_string_length - 1; i >= 0; i--) {
+ if (binary_string[i] == '1') {
+ integer_output += (base_exp << (binary_string_length - (i+1)));
+ }
+ }
+
+ return integer_output;
+}
+
bool UbloxCellularBase::is_modem_awake()
{
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;
+}
+
+uint32_t UbloxCellularBase::get_receive_period() {
+ uint32_t edrx_value = 2;
+ char buf[24] = {0x00};
+ char 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) {
+
+ edrx_value = binary_str_to_uint(edrx_val,4);
+ }
+ }
+
+ if (_at->send("AT+CEDRXRDP") && _at->recv("OK")) {
+ }
+
+ tr_info("edrx_value. %d", edrx_value);
+
+ UNLOCK();
+ return edrx_value;
+}
+#endif //TARGET_UBLOX_C030_R41XM
+
//application should call init() or connect() in order to initialize the modem
void UbloxCellularBase::wakeup_modem()
{
diff -r e67d3d9d2e7e -r e4e444cc7b14 UbloxCellularBase.h
--- a/UbloxCellularBase.h Wed May 29 12:39:28 2019 +0500
+++ b/UbloxCellularBase.h Thu Aug 01 18:57:01 2019 +0500
@@ -1,4 +1,4 @@
-/* Copyright (c) 2017 ARM Limited
+/* Copyright (c) 2019 ARM Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -83,6 +83,17 @@
ASLEEP = 1
} ModemPSMState;
+ /**
+ * edrx access technology
+ */
+ typedef enum {
+ EDRXGSM_EC_GSM_IoT_mode = 1,
+ EDRXGSM_A_Gb_mode,
+ EDRXUTRAN_Iu_mode,
+ EDRXEUTRAN_WB_S1_mode,
+ EDRXEUTRAN_NB_S1_mode
+ }tEDRXAccessTechnology;
+
/** Initialise the modem, ready for use.
*
* @param pin PIN for the SIM card.
@@ -400,6 +411,54 @@
bool is_modem_awake();
#endif
+#ifdef TARGET_UBLOX_C030_R41XM
+ /** Set discontinuous reception time on cellular device.
+ * SARA-R404M / SARA-R410M-02B / SARA-R410M-52B / SARA-R412M / SARA-N4 : The <Paging_time_window> parameter cannot be set by means of the set command.
+ *
+ *
+ * @remark See 3GPP TS 27.007 eDRX for details.
+ *
+ * @param mode disable or enable the use of eDRX
+ * @param act_type type of access technology
+ * @param edrx_value requested edxr value. Extended DRX parameters information element.
+ *
+ * @return 0 on success
+ * 1 on failure
+ */
+ int set_receive_period(int mode, tEDRXAccessTechnology act_type, uint8_t edrx_value);
+
+ /** Set discontinuous reception time on cellular device.
+ *
+ * @remark See 3GPP TS 27.007 eDRX for details.
+ *
+ * @param mode disable or enable the use of eDRX
+ * @param act_type type of access technology
+ *
+ * @return 0 on success
+ * 1 on failure
+ */
+ int set_receive_period(int mode, tEDRXAccessTechnology act_type);
+
+ /** Set discontinuous reception time on cellular device. (Disable)
+ *
+ * @remark See 3GPP TS 27.007 eDRX for details.
+ *
+ * @param mode disable or enable the use of eDRX
+ *
+ * @return 0 on success
+ * 1 on failure
+ */
+ int set_receive_period(int mode);
+
+ /** get discontinuous reception time on cellular device.
+ *
+ * @remark See 3GPP TS 27.007 eDRX for details.
+ *
+ * @return uint32_t
+ */
+ uint32_t get_receive_period();
+#endif
+
protected:
#define OUTPUT_ENTER_KEY "\r"
@@ -649,6 +708,16 @@
* @param bit_cnt defines how many bits are filled to buffer started from lsb
*/
void uint_to_binary_str(uint32_t num, char* str, int str_size, int bit_cnt);
+
+ /** Converts the given binary string to uint.
+ * For example binary_str_to_uint("0000001001", 10) would return 9
+ *
+ * @param binary_string binary string from where chars are converted to uint
+ * @param binary_string_length length of the param binary_string
+ * @return uint represented by the binary string
+ */
+ uint32_t binary_str_to_uint(const char *binary_string, int binary_string_length);
+
#endif
private:
@@ -677,6 +746,9 @@
Callback<void(void*)> _func_psm_coming_out; /**< Callback. */
void set_modem_psm_state(int state);
#endif
+#ifdef TARGET_UBLOX_C030_R41XM
+ bool _edrx_configured;
+#endif
};
#endif // _UBLOX_CELLULAR_BASE_