-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathexample-01.ino
More file actions
49 lines (40 loc) · 1.08 KB
/
example-01.ino
File metadata and controls
49 lines (40 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include <Arduino.h>
#include <PPNet.h>
#include <WiFi.h>
#define SOFTWARE_VERSION 0x00001
#define HARDWARE_REVISION 0x0003
PPNetwork::PPNet ppnet(&Serial1, PPNetwork::WriteTargetType::SUNTECH);
void setup()
{
Serial.begin(115200);
// We'll use Serial1 as our Suntech device
Serial1.begin(9600);
// start wifi so we have true random numbers
WiFi.mode(WIFI_STA);
WiFi.begin();
// get our unique ID
char devId[64];
snprintf(devId, sizeof(devId), "%llX", ESP.getEfuseMac());
// Since we just booted, we send a HELLO message to the server
ppnet.WriteMessage(PPNetwork::Message::HelloMessage {
// our unique board ID
.uniqueId = devId,
// the name of the board
.boardIdentifier = "DemoBoard",
// our current system version
.version = SOFTWARE_VERSION,
.boardVersion = HARDWARE_REVISION,
.bootId = esp_random(),
});
}
void loop()
{
// send one fake message every 5 seconds
ppnet.WriteMessage(PPNetwork::Message::SingleCounterMessage {
.kind = "MIO/PEN",
.value = 1,
.pulses = 6,
.duration_ms = 5000
});
delay(5000);
}