Library built on Espressif NON-OS SDK with common functions for esp8266 apps.
- configuration persistency
- cron (linux style)
- customizable logger over serial interface
- customizable diagnostic events logger (in memory, available through http)
- digital I/O provisioning and management
- json
- linked lists
- mDns
- macros for storing strings into flash and save on RAM memory
- memory monitor (stack and heap)
- OTA
- queues
- customizable profiler over serial interface
- SPIFFS
- time and date with or without SNTP
- wifi management (chromecast style)
- WEBCLIENT
- customizable WEBSERVER
- about 30 kB of RAM are available to user application (while idle more than 43 kB are available but under stress conditions, for both SDK and ESPBOT, available memory got reduced by 10 kB and a little more)
- ESPBOT uses 88 bytes of RTC memory, leaving 424 bytes available to user application
Espbot REST apis are detailed by espbot_api.yaml.
Open the file with the Swagger online editor or (better) with Visual Studio Swagger Viewer extension for description.
Using a Swagger editor locally or Swagger Viewer allows for using the API and communicate with the host device.
Required:
-
[Espressif NON-OS SDK] (https://github.com/espressif/ESP8266_NONOS_SDK) in a separate repository.
-
[esp-open-sdk toolchain] (https://github.com/pfalcon/esp-open-sdk) in a separate repository; build the bare Xtensa toolchain and leave ESP8266 SDK separate using:
make STANDALONE=n
Build steps (linux)
-
Clone the repository.
-
Customize build variables according to your ESP8266 module and environment:
cd <your path>/espbot ./gen_env.sh this will generate a env.sh file for instance a WEMOS D1 mini file will look like this: export SDK_DIR=<your path to ESP8266_NONOS_SDK> export COMPILE=gcc export BOOT=new export APP=1 export SPI_SPEED=40 export SPI_MODE=DIO export SPI_SIZE_MAP=4 export COMPILE=gcc export COMPORT=<your COM port> export CC_DIR=<your path to compiler> export PATH=$PATH:<your path to compiler> export SDK_DIR=<your path to ESP8266_NONOS_SDK> export BOOT=new export APP=1 export SPI_SPEED=40 export FREQDIV=0 export SPI_MODE=dio export MODE=2 export SPI_SIZE_MAP=6 export FLASH_SIZE=4096 export LD_REF=2048 export FLASH_OPTIONS=" write_flash -fm dio -fs 32m-c1 -ff 40m " export FLASH_INIT="0x3FB000 <your path to ESP8266_NONOS_SDK>/bin/blank.bin 0x3FC000 <your path to ESP8266_NONOS_SDK>/bin/esp_init_data_default_v08.bin 0x3FE000 <your path to ESP8266_NONOS_SDK>/blank.bin" -
Building (commands available as tasks in case you are using Visual Studio)
Clean project
source ${workspaceFolder}/env.sh && make cleanBuilding current user#.bin
source ${workspaceFolder}/env.sh && make allBuilding user1.bin
source ${workspaceFolder}/env.sh && make -e APP=1 allBuilding user2.bin
source ${workspaceFolder}/env.sh && make -e APP=2 allBuilding both user1.bin and user2.bin
source ${workspaceFolder}/env.sh && make -e APP=1 all && make -e APP=2 all -
Flashing ESP8266 using esptool.py (checkout your distribution packages or github repository) (commands available as tasks in case you are using Visual Studio)
Erase flash
source ${workspaceFolder}/env.sh && make flash_eraseFlash the bootloader
source ${workspaceFolder}/env.sh && make flash_bootFlash init
source ${workspaceFolder}/env.sh && make flash_initFlash current user#.bin
source ${workspaceFolder}/env.sh && make flashFlash user1.bin
source ${workspaceFolder}/env.sh && make -e APP=1 flashFlash user2.bin
source ${workspaceFolder}/env.sh && make -e APP=2 flash
Here is an example on how to use espbot FOTA using a docker container as http server (thank you docker for existing).
Start an http server using docker:
$ docker run -d --name espbot-http-upgrade -p 80:80 -v <your espbot directory>/bin/upgrade/www:/usr/share/nginx/html:ro nginx:alpine
Configure and command espbot with following curl examples or use the REST apis with any swagger viewer.
Configure espbot:
curl --location --request POST 'http://{{device_host}}/api/ota/cfg' \
--header 'Content-Type: application/json' \
--data-raw '{
"host": "{{your host IP}}",
"port": 80,
"path": "/",
"check_version": "false",
"reboot_on_completion": "true"
}'
Start upgrade:
curl --location --request POST 'http://{{device_host}}/api/ota' \
--data-raw ''
To integrate espbot in your project as a library checkout src/app example source files for how to build your app and use the following files:
- lib/libespbot.a
- lib/libdriver.a
- lib/libspiffs.a
To import the library source files use the following files:
- src/driver
- src/espbot
- src/spiffs
Espot include files are:
- driver_hw_timer.h"
- driver_uart.h"
- driver_uart_register.h"
- esp8266_io.h"
- espbot_cfgfile.hpp"
- espbot_cron.hpp"
- espbot_diagnostic.hpp"
- espbot_event_codes.h"
- espbot_gpio.hpp"
- espbot_hal.h"
- espbot_http.hpp"
- espbot_http_client.hpp"
- espbot_http_routes.hpp"
- espbot_http_server.hpp"
- espbot_json.hpp"
- espbot_list.hpp"
- espbot_mdns.hpp"
- espbot_mem_macros.h"
- espbot_mem_mon.hpp"
- espbot_ota.hpp"
- espbot_profiler.hpp"
- espbot_queue.hpp"
- espbot_rtc_mem_map.h"
- espbot_spiffs.hpp"
- espbot_timedate.h"
- espbot_timedate.hpp"
- espbot_utils.hpp"
- espbot_wifi.hpp"
- espbot.hpp"
- spiffs_config.h"
- spiffs_nucleus.h"
- spiffs.h"
Espbot comes with a [BEER-WARE] license.
Enjoy.