From 8bf0243739f7a1eaac8b5e3bc3b19c49a907cc47 Mon Sep 17 00:00:00 2001 From: Chavee Issariyapat Date: Tue, 31 May 2016 15:20:39 +0700 Subject: [PATCH] Update README.md --- README.md | 106 ++++++++++++++++++++++++++---------------------------- 1 file changed, 51 insertions(+), 55 deletions(-) diff --git a/README.md b/README.md index 1a36c16..3f54eed 100644 --- a/README.md +++ b/README.md @@ -6,9 +6,10 @@ microgear-esp8266-arduino is a client library that is used to connect an ESP826 We have tested this library and found it compatible with (but not limited to) the following hardware - ESP8266-01, 07, 12E, 12F - NodeMCU v1, v2, V3 +- Espresso Lite v2.0 ## Installation -* Download Arduino IDE 1.6.5 from https://www.arduino.cc/en/Main/Software +* Download Arduino IDE 1.6.9 or later from https://www.arduino.cc/en/Main/Software * After installation, open Preferences * Enter `http://arduino.esp8266.com/stable/package_esp8266com_index.json`in the field Additional Board Manager URLs * Open Boards Manager menu Tools. Search for `esp8266` and click install @@ -19,22 +20,16 @@ We have tested this library and found it compatible with (but not limited to) th Usage Example ```c++ -#include -#include -#include -#include -#include #include -#include #include const char* ssid = ; const char* password = ; -#define APPID +#define APPID #define KEY #define SECRET -#define ALIAS "mygear" +#define ALIAS "esp8266" WiFiClient client; AuthClient *authclient; @@ -43,30 +38,31 @@ int timer = 0; MicroGear microgear(client); void onMsghandler(char *topic, uint8_t* msg, unsigned int msglen) { - Serial.print("Incoming message --> "); - msg[msglen] = '\0'; - Serial.println((char *)msg); + Serial.print("Incoming message --> "); + msg[msglen] = '\0'; + Serial.println((char *)msg); } void onFoundgear(char *attribute, uint8_t* msg, unsigned int msglen) { - Serial.print("Found new member --> "); - for (int i=0; i "); + for (int i=0; i "); - for (int i=0; i "); + for (int i=0; i - //microgear.resetToken(); - microgear.init(KEY, SECRET, ALIAS); - microgear.connect(APPID); - } + //uncomment the line below if you want to reset token --> + //microgear.resetToken(); + microgear.init(KEY,SECRET,ALIAS); + microgear.connect(APPID); } void loop() { - if (microgear.connected()) { - Serial.println("connected"); - microgear.loop(); - if (timer >= 1000) { - Serial.println("Publish..."); - microgear.chat("mygear","Hello"); - timer = 0; - } - else timer += 100; - } - else { - Serial.println("connection lost, reconnect..."); - if (timer >= 5000) { - microgear.connect(APPID); - timer = 0; + if (microgear.connected()) { + Serial.println("connected"); + microgear.loop(); + if (timer >= 1000) { + Serial.println("Publish..."); + microgear.chat(ALIAS,"Hello"); + timer = 0; + } + else timer += 100; } - else timer += 100; - } - delay(100); + else { + Serial.println("connection lost, reconnect..."); + if (timer >= 5000) { + microgear.connect(APPID); + timer = 0; + } + else timer += 100; + } + delay(100); } - ``` ## Library Usage --- **microgear.init (*key*, *secret*, *alias*)** **arguments** -* *gearkey* `string` - is used as a microgear identity. -* *gearsecret* `string` comes in a pair with gearkey. The secret is used for authentication and integrity. +* *key* `string` - is used as a microgear identity. +* *secret* `string` comes in a pair with gearkey. The secret is used for authentication and integrity. * *alias* `string` - specifies the device alias. ```c++ @@ -132,3 +127,4 @@ microGear.init("sXfqDcXHzbFXiLk", "DNonzg2ivwS8ceksykGntrfQjxbL98", "myplant"); ``` +