Treat signal level in network messages as a (RMS) amplitude, since that

is what was previously done and it gives us better range for small signals.

Means a sqrt() call on beast output, but this shouldn't be too bad as
it's only done once per message.
This commit is contained in:
Oliver Jowett 2015-01-22 15:28:35 +00:00
parent fac838b9ad
commit 89d6b64747

View file

@ -293,7 +293,7 @@ void modesSendBeastOutput(struct modesMessage *mm) {
if (0x1A == ch) {*p++ = ch; }
}
*p++ = ch = (char) round(mm->signalLevel * 255);
*p++ = ch = (char) round(sqrt(mm->signalLevel) * 255);
if (0x1A == ch) {*p++ = ch; }
for (j = 0; j < msgLen; j++) {
@ -569,7 +569,8 @@ int decodeBinMessage(struct client *c, char *p) {
}
ch = *p++; // Grab the signal level
mm.signalLevel = 1e-5 + (unsigned char)ch / 256.0;
mm.signalLevel = ((unsigned char)ch / 256.0);
mm.signalLevel = mm.signalLevel * mm.signalLevel + 1e-5;
if (0x1A == ch) {p++;}
for (j = 0; j < msgLen; j++) { // and the data
@ -645,7 +646,8 @@ int decodeHexMessage(struct client *c, char *hex) {
switch(hex[0]) {
case '<': {
mm.signalLevel = 1e-5 + ((hexDigitVal(hex[13])<<4) | hexDigitVal(hex[14])) / 256.0;
mm.signalLevel = ((hexDigitVal(hex[13])<<4) | hexDigitVal(hex[14])) / 256.0;
mm.signalLevel = mm.signalLevel * mm.signalLevel + 1e-5;
hex += 15; l -= 16; // Skip <, timestamp and siglevel, and ;
break;}