Add methods to return IMEI, MEID, IMSI, ICCID and RSSI.
Fork of ublox-cellular-base by
Revision 11:57f64bc518c0, committed 2018-01-02
- Comitter:
- fahim alavi
- Date:
- Tue Jan 02 12:38:56 2018 +0500
- Parent:
- 10:c4281fa79b8f
- Child:
- 12:aa3cbc3f88c5
- Commit message:
- IMEI provided to application
Changed in this revision
| UbloxCellularBase.cpp | Show annotated file Show diff for this revision Revisions of this file |
| UbloxCellularBase.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/UbloxCellularBase.cpp Tue Jan 02 05:45:24 2018 +0000
+++ b/UbloxCellularBase.cpp Tue Jan 02 12:38:56 2018 +0500
@@ -209,6 +209,32 @@
return success;
}
+/** Get the IMEI.
+ *
+ * @return true if successful, otherwise false.
+ */
+bool UbloxCellularBase::get_imei(char *imei_to_send,int size)
+{
+ bool success;
+ LOCK();
+
+ MBED_ASSERT(_at != NULL);
+
+ // International mobile equipment identifier
+ // AT Command Manual UBX-13002752, section 4.7
+ success = _at->send("AT+CGSN") && _at->recv("%15[^\n]\nOK\n", _dev_info.imei);
+ tr_info("DevInfo: IMEI=%s", _dev_info.imei);
+
+ if(success)
+ {
+ memcpy(imei_to_send,_dev_info.imei,size);
+ imei_to_send[size-1] = '\0';
+ }
+
+ UNLOCK();
+ return success;
+}
+
bool UbloxCellularBase::get_meid()
{
bool success;
--- a/UbloxCellularBase.h Tue Jan 02 05:45:24 2018 +0000
+++ b/UbloxCellularBase.h Tue Jan 02 12:38:56 2018 +0500
@@ -134,6 +134,12 @@
*/
bool change_sim_pin(const char *new_pin);
+ /** Get the IMEI.
+ *
+ * @return true if successful, otherwise false.
+ */
+ bool get_imei(char *imei_to_send,int size);
+
protected:
#define OUTPUT_ENTER_KEY "\r"
@@ -162,6 +168,7 @@
DEV_LISA_U2,
DEV_LISA_U2_03S,
DEV_SARA_U2,
+ DEV_SARA_R4,
DEV_LEON_G2,
DEV_TOBY_L2,
DEV_MPCI_L2
