You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Once the platform and libraries are downloaded the back end should be compiling.
47
49
48
50
> **WINDOWS BUILDS**: If building under Windows you need to delete .piolibdeps/Time/Time.h - due to a [file system case insensitivity issue](https://github.com/me-no-dev/ESPAsyncWebServer/issues/96)
49
51
52
+
#### Uploading the firmware
53
+
54
+
Standard configuration settings, such as build flags, libraries and device configuration can be found in ['platformio.ini'](platformio.ini). The project is configured to upload via serial by default, you can change the upload mechanism to OTA by uncommenting the relevant lines.
55
+
56
+
See the [PlatformIO docs](http://docs.platformio.org/en/latest/projectconf.html) for full details on what you can do with this.
57
+
58
+
Click the upload button in PlatformIO, or type the upload command if prefer the command line approach:
59
+
60
+
```bash
61
+
platformio run -t upload
62
+
```
63
+
64
+

65
+
50
66
### Building the interface
51
67
52
-
The interface has been configured with create-react-app and react-app-rewired so the build can customized for the target device. The large artefacts are gzipped and source maps and service worker are excluded from the production build.
68
+
The interface has been configured with create-react-app and react-app-rewired so the build can customized for the target device. The large artefacts are gzipped and source maps and service worker are excluded from the production build. This reduces the production build to around ~200k, which easily fits on the device.
53
69
54
-
Change to this directory with your bash shell (or Git Bash) and use the standard commands you would with any react app built with create-react-app:
70
+
Change to the ['interface'](interface) directory with your bash shell (or Git Bash) and use the standard commands you would with any react app built with create-react-app:
55
71
56
72
#### Change to interface directory
57
73
@@ -73,31 +89,85 @@ npm run build
73
89
74
90
> **Note**: The build command will also delete the previously built interface, in the ['data/www'](data/www) directory, replacing it with the freshly built one ready to upload to the device.
75
91
76
-
####Running the interface locally
92
+
### Running the interface locally
77
93
78
-
You can run a local development server during development to preview changes to the front end them without uploading a file system image to the device.
94
+
You can run a local development server during development to preview changes to the front end them without the need to upload a file system image to the device after each change.
79
95
80
96
```bash
81
97
npm start
82
98
```
83
99
84
100
> **Note**: To run the interface locally you will need to modify the endpoint root path and enable CORS.
85
101
86
-
The endpoint root path can be found in .env.development, defined as the environment variable 'REACT_APP_ENDPOINT_ROOT'. This needs to be the root URL of the device running the back end, for example:
102
+
#### Changing the endpoint root
103
+
104
+
The endpoint root path can be found in ['interface/.env.development'](interface/.env.development), defined as the environment variable 'REACT_APP_ENDPOINT_ROOT'. This needs to be the root URL of the device running the back end, for example:
87
105
88
106
```js
89
107
REACT_APP_ENDPOINT_ROOT=http://192.168.0.6/rest/
90
108
```
91
109
92
-
CORS can be enabled on the back end by uncommenting the -D ENABLE_CORS build flag in platformio.ini and re-deploying.
110
+
#### Enabling CORS
111
+
112
+
You can enable CORS on the back end by uncommenting the -D ENABLE_CORS build flag in ['platformio.ini'](platformio.ini) then re-building and uploading the firmware to the device. The default settings assume you will be accessing the development server on the default port on [http://localhost:3000](http://localhost:3000) this can also be changed if required:
113
+
114
+
```
115
+
-D ENABLE_CORS
116
+
-D CORS_ORIGIN=\"http://localhost:3000\"
117
+
```
118
+
119
+
## Device Configuration
120
+
121
+
As well as containing the interface, the SPIFFS image (in the ['data'](data) folder) contains a JSON settings file for each of the configurable features. The config files can be found in the ['data/config'](data/config) directory:
122
+
123
+
File | Description
124
+
---- | -----------
125
+
[apSettings.json](data/config/apSettings.json) | Access point settings
The default settings configure the device to bring up an access point on start up which can be used to configure the device:
132
+
133
+
* SSID: ESP8266-React
134
+
* Password: esp-react
135
+
136
+
### Building for different devices
137
+
138
+
This project supports ESP8266 and ESP32 platforms. To support OTA programming, enough free space to upload the new sketch and file system image will be required. It is recommended that a board with at least 2mb of flash is used.
139
+
140
+
By default, the target device is "esp12e". This is a common ESP8266 variant with 4mb of flash:
141
+
142
+

143
+
144
+
The settings file ['platformio.ini'](platformio.ini) configures the platform and board:
145
+
146
+
```
147
+
[env:esp12e]
148
+
platform = espressif8266
149
+
board = esp12e
150
+
```
151
+
152
+
If you want to build for an ESP32 device, all you need to do is re-configure ['platformio.ini'](platformio.ini) with your devices settings.
153
+
154
+

155
+
156
+
Building for the common esp32 "node32s" board for example requires the following configuration:
157
+
158
+
```
159
+
[env:node32s]
160
+
platform = espressif32
161
+
board = node32s
162
+
```
93
163
94
164
## Customizing and theming
95
165
96
166
The framework, and MaterialUI allows for a good degree of custoimzation with little effort.
97
167
98
168
### Theming the app
99
169
100
-
The app can be easily themed by editing the [MaterialUI theme](https://material-ui.com/customization/themes/). Edit the theme in ./interface/src/App.js as you desire:
170
+
The app can be easily themed by editing the [MaterialUI theme](https://material-ui.com/customization/themes/). Edit the theme in ['interface/src/App.js'](interface/src/App.js) as you desire:
You can replace the app icon is located at [./interface/public/app/icon.png](interface/public/app/icon.png) with one of your preference. A 256 x 256 PNG is recommended for best compatibility.
187
+
You can replace the app icon is located at ['interface/public/app/icon.png'](interface/public/app/icon.png) with one of your preference. A 256 x 256 PNG is recommended for best compatibility.
118
188
119
189
120
190
### Changing the app name
121
191
122
-
The app name displayed on the login page and on the menu bar can be modified by editing the REACT_APP_NAME property in [./interface/.env](interface/.env)
192
+
The app name displayed on the login page and on the menu bar can be modified by editing the REACT_APP_NAME property in ['interface/.env'](interface/.env)
123
193
124
194
```js
125
195
REACT_APP_NAME=Funky IoT Project
126
196
```
127
197
128
-
There is also a manifest file which contains the app name to use when adding the app to a mobile device, so you may wish to also edit [./interface/public/app/manifest.json](interface/public/app/manifest.json):
198
+
There is also a manifest file which contains the app name to use when adding the app to a mobile device, so you may wish to also edit ['interface/public/app/manifest.json'](interface/public/app/manifest.json):
129
199
130
200
```json
131
201
{
@@ -142,55 +212,9 @@ There is also a manifest file which contains the app name to use when adding the
142
212
}
143
213
```
144
214
145
-
## Building for different devices
146
215
147
-
This project supports ESP8266 and ESP32 platforms. To support OTA programming, enough free space to upload the new sketch and file system image will be required. It is recommended that a board with at least 2mb of flash is used.
148
216
149
-
By default, the target device is "esp12e". This is a common ESP8266 variant with 4mb of flash:
150
-
151
-

152
-
153
-
The settings file platformio.ini configures the platform and board:
154
-
155
-
```
156
-
[env:esp12e]
157
-
platform = espressif8266
158
-
board = esp12e
159
-
```
160
-
161
-
If you want to build for an ESP32 device, all you need to do is re-configure playformio.ini with your devices settings.
162
-
163
-

164
-
165
-
Building for the common esp32 "node32s" board for example requires the following configuration:
166
-
167
-
```
168
-
[env:node32s]
169
-
platform = espressif32
170
-
board = node32s
171
-
```
172
-
173
-
## Configuration & Deployment
174
-
175
-
Standard configuration settings, such as build flags, libraries and device configuration can be found in platformio.ini. See the [PlatformIO docs](http://docs.platformio.org/en/latest/projectconf.html) for full details on what you can do with this.
176
-
177
-
***** TODO ******
178
-
The project is configured to upload via serial by default, you can change the upload mechanism to OTA by uncommenting the relevant lines.
179
-
180
-
As well as containing the interface, the SPIFFS image (in the ./data folder) contains a JSON settings file for each of the configurable features. The config files can be found in the ./data/config directory:
181
-
182
-
File | Description
183
-
---- | -----------
184
-
apSettings.json | Access point settings
185
-
ntpSettings.json | NTP synchronization settings
186
-
otaSettings.json | OTA update configuration
187
-
securitySettings.json | Security settings and user credentials
188
-
wifiSettings.json | WiFi connection settings
189
-
190
-
The default settings configure the device to bring up an access point on start up which can be used to configure the device:
0 commit comments