Skip to content

Commit

Permalink
factory config
Browse files Browse the repository at this point in the history
  • Loading branch information
lws-team committed Mar 16, 2017
1 parent 95e3955 commit f5a8c98
Show file tree
Hide file tree
Showing 280 changed files with 76,899 additions and 667 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "components/libwebsockets"]
path = components/libwebsockets
url = https://github.com/warmcat/libwebsockets
748 changes: 546 additions & 202 deletions LICENSE

Large diffs are not rendered by default.

26 changes: 17 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,25 @@ PROJECT_NAME := lws-esp32
SSL_CERT_PEM:=${PWD}/build/libwebsockets/libwebsockets-test-server
SSL_KEY_PEM:=${PWD}/build/libwebsockets/libwebsockets-test-server.key

export SSL_CERT_PEM
export SSL_KEY_PEM
EXTRA_COMPONENT_DIRS := components
LWS_IS_FACTORY_APPLICATION=0
export LWS_IS_FACTORY_APPLICATION

include $(IDF_PATH)/make/project.mk
include sdkconfig
# stick the romfs filesystem in its own romfs part
flash-romfs:
$(IDF_PATH)/components/esptool_py/esptool/esptool.py \
--chip esp32 \
--port $(CONFIG_ESPTOOLPY_PORT) \
--baud $(CONFIG_ESPTOOLPY_BAUD) \
write_flash 0x310000 build/main/romfs.img
include ${PWD}/components/libwebsockets/scripts/esp32.mk

CFLAGS+= -I$(COMPONENT_PATH)/../components/libwebsockets/plugins -DLWS_IS_FACTORY_APPLICATION=$(LWS_IS_FACTORY_APPLICATION)

export IDF_PATH

$(COMPONENT_PATH)/../ssl-cert.der:
tail -n +2 $(SSL_CERT_PEM).pem | \
head -n -1 | base64 -d - \
> $(COMPONENT_PATH)/../ssl-cert.der

$(COMPONENT_PATH)/../ssl-key.der:
tail -n +2 $(SSL_KEY_PEM).pem | \
head -n -1 | base64 -d - \
> $(COMPONENT_PATH)/../ssl-key.der

112 changes: 14 additions & 98 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,116 +1,28 @@
lws-esp32
=========
lws-esp32-test-server-demos
===========================

## Status
## For use with lws-esp32-factory

- Station mode provides the full lws test server on port 443 over htps, all working
This relies on setup capability provided by

- ESP32 becomes an AP and serves dynamic websocket-based scan / config page,
so you can set up your AP and password. Initially comes up in this since
the AP details are not set yet.
https://github.com/warmcat/lws-esp32-factory

![lws AP mode config page](https://libwebsockets.org/lws-esp32-ap.png)
which runs from the "factory" partition on ESP32. This app is
designed to run from the since 2.9MB OTA partition.

- Integration to new projects hugely simplified by moving common lws support code
into lws directly. Non-library parts licensed are CC0.
## Build


## Customizing to your build setup

### 0) Set the right serial device in menuconfig

### 1) Patch esp-idf

You can either use the already-patched esp-idf at

$ git clone --init --recursive https://github.com/lws-team/lws-esp-idf

or you can apply this patch to your own esp-idf

```diff
Apply this patch on esp-idf, then


diff --git a/.gitmodules b/.gitmodules
index 6a6af0e..897992d 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -13,3 +13,7 @@
[submodule "components/coap/libcoap"]
path = components/coap/libcoap
url = https://github.com/obgm/libcoap.git
+[submodule "components/libwebsockets"]
+ path = components/libwebsockets
+ url = https://[email protected]/warmcat/libwebsockets
+ branch=master
diff --git a/components/libwebsockets b/components/libwebsockets
new file mode 160000
index 0000000..3a09c3b
--- /dev/null
+++ b/components/libwebsockets
@@ -0,0 +1 @@
+Subproject commit 102d40e6b6486076f37a46708604ec387834f16c
```

and then do

$ make all flash_ota monitor
```
$ git submodules update --recursive
```

from the esp-idf

### 2) Partitioning the device

Clear down the partitioning since we write a custom table and the bootloader
will choke if the OTA parts are not initialized like this

```
$ make erase_flash
```

## Writing the ROMFS to flash

A ROMFS contains the files to be served, stored at a partition at the end
of the flash.

There's currently space for ~900KiB there.

The ROMFS is generated automatically from files in `./romfs-files` every make.

Write it and update it in the flash like this:

```
$ make all flash-romfs
```

## General build and flash

```
$ make all flash monitor
```

## Using the AP config

- connect your wifi to the ap "lws-config-...."

- In a browser, go to https://192.168.4.1

- set a serial number, like 1234

- Select your normal AP from the list

- Give the AP password and click the button

- Your ESP32 resets into Station mode and associates with the AP

## Using the lws test apps

See what IP your ESP32 got from your AP, the visit it in your browser
using, eg https://192.168.2.249

If your dhcp server provides your dns, you can also reach the device
using lws-serial, eg, https://lws-1234
using lws-serial, eg, https://lws-1234 or https://lws-1234.local

- dumb increment should be updating at ~20Hz

Expand All @@ -123,3 +35,7 @@ using lws-serial, eg, https://lws-1234

- POST tests should pass the string and upload the file if one given

- The button at the bottom should reset you into the setup / factory app

- The "War and Peace" demo should load the 4MB text from the 1.2MB gzipped zip
file directly, using gzipped data to the browser.
1 change: 1 addition & 0 deletions components/libwebsockets
Submodule libwebsockets added at 53f897
26 changes: 26 additions & 0 deletions components/zlib/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
*.diff
*.patch
*.orig
*.rej

*~
*.a
*.lo
*.o
*.dylib

*.gcda
*.gcno
*.gcov

/example
/example64
/examplesh
/libz.so*
/minigzip
/minigzip64
/minigzipsh
/zlib.pc
/configure.log

.DS_Store
Loading

0 comments on commit f5a8c98

Please sign in to comment.