mcci-catena / arduino-lorawan

User-friendly library for using arduino-lmic with The Things Network and other LoRaWAN® networks
MIT License
274 stars 54 forks source link

Print Spread Factor, and Power Consumption #202

Closed Junaid-Qadir-UniGe closed 1 year ago

Junaid-Qadir-UniGe commented 1 year ago

Dear Mr. Terry Moore (@terrillmoore ),

I am using LMIC code for experiment purposes and would like to print the spread factor and power consumed for each payload sent to the Server. I do wanna look at both parameters i,e SF and Power consumption on Serial console on Arduino IDE. Would you please provide me with your kind instruction on how to do that?

LMIC_setLinkCheckMode(0); LMIC_setDrTxpow(DR_SF7,14);

I would like to change the value from 14 dBi to 20 dBi and DR_SF7 to DR_SF12 and do wanna see the result on Arduino Console.

Looking forward to hearing from you Thank you

Best,

image

terrillmoore commented 1 year ago

Hi, sure. My recommendation is to capture this info during EV_TXSTART processing, and then print it later when it's not time critical (e.g., during EV_JOIN_TXCOMPLETE). (Printing takes time and the LMIC has hard-real-time paths.)

With respect to Tx power, there is some tricky handoff between the LMIC and the radio driver, I'll have to look up the exact correct variable to capture. Which version of LMIC are you using?

Junaid-Qadir-UniGe commented 1 year ago

EV_TXSTART

Dear Mr. Terry Moore,

Thanks for your prompt response. What I understood from your recommendation is to capture SPREAD_FACTOR information in the main code (ttn-otaa-feather-us915-dht22.ino) file, or do we have to define it in the LMIC.C file?

  `case EV_TXSTART:
        Serial.println(F("EV_TXSTART"));
        break;
    case SPREAD_FACTOR:      // <=================
        break;
    case EV_TXCANCELED:
        Serial.println(F("EV_TXCANCELED"));
        break;
    case EV_RXSTART:
        /* do not print anything -- it wrecks timing */
        break;
    case EV_JOIN_TXCOMPLETE:
        Serial.println(F("SPREAD_FACTOR: Uplink Packet sent with Spread Factor"));    // <=================
        Serial.println(F("EV_JOIN_TXCOMPLETE: no JoinAccept"));
        break;` 

I added those two lines but it gives me an error that "SPREAD_FACTOR" was not declared in this scope. For sure it must show this error because we didn't define it in the code. Would you be kind enough to please let me know where and how can we define the statement for the Spread Factor?


For Powe consumption, I kindly looking forward to hearing from you, when you get a chance in your free time. I tried myself but couldn't solve the issue.

I am using the latest version of LMIC [4.1.1]

Thank you

I kindly need the result like this SAMPLE SNAPSHOT image

terrillmoore commented 1 year ago

Sorry, I was not clear. While processing the event EV_TXSTART, the code should cache the values of:

Please refer to doc/RadioDriver.md for more info.

terrillmoore commented 1 year ago

As this isn't really a bug, converting to a discussion.