Grouped connection quality functions

This commit is contained in:
SRGDamia1
2017-06-08 13:29:05 -04:00
parent b5dace330b
commit ea1a4706f9
6 changed files with 81 additions and 85 deletions

View File

@@ -224,7 +224,7 @@ public:
}
/*
* SIM card & Network Operator functions
* SIM card functions
*/
bool simUnlock(const char *pin) { // Not supported
@@ -253,23 +253,6 @@ public:
return res;
}
int getSignalQuality() {
commandMode();
if (beeType == S6B) sendAT(GF("LM")); // ask for the "link margin" - the dB above sensitivity
else sendAT(GF("DB")); // ask for the cell strenght in dBm
// wait for the response
unsigned long startMillis = millis();
while (!stream.available() && millis() - startMillis < 1000) {};
char buf[2] = {0}; // Set up buffer for response
buf[0] = streamRead();
buf[1] = streamRead();
DBG(buf[0], buf[1], "\n");
exitCommand();
int intr = strtol(buf, 0, 16);
if (beeType == S6B) return -93 + intr; // the maximum sensitivity is -93dBm
else return -1*intr; // need to convert to negative number
}
SimStatus getSimStatus(unsigned long timeout = 10000L) {
return SIM_READY; // unsupported
}
@@ -311,6 +294,26 @@ public:
return res;
}
/*
* Generic network functions
*/
int getSignalQuality() {
commandMode();
if (beeType == S6B) sendAT(GF("LM")); // ask for the "link margin" - the dB above sensitivity
else sendAT(GF("DB")); // ask for the cell strenght in dBm
// wait for the response
unsigned long startMillis = millis();
while (!stream.available() && millis() - startMillis < 1000) {};
char buf[2] = {0}; // Set up buffer for response
buf[0] = streamRead();
buf[1] = streamRead();
DBG(buf[0], buf[1], "\n");
exitCommand();
int intr = strtol(buf, 0, 16);
if (beeType == S6B) return -93 + intr; // the maximum sensitivity is -93dBm
else return -1*intr; // need to convert to negative number
}
bool waitForNetwork(unsigned long timeout = 60000L) {
for (unsigned long start = millis(); millis() - start < timeout; ) {