Updated node 3 example
This commit is contained in:
parent
d142eb5771
commit
0aead0a3d9
1 changed files with 25 additions and 8 deletions
|
@ -27,6 +27,26 @@ void setup() {
|
||||||
Serial.println(state, HEX);
|
Serial.println(state, HEX);
|
||||||
while(true);
|
while(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Serial.print("[ESP8266] Joining AP ... ");
|
||||||
|
state = wifi.join("SSID", "PASSWORD");
|
||||||
|
if(state == ERR_NONE) {
|
||||||
|
Serial.println("success!");
|
||||||
|
} else {
|
||||||
|
Serial.print("failed, code 0x");
|
||||||
|
Serial.println(state, HEX);
|
||||||
|
while(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
Serial.print("[ESP8266] Connecting to MQTT broker ... ");
|
||||||
|
state = wifi.MqttConnect("broker.shiftr.io", "KiteNode3", "KiteNode3", "adea1a9c95ef8cb6");
|
||||||
|
if(state == ERR_NONE) {
|
||||||
|
Serial.println("success!");
|
||||||
|
} else {
|
||||||
|
Serial.print("failed, code 0x");
|
||||||
|
Serial.println(state, HEX);
|
||||||
|
while(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
|
@ -60,17 +80,14 @@ void loop() {
|
||||||
Serial.print(lora.lastPacketRSSI);
|
Serial.print(lora.lastPacketRSSI);
|
||||||
Serial.println(" dBm");
|
Serial.println(" dBm");
|
||||||
|
|
||||||
/*Serial.print("[ESP266] Sending HTTP POST ...");
|
Serial.print("[ESP8266] Publishing MQTT message ... ");
|
||||||
String response;
|
byte state = wifi.MqttPublish("Kite", String(pack.data));
|
||||||
int http_code = wifi.HttpPost("http://www.httpbin.org/ip", String(pack.data), response);
|
if(state == ERR_NONE) {
|
||||||
if(http_code == 200) {
|
|
||||||
Serial.println("success!");
|
Serial.println("success!");
|
||||||
Serial.println("[ESP8266] Response:\n");
|
|
||||||
Serial.println(response);
|
|
||||||
} else {
|
} else {
|
||||||
Serial.print("failed, code 0x");
|
Serial.print("failed, code 0x");
|
||||||
Serial.println(http_code, HEX);
|
Serial.println(state, HEX);
|
||||||
}*/
|
}
|
||||||
|
|
||||||
} else if(state == ERR_RX_TIMEOUT) {
|
} else if(state == ERR_RX_TIMEOUT) {
|
||||||
Serial.println("timeout!");
|
Serial.println("timeout!");
|
||||||
|
|
Loading…
Add table
Reference in a new issue