An application to log WiFi SSIDs for position lookup testing
Dependencies: C027_Support SWO mbed-rtos mbed picojson
Fork of lpc4088_ebb_ublox_Cellular_PubNubDemo_rtos by
device/DeviceInfo.cpp@1:cac9b2960637, 2015-02-15 (annotated)
- Committer:
- rosterloh84
- Date:
- Sun Feb 15 22:04:12 2015 +0000
- Revision:
- 1:cac9b2960637
First working version. Lots to do still.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
rosterloh84 | 1:cac9b2960637 | 1 | #include "DeviceInfo.h" |
rosterloh84 | 1:cac9b2960637 | 2 | #include <stdlib.h> |
rosterloh84 | 1:cac9b2960637 | 3 | #include <string.h> |
rosterloh84 | 1:cac9b2960637 | 4 | |
rosterloh84 | 1:cac9b2960637 | 5 | DeviceInfo::DeviceInfo(MDMSerial& mdm, MDMParser::DevStatus& devStatus) : |
rosterloh84 | 1:cac9b2960637 | 6 | _mdm(mdm) |
rosterloh84 | 1:cac9b2960637 | 7 | { |
rosterloh84 | 1:cac9b2960637 | 8 | *_cellId = '\0'; |
rosterloh84 | 1:cac9b2960637 | 9 | memcpy(&_devStatus, &devStatus, sizeof(MDMParser::DevStatus)); |
rosterloh84 | 1:cac9b2960637 | 10 | memset(&_netStatus, 0, sizeof(MDMParser::NetStatus)); |
rosterloh84 | 1:cac9b2960637 | 11 | memset(&_signalQuality, 0, sizeof(DeviceInfo::SignalQuality)); |
rosterloh84 | 1:cac9b2960637 | 12 | } |
rosterloh84 | 1:cac9b2960637 | 13 | |
rosterloh84 | 1:cac9b2960637 | 14 | const char * DeviceInfo::imsi() |
rosterloh84 | 1:cac9b2960637 | 15 | { |
rosterloh84 | 1:cac9b2960637 | 16 | return _devStatus.imsi; |
rosterloh84 | 1:cac9b2960637 | 17 | } |
rosterloh84 | 1:cac9b2960637 | 18 | |
rosterloh84 | 1:cac9b2960637 | 19 | const char * DeviceInfo::imei() |
rosterloh84 | 1:cac9b2960637 | 20 | { |
rosterloh84 | 1:cac9b2960637 | 21 | return _devStatus.imei; |
rosterloh84 | 1:cac9b2960637 | 22 | } |
rosterloh84 | 1:cac9b2960637 | 23 | |
rosterloh84 | 1:cac9b2960637 | 24 | const char * DeviceInfo::cellId() |
rosterloh84 | 1:cac9b2960637 | 25 | { |
rosterloh84 | 1:cac9b2960637 | 26 | if (!refreshNetStatus()) |
rosterloh84 | 1:cac9b2960637 | 27 | return NULL; |
rosterloh84 | 1:cac9b2960637 | 28 | |
rosterloh84 | 1:cac9b2960637 | 29 | if (snprintf(_cellId, sizeof(_cellId), "%X", _netStatus.ci) < 1) |
rosterloh84 | 1:cac9b2960637 | 30 | return NULL; |
rosterloh84 | 1:cac9b2960637 | 31 | return _cellId; |
rosterloh84 | 1:cac9b2960637 | 32 | } |
rosterloh84 | 1:cac9b2960637 | 33 | |
rosterloh84 | 1:cac9b2960637 | 34 | const char * DeviceInfo::iccid() |
rosterloh84 | 1:cac9b2960637 | 35 | { |
rosterloh84 | 1:cac9b2960637 | 36 | return _devStatus.ccid; |
rosterloh84 | 1:cac9b2960637 | 37 | } |
rosterloh84 | 1:cac9b2960637 | 38 | |
rosterloh84 | 1:cac9b2960637 | 39 | DeviceInfo::SignalQuality * DeviceInfo::signalQuality() |
rosterloh84 | 1:cac9b2960637 | 40 | { |
rosterloh84 | 1:cac9b2960637 | 41 | memset(&_signalQuality, 0, sizeof(DeviceInfo::SignalQuality)); |
rosterloh84 | 1:cac9b2960637 | 42 | if (!refreshNetStatus()) |
rosterloh84 | 1:cac9b2960637 | 43 | return NULL; |
rosterloh84 | 1:cac9b2960637 | 44 | |
rosterloh84 | 1:cac9b2960637 | 45 | if ((_netStatus.rssi == 0) || (_netStatus.ber == 0)) |
rosterloh84 | 1:cac9b2960637 | 46 | return NULL; |
rosterloh84 | 1:cac9b2960637 | 47 | |
rosterloh84 | 1:cac9b2960637 | 48 | _signalQuality.rssi = _netStatus.rssi; |
rosterloh84 | 1:cac9b2960637 | 49 | _signalQuality.ber = _netStatus.ber; |
rosterloh84 | 1:cac9b2960637 | 50 | return &_signalQuality; |
rosterloh84 | 1:cac9b2960637 | 51 | } |
rosterloh84 | 1:cac9b2960637 | 52 | |
rosterloh84 | 1:cac9b2960637 | 53 | bool DeviceInfo::refreshNetStatus() |
rosterloh84 | 1:cac9b2960637 | 54 | { |
rosterloh84 | 1:cac9b2960637 | 55 | return _mdm.checkNetStatus(&_netStatus); |
rosterloh84 | 1:cac9b2960637 | 56 | } |