DIYmall 0.96" Inch I2c IIC Serial 128x64 Oled LCD LED White Display Module
Dependencies: Adafruit_GFX SDFileSystem
Fork of ATT_AWS_IoT_demo by
Diff: WNCInterface/WncControllerK64F/WncController/WncController.cpp
- Revision:
- 28:4650c541b029
- Parent:
- 15:6f2798e45099
diff -r 2f486c766854 -r 4650c541b029 WNCInterface/WncControllerK64F/WncController/WncController.cpp --- a/WNCInterface/WncControllerK64F/WncController/WncController.cpp Tue Feb 07 16:18:57 2017 +0000 +++ b/WNCInterface/WncControllerK64F/WncController/WncController.cpp Tue Oct 09 20:57:34 2018 +0000 @@ -31,6 +31,9 @@ #include <cctype> #include "WncController.h" +extern int16_t RSSI; + + namespace WncController_fk { ///////////////////////////////////////////////////// @@ -2008,8 +2011,10 @@ return (false); } + bool WncController::at_getrssiber_wnc(int16_t * dBm, int16_t * ber) { + string * pRespStr; AtCmdErr_e cmdRes; cmdRes = at_send_wnc_cmd("AT+CSQ", &pRespStr, m_sCmdTimeoutMs); // Check RSSI,BER @@ -2047,6 +2052,7 @@ else { dbgPuts("Invalid RSSI!"); return (false); + RSSI = *dBm; } // Parse out BER: 0..7 as RXQUAL values in the table 3GPP TS 45.008 subclause 8.2.4 // 99 - unknown or undetectable @@ -2078,7 +2084,37 @@ dbgPuts("<-------- Begin Cell Status ------------"); cmdRes1 = at_send_wnc_cmd("AT+CSQ", &pRespStr, m_sCmdTimeoutMs); // Check RSSI,BER - + if (pRespStr->size() == 0) + { + dbgPuts("Strange RSSI result!"); + return (false); + } + else + { + size_t pos1 = pRespStr->find("SQ:"); + size_t pos2 = pRespStr->rfind(","); + // Sanity check + if ((pos1 != string::npos) && (pos2 != string::npos) && (pos2 > pos1)) + { + string subStr = pRespStr->substr(pos1 + 4, pos2 - pos1 ); + int rawRssi = atoi(subStr.c_str()); + if (rawRssi == 99) + RSSI = -199; + else if (rawRssi == 0) + RSSI = -113; + else if (rawRssi == 1) + RSSI = -111; + else if (rawRssi == 31) + RSSI = -51; + else if (rawRssi >= 2 && rawRssi <= 30) + RSSI = -113 + 2 * rawRssi; + else + { + dbgPuts("Invalid RSSI!"); + return (false); + } + } + } // If no response, don't bother with more commands if (cmdRes1 != WNC_AT_CMD_TIMEOUT) cmdRes2 = at_send_wnc_cmd("AT+CPIN?", &pRespStr, m_sCmdTimeoutMs); // Check if SIM locked