TheThingsNetwork / arduino-device-lib

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

Make `fp` argument a const in the examples #134

Closed FokkeZB closed 7 years ago

FokkeZB commented 7 years ago

I've already seen several people run into not noticing they have to select either frequency plan:

https://github.com/TheThingsNetwork/arduino-device-lib/blob/master/examples/Send/Send.ino#L3-L10

We should change this to:

const char *appEui = "0000000000000000";
const char *appKey = "00000000000000000000000000000000";
const ttn_fp_t freqPlan = // Use either TTN_FP_EU868; or TTN_FP_US915; here

#define loraSerial Serial1
#define debugSerial Serial

TheThingsNetwork ttn(loraSerial, debugSerial, freqPlan);

@johanstokking I know you don't like to default to either plan, but it has surprised me how people didn't even notice it was a comment they needed to replace with either values. Also, with the above change the examples will not have a syntax error, which is also convenient for #121

johanstokking commented 7 years ago

Hm. So if error A is that people don't notice it's a comment but they need to change it, and error B is that they just hit compile and upload to debug forever that it doesn't work, which error is worse? Can't we solve this with comments? RTFM?

BTW, it's not a pointer

FokkeZB commented 7 years ago

Agree. I think it's also the place and type of (block) comment that confused people. I changed the above example to use standard // comment and by setting it via a const I think it's much clearer now.

johanstokking commented 7 years ago

Yes. And the ; to make it foolproof!

FokkeZB commented 7 years ago

Like now?

johanstokking commented 7 years ago

Yep

FokkeZB commented 7 years ago

Closed by #138