Base class for the ublox-xxx-cellular-xxx classes. Cannot be used standalone, only inherited by classes that do properly useful stuff. Or, to put it another way, if you are using any of the ublox-xxx-cellular-xxx classes, you will need this class also.
Dependents: example-ublox-cellular-interface example-ublox-cellular-driver-gen HelloMQTT example-ublox-cellular-interface_r410M ... more
Diff: UbloxCellularBase.cpp
- Revision:
- 26:e4e444cc7b14
- Parent:
- 25:e67d3d9d2e7e
- Child:
- 27:250eaef6232d
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()
{
u-blox