Skip to content

Commit d568a74

Browse files
Merge pull request #177 from TheThingsNetwork/example/node
Revert Node from landing config
2 parents 97af939 + 2e115dc commit d568a74

File tree

2 files changed

+11
-26
lines changed

2 files changed

+11
-26
lines changed

examples/Node/Decoder.js

+4-12
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
/**
22
* Use as payload decoder function.
33
*
4-
* 12 8E 00 21 09 5A
4+
* 12 8E 00 21 09 5A (port 2)
55
*
66
* {
77
* "event": "interval",
8-
* "device": "node",
98
* "battery": 4750,
109
* "light": 33,
1110
* "temperature": 23.94
@@ -22,17 +21,10 @@ function Decoder(bytes, port) {
2221
4: 'button'
2322
};
2423

25-
if (port > 10) {
26-
port = port - 10;
27-
decoded.device = 'uno';
28-
} else {
29-
decoded.device = 'node';
30-
decoded.battery = (bytes[0] << 8) + bytes[1];
31-
decoded.light = (bytes[2] << 8) + bytes[3];
32-
decoded.temperature = ((bytes[4] << 8) + bytes[5]) / 100;
33-
}
34-
3524
decoded.event = events[port];
25+
decoded.battery = (bytes[0] << 8) + bytes[1];
26+
decoded.light = (bytes[2] << 8) + bytes[3];
27+
decoded.temperature = ((bytes[4] << 8) + bytes[5]) / 100;
3628

3729
return decoded;
3830
}

examples/Node/Node.ino

+7-14
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
#include <TheThingsNetwork.h>
22
#include <TheThingsNode.h>
33

4-
// These keys are for https://ttn.fyi/activate
5-
// Replace them if you want to use your own app
6-
const char *appEui = "70B3D57EF0001CEE";
7-
const char *appKey = "F2E5C891560FF9CE24AD56E1A69B85DF";
4+
// Set your AppEUI and AppKey
5+
const char *appEui = "0000000000000000";
6+
const char *appKey = "00000000000000000000000000000000";
87

98
#define loraSerial Serial1
109
#define debugSerial Serial
1110

1211
// Replace REPLACE_ME with TTN_FP_EU868 or TTN_FP_US915
13-
#define freqPlan REPLACE_ME
12+
#define freqPlan TTN_FP_EU868
1413

1514
TheThingsNetwork ttn(loraSerial, debugSerial, freqPlan);
1615
TheThingsNode *node;
@@ -24,8 +23,8 @@ void setup() {
2423
loraSerial.begin(57600);
2524
debugSerial.begin(9600);
2625

27-
// Test LoRa module
28-
ttn.showStatus();
26+
// Wait a maximum of 10s for Serial Monitor
27+
while (!debugSerial && millis() < 10000);
2928

3029
// Config Node
3130
node = TheThingsNode::setup();
@@ -41,12 +40,6 @@ void setup() {
4140
node->showStatus();
4241
node->setColor(TTN_GREEN);
4342

44-
// Wait a maximum of 10s for Serial Monitor
45-
while (!debugSerial && millis() < 10000);
46-
47-
debugSerial.println("-- NODE: STATUS");
48-
node->showStatus();
49-
5043
debugSerial.println("-- TTN: STATUS");
5144
ttn.showStatus();
5245

@@ -97,7 +90,7 @@ void sendData(uint8_t port) {
9790
node->showStatus();
9891

9992
byte* bytes;
100-
byte payload[9];
93+
byte payload[6];
10194

10295
uint16_t battery = node->getBattery();
10396
bytes = (byte*) &battery;

0 commit comments

Comments
 (0)