Skip to content

Commit eaa3f4f

Browse files
committed
transform sketch as a library, and add examples
1 parent 8d4f8c6 commit eaa3f4f

30 files changed

+2319
-1015
lines changed

AloesDevice.h

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
#ifndef AloesDevice_h
2+
#define AloesDevice_h
3+
4+
// #include <Arduino.h>
5+
6+
#include <FS.h>
7+
#include <advancedSerial.h>
8+
9+
#include <ESP8266WiFi.h>
10+
#include <ESP8266WiFiMulti.h>
11+
#include <ESP8266httpUpdate.h>
12+
#include <ESP8266mDNS.h>
13+
// #include <DNSServer.h>
14+
#include <TimeLib.h>
15+
#include <Wire.h>
16+
17+
18+
#if CLIENT_SECURE == 1
19+
#include <WiFiClientSecure.h>
20+
#endif
21+
22+
#include <ESP8266WebServer.h>
23+
#include <WiFiManager.h>
24+
#include <ArduinoJson.h>
25+
26+
#include "lib/Constants.h"
27+
28+
ESP8266WiFiMulti WiFiMulti;
29+
30+
#if CLIENT_SECURE == 0
31+
WiFiClient wifiClient;
32+
#elif CLIENT_SECURE == 1
33+
WiFiClientSecure wifiClient;
34+
#endif
35+
36+
Config config;
37+
Message message;
38+
39+
// todo :remove from global but need to change attachInterrupt callback signature ?
40+
WiFiManager wifiManager;
41+
42+
43+
#include "lib/Helpers.cpp"
44+
Helpers helpers;
45+
46+
#include "lib/Transport.cpp"
47+
#if MQTT_CLIENT == 1
48+
Transport transport(wifiClient);
49+
#elif WEB_SERVER == 1
50+
ESP8266WebServer server(80);
51+
WiFiClient client = server.client();
52+
Transport transport(client);
53+
#endif
54+
55+
#include "lib/Network.cpp"
56+
Network network(config);
57+
58+
#include "lib/Manager.cpp"
59+
Manager manager(config);
60+
61+
#include "lib/Aloes.cpp"
62+
extern Aloes aloes;
63+
Aloes aloes;
64+
65+
#include "lib/Exec.cpp"
66+
67+
#endif

README.md

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Arduino-device-mqtt
22

3-
ESP8266 arduino sketch to interact with [Aloes backend](https://framagit.org/aloes/device-manager) MQTT API.
3+
ESP8266 arduino library to interact with [Aloes backend](https://framagit.org/aloes/device-manager) MQTT API.
44

55

66
## Requirements
@@ -13,37 +13,29 @@ Packages for ESP8266
1313

1414
- Enter `http://arduino.esp8266.com/stable/package_esp8266com_index.json` into Additional Board Manager URLs field.
1515

16-
following libraries are required :
17-
18-
- ArduinoJson
19-
- Bounce2
20-
- FS
21-
- Ticker
22-
- WifiManager
2316

2417
## Installation
2518

19+
- Via git, clone into your `~/Arduino/Libraries` folder
2620
```
2721
git clone https://framagit.org/aloes/arduino-device-mqtt.git
2822
```
2923

24+
- Via Arduino Library Manager, look for AloesDevice
25+
26+
3027
## Usage
3128

3229
- Open any .ino file of the folder with Arduino IDE
3330

3431
- Edit your preferences in `config.h`
3532

36-
- Upload the code on your ESP8266 board
33+
- Enter wifi and device credentials or configure the board via the Access Point ( 192.168.244.1 )
3734

38-
#if using MQTT_CLIENT
35+
- Configure your sensors following [Open Mobile Alliance LwM2M Registry](http://openmobilealliance.org/wp/OMNA/LwM2M/LwM2MRegistry.html) ( see examples )
3936

40-
- Copy the deviceId ( generated at setup on the serial interface ) to Aloes backend
41-
42-
- Enter wifi and device credentials in `config.h` or configure the board via the Access Point ( 192.168.244.1 )
43-
44-
#endif
37+
- Upload the code on your ESP8266 board
4538

39+
- Copy the deviceId ( generated at setup on the serial interface ) to Aloes backend
4640

47-
## Reference
4841

49-
- Set resetConfig to true, to restore default state at reset

0 commit comments

Comments
 (0)