Skip to content

Commit f33745e

Browse files
committed
Code style
1 parent 7020915 commit f33745e

File tree

3 files changed

+58
-60
lines changed

3 files changed

+58
-60
lines changed

src/TheThingsNetwork.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,14 @@ const char* const compare_table[] PROGMEM = {ok,on,off,accepted,mac_tx_ok,mac_rx
3232

3333
const char eui[] PROGMEM = "EUI: ";
3434
const char battery[] PROGMEM = "Battery: ";
35-
const char appEui[] PROGMEM = "AppEui: ";
36-
const char devEui[] PROGMEM = "DevEui: ";
35+
const char appEui[] PROGMEM = "AppEUI: ";
36+
const char devEui[] PROGMEM = "DevEUI: ";
3737
const char band[] PROGMEM = "Band: ";
3838
const char data_rate[] PROGMEM = "Data Rate: ";
3939
const char rx_delay_1[] PROGMEM = "RX Delay 1: ";
4040
const char rx_delay_2[] PROGMEM = "RX Delay 2: ";
4141
const char total_airtime[] PROGMEM = "Total Airtime: ";
42-
const char airtime_added[] PROGMEM = "Airtime added: ";
42+
const char airtime_added[] PROGMEM = "Airtime Added: ";
4343
const char version[] PROGMEM = "Version is ";
4444
const char model[] PROGMEM = ", model is ";
4545

@@ -260,7 +260,7 @@ TheThingsNetwork::TheThingsNetwork(Stream& modemStream, Stream& debugStream, ttn
260260
this->fsb = fsb;
261261
}
262262

263-
const char *TheThingsNetwork::readLine() {
263+
uint32_t TheThingsNetwork::readLine(const byte* buffer, uint32_t size) {
264264
char get_bytes[TTN_BUFFER_SIZE];
265265
char get_buffer[TTN_BUFFER_SIZE];
266266
for (size_t i = TTN_BUFFER_SIZE; i--; ) {

src/TheThingsNetwork.h

Lines changed: 52 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,21 @@
1919

2020
typedef uint8_t port_t;
2121

22-
enum ttn_response_t {
22+
enum ttn_response_t
23+
{
2324
TTN_ERROR_SEND_COMMAND_FAILED = (-1),
2425
TTN_ERROR_UNEXPECTED_RESPONSE = (-10),
2526
TTN_SUCCESSFUL_TRANSMISSION = 1,
2627
TTN_SUCCESSFUL_RECEIVE = 2
2728
};
2829

29-
enum ttn_fp_t {
30+
enum ttn_fp_t
31+
{
3032
TTN_FP_EU868,
3133
TTN_FP_US915
3234
};
3335

34-
typedef struct airtime_s
36+
typedef struct airtime_s
3537
{
3638
uint8_t sf;
3739
uint8_t de;
@@ -43,55 +45,55 @@ typedef struct airtime_s
4345

4446
class TheThingsNetwork
4547
{
46-
private:
47-
port_t port;
48-
Stream* modemStream;
49-
Stream* debugStream;
50-
bool model_EU;
51-
airtime_t info;
52-
ttn_fp_t fp;
53-
uint8_t sf;
54-
uint8_t fsb;
55-
void (* messageCallback)(const byte* payload, size_t length, port_t port);
48+
private:
49+
port_t port;
50+
Stream *modemStream;
51+
Stream *debugStream;
52+
bool model_EU;
53+
airtime_t info;
54+
ttn_fp_t fp;
55+
uint8_t sf;
56+
uint8_t fsb;
57+
void (*messageCallback)(const byte *payload, size_t length, port_t port);
5658

57-
const char *readLine();
58-
void fillAirtimeInfo();
59-
void trackAirtime(size_t payloadSize);
60-
void reset(bool adr = true);
61-
void configureEU868(uint8_t sf);
62-
void configureUS915(uint8_t sf, uint8_t fsb);
63-
void configureChannels(uint8_t sf, uint8_t fsb);
64-
bool waitForOk();
65-
void sendCommand(uint8_t table, uint8_t index, bool with_space, bool print = true);
66-
bool sendMacSet(uint8_t index, const char* setting);
67-
bool sendChSet(uint8_t index, uint8_t channel, const char* setting);
68-
bool sendJoinSet(uint8_t type);
69-
bool sendPayload(uint8_t mode, uint8_t port, uint8_t* payload, size_t len);
70-
void sendGetValue(uint8_t table, uint8_t prefix, uint8_t index);
71-
const char *subString(const char *response, int16_t start, int16_t end = -2);
72-
bool compareStrings(const char *str1, uint8_t msg, size_t length = -2);
73-
uint8_t receivedPort(const char *response, size_t length);
74-
size_t bufLength(const char *data);
75-
size_t portLength(size_t port);
76-
const char *readValue(uint8_t prefixTable, uint8_t indexTable, uint8_t index);
77-
const char *readValue(uint8_t table, uint8_t index);
78-
void stateMessage(uint8_t type, uint8_t indexMsg, const char *output = NULL);
79-
void valueToShow(uint8_t index, const char *value = NULL);
59+
uint32_t readLine(const byte *buffer, uint32_t size);
60+
void fillAirtimeInfo();
61+
void trackAirtime(size_t payloadSize);
62+
void reset(bool adr = true);
63+
void configureEU868(uint8_t sf);
64+
void configureUS915(uint8_t sf, uint8_t fsb);
65+
void configureChannels(uint8_t sf, uint8_t fsb);
66+
bool waitForOk();
67+
void sendCommand(uint8_t table, uint8_t index, bool with_space, bool print = true);
68+
bool sendMacSet(uint8_t index, const char *setting);
69+
bool sendChSet(uint8_t index, uint8_t channel, const char *setting);
70+
bool sendJoinSet(uint8_t type);
71+
bool sendPayload(uint8_t mode, uint8_t port, uint8_t *payload, size_t len);
72+
void sendGetValue(uint8_t table, uint8_t prefix, uint8_t index);
73+
const char *subString(const char *response, int16_t start, int16_t end = -2);
74+
bool compareStrings(const char *str1, uint8_t msg, size_t length = -2);
75+
uint8_t receivedPort(const char *response, size_t length);
76+
size_t bufLength(const char *data);
77+
size_t portLength(size_t port);
78+
const char *readValue(uint8_t prefixTable, uint8_t indexTable, uint8_t index);
79+
const char *readValue(uint8_t table, uint8_t index);
80+
void stateMessage(uint8_t type, uint8_t indexMsg, const char *output = NULL);
81+
void valueToShow(uint8_t index, const char *value = NULL);
8082

81-
public:
82-
TheThingsNetwork(Stream& modemStream, Stream& debugStream, ttn_fp_t fp, uint8_t sf = TTN_DEFAULT_SF, uint8_t fsb = TTN_DEFAULT_FSB);
83-
float airtime;
84-
float calculateAirtime(size_t payload);
85-
void showStatus();
86-
void onMessage(void (*cb)(const byte* payload, size_t length, port_t port));
87-
bool provision(const char *appEui, const char *appKey);
88-
bool join(const char *appEui, const char *appKey, int8_t retries = -1, uint32_t retryDelay = 10000);
89-
bool join(int8_t retries = -1, uint32_t retryDelay = 10000);
90-
bool personalize(const char *devAddr, const char *nwkSKey, const char *appSKey);
91-
bool personalize();
92-
ttn_response_t sendBytes(const byte* payload, size_t length, port_t port = 1, bool confirm = false);
93-
void sleep(unsigned long mseconds);
94-
int8_t poll(port_t port = 1, bool confirm = false);
83+
public:
84+
TheThingsNetwork(Stream &modemStream, Stream &debugStream, ttn_fp_t fp, uint8_t sf = TTN_DEFAULT_SF, uint8_t fsb = TTN_DEFAULT_FSB);
85+
float airtime;
86+
float calculateAirtime(size_t payload);
87+
void showStatus();
88+
void onMessage(void (*cb)(const byte *payload, size_t length, port_t port));
89+
bool provision(const char *appEui, const char *appKey);
90+
bool join(const char *appEui, const char *appKey, int8_t retries = -1, uint32_t retryDelay = 10000);
91+
bool join(int8_t retries = -1, uint32_t retryDelay = 10000);
92+
bool personalize(const char *devAddr, const char *nwkSKey, const char *appSKey);
93+
bool personalize();
94+
ttn_response_t sendBytes(const byte *payload, size_t length, port_t port = 1, bool confirm = false);
95+
void sleep(unsigned long mseconds);
96+
int8_t poll(port_t port = 1, bool confirm = false);
9597
};
9698

9799
#endif

src/TheThingsNode.h

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,9 @@ enum ttn_color: byte
3030
class TheThingsNode
3131
{
3232
private:
33-
34-
// private constructor to achieve singleton pattern
3533
TheThingsNode();
36-
TheThingsNode(TheThingsNode const&); // copy disabled
37-
void operator=(TheThingsNode const&); // assigment disabled
34+
TheThingsNode(TheThingsNode const&);
35+
void operator=(TheThingsNode const&);
3836

3937
bool intervalEnabled;
4038
uint32_t intervalMs;
@@ -73,8 +71,6 @@ class TheThingsNode
7371
void deepSleep(void);
7472

7573
public:
76-
77-
// static method to get the instance
7874
static TheThingsNode* setup() {
7975
static TheThingsNode node;
8076
return &node;

0 commit comments

Comments
 (0)