Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Towards V2.1 #458

Closed
wants to merge 62 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
f7bc627
Revert tree to v1.5.0 (dev now happens in develop branch)
marvinroger Sep 22, 2016
528a4f7
Use new name of Json library (#144)
marvinroger Sep 22, 2016
dad284b
:bug: Fix compatibility with ArduinoJson 5.11.0 (#362)
bblanchon Jun 29, 2017
f06f111
:bug: Backport fix for issue #178 into master/stable branch (#416)
nkaminski Nov 15, 2017
6b63e57
Refactor + Config changes
timpur Dec 22, 2017
cd3c6e7
Add last step to uibundle README (#460)
Dec 26, 2017
63fb96d
Update updater script addressing quirks (#461)
Dec 26, 2017
bbe347f
Fixed Config updates via patch.
timpur Dec 27, 2017
37f5b62
Added ability to set settings via code and save to config ( #457 ) + …
timpur Dec 29, 2017
494441d
Lint Fixes
timpur Dec 29, 2017
9faa2b9
Version Change
timpur Dec 29, 2017
74a21d0
Added getDeviceID
timpur Dec 29, 2017
b0ac5ff
Add the ability to access settings before setup ( #372 )
timpur Dec 30, 2017
e64784b
Fix to Refactor error for Settings.
timpur Dec 30, 2017
00843f3
TLS support + fingerprint attribute in config file ( #399 )
timpur Dec 30, 2017
3a15a2b
Minor Refactor of Limit Names
timpur Jan 1, 2018
2a8a8f1
Refactor SSL to only compile when enabled (`#if ASYNC_TCP_SSL_ENABLED`)
timpur Jan 1, 2018
87b01f0
Uupdated Homie log messages
timpur Jan 1, 2018
ef478e0
Lint Issues
timpur Jan 1, 2018
9f05e09
Update API for /wifi/connect from GET to PUT (#468)
tripflex Jan 3, 2018
6495a3e
Added Restart + Fixups
timpur Jan 7, 2018
73bb2ab
Fix #446 CORS Issue
timpur Jan 9, 2018
852a4d6
Config Mode - get current config
timpur Jan 11, 2018
cc8aee5
Merge remote-tracking branch 'remote/develop' into v2.1
timpur Jan 11, 2018
9025722
Refactor internal flags + OneButton + Switch between modes using Homi…
timpur Jan 17, 2018
02a054a
Inital Patch Via Config File #433
timpur Feb 21, 2018
57ecb0d
fix for #477 and Homie Button Config in arduino SDK
timpur Feb 22, 2018
de3c3b6
Small Fix ups + fix #462
timpur Feb 25, 2018
b5e8926
Show Homie version
timpur Mar 12, 2018
ffebed0
Lint + Small Fixed
timpur Mar 12, 2018
5288d7a
Touch ups + restore example
timpur Mar 12, 2018
da58af9
Small Fix
timpur Mar 12, 2018
3497d01
Fix to Homie Button on click reg
timpur Mar 12, 2018
b884730
Fix #446 CORS Issue
timpur Mar 18, 2018
f3cc890
Fix for #477
timpur Mar 18, 2018
07219fc
Fix Lint
timpur Mar 18, 2018
95d9566
Fix #446 #477 (#501)
timpur Mar 18, 2018
b7b6776
Fix Safari not displaying the config bundle HTML page (Fix #476) (#502)
timpur Mar 19, 2018
259841f
Merge branch 'develop' of https://github.com/marvinroger/homie-esp826…
timpur Mar 19, 2018
15201de
Merge
timpur Mar 19, 2018
03938e1
Update Readme Homie Version
timpur Mar 19, 2018
a464ddb
Merge branch 'develop' of https://github.com/marvinroger/homie-esp826…
timpur Mar 19, 2018
072fd9a
Merge branch 'develop' of https://github.com/marvinroger/homie-esp826…
timpur Mar 19, 2018
7f2acdb
Fix Warnings
timpur Mar 19, 2018
901076f
Fix Warnings (#503)
timpur Mar 19, 2018
9e83c6a
Minor Change from string to strcmp
timpur Mar 19, 2018
bfba03d
Update Readme - Homie Convention
timpur Mar 20, 2018
6ffa5ab
merge dev
timpur Mar 26, 2018
e229bc1
Update to use homie convention v2.0.1
timpur Mar 26, 2018
82c488b
Merge dev
timpur Mar 26, 2018
b17b626
Minor Fix
timpur Mar 26, 2018
99161ce
Update to Homie Convention v2.0.1 (#507)
timpur Mar 30, 2018
05fcbfd
Add getHomieBootMode
timpur Apr 1, 2018
c105381
Revert Beaking chnage
timpur May 27, 2018
d014eef
Release 2.0.0
timpur Jun 2, 2018
0e91734
Merge develop
timpur Jun 2, 2018
1e8e7a5
Merge branch 'develop' of https://github.com/marvinroger/homie-esp826…
timpur Jun 2, 2018
de31729
update file permissions
timpur Jun 2, 2018
f4396c4
update file permissions
timpur Jun 2, 2018
bc88b91
Merge branch 'develop' of https://github.com/timpur/homie-esp8266 int…
timpur Jun 2, 2018
53c08db
Update CI Build
timpur Jun 2, 2018
adb838c
Merge branch 'develop' into v2.1
timpur Jun 2, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ jobs:
- checkout
- run:
name: install PlatformIO
command: sudo pip install -U https://github.com/platformio/platformio-core/archive/develop.zip
command: sudo pip install -U platformio
- run:
name: install current code as a PlatformIO library with all dependencies
command: platformio lib -g install file://.
- run:
name: install staging version of Arduino Core for ESP8266
command: platformio platform install https://github.com/platformio/platform-espressif8266.git#feature/stage
name: install Arduino Core for ESP8266
command: platformio platform install espressif8266
- run:
name: install exemples dependencies
command: platformio lib -g install Shutters@2.1.1 SonoffDual@1.1.0
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ Homie for ESP8266

An Arduino for ESP8266 implementation of [Homie](https://github.com/marvinroger/homie), an MQTT convention for the IoT.

Currently Homie for ESP8266 implements [Homie 2.0.1](https://github.com/marvinroger/homie/releases/tag/v2.0.1)

## Note for v1.x users

The old configurator is not available online anymore. You can download it [here](https://github.com/marvinroger/homie-esp8266/releases/download/v1.5.0/homie-esp8266-v1-setup.zip).
Expand Down
4 changes: 3 additions & 1 deletion data/homie/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
This folder contains the data you can upload to the SPIFFS of your ESP8266.
This is optional.

To upload files to the SPIFFS of your device, create a folder named `data` in your sketch directory. In this `data` folder, create an `homie` directory. You can put two files in it:
To upload files to the SPIFFS of your device, first create a folder named `data` in your sketch directory. In this `data` folder, create an `homie` directory. You can put two files in it:

1. The `config.json` file, if you want to bypass the `configuration` mode.
2. The `ui_bundle.gz` file, that you can download [here](http://setup.homie-esp8266.marvinroger.fr/ui_bundle.gz). If present, the configuration UI will be served directly from the ESP8266.

Finally initiate the [SPIFFS upload process](http://docs.platformio.org/en/stable/platforms/espressif8266.html?highlight=spiffs#uploading-files-to-file-system-spiffs) via PlatformIO, or via the [Arduino IDE](http://esp8266.github.io/Arduino/versions/2.3.0/doc/filesystem.html#uploading-files-to-file-system)
14 changes: 14 additions & 0 deletions docs/advanced-usage/custom-settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,17 @@ For this example, if you want to provide the `percentage` setting, you will have
See the following example for a concrete use case:

[![GitHub logo](../assets/github.png) CustomSettings.ino](https://github.com/marvinroger/homie-esp8266/blob/develop/examples/CustomSettings/CustomSettings.ino)

You can also change the value of the setting at any time via updates to the config file or via code using:

```c++
percentageSetting.set(50, true);
```

You can also load the value of setthings from the config file before homie is setup. This is useful when you need these settings to setup nodes before you call `Homie.setup`.

```c++
Homie.loadSettings();
```

See the [API](http://marvinroger.github.io/homie-esp8266/docs/develop/others/cpp-api-reference/#homiesetting) for more information.
6 changes: 6 additions & 0 deletions docs/advanced-usage/miscellaneous.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ You can get access to the configuration of the device. The representation of the
struct ConfigStruct {
char* name;
char* deviceId;
uint16_t deviceStatsInterval;

struct WiFi {
char* ssid;
Expand All @@ -35,6 +36,11 @@ struct ConfigStruct {
struct Server {
char* host;
uint16_t port;
struct {
bool enabled;
bool hasFingerprint;
uint8_t fingerprint[MAX_FINGERPRINT_SIZE];
} ssl;
} server;
char* baseTopic;
bool auth;
Expand Down
95 changes: 92 additions & 3 deletions docs/configuration/http-json-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,10 @@ If anything goes wrong, a return code != 2xx will be returned, with a JSON `erro
```json
{
"hardware_device_id": "52a8fa5d",
"homie_esp8266_version": "2.0.0",
"homie_version": "2.0.0",
"homie_esp8266_version": "2.1.0",
"device_config_state": false,
"device_config_state_error": "ERROR MESSAGE",
"firmware": {
"name": "awesome-device",
"version": "1.0.0"
Expand Down Expand Up @@ -116,6 +119,60 @@ If anything goes wrong, a return code != 2xx will be returned, with a JSON `erro

--------------

??? summary "GET `/config`"
Retrieve the Config file of the device.

## Response

!!! success "In case of success"
`200 OK (application/json)`

```json
{
"name": "The kitchen light",
"device_id": "kitchen-light",
"device_stats_interval": 60,
"wifi": {
"ssid": "Network_1",
"password": "I'm a Wi-Fi password!",
"bssid": "DE:AD:BE:EF:BA:BE",
"channel": 1,
"ip": "192.168.1.5",
"mask": "255.255.255.0",
"gw": "192.168.1.1",
"dns1": "8.8.8.8",
"dns2": "8.8.4.4"
},
"mqtt": {
"host": "192.168.1.10",
"port": 1883,
"base_topic": "devices/",
"auth": true,
"username": "user",
"password": "pass",
"ssl": true,
"ssl_fingerprint": "a27992d3420c89f293d351378ba5f5675f74fe3c"
},
"ota": {
"enabled": true
},
"settings": {
"percentage": 55
}
}
```

!!! failure "In case there was something wrong loading the current config."
`500 Service Unavailable (application/json)`

```json
{
"error": "ERROR MESSAGE"
}
```

--------------

??? summary "PUT `/config`"
Save the config to the device.

Expand Down Expand Up @@ -158,7 +215,39 @@ If anything goes wrong, a return code != 2xx will be returned, with a JSON `erro

--------------

??? summary "GET `/wifi/connect`"
??? summary "POST `/config/patch`"
Save the config to the device via incremental patches.

## Request body

`(application/json)`

See [JSON configuration file](json-configuration-file.md).

## Response

!!! success "In case of success"
`200 OK (application/json)`

```json
{
"success": true
}
```

!!! failure "In case of error in the payload"
`400 Bad Request (application/json)`

```json
{
"success": false,
"error": "Reason why the payload is invalid"
}
```

--------------

??? summary "POST `/wifi/connect`"
Initiates the connection of the device to the Wi-Fi network while in configuation mode. This request is not synchronous and the result (Wi-Fi connected or not) must be obtained by with `GET /wifi/status`.

## Request body
Expand Down Expand Up @@ -221,7 +310,7 @@ If anything goes wrong, a return code != 2xx will be returned, with a JSON `erro

--------------

??? summary "PUT `/proxy/control`"
??? summary "POST `/proxy/control`"
Enable/disable the device to act as a transparent proxy between AP and Station networks.

All requests that don't collide with existing API paths will be bridged to the destination according to the `Host` HTTP header. The destination host is called using the existing Wi-Fi connection (established after a `PUT /wifi/connect`) and all contents are bridged back to the connection made to the AP side.
Expand Down
8 changes: 6 additions & 2 deletions docs/configuration/json-configuration-file.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ Below is the format of the JSON configuration you will have to provide:
"base_topic": "devices/",
"auth": true,
"username": "user",
"password": "pass"
"password": "pass",
"ssl": true,
"ssl_fingerprint": "a27992d3420c89f293d351378ba5f5675f74fe3c"
},
"ota": {
"enabled": true
Expand All @@ -45,7 +47,8 @@ Here are the rules:
* `bssid`, `channel`, `ip`, `mask`, `gw`, `dns1`, `dns2` are not mandatory and are only needed to if there is a requirement to specify particular AP or set Static IP address. There are some rules which needs to be satisfied:
- `bssid` and `channel` have to be defined together and these settings are independand of settings related to static IP
- to define static IP, `ip` (IP address), `mask` (netmask) and `gw` (gateway) settings have to be defined at the same time
- to define second DNS `dns2` the first one `dns1` has to be defined. Set DNS without `ip`, `mask` and `gw` does not affect the configuration (dns server will be provided by DHCP). It is not required to set DNS servers.
- to define second DNS `dns2` the first one `dns1` has to be defined. Set `ip`, `mask` and `gw` without DNS, does not affect the configuration (dns server will be provided by DHCP). It is not required to set DNS servers.
* `ssl_fingerprint` is not required if `ssl` is enabled.


Default values if not provided:
Expand All @@ -55,5 +58,6 @@ Default values if not provided:
* `mqtt.port`: `1883`
* `mqtt.base_topic`: `homie/`
* `mqtt.auth`: `false`
* `mqtt.ssl`: `false`

The `mqtt.host` field can be either an IP or an hostname.
57 changes: 50 additions & 7 deletions docs/others/cpp-api-reference.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Homie
## Main

You don't have to instantiate an `Homie` instance, it is done internally.

Expand All @@ -20,7 +21,7 @@ Handle Homie work.
!!! warning "Mandatory!"
Must be called once in `loop()`.

## Functions to call *before* `Homie.setup()`
### Functions to call *before* `Homie.setup()`

```c++
void Homie_setFirmware(const char* name, const char* version);
Expand All @@ -45,6 +46,16 @@ Set the brand of the device, used in the configuration AP, the device hostname a

* **`name`**: Name of the brand. Default value is `Homie`

```c++
bool loadSettings();
```

Validates settings and loads the config file setting values. Returns true if the config file load was successful and false if it failed.

**Note**, if config file load faild then only default values will be present.

**Note**, since this method loads the config file, you can also use `getConfiguration()` before `setup()`.

```c++
Homie& disableLogging();
```
Expand Down Expand Up @@ -119,7 +130,7 @@ Set the event handler. Useful if you want to hook to Homie events.
Homie& setResetTrigger(uint8_t pin, uint8_t state, uint16_t time);
```

Set the reset trigger. By default, the device will reset when pin `0` is `LOW` for `5000`ms.
Set the reset trigger and the Homie Button. By default, the device will reset when pin `0` is `LOW` for `5000`ms. This Homie button can also be used by the user with `setHomieButtonClick(fnc)` and also used to swap between boot modes. This is usefull to update the config.

* **`pin`**: Pin of the reset trigger
* **`state`**: Reset when the pin reaches this state for the given time
Expand Down Expand Up @@ -153,13 +164,27 @@ Homie& setStandalone();

This will mark the Homie firmware as standalone, meaning it will first boot in `standalone` mode. To configure it and boot to `configuration` mode, the device has to be resetted.

## Functions to call *after* `Homie.setup()`
```c++
HomieClass& setHomieButtonClick(std::function<void()> function);
```

You can provide the function that will be called when the homie button is clicked.

* **`callback`**: Loop function

### Functions to call *after* `Homie.setup()`

```c++
void reboot();
```

Flag the device for reboot (restart).

```c++
void reset();
```

Flag the device for reset.
Flag the device for reset (Wipes config).

```c++
void setIdle(bool idle);
Expand All @@ -179,7 +204,7 @@ Prepare the device for deep sleep. It ensures messages are sent and disconnects
void doDeepSleep(uint32_t time_us = 0, RFMode mode = RF_DEFAULT);
```

Puth the device into deep sleep. It ensures the Serial is flushed.
Puts the device into deep sleep. It ensures the Serial is flushed.

```c++
bool isConfigured() const;
Expand Down Expand Up @@ -214,9 +239,21 @@ Logger& getLogger();

Get the underlying `Logger` object, which is only a wrapper around `Serial` by default.

```c++
String getDeviceID();
```

Get the Device ID, which homie is using. Could be the config `device_id` or the inertnal device `mac`.

```c++
HomieBootMode getHomieBootMode();
```

Get the boot mode of homie: `UNDEFINED,STANDALONE,CONFIGURATION,NORMAL`.

-------

# HomieNode
## HomieNode

```c++
HomieNode(const char* id, const char* type, std::function<bool(const String& property, const HomieRange& range, const String& value)> handler = );
Expand Down Expand Up @@ -282,7 +319,7 @@ uint16_t send(const String& value); // finally send the property, return the pa

Method names should be self-explanatory.

# HomieSetting
## HomieSetting

```c++
HomieSetting<T>(const char* name, const char* description);
Expand All @@ -300,6 +337,12 @@ T get() const;

Get the default value if the setting is optional and not provided, or the provided value if the setting is required or optional but provided.

```c++
bool set(T value, bool saveToConfig = false);
```

Sets the setting to a new value. Use `saveToConfig` to eaither save this new value to the config file or just use it in memory.

```c++
bool wasProvided() const;
```
Expand Down
4 changes: 4 additions & 0 deletions docs/others/homie-implementation-specifics.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ The Homie `$implementation` identifier is `esp8266`.

* `$implementation/reset`: You can publish a `true` to this topic to reset the device

# Restart

* `$implementation/restart`: You can publish a `true` to this topic to restart the device

# Configuration

* `$implementation/config`: The `configuration.json` is published there, with `wifi.password`, `mqtt.username` and `mqtt.password` fields stripped
Expand Down
2 changes: 1 addition & 1 deletion docs/quickstart/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ There is a YouTube video with instructions:

Homie for ESP8266 has 5 dependencies:

* [ArduinoJson](https://github.com/bblanchon/ArduinoJson) >= 5.0.8
* [ArduinoJson](https://github.com/bblanchon/ArduinoJson) >= 5.10.0
* [Bounce2](https://github.com/thomasfredericks/Bounce2)
* [ESPAsyncTCP](https://github.com/me-no-dev/ESPAsyncTCP) >= [c8ed544](https://github.com/me-no-dev/ESPAsyncTCP)
* [AsyncMqttClient](https://github.com/marvinroger/async-mqtt-client)
Expand Down
Loading