IMEI Read Example

IMEI Read Example

IMEI (International Mobile Equipment Identity) is a unique 15-digit number assigned to devices with cellular capability. This identifier is used primarily for distinguishing each device when it connects to a mobile network.

Before attempting to read the IMEI, ensure that the device has successfully registered on the GSM network. This can be verified by checking that the SENSOR_GSM_REGISTERED status is set to true. Once the device is registered, the IMEI can be read using the read_buf(IMEI, ...) function.

1. IMEI Read Example Code

#include <io> #include <read> #include <float> #include <string> #include <core> #include <write> #include <define> #include <socket> #include <debug> #define RS232_SPEED 115200 #define WORD_LENGTH WORDLENGTH_8 #define STOP_BITS STOPBITS_1 #define PARITY PARITY_NONE forward wait_for_modem(); new str_temp[16]; main() { Init(RS232, RS232_SPEED, WORD_LENGTH, STOP_BITS, PARITY); debug_init(RS232); wait_for_modem(); read_buf(IMEI, 15, str_temp); debug_print("IMEI: "); debug_print(str_temp); for(;;) { Delay(10000); } } wait_for_modem() { while (get_val(SENSOR_GSM_REGISTERED) == false) { Delay(1000); debug_print("Waiting for Modem...\r\n"); } }