diff --git a/CHANGELOG b/CHANGELOG index cd7f00c..e119b25 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,14 @@ ME310 0.0.0 - ????.??.?? + +ME310 2.10.0 - 2022.01.31 +* Added several lwm2m utility functions +* Fixed issue with psm_setting method empty parameters management +* Fixed unused parameter in ssl_configure_general_param method + +ME310 2.9.0 - 2022.01.11 +* code cleanup + ME310 2.8.0 - 2021.11.19 * Added lwm2m objset function * Added float to string method diff --git a/examples/LWM2M_Get_Object_example/LWM2M_Get_Object_example.ino b/examples/LWM2M_Get_Object_example/LWM2M_Get_Object_example.ino new file mode 100644 index 0000000..f03ae42 --- /dev/null +++ b/examples/LWM2M_Get_Object_example/LWM2M_Get_Object_example.ino @@ -0,0 +1,286 @@ +/*Copyright (C) 2020 Telit Communications S.p.A. Italy - All Rights Reserved.*/ +/* See LICENSE file in the project root for full license information. */ + +/** + @file + ME310.cpp + string.h + stdio.h + + @brief + Sample test of the use of AT commands via ME310 library + + @details + In this sketch, the operation of the get object functions in LWM2M objects is shown. + + NOTE:\n + + + @version + 1.0.0 + + @note + + @author + Cristina Desogus + + @date + 24/01/2022 + */ + + +#include + +#include +#include + + +#define APN "web.omnitel.it" + +#define ON_OFF 6 /*Select the GPIO to control ON_OFF*/ + + +using namespace me310; + +ME310 myME310; +ME310::return_t myRc; +char ipProt[] = "IP"; +const char* pin = 0; +bool setupValid = true; +int CID = 1; +int count = 0; + + +void setup() { + + pinMode(ON_OFF, OUTPUT); + pinMode(LED_BUILTIN, OUTPUT); + delay(100); + Serial.begin(115200); + myME310.begin(115200); + delay(1000); + myME310.powerOn(ON_OFF); + delay(2000); + + Serial.println("Start LWM2M example"); + myRc = myME310.report_mobile_equipment_error(2); //issue command AT+CMEE=2 and wait for answer or timeout + if(checkSIM()) + { + if(PDPContext()) + { + if(registrationStatus()) + { + if(LWM2MEnable()) + { + Serial.println("Configuration completed successfully"); + } + else + { + setupValid = false; + } + } + else + { + setupValid = false; + } + } + else + { + setupValid = false; + } + } + else + { + setupValid = false; + } + // put your setup code here, to run once: + +} + +void loop() { + + if(!setupValid) + { + Serial.println("Configuration ERROR"); + exit(0); + } + else + { + Serial.println("Get Object 6"); + myRc = myME310.LWM2M_get_object(0,6); //issue command AT#LWM2MOBJGET=agentInstanceID,objectID + if(myRc != ME310::RETURN_VALID) + { + exit(0); + } + + Serial.print("<"); + Serial.print(myME310.buffer_cstr_raw()); + Serial.println(">"); + + Serial.println("Get Object 6 instance 0"); + myRc = myME310.LWM2M_get_object_instance(0,6,0); //issue command AT#LWM2MOBJGET=agentInstanceID,objectID,objectInstanceID + if(myRc != ME310::RETURN_VALID) + { + exit(0); + } + + Serial.print("<"); + Serial.print(myME310.buffer_cstr_raw()); + Serial.println(">"); + + Serial.println("Get Object 6 instance 0 resource 1"); + myRc = myME310.LWM2M_get_object_resource(0,6,0,1); //issue command AT#LWM2MOBJGET=agentInstanceID,objectID,objectInstanceID,resourceID + if(myRc != ME310::RETURN_VALID) + { + exit(0); + } + + Serial.print("<"); + Serial.print(myME310.buffer_cstr_raw()); + Serial.println(">"); + } + Serial.println("End Application."); + exit(0); +} + +//! \brief Checks SIM +/*! \details +This function checks for the presence of the SIM and its management. + * + * \return returns true if the SIM and its management is done correctly, otherwise false. + */ +bool checkSIM() +{ + bool rc = false; + Serial.println("Check SIM"); + myRc = myME310.read_enter_pin(); //issue command AT+cpin? in read mode, check that the SIM is inserted and the module is not waiting for the PIN + String result = myME310.buffer_cstr(1); + if(result.endsWith("READY")) + { + Serial.println("SIM is READY"); + delay(5000); + rc = true; + } + else if (result.endsWith("SIM PIN")) + { + if (pin != NULL) + { + myME310.enter_pin(pin); //issue command AT+cpin=PIN + result = myME310.buffer_cstr(1); + if(result.endsWith("READY")) + { + Serial.println("SIM is READY"); + rc = true; + } + else + { + rc = false; + } + } + } + else + { + rc = false; + } + return rc; +} + +//! \brief PDP Context management. +/*! \details +This function deals with the management of the PDP Context. + * + * \return returns true if the management is done correctly, otherwise false. + */ +bool PDPContext() +{ + bool rc = false; + myRc = myME310.define_pdp_context(CID, ipProt, APN); //issue command AT+CGDCONT=cid,PDP_type,APN + if(myRc == ME310::RETURN_VALID) + { + rc = true; + } + else + { + rc = false; + } + return rc; +} + +//! \brief Checks GPRS network registration status. +/*! \details +This function takes care of checking the GPRS network registration status. + * + * \return returns true if the checking is done correctly, otherwise false. + */ +bool registrationStatus() +{ + bool rc = true; + Serial.println("GPRS network registration status"); + myRc = myME310.read_gprs_network_registration_status(); //issue command AT+CGREG=? (read mode) + if(myRc == ME310::RETURN_VALID) + { + char *resp = (char*) myME310.buffer_cstr(1); + while(resp != NULL) + { + if ((strcmp(resp, "+CGREG: 0,1") != 0) && (strcmp(resp, "+CGREG: 0,5") != 0)) + { + delay(3000); + myRc = myME310.read_gprs_network_registration_status(); + if(myRc != ME310::RETURN_VALID) + { + Serial.print("Read GPRS network registration status: "); + Serial.println(myME310.return_string(myRc)); + rc = false; + break; + } + Serial.println(myME310.buffer_cstr(1)); + resp = (char* )myME310.buffer_cstr(1); + } + else + { + break; + } + } + } + else + { + rc = false; + } + return rc; +} + +//! \brief Enable LWM2M +/*! \details +This function is responsible for managing the enable of the LWM2M, checking the existence of objects and creating a new instance for objects 3 and 3313. + * + * \return returns true if the management is done correctly, otherwise false. + */ +bool LWM2MEnable() +{ + bool ret = false; + Serial.println("LWM2MEnable"); + myRc = myME310.read_enableLWM2M(); //issue command AT#LWM2MENA?, in read mode. + String resp = (char*)myME310.buffer_cstr(1); + Serial.println(resp.c_str()); + if(resp.endsWith("\"ACTIVE\"")) + { + ret = true; + } + else + { + myRc = myME310.enableLWM2M(1,1); + delay(1000); + myRc = myME310.read_enableLWM2M(); //issue command AT#LWM2MENA?, in read mode. + String resp = (char*)myME310.buffer_cstr(1); + Serial.println(resp.c_str()); + if(resp.endsWith("\"ACTIVE\"")) + { + ret = true; + } + else + { + ret = false; + } + } + return ret; +} \ No newline at end of file diff --git a/examples/LWM2M_first_example/LWM2M_first_example.ino b/examples/LWM2M_first_example/LWM2M_first_example.ino new file mode 100644 index 0000000..2b0b2a0 --- /dev/null +++ b/examples/LWM2M_first_example/LWM2M_first_example.ino @@ -0,0 +1,422 @@ +/*Copyright (C) 2020 Telit Communications S.p.A. Italy - All Rights Reserved.*/ +/* See LICENSE file in the project root for full license information. */ + +/** + @file + ME310.cpp + string.h + stdio.h + + @brief + Sample test of the use of AT commands via ME310 library + + @details + In this sketch, the operation of the read and set functions in LWM2M objects is shown.\n + The resources Model Number (1), Serial Number (2), Firmware Version (3), of the Device object (3) are read.\n + In object 3313 (Accelerometer), set in resources x (5702), y (5703), z (5704).\n + + NOTE:\n + For the sketch to work correctly, it is necessary to load the XML of the object 3313 on the board.\n + + @version + 1.0.0 + + @note + + @author + Cristina Desogus + + @date + 14/01/2022 + */ + + +#include +#include + +#include +#include + + +#define APN "APN" + + +#define LWM2M_EXIST_DEVICE "AT#LWM2MEXIST=0,3,0" +#define LWM2M_NEWINST_DEVICE "AT#LWM2MNEWINST=0,3,0" + +#define LWM2M_EXIST_ACCELEROMETER "AT#LWM2MEXIST=0,3313,0" +#define LWM2M_NEWINST_ACCELEROMETER "AT#LWM2MNEWINST=0,3313,0" + +#define OK_ANSWER "OK" + +#define ON_OFF 6 /*Select the GPIO to control ON_OFF*/ + +/* Earth's gravity in m/s^2 */ +#define GRAVITY_EARTH (9.80665f) + +/* 39.0625us per tick */ +#define SENSOR_TICK_TO_S (0.0000390625f) + +using namespace me310; + +ME310 myME310; +ME310::return_t myRc; +char ipProt[] = "IP"; +const char* pin = 0; +bool setupValid = true; +int CID = 1; +int count = 0; + +static float lsb_to_ms2(int16_t accel_data, uint8_t g_range, uint8_t bit_width); + +struct bma400_dev bma; +struct bma400_sensor_conf conf; +struct bma400_sensor_data data; +struct bma400_int_enable int_en; +int8_t rslt; + +float x, y, z; +uint16_t int_status = 0; + +static float lsb_to_ms2(int16_t accel_data, uint8_t g_range, uint8_t bit_width) +{ + float accel_ms2; + int16_t half_scale; + + half_scale = 1 << (bit_width - 1); + accel_ms2 = (GRAVITY_EARTH * accel_data * g_range) / half_scale; + + return accel_ms2; +} + +void setup() { + + pinMode(ON_OFF, OUTPUT); + pinMode(LED_BUILTIN, OUTPUT); + delay(100); + Serial.begin(115200); + myME310.begin(115200); + delay(1000); + myME310.powerOn(ON_OFF); + delay(2000); + + Serial.println("Start LWM2M example"); + myRc = myME310.report_mobile_equipment_error(2); //issue command AT+CMEE=2 and wait for answer or timeout + if(checkSIM()) + { + if(PDPContext()) + { + if(registrationStatus()) + { + if(LWM2MEnable()) + { + Serial.println("Configuration completed successfully"); + /* Interface reference is given as a parameter + * For I2C : BMA400_I2C_INTF + */ + rslt = bma400_interface_init(&bma, BMA400_I2C_INTF); + + bma400_check_rslt("bma400_interface_init", rslt); + + rslt = bma400_soft_reset(&bma); + bma400_check_rslt("bma400_soft_reset", rslt); + + rslt = bma400_init(&bma); + bma400_check_rslt("bma400_init", rslt); + + /* Select the type of configuration to be modified */ + conf.type = BMA400_ACCEL; + + /* Get the accelerometer configurations which are set in the sensor */ + rslt = bma400_get_sensor_conf(&conf, 1, &bma); + bma400_check_rslt("bma400_get_sensor_conf", rslt); + + /* Modify the desired configurations as per macros + * available in bma400_defs.h file */ + conf.param.accel.odr = BMA400_ODR_100HZ; + conf.param.accel.range = BMA400_RANGE_2G; + conf.param.accel.data_src = BMA400_DATA_SRC_ACCEL_FILT_1; + + /* Set the desired configurations to the sensor */ + rslt = bma400_set_sensor_conf(&conf, 1, &bma); + bma400_check_rslt("bma400_set_sensor_conf", rslt); + + rslt = bma400_set_power_mode(BMA400_MODE_NORMAL, &bma); + bma400_check_rslt("bma400_set_power_mode", rslt); + + int_en.type = BMA400_DRDY_INT_EN; + int_en.conf = BMA400_ENABLE; + + rslt = bma400_enable_interrupt(&int_en, 1, &bma); + bma400_check_rslt("bma400_enable_interrupt", rslt); + } + else + { + setupValid = false; + } + } + else + { + setupValid = false; + } + } + else + { + setupValid = false; + } + } + else + { + setupValid = false; + } + // put your setup code here, to run once: + +} + +void loop() { + + if(!setupValid) + { + Serial.println("Configuration ERROR"); + exit(0); + } + else + { + myRc = myME310.readResourceString(0,3,0,1,0); + if(myRc == ME310::RETURN_VALID) + { + Serial.println(myME310.buffer_cstr(1)); + } + myRc = myME310.readResourceString(0,3,0,2,0); + if(myRc == ME310::RETURN_VALID) + { + Serial.println(myME310.buffer_cstr(1)); + } + myRc = myME310.readResourceString(0,3,0,3,0); + if(myRc == ME310::RETURN_VALID) + { + Serial.println(myME310.buffer_cstr(1)); + } + + Serial.print("\nGet accel data - BMA400_DATA_SENSOR_TIME\n"); + + while ((rslt == BMA400_OK)) + { + rslt = bma400_get_interrupt_status(&int_status, &bma); + if (count < 20) + { + if (int_status & BMA400_ASSERTED_DRDY_INT) + { + rslt = bma400_get_accel_data(BMA400_DATA_SENSOR_TIME, &data, &bma); + /* 12-bit accelerometer at range 2G */ + x = lsb_to_ms2(data.x, 2, 12); + y = lsb_to_ms2(data.y, 2, 12); + z = lsb_to_ms2(data.z, 2, 12); + Serial.println(""); + Serial.println("Accelation values by bma400_get_accel_data function: "); + Serial.println((String)"X-> " + x + ", Y-> "+ y+ ", Z-> " +z); + + myME310.setResourceFloat(3313,0,5702,0,x); + myME310.setResourceFloat(3313,0,5703,0,y); + myME310.setResourceFloat(3313,0,5704,0,z); + count++; + delay(30000); + } + } + else + { + Serial.println("The application has ended... "); + exit(0); + } + } + } +} + +//! \brief Checks SIM +/*! \details +This function checks for the presence of the SIM and its management. + * + * \return returns true if the SIM and its management is done correctly, otherwise false. + */ +bool checkSIM() +{ + bool rc = false; + Serial.println("Check SIM"); + myRc = myME310.read_enter_pin(); //issue command AT+cpin? in read mode, check that the SIM is inserted and the module is not waiting for the PIN + String result = myME310.buffer_cstr(1); + if(result.endsWith("READY")) + { + Serial.println("SIM is READY"); + delay(5000); + rc = true; + } + else if (result.endsWith("SIM PIN")) + { + if (pin != NULL) + { + myME310.enter_pin(pin); //issue command AT+cpin=PIN + result = myME310.buffer_cstr(1); + if(result.endsWith("READY")) + { + Serial.println("SIM is READY"); + rc = true; + } + else + { + rc = false; + } + } + } + else + { + rc = false; + } + return rc; +} + +//! \brief PDP Context management. +/*! \details +This function deals with the management of the PDP Context. + * + * \return returns true if the management is done correctly, otherwise false. + */ +bool PDPContext() +{ + bool rc = false; + myRc = myME310.define_pdp_context(CID, ipProt, APN); //issue command AT+CGDCONT=cid,PDP_type,APN + if(myRc == ME310::RETURN_VALID) + { + rc = true; + } + else + { + rc = false; + } + return rc; +} + +//! \brief Checks GPRS network registration status. +/*! \details +This function takes care of checking the GPRS network registration status. + * + * \return returns true if the checking is done correctly, otherwise false. + */ +bool registrationStatus() +{ + bool rc = true; + Serial.println("GPRS network registration status"); + myRc = myME310.read_gprs_network_registration_status(); //issue command AT+CGREG=? (read mode) + if(myRc == ME310::RETURN_VALID) + { + char *resp = (char*) myME310.buffer_cstr(1); + while(resp != NULL) + { + if ((strcmp(resp, "+CGREG: 0,1") != 0) && (strcmp(resp, "+CGREG: 0,5") != 0)) + { + delay(3000); + myRc = myME310.read_gprs_network_registration_status(); + if(myRc != ME310::RETURN_VALID) + { + Serial.print("Read GPRS network registration status: "); + Serial.println(myME310.return_string(myRc)); + rc = false; + break; + } + Serial.println(myME310.buffer_cstr(1)); + resp = (char* )myME310.buffer_cstr(1); + } + else + { + break; + } + } + } + else + { + rc = false; + } + return rc; +} + +//! \brief Enable LWM2M +/*! \details +This function is responsible for managing the enable of the LWM2M, checking the existence of objects and creating a new instance for objects 3 and 3313. + * + * \return returns true if the management is done correctly, otherwise false. + */ +bool LWM2MEnable() +{ + bool ret = false; + Serial.println("LWM2MEnable"); + myRc = myME310.read_enableLWM2M(); //issue command AT#LWM2MENA?, in read mode. + String resp = (char*)myME310.buffer_cstr(1); + Serial.println(resp.c_str()); + if(resp.endsWith("\"ACTIVE\"")) + { + ret = true; + } + else + { + myRc = myME310.enableLWM2M(1, 1, ME310::TOUT_45SEC); //issue command AT#LWM2MENA=enable/disable, PDP context identifier + if (myRc == ME310::RETURN_VALID) + { + delay(10000); + Serial.println("Registered on server DM"); + if(!checkExistAgent(LWM2M_EXIST_DEVICE)) + { + myRc = myME310.send_command(LWM2M_NEWINST_DEVICE); //issue command AT#LWM2MNEWINST=agentInstance, objectID, objectInstanceID + Serial.println(myME310.return_string(myRc)); + if(myRc != ME310::RETURN_VALID) + { + ret = false; + } + else + { + ret = true; + } + } + if(!checkExistAgent(LWM2M_EXIST_ACCELEROMETER)) + { + myRc = myME310.send_command(LWM2M_NEWINST_ACCELEROMETER); + Serial.println(myME310.return_string(myRc)); + if(myRc != ME310::RETURN_VALID) + { + ret = false; + } + else + { + ret = true; + } + } + } + else + { + Serial.println("Enabling LWM2M returned error"); + ret = false; + } + } + return ret; +} + +//! \brief Checks exist agent. +/*! \details +This function checks whether or not a particular agent exists. + * + * \param LWM2MEXISTCommand the command string to send. + * \return returns true if the answer is positive, otherwise false. + */ +bool checkExistAgent(String LWM2MEXISTCommand) +{ + bool ret = false; + myRc = myME310.send_command(LWM2MEXISTCommand.c_str(), OK_ANSWER); //issue command AT#LWM2MEXIST=agentInstance, objectNumber, objecttInstanceNumber. + String resp = myME310.buffer_cstr(1); + if(resp.endsWith("OK")) + { + ret = true; + } + else + { + ret = false; + } + return ret; +} \ No newline at end of file diff --git a/library.properties b/library.properties index 9136fc3..e7f53d2 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=ME310G1 -version=2.9.0 +version=2.10.0 author=Telit maintainer=Telit sentence=Allows communication with ME310G1 Telit module. diff --git a/src/ATCommandDataParsing.cpp b/src/ATCommandDataParsing.cpp index bbc9f2a..198779f 100644 --- a/src/ATCommandDataParsing.cpp +++ b/src/ATCommandDataParsing.cpp @@ -13,7 +13,7 @@ It is possible obtain data payload @version - 1.2.1 + 2.10.0 @note Dependencies: diff --git a/src/ATCommandDataParsing.h b/src/ATCommandDataParsing.h index 7922cea..b4c160e 100644 --- a/src/ATCommandDataParsing.h +++ b/src/ATCommandDataParsing.h @@ -12,7 +12,7 @@ It is possible obtain data payload, receivedBytes @version - 1.2.1 + 2.10.0 @note Dependencies: diff --git a/src/ME310.cpp b/src/ME310.cpp index e92bdaf..eca94f4 100644 --- a/src/ME310.cpp +++ b/src/ME310.cpp @@ -17,7 +17,7 @@ It makes it easy to build Arduino applications that use the full power of ME310 module @version - 2.8.0 + 2.10.0 @note @@ -5174,7 +5174,7 @@ This command configures SSL connection parameters. ME310::return_t ME310::ssl_configure_general_param(int ssid , int cid, int pktSx, int maxTo, int defTo, int txTo, int SSLSRingMode, int noCarrierMode, int skipHostMismatch , int equalizeTx, int unused1, int unused2, tout_t aTimeout) { memset(mBuffer, 0, ME310_BUFFSIZE); - snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#SSLCFG=%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d"), ssid, cid, pktSx, maxTo, defTo, txTo, SSLSRingMode, noCarrierMode, skipHostMismatch, equalizeTx, unused1, unused2); + snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#SSLCFG=%d,%d,%d,%d,%d,%d,%d,%d,%d,%d"), ssid, cid, pktSx, maxTo, defTo, txTo, SSLSRingMode, noCarrierMode, skipHostMismatch, equalizeTx); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -5533,7 +5533,20 @@ This function enables the Telit LwM2M Client feature. * \param aTimeout timeout in ms * \return return code */ -ME310::return_t ME310::enableLWM2M(int enable, int ctxID,tout_t aTimeout) +ME310::return_t ME310::enableLWM2M(int enable, int ctxID, tout_t aTimeout) +{ + return LWM2M_enable(enable, ctxID, aTimeout); +} + +/*! \brief Implements the AT#LWM2MENA command and waits for unsolicited message +/*! \details +This function enables the Telit LwM2M Client feature. + * \param enable contains the value that enables the LWM2M client + * \param ctxID contains the PDP context identifier + * \param aTimeout timeout in ms + * \return return code + */ +ME310::return_t ME310::LWM2M_enable(int enable, int ctxID,tout_t aTimeout) { ME310::return_t ret; memset(mBuffer,0,ME310_BUFFSIZE); @@ -5547,243 +5560,1133 @@ ME310::return_t ME310::enableLWM2M(int enable, int ctxID,tout_t aTimeout) return ret; } -/*! \brief Implements the AT#LWM2MENA command and waits for unsolicited message +/*! \brief Implements the AT#LWM2MENA command and waits for unsolicited message +/*! \details +This function disable the Telit LwM2M Client feature. + * \param disable contains the value that disables the LWM2M client + * \param aTimeout timeout in ms + * \return return code + */ +ME310::return_t ME310::disableLWM2M(int disable, tout_t aTimeout) +{ + return LWM2M_disable(disable, aTimeout); +} + +/*! \brief Implements the AT#LWM2MENA command and waits for unsolicited message +/*! \details +This function disable the Telit LwM2M Client feature. + * \param disable contains the value that disables the LWM2M client + * \param aTimeout timeout in ms + * \return return code + */ +ME310::return_t ME310::LWM2M_disable(int disable, tout_t aTimeout) +{ + ME310::return_t ret; + memset(mBuffer,0,ME310_BUFFSIZE); + snprintf((char*)mBuffer, ME310_BUFFSIZE-1,F("AT#LWM2MENA=%d"), disable); + ret = send_wait((char*)mBuffer,OK_STRING, aTimeout); + if ((ret == RETURN_VALID)) + { + memset(mBuffer, 0, ME310_BUFFSIZE); + ret = wait_for_unsolicited(aTimeout); + } + return ret; +} + +/*! \brief Implements the AT#LWM2MW command and wait OK answer +/*! \details +This function selects the parameters for the write operation on the lwm2m agent, it requires the +correspondent lwm2m agent enabled and working. + * \param agent specifies the agent (0=telit agent) + * \param objID identifies the object ID + * \param instanceID identifies the object instance + * \param resourceID identifies the resource ID + * \param resourceInstance identifies the resource instance + * \param value sets the resource value + * \param aTimeout timeout in ms + * \return return code +*/ + ME310::return_t ME310::writeResource(int agent, int objID, int instanceID, int resourceID, int resourceInstance, int value, tout_t aTimeout) + { + return LWM2M_write_resource(agent, objID, instanceID, resourceID, resourceInstance, value, aTimeout); +} + +/*! \brief Implements the AT#LWM2MW command and wait OK answer +/*! \details +This function selects the parameters for the write operation on the lwm2m agent, it requires the +correspondent lwm2m agent enabled and working. + * \param agent specifies the agent (0=telit agent) + * \param objID identifies the object ID + * \param instanceID identifies the object instance + * \param resourceID identifies the resource ID + * \param resourceInstance identifies the resource instance + * \param value sets the resource value + * \param aTimeout timeout in ms + * \return return code +*/ + ME310::return_t ME310::LWM2M_write_resource(int agent, int objID, int instanceID, int resourceID, int resourceInstance, int value, tout_t aTimeout) + { + memset(mBuffer,0,ME310_BUFFSIZE); + snprintf((char*)mBuffer, ME310_BUFFSIZE-1,F("AT#LWM2MW=%d,%d,%d,%d,%d,%d"), agent,objID,instanceID,resourceID, resourceInstance,value); + return send_wait((char*)mBuffer,OK_STRING, aTimeout); +} + +/*! \brief Implements the AT#LWM2MW command and wait OK answer +/*! \details +This function selects the parameters for the write operation on the lwm2m agent, it requires the +correspondent lwm2m agent enabled and working. + * \param agent specifies the agent (0=telit agent) + * \param objID identifies the object ID + * \param instanceID identifies the object instance + * \param resourceID identifies the resource ID + * \param resourceInstance identifies the resource instance + * \param value sets the resource value + * \param aTimeout timeout in ms + * \return return code +*/ + ME310::return_t ME310::writeResource(int agent, int objID, int instanceID, int resourceID, int resourceInstance, char* value, tout_t aTimeout) + { + return LWM2M_write_resource(agent, objID, instanceID, resourceID, resourceInstance, value); +} + +/*! \brief Implements the AT#LWM2MW command and wait OK answer +/*! \details +This function selects the parameters for the write operation on the lwm2m agent, it requires the +correspondent lwm2m agent enabled and working. + * \param agent specifies the agent (0=telit agent) + * \param objID identifies the object ID + * \param instanceID identifies the object instance + * \param resourceID identifies the resource ID + * \param resourceInstance identifies the resource instance + * \param value sets the resource value + * \param aTimeout timeout in ms + * \return return code +*/ + ME310::return_t ME310::LWM2M_write_resource(int agent, int objID, int instanceID, int resourceID, int resourceInstance, char* value, tout_t aTimeout) + { + memset(mBuffer,0,ME310_BUFFSIZE); + snprintf((char*)mBuffer, ME310_BUFFSIZE-1,F("AT#LWM2MW=%d,%d,%d,%d,%d,%s"), agent,objID,instanceID,resourceID, resourceInstance,value); + return send_wait((char*)mBuffer,OK_STRING, aTimeout); +} + +/*! \brief Implements the AT#LWM2MW command and wait OK answer +/*! \details +This function selects the parameters for the write operation on the lwm2m agent, it requires the +correspondent lwm2m agent enabled and working. + * \param agent specifies the agent (0=telit agent) + * \param objID identifies the object ID + * \param instanceID identifies the object instance + * \param resourceID identifies the resource ID + * \param resourceInstance identifies the resource instance + * \param value sets the resource value + * \param aTimeout timeout in ms + * \return return code +*/ + ME310::return_t ME310::writeResource(int agent, int objID, int instanceID, int resourceID, int resourceInstance, float value, tout_t aTimeout) + { + return LWM2M_write_resource(agent, objID, instanceID, resourceID, resourceInstance, value, aTimeout); + } + +/*! \brief Implements the AT#LWM2MW command and wait OK answer +/*! \details +This function selects the parameters for the write operation on the lwm2m agent, it requires the +correspondent lwm2m agent enabled and working. + * \param agent specifies the agent (0=telit agent) + * \param objID identifies the object ID + * \param instanceID identifies the object instance + * \param resourceID identifies the resource ID + * \param resourceInstance identifies the resource instance + * \param value sets the resource value + * \param aTimeout timeout in ms + * \return return code +*/ + ME310::return_t ME310::LWM2M_write_resource(int agent, int objID, int instanceID, int resourceID, int resourceInstance, float value, tout_t aTimeout) + { + memset(mBuffer,0,ME310_BUFFSIZE); + snprintf((char*)mBuffer, ME310_BUFFSIZE-1,F("AT#LWM2MW=%d,%d,%d,%d,%d,%f"), agent,objID,instanceID,resourceID, resourceInstance,value); + return send_wait((char*)mBuffer,OK_STRING, aTimeout); +} + +/*! \brief Implements the AT#LWM2MW command and wait OK answer +/*! \details +This function selects the parameters for the write operation on the lwm2m agent, it requires the +correspondent lwm2m agent enabled and working. + * \param agent specifies the agent (0=telit agent) + * \param objID identifies the object ID + * \param instanceID identifies the object instance + * \param resourceID identifies the resource ID + * \param resourceInstance identifies the resource instance + * \param value sets the resource value (float) + * \param aTimeout timeout in ms + * \return return code +*/ +ME310::return_t ME310::writeResourcefloat(int agent, int objID, int instanceID, int resourceID, int resourceInstance, float value, tout_t aTimeout) +{ + return LWM2M_write_resource_float(agent, objID, instanceID, resourceID, resourceInstance, value, aTimeout); +} + +/*! \brief Implements the AT#LWM2MW command and wait OK answer +/*! \details +This function selects the parameters for the write operation on the lwm2m agent, it requires the +correspondent lwm2m agent enabled and working. + * \param agent specifies the agent (0=telit agent) + * \param objID identifies the object ID + * \param instanceID identifies the object instance + * \param resourceID identifies the resource ID + * \param resourceInstance identifies the resource instance + * \param value sets the resource value (float) + * \param aTimeout timeout in ms + * \return return code +*/ +ME310::return_t ME310::LWM2M_write_resource_float(int agent, int objID, int instanceID, int resourceID, int resourceInstance, float value, tout_t aTimeout) +{ + memset(mBuffer,0,ME310_BUFFSIZE); + snprintf((char*)mBuffer, ME310_BUFFSIZE-1,F("AT#LWM2MW=%d,%d,%d,%d,%d,%f"), agent,objID,instanceID,resourceID, resourceInstance,value); + return send_wait((char*)mBuffer,OK_STRING, aTimeout); +} + +/*! \brief Implements the AT#LWM2MSET command and wait OK answer +/*! \details +This function sets a user defined value to the specified resource, if whitelisted. + * \param type specifies the type of data to insert + * \param objID identifies the object LWM2M + * \param instanceID identifies the instance of the object + * \param resourceID identifies the resource of the object + * \param resourceInstance identifies the instance of the resource + * \param value identifies the value to be set + * \param aTimeout specifies the timeout + * \return return code +*/ +ME310::return_t ME310::setResourcefloat(int type, int objID, int instanceID, int resourceID, int resourceInstance, float value, tout_t aTimeout) +{ + (void) type; + return setResourceFloat(objID, instanceID, resourceID, resourceInstance, value, aTimeout); +} + +/*! \brief Implements the AT#LWM2MSET command and wait OK answer +/*! \details +This function sets a user defined value to the specified resource, if whitelisted. + * \param objID identifies the object LWM2M + * \param instanceID identifies the instance of the object + * \param resourceID identifies the resource of the object + * \param resourceInstance identifies the instance of the resource + * \param value identifies the value to be set (float) + * \param aTimeout specifies the timeout + * \return return code +*/ +ME310::return_t ME310::setResourceFloat(int objID, int instanceID, int resourceID, int resourceInstance, float value, tout_t aTimeout) +{ + return LWM2M_set_resource_float(objID, instanceID, resourceID, resourceInstance, value, aTimeout); +} + +/*! \brief Implements the AT#LWM2MSET command and wait OK answer +/*! \details +This function sets a user defined value to the specified resource, if whitelisted. + * \param objID identifies the object LWM2M + * \param instanceID identifies the instance of the object + * \param resourceID identifies the resource of the object + * \param resourceInstance identifies the instance of the resource + * \param value identifies the value to be set (float) + * \param aTimeout specifies the timeout + * \return return code +*/ +ME310::return_t ME310::LWM2M_set_resource_float(int objID, int instanceID, int resourceID, int resourceInstance, float value, tout_t aTimeout) +{ + char buff[20]; + memset(mBuffer,0,ME310_BUFFSIZE); + floatToString(value, 6, buff, sizeof(buff)); + snprintf((char*)mBuffer, ME310_BUFFSIZE-1,F("AT#LWM2MSET=%d,%d,%d,%d,%d,%s"), LWM2M_SET_FLOAT, objID, instanceID, resourceID, resourceInstance, buff); + return send_wait((char*)mBuffer,OK_STRING, aTimeout); +} + +/*! \brief Implements the AT#LWM2MSET command and wait OK answer +/*! \details +This function sets a user defined value to the specified resource, if whitelisted. + * \param objID identifies the object LWM2M + * \param instanceID identifies the instance of the object + * \param resourceID identifies the resource of the object + * \param resourceInstance identifies the instance of the resource + * \param value identifies the value to be set (int) + * \param aTimeout specifies the timeout + * \return return code +*/ +ME310::return_t ME310::setResourceInt(int objID, int instanceID, int resourceID, int resourceInstance, int value, tout_t aTimeout) +{ + return LWM2M_set_resource_int(objID, instanceID, resourceID, resourceInstance, value, aTimeout); +} + +/*! \brief Implements the AT#LWM2MSET command and wait OK answer +/*! \details +This function sets a user defined value to the specified resource, if whitelisted. + * \param objID identifies the object LWM2M + * \param instanceID identifies the instance of the object + * \param resourceID identifies the resource of the object + * \param resourceInstance identifies the instance of the resource + * \param value identifies the value to be set (int) + * \param aTimeout specifies the timeout + * \return return code +*/ +ME310::return_t ME310::LWM2M_set_resource_int(int objID, int instanceID, int resourceID, int resourceInstance, int value, tout_t aTimeout) +{ + memset(mBuffer,0,ME310_BUFFSIZE); + snprintf((char*)mBuffer, ME310_BUFFSIZE-1,F("AT#LWM2MSET=%d,%d,%d,%d,%d,%d"), LWM2M_SET_INT, objID, instanceID,resourceID, resourceInstance, value); + return send_wait((char*)mBuffer,OK_STRING, aTimeout); +} + +/*! \brief Implements the AT#LWM2MSET command and wait OK answer +/*! \details +This function sets a user defined value to the specified resource, if whitelisted. + * \param type specifies the type of data to insert + * \param objID identifies the object LWM2M + * \param instanceID identifies the instance of the object + * \param resourceID identifies the resource of the object + * \param resourceInstance identifies the instance of the resource + * \param value identifies the value to be set (bool) + * \param aTimeout specifies the timeout + * \return return code +*/ +ME310::return_t ME310::setResourceBool(int type, int objID, int instanceID, int resourceID, int resourceInstance, int value, tout_t aTimeout) +{ + (void)type; + return setResourceBool(objID, instanceID, resourceID, resourceInstance, value); +} + +/*! \brief Implements the AT#LWM2MSET command and wait OK answer +/*! \details +This function sets a user defined value to the specified resource, if whitelisted. + * \param objID identifies the object LWM2M + * \param instanceID identifies the instance of the object + * \param resourceID identifies the resource of the object + * \param resourceInstance identifies the instance of the resource + * \param value identifies the value to be set (bool) + * \param aTimeout specifies the timeout + * \return return code +*/ +ME310::return_t ME310::setResourceBool(int objID, int instanceID, int resourceID, int resourceInstance, int value, tout_t aTimeout) +{ + return LWM2M_set_resource_bool(objID, instanceID, resourceID, resourceInstance, value, aTimeout); +} + +/*! \brief Implements the AT#LWM2MSET command and wait OK answer +/*! \details +This function sets a user defined value to the specified resource, if whitelisted. + * \param objID identifies the object LWM2M + * \param instanceID identifies the instance of the object + * \param resourceID identifies the resource of the object + * \param resourceInstance identifies the instance of the resource + * \param value identifies the value to be set (bool) + * \param aTimeout specifies the timeout + * \return return code +*/ +ME310::return_t ME310::LWM2M_set_resource_bool(int objID, int instanceID, int resourceID, int resourceInstance, int value, tout_t aTimeout) +{ + memset(mBuffer,0,ME310_BUFFSIZE); + snprintf((char*)mBuffer, ME310_BUFFSIZE-1,F("AT#LWM2MSET=%d,%d,%d,%d,%d,%d"), LWM2M_SET_INT, objID, instanceID, resourceID, resourceInstance, value); + return send_wait((char*)mBuffer,OK_STRING, aTimeout); +} + +/*! \brief Implements the AT#LWM2MSET command and wait OK answer +/*! \details +This function sets a user defined value to the specified resource, if whitelisted. + * \param type specifies the type of data to insert + * \param objID identifies the object LWM2M + * \param instanceID identifies the instance of the object + * \param resourceID identifies the resource of the object + * \param resourceInstance identifies the instance of the resource + * \param value identifies the value to be set (char*) + * \param aTimeout specifies the timeout + * \return return code +*/ +ME310::return_t ME310::setResourceString(int type, int objID, int instanceID, int resourceID, int resourceInstance, char* value, tout_t aTimeout) +{ + (void) type; + return setResourceString(objID, instanceID, resourceID, resourceInstance, value); +} + +/*! \brief Implements the AT#LWM2MSET command and wait OK answer +/*! \details +This function sets a user defined value to the specified resource, if whitelisted. + * \param objID identifies the object LWM2M + * \param instanceID identifies the instance of the object + * \param resourceID identifies the resource of the object + * \param resourceInstance identifies the instance of the resource + * \param value identifies the value to be set (char*) + * \param aTimeout specifies the timeout + * \return return code +*/ +ME310::return_t ME310::setResourceString(int objID, int instanceID, int resourceID, int resourceInstance, char* value, tout_t aTimeout) +{ + return LWM2M_set_resource_string(objID, instanceID, resourceID, resourceInstance, value, aTimeout); +} + +/*! \brief Implements the AT#LWM2MSET command and wait OK answer +/*! \details +This function sets a user defined value to the specified resource, if whitelisted. + * \param objID identifies the object LWM2M + * \param instanceID identifies the instance of the object + * \param resourceID identifies the resource of the object + * \param resourceInstance identifies the instance of the resource + * \param value identifies the value to be set (char*) + * \param aTimeout specifies the timeout + * \return return code +*/ +ME310::return_t ME310::LWM2M_set_resource_string(int objID, int instanceID, int resourceID, int resourceInstance, char* value, tout_t aTimeout) +{ + memset(mBuffer,0,ME310_BUFFSIZE); + snprintf((char*)mBuffer, ME310_BUFFSIZE-1,F("AT#LWM2MSET=%d,%d,%d,%d,%d,%s"), LWM2M_SET_STRING, objID, instanceID, resourceID, resourceInstance, value); + return send_wait((char*)mBuffer,OK_STRING, aTimeout); +} + +/*! \brief Implements the AT#LWM2MSET command and wait OK answer +/*! \details +This function sets a user defined value to the specified resource, if whitelisted. + * \param objID identifies the object LWM2M + * \param instanceID identifies the instance of the object + * \param resourceID identifies the resource of the object + * \param resourceInstance identifies the instance of the resource + * \param value object link values, string of max 11 characters, represented as a couple of integer numbers separated by colon, which represent an Object ID and an Object Instance ID. + * \param aTimeout specifies the timeout + * \return return code +*/ +ME310::return_t ME310::setResourceObjectLink(int objID, int instanceID, int resourceID, int resourceInstance, char* value, tout_t aTimeout) +{ + return LWM2M_set_resource_object_link(objID, instanceID, resourceID, resourceInstance, value, aTimeout); +} + +/*! \brief Implements the AT#LWM2MSET command and wait OK answer +/*! \details +This function sets a user defined value to the specified resource, if whitelisted. + * \param objID identifies the object LWM2M + * \param instanceID identifies the instance of the object + * \param resourceID identifies the resource of the object + * \param resourceInstance identifies the instance of the resource + * \param value object link values, string of max 11 characters, represented as a couple of integer numbers separated by colon, which represent an Object ID and an Object Instance ID. + * \param aTimeout specifies the timeout + * \return return code +*/ +ME310::return_t ME310::LWM2M_set_resource_object_link(int objID, int instanceID, int resourceID, int resourceInstance, char* value, tout_t aTimeout) +{ + memset(mBuffer,0,ME310_BUFFSIZE); + snprintf((char*)mBuffer, ME310_BUFFSIZE-1,F("AT#LWM2MSET=%d,%d,%d,%d,%d,%s"), LWM2M_SET_OBJECT_LINK, objID, instanceID, resourceID, resourceInstance, value); + return send_wait((char*)mBuffer,OK_STRING, aTimeout); +} + +/*! \brief Implements the AT#LWM2MSET command and wait OK answer +/*! \details +This function sets a user defined value to the specified resource, if whitelisted. + * \param objID identifies the object LWM2M + * \param instanceID identifies the instance of the object + * \param resourceID identifies the resource of the object + * \param resourceInstance identifies the instance of the resource + * \param value time values, same notation as integer values, expressed as the number of seconds since Jan 1st, 1970 in the UTC time zone. + * \param aTimeout specifies the timeout + * \return return code +*/ +ME310::return_t ME310::setResourceTime(int objID, int instanceID, int resourceID, int resourceInstance, int value, tout_t aTimeout) +{ + return LWM2M_set_resource_time(objID, instanceID, resourceID, resourceInstance, value, aTimeout); +} + +/*! \brief Implements the AT#LWM2MSET command and wait OK answer +/*! \details +This function sets a user defined value to the specified resource, if whitelisted. + * \param objID identifies the object LWM2M + * \param instanceID identifies the instance of the object + * \param resourceID identifies the resource of the object + * \param resourceInstance identifies the instance of the resource + * \param value time values, same notation as integer values, expressed as the number of seconds since Jan 1st, 1970 in the UTC time zone. + * \param aTimeout specifies the timeout + * \return return code +*/ +ME310::return_t ME310::LWM2M_set_resource_time(int objID, int instanceID, int resourceID, int resourceInstance, int value, tout_t aTimeout) +{ + memset(mBuffer,0,ME310_BUFFSIZE); + snprintf((char*)mBuffer, ME310_BUFFSIZE-1,F("AT#LWM2MSET=%d,%d,%d,%d,%d,%d"), LWM2M_SET_TIME, objID, instanceID,resourceID, resourceInstance, value); + return send_wait((char*)mBuffer,OK_STRING, aTimeout); +} + +/*! \brief Implements the AT#LWM2MOBJSET command and wait OK answer +/*! \details +This function sets a object by a json string. + * \param agent identifies the agent LWM2M + * \param objID identifies the object LWM2M + * \param instanceID identifies the instance of the object + * \param jsonString json string contained object parameters + * \param aTimeout specifies the timeout + * \return return code +*/ +ME310::return_t ME310::setObject(int agent, int objID, int instanceID, char* jsonString, tout_t aTimeout) +{ + return LWM2M_set_object(agent, objID, instanceID, jsonString, aTimeout); +} + +/*! \brief Implements the AT#LWM2MOBJSET command and wait OK answer +/*! \details +This function sets a object by a json string. + * \param agent identifies the agent LWM2M + * \param objID identifies the object LWM2M + * \param instanceID identifies the instance of the object + * \param jsonString json string contained object parameters + * \param aTimeout specifies the timeout + * \return return code +*/ +ME310::return_t ME310::LWM2M_set_object(int agent, int objID, int instanceID, char* jsonString, tout_t aTimeout) +{ + ME310::return_t ret; + memset(mBuffer, 0, ME310_BUFFSIZE); + snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#LWM2MOBJSET=%d,%d,%d"), agent, objID, instanceID); + ret = send_wait((char*)mBuffer, WAIT_DATA_STRING, aTimeout); + if ((ret == RETURN_VALID)) + { + memset(mBuffer, 0, ME310_BUFFSIZE); + snprintf((char *)mBuffer, ME310_BUFFSIZE-1, jsonString); + ret = send_wait((char*)mBuffer, OK_STRING, CTRZ, aTimeout); + } + return ret; +} +/*! \brief Implements the AT#LWM2MR command and wait OK answer +/*! \details +This function selects the parameters for the read operation on the lwm2m agent, it requires the +correspondent lwm2m agent enabled and working. + * \param agent identifies the agent LWM2M + * \param objID identifies the object LWM2M + * \param instanceID identifies the instance of the object + * \param resourceID identifies the resource of the object + * \param resourceInstance identifies the instance of the resource + * \param aTimeout specifies the timeout + * \return return code +*/ +ME310::return_t ME310::readResource(int agent, int objID, int instanceID, int resourceID, int resourceInstance, tout_t aTimeout) +{ + return LWM2M_read_resource(agent, objID, instanceID, resourceID, resourceInstance, aTimeout); +} + +/*! \brief Implements the AT#LWM2MR command and wait OK answer +/*! \details +This function selects the parameters for the read operation on the lwm2m agent, it requires the +correspondent lwm2m agent enabled and working. + * \param agent identifies the agent LWM2M + * \param objID identifies the object LWM2M + * \param instanceID identifies the instance of the object + * \param resourceID identifies the resource of the object + * \param resourceInstance identifies the instance of the resource + * \param aTimeout specifies the timeout + * \return return code +*/ +ME310::return_t ME310::LWM2M_read_resource(int agent, int objID, int instanceID, int resourceID, int resourceInstance, tout_t aTimeout) +{ + memset(mBuffer,0,ME310_BUFFSIZE); + snprintf((char*)mBuffer, ME310_BUFFSIZE-1,F("AT#LWM2MR=%d,%d,%d,%d,%d"), agent,objID,instanceID,resourceID, resourceInstance); + return send_wait((char*)mBuffer,OK_STRING, aTimeout); +} +/*! \brief Implements the AT#LWM2MR command and wait OK answer +/*! \details +This function selects the parameters for the read operation on the lwm2m agent, it requires the +correspondent lwm2m agent enabled and working. + * \param agent identifies the agent LWM2M + * \param objID identifies the object LWM2M + * \param instanceID identifies the instance of the object + * \param resourceID identifies the resource of the object + * \param resourceInstance identifies the instance of the resource + * \param aTimeout specifies the timeout + * \return return code +*/ +ME310::return_t ME310::readResourcefloat(int agent,int objID,int instanceID,int resourceID, int resourceInstance, tout_t aTimeout) +{ + return readResourceFloat(agent, objID, instanceID, resourceInstance, aTimeout); +} + +/*! \brief Implements the AT#LWM2MR command and wait OK answer +/*! \details +This function selects the parameters for the read operation on the lwm2m agent, it requires the +correspondent lwm2m agent enabled and working. + * \param agent identifies the agent LWM2M + * \param objID identifies the object LWM2M + * \param instanceID identifies the instance of the object + * \param resourceID identifies the resource of the object + * \param resourceInstance identifies the instance of the resource + * \param aTimeout specifies the timeout + * \return return code +*/ +ME310::return_t ME310::readResourceFloat(int agent, int objID, int instanceID, int resourceID, int resourceInstance, tout_t aTimeout) +{ + return LWM2M_read_resource_float(agent, objID, instanceID, resourceID, resourceInstance, aTimeout); +} + +/*! \brief Implements the AT#LWM2MR command and wait OK answer +/*! \details +This function selects the parameters for the read operation on the lwm2m agent, it requires the +correspondent lwm2m agent enabled and working. + * \param agent identifies the agent LWM2M + * \param objID identifies the object LWM2M + * \param instanceID identifies the instance of the object + * \param resourceID identifies the resource of the object + * \param resourceInstance identifies the instance of the resource + * \param aTimeout specifies the timeout + * \return return code +*/ +ME310::return_t ME310::LWM2M_read_resource_float(int agent, int objID, int instanceID, int resourceID, int resourceInstance, tout_t aTimeout) +{ + memset(mBuffer,0,ME310_BUFFSIZE); + snprintf((char*)mBuffer, ME310_BUFFSIZE-1,F("AT#LWM2MR=%d,%d,%d,%d,%d"), agent,objID,instanceID,resourceID, resourceInstance); + return send_wait((char*)mBuffer,OK_STRING, aTimeout); +} + +/*! \brief Implements the AT#LWM2MR command and wait OK answer +/*! \details +This function selects the parameters for the read operation on the lwm2m agent, it requires the +correspondent lwm2m agent enabled and working. + * \param agent identifies the agent LWM2M + * \param objID identifies the object LWM2M + * \param instanceID identifies the instance of the object + * \param resourceID identifies the resource of the object + * \param resourceInstance identifies the instance of the resource + * \param value identifies the value to be set (int) + * \param aTimeout specifies the timeout + * \return return code +*/ +ME310::return_t ME310::readResourceInt(int agent, int objID, int instanceID, int resourceID, int resourceInstance, int &value, tout_t aTimeout) +{ + ME310::return_t ret; + int i = 0; + memset(mBuffer,0,ME310_BUFFSIZE); + snprintf((char*)mBuffer, ME310_BUFFSIZE-1,F("AT#LWM2MR=%d,%d,%d,%d,%d"), agent,objID,instanceID,resourceID, resourceInstance); + ret = send_wait((char*)mBuffer,OK_STRING, aTimeout); + if(ret == RETURN_VALID) + { + while(buffer_cstr(i) != NULL) + { + String retValue = buffer_cstr(i); + if(retValue.startsWith("#LWM2MR:")) + { + int pos = retValue.indexOf(":"); + value = atoi(retValue.substring(pos +1).c_str()); + ret = RETURN_VALID; + break; + } + i++; + } + } + return ret; +} + +/*! \brief Implements the AT#LWM2MR command and wait OK answer +/*! \details +This function selects the parameters for the read operation on the lwm2m agent, it requires the +correspondent lwm2m agent enabled and working. + * \param agent identifies the agent LWM2M + * \param objID identifies the object LWM2M + * \param instanceID identifies the instance of the object + * \param resourceID identifies the resource of the object + * \param resourceInstance identifies the instance of the resource + * \param value identifies the value to be set (int) + * \param aTimeout specifies the timeout + * \return return code +*/ +ME310::return_t ME310::LWM2M_read_resource_int(int agent, int objID, int instanceID, int resourceID, int resourceInstance, int &value, tout_t aTimeout) +{ + ME310::return_t ret; + int i = 0; + memset(mBuffer,0,ME310_BUFFSIZE); + snprintf((char*)mBuffer, ME310_BUFFSIZE-1,F("AT#LWM2MR=%d,%d,%d,%d,%d"), agent,objID,instanceID,resourceID, resourceInstance); + ret = send_wait((char*)mBuffer,OK_STRING, aTimeout); + if(ret == RETURN_VALID) + { + while(buffer_cstr(i) != NULL) + { + String retValue = buffer_cstr(i); + if(retValue.startsWith("#LWM2MR:")) + { + int pos = retValue.indexOf(":"); + value = atoi(retValue.substring(pos +1).c_str()); + ret = RETURN_VALID; + break; + } + i++; + } + } + return ret; +} + +/*! \brief Implements the AT#LWM2MR command and wait OK answer +/*! \details +This function selects the parameters for the read operation on the lwm2m agent, it requires the +correspondent lwm2m agent enabled and working. + * \param agent identifies the agent LWM2M + * \param objID identifies the object LWM2M + * \param instanceID identifies the instance of the object + * \param resourceID identifies the resource of the object + * \param resourceInstance identifies the instance of the resource + * \param aTimeout specifies the timeout + * \return return code +*/ +ME310::return_t ME310::readResourceString(int agent, int objID, int instanceID, int resourceID, int resourceInstance, tout_t aTimeout) +{ + return LWM2M_read_resource_string(agent, objID, instanceID, resourceID, resourceInstance, aTimeout); +} + +/*! \brief Implements the AT#LWM2MR command and wait OK answer +/*! \details +This function selects the parameters for the read operation on the lwm2m agent, it requires the +correspondent lwm2m agent enabled and working. + * \param agent identifies the agent LWM2M + * \param objID identifies the object LWM2M + * \param instanceID identifies the instance of the object + * \param resourceID identifies the resource of the object + * \param resourceInstance identifies the instance of the resource + * \param aTimeout specifies the timeout + * \return return code +*/ +ME310::return_t ME310::LWM2M_read_resource_string(int agent, int objID, int instanceID, int resourceID, int resourceInstance, tout_t aTimeout) +{ + memset(mBuffer,0,ME310_BUFFSIZE); + snprintf((char*)mBuffer, ME310_BUFFSIZE-1,F("AT#LWM2MR=%d,%d,%d,%d,%d"), agent, objID, instanceID, resourceID, resourceInstance); + return send_wait((char*)mBuffer,OK_STRING, aTimeout); +} + +/*! \brief Implements the AT#LWM2MEXIST command and wait OK answer +/*! \details +This function allows the end-user to query the module in order to discover if a given agent exist. + * \param agentInstance identifies the agent LWM2M + * \param aTimeout specifies the timeout + * \return return code +*/ +ME310::return_t ME310::checkAgentExist(int agentInstance, tout_t aTimeout) +{ + return LWM2M_check_agent_exist(agentInstance, aTimeout); +} + +/*! \brief Implements the AT#LWM2MEXIST command and wait OK answer +/*! \details +This function allows the end-user to query the module in order to discover if a given agent exist. + * \param agentInstance identifies the agent LWM2M + * \param aTimeout specifies the timeout + * \return return code +*/ +ME310::return_t ME310::LWM2M_check_agent_exist(int agentInstance, tout_t aTimeout) +{ + memset(mBuffer,0,ME310_BUFFSIZE); + snprintf((char*)mBuffer, ME310_BUFFSIZE-1,F("AT#LWM2MEXIST=%d"), agentInstance); + return send_wait((char*)mBuffer,OK_STRING, aTimeout); +} + +/*! \brief Implements the AT#LWM2MEXIST command and wait OK answer +/*! \details +This function allows the end-user to query the module in order to discover if agiven agent and URI path combination exist. + * \param agentInstance identifies the agent LWM2M + * \param objectNumber object number to be selected + * \param objectInstanceNumber object instance for the query + * \param aTimeout specifies the timeout + * \return return code +*/ +ME310::return_t ME310::checkObjectExist(int agentInstance, int objectNumber, int objectInstanceNumber, tout_t aTimeout) +{ + return LWM2M_check_object_exist(agentInstance, objectNumber, objectInstanceNumber, aTimeout); +} + +/*! \brief Implements the AT#LWM2MEXIST command and wait OK answer +/*! \details +This function allows the end-user to query the module in order to discover if agiven agent and URI path combination exist. + * \param agentInstance identifies the agent LWM2M + * \param objectNumber object number to be selected + * \param objectInstanceNumber object instance for the query + * \param aTimeout specifies the timeout + * \return return code +*/ +ME310::return_t ME310::LWM2M_check_object_exist(int agentInstance, int objectNumber, int objectInstanceNumber, tout_t aTimeout) +{ + memset(mBuffer,0,ME310_BUFFSIZE); + snprintf((char*)mBuffer, ME310_BUFFSIZE-1,F("AT#LWM2MEXIST=%d,%d,%d"), agentInstance, objectNumber, objectInstanceNumber); + return send_wait((char*)mBuffer,OK_STRING, aTimeout); +} + +/*! \brief Implements the AT#LWM2MEXIST command and wait OK answer +/*! \details +This function allows the end-user to query the module in order to discover if agiven agent and URI path combination exist. + * \param agentInstance identifies the agent LWM2M + * \param objectNumber object number to be selected + * \param objectInstanceNumber object instance for the query + * \param resourceNumber resource number for the query + * \param resourceInstanceNumber resource instance number for the query + * \param aTimeout specifies the timeout + * \return return code +*/ +ME310::return_t ME310::checkURIExist(int agentInstance, int objectNumber, int objectInstanceNumber, int resourceNumber, int resourceInstanceNumber, tout_t aTimeout) +{ + return LWM2M_check_URI_exist(agentInstance, objectNumber, objectInstanceNumber, resourceNumber, resourceInstanceNumber, aTimeout); +} + +/*! \brief Implements the AT#LWM2MEXIST command and wait OK answer +/*! \details +This function allows the end-user to query the module in order to discover if agiven agent and URI path combination exist. + * \param agentInstance identifies the agent LWM2M + * \param objectNumber object number to be selected + * \param objectInstanceNumber object instance for the query + * \param resourceNumber resource number for the query + * \param resourceInstanceNumber resource instance number for the query + * \param aTimeout specifies the timeout + * \return return code +*/ +ME310::return_t ME310::LWM2M_check_URI_exist(int agentInstance, int objectNumber, int objectInstanceNumber, int resourceNumber, int resourceInstanceNumber, tout_t aTimeout) +{ + memset(mBuffer,0,ME310_BUFFSIZE); + snprintf((char*)mBuffer, ME310_BUFFSIZE-1,F("AT#LWM2MEXIST=%d,%d,%d,%d,%d"), agentInstance, objectNumber, objectInstanceNumber, resourceNumber, resourceInstanceNumber); + return send_wait((char*)mBuffer,OK_STRING, aTimeout); +} + +/*! \brief Implements the AT#LWM2MNEWINST command and wait OK answer +/*! \details +This function can be used to create dynamically the new object instance ID of the specified object. + * \param agentInstance identifies the agent LWM2M + * \param objectID object number to be selected + * \param objectInstanceID object instance for the query + * \param aTimeout specifies the timeout + * \return return code +*/ +ME310::return_t ME310::createNewObjectInstance(int agentInstance, int objectID, int objectInstanceID, tout_t aTimeout) +{ + return LWM2M_create_new_object_instance(agentInstance, objectID, objectInstanceID, aTimeout); +} + +/*! \brief Implements the AT#LWM2MNEWINST command and wait OK answer +/*! \details +This function can be used to create dynamically the new object instance ID of the specified object. + * \param agentInstance identifies the agent LWM2M + * \param objectID object number to be selected + * \param objectInstanceID object instance for the query + * \param aTimeout specifies the timeout + * \return return code +*/ +ME310::return_t ME310::LWM2M_create_new_object_instance(int agentInstance, int objectID, int objectInstanceID, tout_t aTimeout) +{ + memset(mBuffer,0,ME310_BUFFSIZE); + snprintf((char*)mBuffer, ME310_BUFFSIZE-1,F("AT#LWM2MNEWINST=%d,%d,%d"), agentInstance, objectID, objectInstanceID); + return send_wait((char*)mBuffer,OK_STRING, aTimeout); +} + +/*! \brief Implements the AT#LWM2MACK command and wait OK answer +/*! \details +This function requires an ACK to performs its operations on the dedicated data context. + * \param aTimeout specifies the timeout + * \return return code +*/ +ME310::return_t ME310::sendLWM2MACK(tout_t aTimeout) +{ + return LWM2M_send_ACK(aTimeout); +} + +/*! \brief Implements the AT#LWM2MACK command and wait OK answer /*! \details -This function disable the Telit LwM2M Client feature. - * \param disable contains the value that disables the LWM2M client - * \param aTimeout timeout in ms +This function requires an ACK to performs its operations on the dedicated data context. + * \param aTimeout specifies the timeout * \return return code - */ -ME310::return_t ME310::disableLWM2M(int disable, tout_t aTimeout) +*/ +ME310::return_t ME310::LWM2M_send_ACK(tout_t aTimeout) { - ME310::return_t ret; - memset(mBuffer,0,ME310_BUFFSIZE); - snprintf((char*)mBuffer, ME310_BUFFSIZE-1,F("AT#LWM2MENA=%d"), disable); - ret = send_wait((char*)mBuffer,OK_STRING, aTimeout); - if ((ret == RETURN_VALID)) - { - memset(mBuffer, 0, ME310_BUFFSIZE); - ret = wait_for_unsolicited(aTimeout); - } - return ret; + memset(mBuffer,0,ME310_BUFFSIZE); + snprintf((char*)mBuffer, ME310_BUFFSIZE-1,F("AT#LWM2MACK=1")); + return send_wait((char*)mBuffer,OK_STRING, aTimeout); +} +/*! \brief Implements the AT#LWM2MCFG command and wait OK answer +/*! \details +This function allows the user to configure a parameter specified by parameter ID. + * \param agentID identifier of the LwM2M agent related to the request + * \param paramID identifier of the parameter to be configured + * \param actionID the required action + * \param value identifier of the configured value + * \param aTimeout specifies the timeout + * \return return code +*/ +ME310::return_t ME310::LWM2M_set_configuration(int agentID, int paramID, int value, tout_t aTimeout) +{ + int actionID = 0; + memset(mBuffer,0,ME310_BUFFSIZE); + snprintf((char*)mBuffer, ME310_BUFFSIZE-1,F("AT#LWM2MCFG=%d,%d,%d,%d"), agentID, paramID, actionID, value); + return send_wait((char*)mBuffer,OK_STRING, aTimeout); } -/*! \brief Implements the AT#LWM2MW command and wait OK answer +/*! \brief Implements the AT#LWM2MCFG command and wait OK answer /*! \details -This function selects the parameters for the write operation on the lwm2m agent, it requires the -correspondent lwm2m agent enabled and working. - * \param agent specifies the agent (0=telit agent) - * \param objID identifies the object ID - * \param instanceID identifies the object instance - * \param resourceID identifies the resource ID - * \param resourceInstance identifies the resource instance - * \param value sets the resource value - * \param aTimeout timeout in ms +This function allows the user to configure a parameter specified by parameter ID. + * \param agentID identifier of the LwM2M agent related to the request + * \param paramID identifier of the parameter to be configured + * \param aTimeout specifies the timeout * \return return code */ - ME310::return_t ME310::writeResource(int agent, int objID, int instanceID,int resourceID, int resourceInstance, int value, tout_t aTimeout) - { - memset(mBuffer,0,ME310_BUFFSIZE); - snprintf((char*)mBuffer, ME310_BUFFSIZE-1,F("AT#LWM2MW=%d,%d,%d,%d,%d,%d"), agent,objID,instanceID,resourceID, resourceInstance,value); +ME310::return_t ME310::LWM2M_get_configuration(int agentID, int paramID, tout_t aTimeout) +{ + int actionID = 1; + memset(mBuffer,0,ME310_BUFFSIZE); + snprintf((char*)mBuffer, ME310_BUFFSIZE-1,F("AT#LWM2MCFG=%d,%d,%d,%d"), agentID, paramID, actionID); return send_wait((char*)mBuffer,OK_STRING, aTimeout); } -/*! \brief Implements the AT#LWM2MW command and wait OK answer +/*! \brief Implements the AT#LWM2MCIPHERENA command and wait OK answer /*! \details -This function selects the parameters for the write operation on the lwm2m agent, it requires the -correspondent lwm2m agent enabled and working. - * \param agent specifies the agent (0=telit agent) - * \param objID identifies the object ID - * \param instanceID identifies the object instance - * \param resourceID identifies the resource ID - * \param resourceInstance identifies the resource instance - * \param value sets the resource value (float) - * \param aTimeout timeout in ms +This function sets the cipher suits for the agent specified. + * \param agentID identifier of the LwM2M agent related to the request + * \param cipher_mode Cipher mode (0 is default ciphers, 1 is advanced ciphers) + * \param aTimeout specifies the timeout * \return return code */ -ME310::return_t ME310::writeResourcefloat(int agent, int objID, int instanceID,int resourceID, int resourceInstance, float value, tout_t aTimeout) +ME310::return_t ME310::LWM2M_set_ciphers(int agentID, int cipher_mode, tout_t aTimeout) { - memset(mBuffer,0,ME310_BUFFSIZE); - snprintf((char*)mBuffer, ME310_BUFFSIZE-1,F("AT#LWM2MW=%d,%d,%d,%d,%d,%f"), agent,objID,instanceID,resourceID, resourceInstance,value); + memset(mBuffer,0,ME310_BUFFSIZE); + snprintf((char*)mBuffer, ME310_BUFFSIZE-1,F("AT#LWM2MCIPHERENA=%d,%d"), agentID, cipher_mode); return send_wait((char*)mBuffer,OK_STRING, aTimeout); } -/*! \brief Implements the AT#LWM2MSET command and wait OK answer +/*! \brief Implements the AT#LWM2MCUST command and wait OK answer /*! \details -This function sets a user defined value to the specified resource, if whitelisted. - * \param type specifies the type of data to insert - * \param objID identifies the object LWM2M - * \param instanceID identifies the instance of the object - * \param resourceID identifies the resource of the object - * \param resourceInstance identifies the instance of the resource - * \param value identifies the value to be set +This function allows the end-user to set LwM2M customization parameters related to the module.\n +Those settings are generally neither related nor manageable with other LwM2M agent commands + * \param paramID identifier of the parameter to be set. + * \param data data to be set. * \param aTimeout specifies the timeout * \return return code */ -ME310::return_t ME310::setResourcefloat(int type, int objID, int instanceID, int resourceID, int resourceInstance, float value, tout_t aTimeout) +ME310::return_t ME310::LWM2M_set_general_parameter(int paramID, char* data, tout_t aTimeout) { - (void) type; - return setResourceFloat(objID, instanceID, resourceID, resourceInstance, value, aTimeout); + memset(mBuffer,0,ME310_BUFFSIZE); + snprintf((char*)mBuffer, ME310_BUFFSIZE-1,F("AT#LWM2MCUST=%d,%s"), paramID, data); + return send_wait((char*)mBuffer,OK_STRING, aTimeout); } -/*! \brief Implements the AT#LWM2MSET command and wait OK answer +/*! \brief Implements the AT#LWM2ME command and wait OK answer /*! \details -This function sets a user defined value to the specified resource, if whitelisted. - * \param type specifies the type of data to insert - * \param objID identifies the object LWM2M - * \param instanceID identifies the instance of the object - * \param resourceID identifies the resource of the object - * \param resourceInstance identifies the instance of the resource - * \param value identifies the value to be set +This function allows the end-user to set LwM2M customization parameters related to the module.\n +Those settings are generally neither related nor manageable with other LwM2M agent commands + * \param agentInstance selects the lwm2m instance. + * \param objectID select object identifier. + * \param objectInstanceID select object Instance identifier for the query + * \param resourceID select resource identifier + * \param resourceInstanceID selects the resource instance identifier * \param aTimeout specifies the timeout * \return return code */ -ME310::return_t ME310::setResourceFloat(int objID, int instanceID, int resourceID, int resourceInstance, float value, tout_t aTimeout) +ME310::return_t ME310::LWM2M_client_resource_exec(int agentInstance, int objectID, int objectInstanceID, int resourceID, int resourceInstanceID, tout_t aTimeout) { - char buff[20]; memset(mBuffer,0,ME310_BUFFSIZE); - floatToString(value, 6, buff, sizeof(buff)); - snprintf((char*)mBuffer, ME310_BUFFSIZE-1,F("AT#LWM2MSET=%d,%d,%d,%d,%d,%s"), LWM2M_SET_FLOAT, objID, instanceID, resourceID, resourceInstance, buff); + snprintf((char*)mBuffer, ME310_BUFFSIZE-1,F("AT#LWM2ME=%d,%d,%d,%d,%d"), agentInstance, objectID, objectInstanceID, resourceID, resourceInstanceID); return send_wait((char*)mBuffer,OK_STRING, aTimeout); } -/*! \brief Implements the AT#LWM2MOBJSET command and wait OK answer +/*! \brief Implements the AT#LWM2MGET command and wait OK answer /*! \details -This function sets a object by a json string. - * \param agent identifies the agent LWM2M - * \param objID identifies the object LWM2M - * \param instanceID identifies the instance of the object - * \param jsonString json string contained object parameters +This function gets a user defined value to the specified resource, if URI is whitelisted; error otherwise. + * \param type data type to be inserted. + * \param objectID select object identifier. + * \param objectInstanceID select object Instance identifier for the query + * \param resourceID select resource identifier + * \param resourceInstanceID selects the resource instance identifier * \param aTimeout specifies the timeout * \return return code */ -ME310::return_t ME310::setObject(int agent, int objID, int instanceID, char* jsonString, tout_t aTimeout) +ME310::return_t ME310::LWM2M_get_resource(int type, int objectID, int objectInstanceID, int resourceID, int resourceInstanceID, tout_t aTimeout) { - ME310::return_t ret; - memset(mBuffer, 0, ME310_BUFFSIZE); - snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#LWM2MOBJSET=%d,%d,%d"), agent, objID, instanceID); - ret = send_wait((char*)mBuffer, WAIT_DATA_STRING, aTimeout); - if ((ret == RETURN_VALID)) - { - memset(mBuffer, 0, ME310_BUFFSIZE); - snprintf((char *)mBuffer, ME310_BUFFSIZE-1, jsonString); - ret = send_wait((char*)mBuffer, OK_STRING, CTRZ, aTimeout); - } - return ret; + memset(mBuffer,0,ME310_BUFFSIZE); + snprintf((char*)mBuffer, ME310_BUFFSIZE-1,F("AT#LWM2MGET=%d,%d,%d,%d,%d"), type, objectID, objectInstanceID, resourceID, resourceInstanceID); + return send_wait((char*)mBuffer,OK_STRING, aTimeout); } -/*! \brief Implements the AT#LWM2MSET command and wait OK answer +/*! \brief Implements the AT#LWM2MLIST command and wait OK answer /*! \details -This function sets a user defined value to the specified resource, if whitelisted. - * \param type specifies the type of data to insert - * \param objID identifies the object LWM2M - * \param instanceID identifies the instance of the object - * \param resourceID identifies the resource of the object - * \param resourceInstance identifies the instance of the resource - * \param value identifies the value to be set +This function allows the end-user to query the module to retrieve the list of the objects and object instances supported for a given agent. + * \param agentInstance selects the lwm2m instance. * \param aTimeout specifies the timeout * \return return code */ - ME310::return_t ME310::setResourceInt(int objID, int instanceID, int resourceID, int resourceInstance, int value, tout_t aTimeout) - { - memset(mBuffer,0,ME310_BUFFSIZE); - snprintf((char*)mBuffer, ME310_BUFFSIZE-1,F("AT#LWM2MSET=%d,%d,%d,%d,%d,%d"), LWM2M_SET_INT, objID, instanceID,resourceID, resourceInstance, value); +ME310::return_t ME310::LWM2M_get_report_object(int agentInstance, tout_t aTimeout) +{ + memset(mBuffer,0,ME310_BUFFSIZE); + snprintf((char*)mBuffer, ME310_BUFFSIZE-1,F("AT#LWM2MLIST=%d"), agentInstance); return send_wait((char*)mBuffer,OK_STRING, aTimeout); } -/*! \brief Implements the AT#LWM2MSET command and wait OK answer +/*! \brief Implements the AT#LWM2MMON command and wait OK answer /*! \details -This function sets a user defined value to the specified resource, if whitelisted. - * \param type specifies the type of data to insert - * \param objID identifies the object LWM2M - * \param instanceID identifies the instance of the object - * \param resourceID identifies the resource of the object - * \param resourceInstance identifies the instance of the resource - * \param value identifies the value to be set (int) +This function can be used to activate/deactivate the resource changes monitoring. + * \param action activate (value is 1), deactivate (value is 0) the resource monitoring. + * \param objectID object identifier. * \param aTimeout specifies the timeout * \return return code */ -ME310::return_t ME310::setResourceBool(int type,int objID,int instanceID,int resourceID, int resourceInstance,int value, tout_t aTimeout) +ME310::return_t ME310::LWM2M_activate_resource(int action, int objectID, tout_t aTimeout) { - memset(mBuffer,0,ME310_BUFFSIZE); - snprintf((char*)mBuffer, ME310_BUFFSIZE-1,F("AT#LWM2MSET=%d,%d,%d,%d,%d,%d"), type,objID,instanceID,resourceID, resourceInstance,value); + memset(mBuffer,0,ME310_BUFFSIZE); + snprintf((char*)mBuffer, ME310_BUFFSIZE-1,F("AT#LWM2MMON=%d,%d"), action, objectID); return send_wait((char*)mBuffer,OK_STRING, aTimeout); } -/*! \brief Implements the AT#LWM2MR command and wait OK answer +/*! \brief Implements the AT#LWM2MNFYACKENA command and wait OK answer /*! \details -This function selects the parameters for the read operation on the lwm2m agent, it requires the -correspondent lwm2m agent enabled and working. - * \param type specifies the type of data to insert - * \param objID identifies the object LWM2M - * \param instanceID identifies the instance of the object - * \param resourceID identifies the resource of the object - * \param resourceInstance identifies the instance of the resource - * \param value identifies the value to be set (int) +This function can be used to activate/deactivate the resource changes monitoring. + * \param agentInstanceID selects the lwm2m instance + * \param action disable URC reporting (value is 0), enable URC reporting (value is 1), read URC reporting status (value is 2). * \param aTimeout specifies the timeout * \return return code */ -ME310::return_t ME310::readResourcefloat(int agent,int objID,int instanceID,int resourceID, int resourceInstance, tout_t aTimeout) +ME310::return_t ME310::LWM2M_control_URC_reporting(int agentInstanceID, int action, tout_t aTimeout) { - return readResourceFloat(agent, objID, instanceID, resourceInstance, aTimeout); + memset(mBuffer,0,ME310_BUFFSIZE); + snprintf((char*)mBuffer, ME310_BUFFSIZE-1,F("AT#LWM2MNFYACKENA=%d,%d"), agentInstanceID, action); + return send_wait((char*)mBuffer,OK_STRING, aTimeout); } -/*! \brief Implements the AT#LWM2MR command and wait OK answer +/*! \brief Implements the AT#LWM2MNFYACKURI command and wait OK answer /*! \details -This function selects the parameters for the read operation on the lwm2m agent, it requires the -correspondent lwm2m agent enabled and working. - * \param type specifies the type of data to insert - * \param objID identifies the object LWM2M - * \param instanceID identifies the instance of the object - * \param resourceID identifies the resource of the object - * \param resourceInstance identifies the instance of the resource - * \param value identifies the value to be set (int) +This function can be used to remove, add and list the URIs of the resources\n +for issuing an URC at reception of an Ack sent from a server that receives a LWM2M notify for that resource. + * \param agentInstanceID selects the lwm2m instance. + * \param action remove URI reporting (value is 0), add URI reporting (value is 1), list URI reporting (value is 2). + * \param objectID selects the object identifier of the URI. + * \param objectInstanceID selects the object instance identifier of the URI, + * \param resourceID selects the resource identifier of the URI. * \param aTimeout specifies the timeout * \return return code */ -ME310::return_t ME310::readResourceFloat(int agent,int objID,int instanceID,int resourceID, int resourceInstance, tout_t aTimeout) +ME310::return_t ME310::LWM2M_manage_URI_reporting(int agentInstanceID, int action, int objectID, int objectInstanceID, int resourceID, tout_t aTimeout) { - memset(mBuffer,0,ME310_BUFFSIZE); - snprintf((char*)mBuffer, ME310_BUFFSIZE-1,F("AT#LWM2MR=%d,%d,%d,%d,%d"), agent,objID,instanceID,resourceID, resourceInstance); + memset(mBuffer,0,ME310_BUFFSIZE); + snprintf((char*)mBuffer, ME310_BUFFSIZE-1,F("AT#LWM2MNFYACKURI=%d,%d,%d,%d,%d"), agentInstanceID, action, objectID, objectInstanceID, resourceID); return send_wait((char*)mBuffer,OK_STRING, aTimeout); } -/*! \brief Implements the AT#LWM2MR command and wait OK answer +/*! \brief Implements the AT#LWM2MOBJGET command and wait OK answer /*! \details -This function selects the parameters for the read operation on the lwm2m agent, it requires the -correspondent lwm2m agent enabled and working. - * \param type specifies the type of data to insert - * \param objID identifies the object LWM2M - * \param instanceID identifies the instance of the object - * \param resourceID identifies the resource of the object - * \param resourceInstance identifies the instance of the resource - * \param value identifies the value to be set (int) +This function allows the user to read a LWM2M object. + * \param agentInstanceID selects the lwm2m instance. + * \param objectID selects the object identifier of the URI. * \param aTimeout specifies the timeout * \return return code */ -ME310::return_t ME310::readResourceInt(int agent,int objID,int instanceID,int resourceID, int resourceInstance, int &value, tout_t aTimeout) +ME310::return_t ME310::LWM2M_get_object(int agentInstanceID, int objectID, tout_t aTimeout) { - ME310::return_t ret; - int i = 0; - memset(mBuffer,0,ME310_BUFFSIZE); - snprintf((char*)mBuffer, ME310_BUFFSIZE-1,F("AT#LWM2MR=%d,%d,%d,%d,%d"), agent,objID,instanceID,resourceID, resourceInstance); - ret = send_wait((char*)mBuffer,OK_STRING, aTimeout); - if(ret == RETURN_VALID) - { - while(buffer_cstr(i) != NULL) - { - String retValue = buffer_cstr(i); - if(retValue.startsWith("#LWM2MR:")) - { - int pos = retValue.indexOf(":"); - value = atoi(retValue.substring(pos +1).c_str()); - ret = RETURN_VALID; - break; - } - i++; - } - } - return ret; + memset(mBuffer,0,ME310_BUFFSIZE); + snprintf((char*)mBuffer, ME310_BUFFSIZE-1,F("AT#LWM2MOBJGET=%d,%d"), agentInstanceID, objectID); + return send_wait((char*)mBuffer, 0, OK_STRING, aTimeout); +} + +/*! \brief Implements the AT#LWM2MOBJGET command and wait OK answer +/*! \details +This function allows the user to read a LWM2M object instance. + * \param agentInstanceID selects the lwm2m instance. + * \param objectID selects the object identifier of the URI. + * \param objectInstanceID selects object instance identifier. + * \param aTimeout specifies the timeout + * \return return code +*/ +ME310::return_t ME310::LWM2M_get_object_instance(int agentInstanceID, int objectID, int objectInstanceID, tout_t aTimeout) +{ + memset(mBuffer,0,ME310_BUFFSIZE); + snprintf((char*)mBuffer, ME310_BUFFSIZE-1,F("AT#LWM2MOBJGET=%d,%d,%d"), agentInstanceID, objectID, objectInstanceID); + return send_wait((char*)mBuffer, 0, OK_STRING, aTimeout); +} + +/*! \brief Implements the AT#LWM2MOBJGET command and wait OK answer +/*! \details +This function allows the user to read a LWM2M object resource. + * \param agentInstanceID selects the lwm2m instance. + * \param objectID selects the object identifier of the URI. + * \param objectInstanceID selects object instance identifier. + * \param resourceID selects resource identifier + * \param aTimeout specifies the timeout + * \return return code +*/ +ME310::return_t ME310::LWM2M_get_object_resource(int agentInstanceID, int objectID, int objectInstanceID, int resourceID, tout_t aTimeout) +{ + memset(mBuffer,0,ME310_BUFFSIZE); + snprintf((char*)mBuffer, ME310_BUFFSIZE-1,F("AT#LWM2MOBJGET=%d,%d,%d,%d"), agentInstanceID, objectID, objectInstanceID,resourceID); + return send_wait((char*)mBuffer, 0, OK_STRING, aTimeout); +} + +/*! \brief Implements the AT#LWM2MSTAT command and wait OK answer +/*! \details +This function sends a query about the status to the Telit LwM2M client. + * \param aTimeout specifies the timeout + * \return return code +*/ +ME310::return_t ME310::LWM2M_client_current_status(tout_t aTimeout) +{ + memset(mBuffer,0,ME310_BUFFSIZE); + snprintf((char*)mBuffer, ME310_BUFFSIZE-1,F("AT#LWM2MSTAT")); + return send_wait((char*)mBuffer, OK_STRING, aTimeout); +} + +/*! \brief Implements the AT#LWM2MREG command and wait OK answer +/*! \details +This function allows the user to request a full registration, a deregistration or a registration update to a LwM2M server. + * \param agentInstanceID identifier of the LwM2M agent related to the request. + * \param actionID identifier of the required action. + * \param shortServerID identifier of the server related to the request. + * \param aTimeout specifies the timeout + * \return return code +*/ +ME310::return_t ME310::LWM2M_registration(int agentInstanceID, int actionID, int shortServerID, tout_t aTimeout) +{ + memset(mBuffer,0,ME310_BUFFSIZE); + snprintf((char*)mBuffer, ME310_BUFFSIZE-1,F("AT#LWM2MREG=%d,%d,%d"), agentInstanceID, actionID, shortServerID); + return send_wait((char*)mBuffer, OK_STRING, aTimeout); +} + +/*! \brief Implements the AT#LWM2MREG command and wait OK answer +/*! \details +This function allows the user to request the registration info to a LwM2M server. + * \param agentInstanceID identifier of the LwM2M agent related to the request. + * \param aTimeout specifies the timeout + * \return return code +*/ +ME310::return_t ME310::LWM2M_registration_info(int agentInstanceID, tout_t aTimeout) +{ + memset(mBuffer,0,ME310_BUFFSIZE); + snprintf((char*)mBuffer, ME310_BUFFSIZE-1,F("AT#LWM2MREG=%d,%d"), agentInstanceID, REGISTRATION_INFO); + return send_wait((char*)mBuffer, OK_STRING, aTimeout); +} + +/*! \brief Implements the AT#LWM2MFOTAACK command and wait OK answer +/*! \details +This function sends an ACK to the LwM2M Client to authorize the FOTA operation required to the specified client. + * \param agentInstanceID identifier of the LwM2M agent related to the request. + * \param action acknowledge to the FOTA required operation + * \param aTimeout specifies the timeout + * \return return code +*/ +ME310::return_t ME310::LWM2M_FOTA_operation_confirmation(int agentInstanceID, int action, tout_t aTimeout) +{ + memset(mBuffer,0,ME310_BUFFSIZE); + snprintf((char*)mBuffer, ME310_BUFFSIZE-1,F("AT#LWM2MFOTAACK=%d,%d"), agentInstanceID, action); + return send_wait((char*)mBuffer, OK_STRING, aTimeout); +} + +/*! \brief Implements the AT#LWM2MFOTACFG command and wait OK answer +/*! \details +This function sends an ACK to the LwM2M Client to authorize the FOTA operation required to the specified client. + * \param agentInstanceID identifier of the LwM2M agent related to the request. + * \param mode select the FOTA mode + * \param timeoutAction select the action to be performed after the FOTA timeout for ACK expiration. + * \param aTimeout specifies the timeout + * \return return code +*/ +ME310::return_t ME310::LWM2M_FOTA_configuration(int agentInstanceID, int mode, int timeoutAction, tout_t aTimeout) +{ + memset(mBuffer,0,ME310_BUFFSIZE); + snprintf((char*)mBuffer, ME310_BUFFSIZE-1,F("AT#LWM2MFOTACFG=%d,%d,%d"), agentInstanceID, mode, timeoutAction); + return send_wait((char*)mBuffer, OK_STRING, aTimeout); +} + +/*! \brief Implements the AT#LWM2MFOTASTATE command and wait OK answer +/*! \details +This function allows the end-user to query the module in order to retrieve, for a given agent, the FOTA client state, +both in terms of the LwM2M specification status and the internal FOTA client management status. + * \param agentInstanceID identifier of the LwM2M agent related to the request. + * \param aTimeout specifies the timeout. + * \return return code +*/ +ME310::return_t ME310::LWM2M_FOTA_state(int agentInstanceID, tout_t aTimeout) +{ + memset(mBuffer,0,ME310_BUFFSIZE); + snprintf((char*)mBuffer, ME310_BUFFSIZE-1,F("AT#LWM2MFOTASTATE=%d"), agentInstanceID); + return send_wait((char*)mBuffer, OK_STRING, aTimeout); } // M2M ------------------------------------------------------------------------- @@ -6434,8 +7337,33 @@ This command enables/disables Power Saving Mode (PSM) mode. */ ME310::return_t ME310::psm_setting(int mode, const char *reqPeriodicRau, const char *reqGPRSreadyTimer, const char *reqPeriodicTau, const char *reqActiveTime, tout_t aTimeout) { + const int size_buf = 12; + char reqPeriodicRau_tmp[size_buf] = ""; + char reqGPRSreadyTimer_tmp[size_buf] = ""; + char reqPeriodicTau_tmp[size_buf] = ""; + char reqActiveTime_tmp[size_buf] = ""; + if(strlen(reqPeriodicRau) != 0) + { + memset(reqPeriodicRau_tmp, 0, size_buf); + snprintf(reqPeriodicRau_tmp, size_buf-1, F("\"%s\""), reqPeriodicRau); + } + if(strlen(reqGPRSreadyTimer) != 0) + { + memset(reqGPRSreadyTimer_tmp, 0, size_buf); + snprintf(reqGPRSreadyTimer_tmp, size_buf-1, F("\"%s\""), reqGPRSreadyTimer); + } + if(strlen(reqPeriodicTau) != 0) + { + memset(reqPeriodicTau_tmp, 0, size_buf); + snprintf(reqPeriodicTau_tmp, size_buf-1, F("\"%s\""), reqPeriodicTau); + } + if(strlen(reqActiveTime) != 0) + { + memset(reqActiveTime_tmp, 0, size_buf); + snprintf(reqActiveTime_tmp, size_buf-1, F("\"%s\""), reqActiveTime); + } memset(mBuffer, 0, ME310_BUFFSIZE); - snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT+CPSMS=%d,\"%s\",\"%s\",\"%s\",\"%s\""), mode, reqPeriodicRau, reqGPRSreadyTimer, reqPeriodicTau, reqActiveTime); + snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT+CPSMS=%d,%s,%s,%s,%s"), mode, reqPeriodicRau_tmp, reqGPRSreadyTimer_tmp, reqPeriodicTau_tmp, reqActiveTime_tmp); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } diff --git a/src/ME310.h b/src/ME310.h index 571dbd3..7f2d185 100644 --- a/src/ME310.h +++ b/src/ME310.h @@ -13,7 +13,7 @@ It makes it easy to build Arduino applications that use the full power of ME310 module @version - 2.8.0 + 2.10.0 @note Dependencies: @@ -95,9 +95,19 @@ namespace me310 LWM2M_SET_INT = 0, LWM2M_SET_FLOAT = 1, LWM2M_SET_STRING = 2, - LWM2M_SET_OPAQUE = 3 + LWM2M_SET_OPAQUE = 3, + LWM2M_SET_OBJECT_LINK = 4, + LWM2M_SET_TIME = 5 } LWM2M_SET_TYPE; + typedef enum + { + DEREGISTER = 0, + FULL_REGISTRATION = 1, + REGISTRATION_UPDATE = 2, + REGISTRATION_INFO = 3 + } LWM2M_REG_ACTION; + #ifdef ARDUINO_TELIT_SAMD_CHARLIE ME310(Uart &aSerial = SerialModule); #else @@ -1031,7 +1041,7 @@ namespace me310 // SSL ------------------------------------------------------------------------- - return_t ssl_configure_general_param(int ssid , int cid, int pktSx =0, int maxTo = 90, int defTo = 100, int txTo = 50, int SSLSRingMode = 0, int noCarrierMode = 0, int skipHostMismatch = 1, int equalizeTx = 0, int unused1 = 0, int unused2 = 0,tout_t aTimeout = TOUT_100MS); + return_t ssl_configure_general_param(int ssid , int cid, int pktSx = 0, int maxTo = 90, int defTo = 100, int txTo = 50, int SSLSRingMode = 0, int noCarrierMode = 0, int skipHostMismatch = 1, int equalizeTx = 0, int unused1 = 0, int unused2 = 0, tout_t aTimeout = TOUT_100MS); _READ_TEST(ssl_configure_general_param,"AT#SSLCFG",TOUT_100MS) return_t ssl_configure_security_param(int ssid, int cipherSuite = 0, int authMode = 0,tout_t aTimeout = TOUT_100MS); @@ -1082,51 +1092,135 @@ namespace me310 return_t odis_command_saving_retrieving_parameters(char* hostUniqueDevId = "HUID0", char *hostManufacturer = "HMAN0", char* hostModel = "HMOD0", char *hostSwVersion = "HSW0", tout_t aTimeout = TOUT_100MS); _READ_TEST(odis_command_saving_retrieving_parameters, "AT+ODIS", TOUT_100MS) - return_t enableLWM2M(int enable, int ctxID,tout_t aTimeout=TOUT_1SEC); - _READ_TEST(enableLWM2M,"AT#LWM2MENA",TOUT_100MS) + return_t FOTA_set_extended_URC(int enable = 0, tout_t aTimeout = TOUT_100MS); + _READ_TEST(FOTA_set_extended_URC, "AT#FOTAURC", TOUT_100MS) - return_t writeResource(int agent,int objID,int instanceID,int resourceID, int resourceInstance,int value, tout_t aTimeout=TOUT_100MS); - _READ_TEST(writeResource,"AT#LWM2MW",TOUT_100MS); + return_t OTA_delta_write(int size, tout_t aTimeout = TOUT_100MS); + _TEST(OTA_delta_write, "AT#OTAUPW", TOUT_100MS) - return_t writeResourcefloat(int agent,int objID,int instanceID,int resourceID, int resourceInstance,float value, tout_t aTimeout=TOUT_100MS); - _READ_TEST(writeResourcefloat,"AT#LWM2MW", TOUT_100MS); + return_t odis_parameters_management(int param, int action, char* value = "", int instance = 0, tout_t aTimeout = TOUT_100MS); + _TEST(odis_parameters_management, "AT#HOSTODIS", TOUT_100MS) - return_t disableLWM2M(int disable, tout_t aTimeout=TOUT_1SEC); - _READ_TEST(disableLWM2M,"AT#LWM2MENA",TOUT_100MS); + // LWM2M ----------------------------------------------------------------------- - return_t setResourcefloat(int type, int objID, int instanceID, int resourceID, int resourceInstance, float value, tout_t aTimeout = TOUT_100MS); - _READ_TEST(setResorcefloat,"AT#LWM2MSET",TOUT_100MS); + return_t LWM2M_enable(int enable, int ctxID, tout_t aTimeout=TOUT_1SEC); + _READ_TEST(LWM2M_enable,"AT#LWM2MENA",TOUT_100MS) - return_t setResourceFloat(int objID, int instanceID, int resourceID, int resourceInstance, float value, tout_t aTimeout = TOUT_100MS); - _READ_TEST(setResorceFloat,"AT#LWM2MSET",TOUT_100MS); + return_t LWM2M_disable(int disable, tout_t aTimeout=TOUT_1SEC); + _READ_TEST(LWM2M_disable,"AT#LWM2MENA",TOUT_100MS) - return_t setResourceInt(int objID,int instanceID,int resourceID, int resourceInstance, int value, tout_t aTimeout = TOUT_100MS); - _READ_TEST(setResorceInt,"AT#LWM2MSET",TOUT_100MS); + return_t LWM2M_write_resource(int agent, int objID, int instanceID, int resourceID, int resourceInstance, int value, tout_t aTimeout=TOUT_100MS); + return_t LWM2M_write_resource(int agent, int objID, int instanceID, int resourceID, int resourceInstance, char* value, tout_t aTimeout=TOUT_100MS); + return_t LWM2M_write_resource(int agent, int objID, int instanceID, int resourceID, int resourceInstance, float value, tout_t aTimeout=TOUT_100MS); + _READ_TEST(LWM2M_write_resource,"AT#LWM2MW",TOUT_100MS) - return_t setResourceBool(int type,int objID,int instanceID,int resourceID, int resourceInstance,int value, tout_t aTimeout = TOUT_100MS); - _READ_TEST(setResourceBool,"AT#LWM2MSET",TOUT_100MS); + return_t LWM2M_write_resource_float(int agent, int objID, int instanceID, int resourceID, int resourceInstance, float value, tout_t aTimeout=TOUT_100MS); + _READ_TEST(LWM2M_write_resource_float,"AT#LWM2MW", TOUT_100MS) - return_t readResourcefloat(int agent,int objID,int instanceID,int resourceID, int resourceInstance, tout_t aTimeout=TOUT_100MS); - _READ_TEST(readResourcefloat,"AT#LWM2MR",TOUT_100MS); + return_t LWM2M_set_resource_float(int objID, int instanceID, int resourceID, int resourceInstance, float value, tout_t aTimeout = TOUT_100MS); + _READ_TEST(LWM2M_set_resource_float,"AT#LWM2MSET",TOUT_100MS) - return_t readResourceFloat(int agent,int objID,int instanceID,int resourceID, int resourceInstance, tout_t aTimeout=TOUT_100MS); - _READ_TEST(readResourceFloat,"AT#LWM2MR",TOUT_100MS); + return_t LWM2M_set_resource_int(int objID, int instanceID, int resourceID, int resourceInstance, int value, tout_t aTimeout = TOUT_100MS); + _READ_TEST(LWM2M_set_resource_int,"AT#LWM2MSET",TOUT_100MS) - return_t readResourceInt(int agent,int objID,int instanceID,int resourceID, int resourceInstance, int &value, tout_t aTimeout=TOUT_100MS); - _READ_TEST(readResourceInt,"AT#LWM2MR",TOUT_100MS); + return_t LWM2M_set_resource_bool(int objID, int instanceID, int resourceID, int resourceInstance, int value, tout_t aTimeout = TOUT_100MS); + _READ_TEST(LWM2M_set_resource_bool,"AT#LWM2MSET",TOUT_100MS) - return_t setObject(int agent, int objID, int instanceID, char* jsonString, tout_t aTimeout=TOUT_100MS); - _READ_TEST(setObject,"AT#LWM2MOBJSET",TOUT_100MS); + return_t LWM2M_set_resource_string(int objID, int instanceID, int resourceID, int resourceInstance, char* value, tout_t aTimeout = TOUT_100MS); + _READ_TEST(LWM2M_set_resource_string,"AT#LWM2MSET",TOUT_100MS) - return_t FOTA_set_extended_URC(int enable = 0, tout_t aTimeout = TOUT_100MS); - _READ_TEST(FOTA_set_extended_URC, "AT#FOTAURC", TOUT_100MS) + return_t LWM2M_set_resource_object_link(int objID, int instanceID, int resourceID, int resourceInstance, char* value, tout_t aTimeout = TOUT_100MS); + _READ_TEST(LWM2M_set_resource_object_link,"AT#LWM2MSET",TOUT_100MS) - return_t OTA_delta_write(int size, tout_t aTimeout = TOUT_100MS); - _TEST(OTA_delta_write, "AT#OTAUPW", TOUT_100MS) + return_t LWM2M_set_resource_time(int objID, int instanceID, int resourceID, int resourceInstance, int value, tout_t aTimeout = TOUT_100MS); + _READ_TEST(LWM2M_set_resource_time,"AT#LWM2MSET",TOUT_100MS) - return_t odis_parameters_management(int param, int action, char* value = "", int instance = 0, tout_t aTimeout = TOUT_100MS); - _TEST(odis_parameters_management, "AT#HOSTODIS", TOUT_100MS) + return_t LWM2M_read_resource(int agent, int objID, int instanceID, int resourceID, int resourceInstance, tout_t aTimeout=TOUT_100MS); + _READ_TEST(LWM2M_read_resource,"AT#LWM2MR",TOUT_100MS) + + return_t LWM2M_read_resource_float(int agent, int objID, int instanceID, int resourceID, int resourceInstance, tout_t aTimeout=TOUT_100MS); + _READ_TEST(LWM2M_read_resource_float,"AT#LWM2MR",TOUT_100MS) + + return_t LWM2M_read_resource_int(int agent, int objID, int instanceID, int resourceID, int resourceInstance, int &value, tout_t aTimeout=TOUT_100MS); + _READ_TEST(LWM2M_read_resource_int,"AT#LWM2MR",TOUT_100MS) + + return_t LWM2M_read_resource_string(int agent, int objID, int instanceID, int resourceID, int resourceInstance, tout_t aTimeout=TOUT_100MS); + _READ_TEST(LWM2M_read_resource_string,"AT#LWM2MR",TOUT_100MS) + + return_t LWM2M_set_object(int agent, int objID, int instanceID, char* jsonString, tout_t aTimeout=TOUT_100MS); + _READ_TEST(LWM2M_set_object,"AT#LWM2MOBJSET",TOUT_100MS) + + return_t LWM2M_check_agent_exist(int agentInstance, tout_t aTimeout=TOUT_100MS); + _READ_TEST(LWM2M_check_agent_exist,"AT#LWM2MEXIST",TOUT_100MS) + + return_t LWM2M_check_object_exist(int agentInstance, int objectNumber, int objectInstanceNumber, tout_t aTimeout=TOUT_100MS); + _READ_TEST(LWM2M_check_object_exist,"AT#LWM2MEXIST",TOUT_100MS) + + return_t LWM2M_check_URI_exist(int agentInstance, int objectNumber, int objectInstanceNumber, int resourceNumber, int resourceInstanceNumber, tout_t aTimeout=TOUT_100MS); + _READ_TEST(LWM2M_check_URI_exist,"AT#LWM2MEXIST",TOUT_100MS) + + return_t LWM2M_create_new_object_instance(int agentInstance, int objectID, int objectInstanceID, tout_t aTimeout=TOUT_100MS); + _READ_TEST(LWM2M_create_new_object_instance,"AT#LWM2MNEWINST",TOUT_100MS) + + return_t LWM2M_send_ACK(tout_t aTimeout=TOUT_100MS); + _TEST(LWM2M_send_ACK,"AT#LWM2MACK",TOUT_100MS) + + return_t LWM2M_set_configuration(int agentID, int paramID, int value, tout_t aTimeout = TOUT_100MS); + _READ_TEST(LWM2M_set_configuration,"AT#LWM2MCFG",TOUT_100MS) + + return_t LWM2M_get_configuration(int agentID, int paramID, tout_t aTimeout = TOUT_100MS); + _READ_TEST(LWM2M_get_configuration,"AT#LWM2MCFG",TOUT_100MS) + + return_t LWM2M_set_ciphers(int agentID, int cipher_mode, tout_t aTimeout = TOUT_100MS); + _READ_TEST(LWM2M_set_ciphers,"AT#LWM2MCIPHERENA",TOUT_100MS) + + return_t LWM2M_set_general_parameter(int paramID, char* data, tout_t aTimeout = TOUT_100MS); + _READ_TEST(LWM2M_set_general_parameter,"AT#LWM2MCUST",TOUT_100MS) + + return_t LWM2M_client_resource_exec(int agentInstance, int objectID, int objectInstanceID, int resourceID, int resourceInstanceID, tout_t aTimeout = TOUT_100MS); + _READ_TEST(LWM2M_client_resource_exec,"AT#LWM2ME",TOUT_100MS) + + return_t LWM2M_get_resource(int type, int objectID, int objectInstanceID, int resourceID, int resourceInstanceID, tout_t aTimeout = TOUT_100MS); + _READ_TEST(LWM2M_get_resource,"AT#LWM2MGET",TOUT_100MS) + + return_t LWM2M_get_report_object(int agentInstance, tout_t aTimeout = TOUT_100MS); + _READ_TEST(LWM2M_get_report_object,"AT#LWM2MLIST",TOUT_100MS) + + return_t LWM2M_activate_resource(int action, int objectID, tout_t aTimeout = TOUT_100MS); + _READ_TEST(LWM2M_activate_resource,"AT#LWM2MMON",TOUT_100MS) + + return_t LWM2M_control_URC_reporting(int agentInstanceID, int action, tout_t aTimeout = TOUT_100MS); + _READ_TEST(LWM2M_control_URC_reporting,"AT#LWM2MNFYACKENA",TOUT_100MS) + return_t LWM2M_manage_URI_reporting(int agentInstanceID, int action, int objectID, int objectInstanceID, int resourceID, tout_t aTimeout = TOUT_100MS); + _READ_TEST(LWM2M_manage_URI_reporting,"AT#LWM2MNFYACKURI",TOUT_100MS) + + return_t LWM2M_get_object(int agentInstanceID, int objectID, tout_t aTimeout = TOUT_100MS); + _READ_TEST(LWM2M_get_object,"AT#LWM2MOBJGET",TOUT_100MS) + + return_t LWM2M_get_object_instance(int agentInstanceID, int objectID, int objectInstanceID, tout_t aTimeout = TOUT_100MS); + _READ_TEST(LWM2M_get_object_instance,"AT#LWM2MOBJGET",TOUT_100MS) + + return_t LWM2M_get_object_resource(int agentInstanceID, int objectID, int objectInstanceID, int resourceID, tout_t aTimeout = TOUT_100MS); + _READ_TEST(LWM2M_get_object_resource,"AT#LWM2MOBJGET",TOUT_100MS) + + return_t LWM2M_client_current_status(tout_t aTimeout = TOUT_100MS); + _TEST(LWM2M_client_current_status,"AT#LWM2MSTAT",TOUT_100MS) + + return_t LWM2M_registration(int agentInstanceID, int actionID, int shortServerID, tout_t aTimeout = TOUT_100MS); + _READ_TEST(LWM2M_registration,"AT#LWM2MREG",TOUT_100MS) + + return_t LWM2M_registration_info(int agentInstanceID, tout_t aTimeout = TOUT_100MS); + _READ_TEST(LWM2M_registration_info,"AT#LWM2MREG",TOUT_100MS) + + return_t LWM2M_FOTA_operation_confirmation(int agentInstanceID, int action = 1, tout_t aTimeout = TOUT_100MS); + _TEST(LWM2M_FOTA_operation_confirmation,"AT#LWM2MFOTAACK",TOUT_100MS) + + return_t LWM2M_FOTA_configuration(int agentInstanceID, int mode = 0, int timeoutAction = 0, tout_t aTimeout = TOUT_100MS); + _READ_TEST(LWM2M_FOTA_configuration,"AT#LWM2MFOTACFG",TOUT_100MS) + + return_t LWM2M_FOTA_state(int agentInstanceID, tout_t aTimeout = TOUT_100MS); + _READ_TEST(LWM2M_FOTA_state,"AT#LWM2MFOTASTATE",TOUT_100MS) // M2M ------------------------------------------------------------------------- return_t m2m_chdir(const char *path,tout_t aTimeout = TOUT_100MS); @@ -1249,7 +1343,7 @@ namespace me310 // PSM ------------------------------------------------------------------------- - return_t psm_setting(int mode, const char * reqPeriodicRau, const char * reqGPRSreadyTimer, const char * reqPeriodicTau, const char * reqActiveTime, tout_t aTimeout = TOUT_100MS); + return_t psm_setting(int mode, const char * reqPeriodicRau = "", const char * reqGPRSreadyTimer = "", const char * reqPeriodicTau = "", const char * reqActiveTime = "", tout_t aTimeout = TOUT_100MS); _READ_TEST(psm_setting,"AT+CPSMS",TOUT_100MS) return_t psm_setting2(int mode, int reqPeriodicRau, int reqGPRSreadyTimer, int reqPeriodicTau, int reqActiveTime, int psmVersion, int psmThreshold, tout_t aTimeout = TOUT_100MS); @@ -1273,6 +1367,103 @@ namespace me310 void send_data(const char *aCommand, const char* term = TERMINATION_STRING, tout_t aTimeout = TOUT_200MS); virtual return_t receive_data(tout_t aTimeout = TOUT_200MS); + // Deprecated methods----------------------------------------------------------- + [[deprecated("Use LWM2M_enable(int enable, int ctxID, tout_t aTimeout) instead.")]] + return_t enableLWM2M(int enable, int ctxID,tout_t aTimeout=TOUT_1SEC); + _READ_TEST(enableLWM2M,"AT#LWM2MENA",TOUT_100MS) + + [[deprecated("Use LWM2M_disable(int disable, tout_t aTimeout) instead.")]] + return_t disableLWM2M(int disable, tout_t aTimeout=TOUT_1SEC); + _READ_TEST(disableLWM2M,"AT#LWM2MENA",TOUT_100MS) + + [[deprecated("Use LWM2M_write_resource(int agent, int objID, int instanceID, int resourceID, int resourceInstance, int value, tout_t aTimeout) instead.")]] + return_t writeResource(int agent, int objID, int instanceID, int resourceID, int resourceInstance, int value, tout_t aTimeout=TOUT_100MS); + [[deprecated("Use LWM2M_write_resource(int agent, int objID, int instanceID, int resourceID, int resourceInstance, char* value, tout_t aTimeout) instead.")]] + return_t writeResource(int agent, int objID, int instanceID, int resourceID, int resourceInstance, char* value, tout_t aTimeout=TOUT_100MS); + [[deprecated("Use LWM2M_write_resource(int agent, int objID, int instanceID, int resourceID, int resourceInstance, float value, tout_t aTimeout) instead.")]] + return_t writeResource(int agent, int objID, int instanceID, int resourceID, int resourceInstance, float value, tout_t aTimeout=TOUT_100MS); + _READ_TEST(writeResource,"AT#LWM2MW",TOUT_100MS) + + [[deprecated("Use LWM2M_write_resource_float(int agent, int objID, int instanceID, int resourceID, int resourceInstance, float value, tout_t aTimeout) instead.")]] + return_t writeResourcefloat(int agent,int objID,int instanceID,int resourceID, int resourceInstance,float value, tout_t aTimeout=TOUT_100MS); + _READ_TEST(writeResourcefloat,"AT#LWM2MW", TOUT_100MS) + + [[deprecated("Use LWM2M_set_resource_float(int objID, int instanceID, int resourceID, int resourceInstance, float value, tout_t aTimeout) instead.")]] + return_t setResourcefloat(int type, int objID, int instanceID, int resourceID, int resourceInstance, float value, tout_t aTimeout = TOUT_100MS); + _READ_TEST(setResourcefloat,"AT#LWM2MSET",TOUT_100MS) + + [[deprecated("Use LWM2M_set_resource_float(int objID, int instanceID, int resourceID, int resourceInstance, float value, tout_t aTimeout) instead.")]] + return_t setResourceFloat(int objID, int instanceID, int resourceID, int resourceInstance, float value, tout_t aTimeout = TOUT_100MS); + _READ_TEST(setResourceFloat,"AT#LWM2MSET",TOUT_100MS) + + [[deprecated("Use LWM2M_set_resource_int(int objID, int instanceID, int resourceID, int resourceInstance, int value, tout_t aTimeout) instead.")]] + return_t setResourceInt(int objID, int instanceID, int resourceID, int resourceInstance, int value, tout_t aTimeout = TOUT_100MS); + _READ_TEST(setResourceInt,"AT#LWM2MSET",TOUT_100MS) + + [[deprecated("Use LWM2M_set_resource_bool(int objID, int instanceID, int resourceID, int resourceInstance, int value, tout_t aTimeout) instead.")]] + return_t setResourceBool(int type, int objID, int instanceID, int resourceID, int resourceInstance, int value, tout_t aTimeout = TOUT_100MS); + [[deprecated("Use LWM2M_set_resource_bool(int objID, int instanceID, int resourceID, int resourceInstance, int value, tout_t aTimeout) instead.")]] + return_t setResourceBool(int objID, int instanceID, int resourceID, int resourceInstance, int value, tout_t aTimeout = TOUT_100MS); + _READ_TEST(setResourceBool,"AT#LWM2MSET",TOUT_100MS) + + [[deprecated("Use LWM2M_set_resource_string(int objID, int instanceID, int resourceID, int resourceInstance, char* value, tout_t aTimeout) instead.")]] + return_t setResourceString(int type, int objID, int instanceID, int resourceID, int resourceInstance, char* value, tout_t aTimeout = TOUT_100MS); + [[deprecated("Use LWM2M_set_resource_string(int objID, int instanceID, int resourceID, int resourceInstance, char* value, tout_t aTimeout) instead.")]] + return_t setResourceString(int objID, int instanceID, int resourceID, int resourceInstance, char* value, tout_t aTimeout = TOUT_100MS); + _READ_TEST(setResourceString,"AT#LWM2MSET",TOUT_100MS) + + [[deprecated("Use LWM2M_set_resource_object_link(int objID, int instanceID, int resourceID, int resourceInstance, char* value, tout_t aTimeout) instead.")]] + return_t setResourceObjectLink(int objID, int instanceID, int resourceID, int resourceInstance, char* value, tout_t aTimeout = TOUT_100MS); + _READ_TEST(setResourceObjectLink,"AT#LWM2MSET",TOUT_100MS) + + [[deprecated("Use LWM2M_set_resource_time(int objID, int instanceID, int resourceID, int resourceInstance, int value, tout_t aTimeout) instead.")]] + return_t setResourceTime(int objID, int instanceID, int resourceID, int resourceInstance, int value, tout_t aTimeout = TOUT_100MS); + _READ_TEST(setResourceTime,"AT#LWM2MSET",TOUT_100MS) + + [[deprecated("Use LWM2M_read_resource(int agent, int objID, int instanceID, int resourceID, int resourceInstance, tout_t aTimeout) instead.")]] + return_t readResource(int agent, int objID, int instanceID, int resourceID, int resourceInstance, tout_t aTimeout=TOUT_100MS); + _READ_TEST(readResource,"AT#LWM2MR",TOUT_100MS) + + [[deprecated("Use LWM2M_read_resource_float(int agent, int objID, int instanceID, int resourceID, int resourceInstance, tout_t aTimeout) instead.")]] + return_t readResourcefloat(int agent,int objID,int instanceID,int resourceID, int resourceInstance, tout_t aTimeout=TOUT_100MS); + _READ_TEST(readResourcefloat,"AT#LWM2MR",TOUT_100MS) + + [[deprecated("Use LWM2M_read_resource_float(int agent, int objID, int instanceID, int resourceID, int resourceInstance, tout_t aTimeout) instead.")]] + return_t readResourceFloat(int agent,int objID,int instanceID,int resourceID, int resourceInstance, tout_t aTimeout=TOUT_100MS); + _READ_TEST(readResourceFloat,"AT#LWM2MR",TOUT_100MS) + + [[deprecated("Use LWM2M_read_resource_int(int agent, int objID, int instanceID, int resourceID, int resourceInstance, int &value, tout_t aTimeout) instead.")]] + return_t readResourceInt(int agent, int objID, int instanceID, int resourceID, int resourceInstance, int &value, tout_t aTimeout=TOUT_100MS); + _READ_TEST(readResourceInt,"AT#LWM2MR",TOUT_100MS) + + [[deprecated("Use LWM2M_read_resource_string(int agent, int objID, int instanceID, int resourceID, int resourceInstance, tout_t aTimeout) instead.")]] + return_t readResourceString(int agent, int objID, int instanceID, int resourceID, int resourceInstance, tout_t aTimeout=TOUT_100MS); + _READ_TEST(readResourceString,"AT#LWM2MR",TOUT_100MS) + + [[deprecated("Use LWM2M_set_object(int agent, int objID, int instanceID, char* jsonString, tout_t aTimeout) instead.")]] + return_t setObject(int agent, int objID, int instanceID, char* jsonString, tout_t aTimeout=TOUT_100MS); + _READ_TEST(setObject,"AT#LWM2MOBJSET",TOUT_100MS) + + [[deprecated("Use LWM2M_check_agent_exist(int agentInstance, tout_t aTimeout) instead.")]] + return_t checkAgentExist(int agentInstance, tout_t aTimeout=TOUT_100MS); + _READ_TEST(checkAgentExist,"AT#LWM2MEXIST",TOUT_100MS) + + [[deprecated("Use LWM2M_check_object_exist(int agentInstance, int objectNumber, int objectInstanceNumber, tout_t aTimeout) instead.")]] + return_t checkObjectExist(int agentInstance, int objectNumber, int objectInstanceNumber, tout_t aTimeout=TOUT_100MS); + _READ_TEST(checkObjectExist,"AT#LWM2MEXIST",TOUT_100MS) + + [[deprecated("Use LWM2M_check_URI_exist(int agentInstance, int objectNumber, int objectInstanceNumber, int resourceNumber, int resourceInstanceNumber, tout_t aTimeout) instead.")]] + return_t checkURIExist(int agentInstance, int objectNumber, int objectInstanceNumber, int resourceNumber, int resourceInstanceNumber, tout_t aTimeout=TOUT_100MS); + _READ_TEST(checkURIExist,"AT#LWM2MEXIST",TOUT_100MS) + + [[deprecated("Use LWM2M_create_new_object_instance(int agentInstance, int objectID, int objectInstanceID, tout_t aTimeout) instead.")]] + return_t createNewObjectInstance(int agentInstance, int objectID, int objectInstanceID, tout_t aTimeout=TOUT_100MS); + _READ_TEST(createNewObjectInstance,"AT#LWM2MNEWINST",TOUT_100MS) + + [[deprecated("Use LWM2M_send_ACK(tout_t aTimeout) instead.")]] + return_t sendLWM2MACK(tout_t aTimeout=TOUT_100MS); + _TEST(sendLWM2MACK,"AT#LWM2MACK",TOUT_100MS) + const uint8_t *buffer(void) { return mBuffer;} //!< Returns pointer to local buffer diff --git a/src/Parser.cpp b/src/Parser.cpp index a971159..3277fb3 100644 --- a/src/Parser.cpp +++ b/src/Parser.cpp @@ -14,7 +14,7 @@ Parser is an abstract class and handles common methods, like gets and parse.\n The concrete classes, derived by Parser, implement the parsing methods for the specific AT command.\n @version - 1.1.1 + 2.10.0 @note Dependencies: diff --git a/src/Parser.h b/src/Parser.h index 7a44f10..26a0744 100644 --- a/src/Parser.h +++ b/src/Parser.h @@ -13,7 +13,7 @@ Parser is an abstract class and handles common methods, like gets and parse.\n The concrete classes, derived by Parser, implement the parsing methods for the specific AT command.\n @version - 1.1.1 + 2.10.0 @note Dependencies: diff --git a/src/PathParsing.cpp b/src/PathParsing.cpp index e1638fe..4d475c7 100644 --- a/src/PathParsing.cpp +++ b/src/PathParsing.cpp @@ -12,7 +12,7 @@ This library contains a interface that implements a parsing functions for path.\n @version - 1.0.0 + 2.10.0 @note Dependencies: diff --git a/src/PathParsing.h b/src/PathParsing.h index d76cb7c..2352121 100644 --- a/src/PathParsing.h +++ b/src/PathParsing.h @@ -11,7 +11,7 @@ @version - 1.0.0 + 2.10.0 @note Dependencies: