TheThingsNetwork / arduino-device-lib

Arduino Library for TTN Devices
MIT License
208 stars 96 forks source link

Track airTime #65

Closed n2jn closed 7 years ago

n2jn commented 7 years ago

Added a timer in sendbytes that calculates air-time of the uplink and a function showAirTime() to show you your air-time. #30

FokkeZB commented 7 years ago

@Nicolasdejean could you resolve the conflict and document what the public API/use is of this change and what I should test?

n2jn commented 7 years ago

@FokkeZB In API.md I put the use of trackAirtime in sendBytes since its a private function. Also @johanstokking shouldn't we print the airtime in the examples to let the user be aware of the 30 seconds fair policy.

FokkeZB commented 7 years ago

If we don't debug print nor make it public it's of no use.

johanstokking commented 7 years ago

Yep, true. Put it in showStatus()

n2jn commented 7 years ago

@johanstokking @FokkeZB It's going to change everytime we send a message so shouldn't we print it in sendBytes() ? Or in another function in void loop ?

johanstokking commented 7 years ago

Yes, we can too

FokkeZB commented 7 years ago

Isn't this information users might want to calculate with? What if we make the property public so that you can read it and do whatever you like (reset every day perhaps)? We could still also include it in showStatus (total airtime) log in sendBytes (added and total airtime)

FokkeZB commented 7 years ago

Also, don't the other commands like for join also cost air time?

n2jn commented 7 years ago

I might be wrong but doesn't the 30 seconds start when we successfully joined the ttn network ?

n2jn commented 7 years ago

@FokkeZB @johanstokking Should I put a limitation to sendbytes(), if the airtime reaches 30 s or if I receive 10 messages, I should stop the uplink and downlinks (I read that it was 10 messages downlink per day) ?

n2jn commented 7 years ago

@FokkeZB I printed the airtime in showstatus. The formula I used in trackAirtime() apply's to all SF, changing it will, I think, be no use to the user, and the airtime is going to reset everytime you close the workshop so think it's better to let trackAirtime() private. What I could do is put fillAirtimeInfo() public so that the user may change the values and may fool around with the airtime system.

johanstokking commented 7 years ago

@Nicolasdejean no blocking, also no fooling around by the user. It's just an indication on the node-side, as @FokkeZB said to change behavior. The tracking itself will be done in the Network Server, further upstream after the Router and Broker.

johanstokking commented 7 years ago

@FokkeZB can you test and merge?

FokkeZB commented 7 years ago

I will, but the branch has conflicts and is all dirty. It should be rebased and cherry picked.

johanstokking commented 7 years ago

@Nicolasdejean please resolve conflicts

johanstokking commented 7 years ago

Replaced by #84