Skip to content

Commit 89eef03

Browse files
committed
merge origin
2 parents b2cadf0 + b4c77dc commit 89eef03

File tree

2 files changed

+21
-38
lines changed

2 files changed

+21
-38
lines changed

README.md

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@ microgear-esp8266-arduino is a client library that is used to connect an ESP826
44

55
## Compatibility
66
We have tested this library and found it compatible with (but not limited to) the following hardware
7-
- ESP8266-01
8-
- ESP8266-12E
9-
- NodeMCU v1 ??? v2
7+
- ESP8266-01, 07, 12E, 12F
8+
- NodeMCU v1, v2, V3
109

1110
## Installation
1211
* Download Arduino IDE 1.6.5 from https://www.arduino.cc/en/Main/Software
@@ -32,10 +31,10 @@ Usage Example
3231
const char* ssid = <WIFI_SSID>;
3332
const char* password = <WIFI_KEY>;
3433

35-
#define APPID <APPID>
36-
#define GEARKEY <APPKEY>
37-
#define GEARSECRET <APPSECRET>
38-
#define SCOPE ""
34+
#define APPID <APPID>
35+
#define KEY <APPKEY>
36+
#define SECRET <APPSECRET>
37+
#define ALIAS "mygear"
3938

4039
WiFiClient client;
4140
AuthClient *authclient;
@@ -65,10 +64,9 @@ void onLostgear(char *attribute, uint8_t* msg, unsigned int msglen) {
6564

6665
void onConnected(char *attribute, uint8_t* msg, unsigned int msglen) {
6766
Serial.println("Connected to NETPIE...");
68-
microgear.setName("mygear");
67+
microgear.setAlias("mygear");
6968
}
7069

71-
7270
void setup() {
7371
/* Event listener */
7472
microgear.on(MESSAGE,onMsghandler);
@@ -92,7 +90,7 @@ void setup() {
9290

9391
//uncomment the line below if you want to reset token -->
9492
//microgear.resetToken();
95-
microgear.init(GEARKEY,GEARSECRET,SCOPE);
93+
microgear.init(KEY, SECRET, ALIAS);
9694
microgear.connect(APPID);
9795
}
9896
}
@@ -118,6 +116,7 @@ void loop() {
118116
}
119117
delay(100);
120118
}
119+
121120
```
122121
## Library Usage
123122
---
@@ -126,17 +125,10 @@ void loop() {
126125
**arguments**
127126
* *gearkey* `string` - is used as a microgear identity.
128127
* *gearsecret* `string` comes in a pair with gearkey. The secret is used for authentication and integrity.
129-
* *scope* `string` - specifies the right.
130-
131-
**scope** is an optional field. This can be specified when the microgear needs additional rights beyond default scope. If the scope is specified, it may need an approval from the Application ID's owner for each request. The scope format is the concatenation of strings in the following forms, separated with commas:
132-
133-
* [r][w]:&lt;/topic/path&gt; - r and w is the right to publish and subscribe topic as specified such as rw:/outdoor/temp
134-
* name:&lt;gearname&gt; - is the right to name the &lt;gearname&gt;
135-
* chat:&lt;gearname&gt; - is the right to chat with &lt;gearname&gt;
136-
In the key generation process on the web netpie.io, the developer can specify basic rights to each key. If the creation of microgear is within right scope, a token will be automatically issued, and the microgear can be connected to NETPIE immediately. However, if the requested scope is beyond the specified right, the developer will recieve a notification to approve a microgear's connection. Note that if the microgear has operations beyond its right (e.g., pulishing to the topic that it does not has the right to do so), NETPIE will automatically disconnect the microgear. In case that APPKEY is used as a gearkey, the developer can ignore this attribute since by default the APPKEY will gain all rights as the ownwer of the app.
128+
* *alias* `string` - specifies the device alias.
137129
138130
```c++
139131
microGear.init("sXfqDcXHzbFXiLk",
140132
"DNonzg2ivwS8ceksykGntrfQjxbL98",
141-
"r:/outdoor/temp,w:/outdoor/valve,name:logger,chat:plant");
142-
```
133+
"myplant");
134+
```

README.th.md

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ const char* ssid = <WIFI_SSID>;
3333
const char* password = <WIFI_KEY>;
3434

3535
#define APPID <APPID>
36-
#define GEARKEY <APPKEY>
37-
#define GEARSECRET <APPSECRET>
38-
#define SCOPE ""
36+
#define KEY <APPKEY>
37+
#define SECRET <APPSECRET>
38+
#define ALIAS "myplant"
3939

4040
WiFiClient client;
4141
AuthClient *authclient;
@@ -90,9 +90,7 @@ void setup() {
9090
Serial.println("IP address: ");
9191
Serial.println(WiFi.localIP());
9292

93-
//uncomment the line below if you want to reset token -->
94-
//microgear.resetToken();
95-
microgear.init(GEARKEY,GEARSECRET,SCOPE);
93+
microgear.init(KEY,SECRET,ALIAS);
9694
microgear.connect(APPID);
9795
}
9896
}
@@ -121,22 +119,15 @@ void loop() {
121119
```
122120
## การใช้งาน library
123121
---
124-
**microgear.init (*gearkey*, *gearsecret*, *scope*)**
122+
**microgear.init (*gearkey*, *gearsecret*, *alias*)**
125123
126124
**arguments**
127-
* *gearkey* `string` - เป็น key สำหรับ gear ที่จะรัน ใช้ในการอ้างอิงตัวตนของ gear
128-
* *gearsecret* `string` - เป็น secret ของ key ซึ่งจะใช้ประกอบในกระบวนการยืนยันตัวตน
129-
* *scope* `string` - เป็นการระบุขอบเขตของสิทธิ์ที่ต้องการ
130-
131-
**scope**
132-
เป็นการต่อกันของ string ในรูปแบบต่อไปนี้ คั่นด้วยเครื่องหมาย comma
133-
* [r][w]:&lt;/topic/path&gt; - r และ w คือสิทธิ์ในการ publish ละ subscribe topic ดังที่ระบุ เช่น rw:/outdoor/temp
134-
* name:&lt;gearname&gt; - คือสิทธิ์ในการตั้งชื่อตัวเองว่า &lt;gearname&gt;
135-
* chat:&lt;gearname&gt; - คือสิทธ์ในการ chat กับ &lt;gearname&gt;
136-
ในขั้นตอนของการสร้าง key บนเว็บ netpie.io นักพัฒนาสามารถกำหนดสิทธิ์ขั้นพื้นฐานให้แต่ละ key ได้อยู่แล้ว หากการ create microgear อยู่ภายใต้ขอบเขตของสิทธิ์ที่มี token จะถูกจ่ายอัตโนมัติ และ microgear จะสามารถเชื่อมต่อ netpie platform ได้ทันที แต่หาก scope ที่ร้องขอนั้นมากเกินกว่าสิทธิ์ที่กำหนดไว้ นักพัฒนาจะได้รับ notification ให้พิจารณาอนุมัติ microgear ที่เข้ามาขอเชื่อมต่อ ข้อควรระวัง หาก microgear มีการกระทำการเกินกว่าสิทธิ์ที่ได้รับไป เช่น พยายามจะ publish ไปยัง topic ที่ตัวเองไม่มีสิทธิ์ netpie จะตัดการเชื่อมต่อของ microgear โดยอัตโนมัติ ในกรณีที่ใช้ APPKEY เป็น gearkey เราสามารถละเว้น attribute นี้ได้ เพราะ APPKEY จะได้สิทธิ์ทุกอย่างในฐานะของเจ้าของ app โดย default อยู่แล้ว
125+
* *key* `string` - เป็น key สำหรับ gear ที่จะรัน ใช้ในการอ้างอิงตัวตนของ gear
126+
* *secret* `string` - เป็น secret ของ key ซึ่งจะใช้ประกอบในกระบวนการยืนยันตัวตน
127+
* *alias* `string` - เป็นการระบุชื่อของ device
137128
138129
```c++
139130
microGear.init("sXfqDcXHzbFXiLk",
140131
"DNonzg2ivwS8ceksykGntrfQjxbL98",
141-
"r:/outdoor/temp,w:/outdoor/valve,name:logger,chat:plant");
132+
"myplant");
142133
```

0 commit comments

Comments
 (0)