├── app
├── include
│ ├── arch
│ │ ├── sys_arch.h
│ │ └── perf.h
│ ├── ssl
│ │ ├── ssl_version.h
│ │ ├── app
│ │ │ └── espconn_secure.h
│ │ └── private_key.h
│ ├── lwip
│ │ ├── icmp.h
│ │ ├── netif.h
│ │ └── app
│ │ │ ├── espconn_tcp.h
│ │ │ ├── espconn_udp.h
│ │ │ └── ping.h
│ ├── mem_manager.h
│ ├── driver
│ │ ├── gpio16.h
│ │ ├── spi_master.h
│ │ ├── key.h
│ │ ├── pwm.h
│ │ └── spi.h
│ ├── pp
│ │ └── esf_buf.h
│ ├── user_version.h
│ ├── u8g_config.h
│ ├── netif
│ │ └── wlan_lwip_if.h
│ ├── user_modules.h
│ └── user_config.h
├── spiffs
│ ├── docs
│ │ ├── IMPLEMENTING
│ │ └── TODO
│ ├── test
│ │ ├── main.c
│ │ ├── testsuites.c
│ │ └── params_test.h
│ ├── LICENSE
│ └── Makefile
├── .gitignore
├── cjson
│ ├── tests
│ │ ├── types.json
│ │ ├── octets-escaped.dat
│ │ ├── README
│ │ ├── numbers.json
│ │ ├── example2.json
│ │ ├── rfc-example1.json
│ │ ├── rfc-example2.json
│ │ ├── example3.json
│ │ ├── genutf8.pl
│ │ ├── example1.json
│ │ └── example5.json
│ ├── THANKS
│ ├── lua
│ │ ├── json2lua.lua
│ │ └── lua2json.lua
│ ├── fpconv.h
│ ├── LICENSE
│ ├── devel
│ │ └── json_parser_outline.txt
│ ├── Makefile
│ └── dtoa_config.h
├── lwip
│ ├── api
│ │ ├── tcpip.c
│ │ ├── netbuf.c
│ │ └── Makefile
│ ├── core
│ │ ├── tcp_in.c
│ │ ├── ipv4
│ │ │ ├── icmp.c
│ │ │ ├── Makefile
│ │ │ └── inet.c
│ │ ├── tcp_out.c
│ │ ├── sys_arch.c
│ │ └── Makefile
│ ├── app
│ │ └── Makefile
│ ├── netif
│ │ └── Makefile
│ └── Makefile
├── u8glib
│ ├── u8g_font_data.c
│ ├── Makefile
│ ├── u8g_com_null.c
│ ├── u8g_u16toa.c
│ └── u8g_u8toa.c
├── libc
│ ├── c_signal.h
│ ├── c_fcntl.h
│ ├── c_errno.h
│ ├── c_string.c
│ ├── c_ctype.c
│ ├── c_stdarg.h
│ ├── c_stddef.h
│ ├── c_ctype.h
│ ├── c_string.h
│ ├── c_locale.h
│ ├── c_math.h
│ ├── Makefile
│ └── c_stdlib.h
├── wofs
│ ├── romfiles.h
│ └── Makefile
├── coap
│ ├── coap_server.h
│ ├── coap_client.h
│ ├── coap_io.h
│ ├── pdu.h
│ ├── hash.h
│ ├── str.c
│ ├── coap_timer.h
│ ├── str.h
│ ├── hash.c
│ ├── LICENSE.txt
│ ├── coap_server.c
│ ├── pdu.c
│ ├── Makefile
│ ├── node.h
│ └── coap_client.c
├── lua
│ ├── legc.c
│ ├── lapi.h
│ ├── legc.h
│ ├── ldebug.h
│ ├── lualib.h
│ ├── lstring.h
│ ├── ltm.h
│ ├── lrodefs.h
│ ├── lvm.h
│ ├── lfunc.h
│ ├── ltable.h
│ ├── lmem.h
│ ├── compiler.h
│ ├── Makefile
│ ├── lundump.h
│ ├── lzio.c
│ ├── ldo.h
│ └── lzio.h
├── platform
│ ├── common.h
│ ├── pin_map.h
│ ├── flash_fs.c
│ ├── Makefile
│ └── flash_fs.h
├── mqtt
│ ├── msg_queue.h
│ ├── Makefile
│ └── msg_queue.c
├── driver
│ ├── gpio16.c
│ └── Makefile
├── modules
│ ├── adc.c
│ └── Makefile
├── json
│ └── Makefile
├── smart
│ └── Makefile
├── ssl
│ ├── app
│ │ └── Makefile
│ ├── ssl
│ │ └── Makefile
│ ├── crypto
│ │ └── Makefile
│ └── Makefile
├── upgrade
│ └── Makefile
└── user
│ └── Makefile
├── lua_examples
├── u8glib
│ ├── u8g_rook.bm
│ └── u8glib_logo.xbm
├── myfile.lua
├── tcp2uart.lua
├── telnet2.lua
├── telnet.lua
├── webap_toggle_pin.lua
├── mcp23008
│ ├── mcp23008_leds.lua
│ └── mcp23008_buttons.lua
├── onewire-ds18b20.lua
└── irsend.lua
├── examples
├── user.lua
├── init.lua
├── tel.lua
└── telnet.lua
├── lib
├── libm.a
├── libat.a
├── libphy.a
├── libpp.a
├── libssl.a
├── libwpa.a
├── libjson.a
├── liblwip.a
├── libmain.a
├── libnet80211.a
├── libupgrade.a
└── libsmartconfig.a
├── bin
├── blank.bin
├── esp_init_data_default.bin
└── .gitignore
├── pre_build
├── README.md
├── 0.9.2
│ ├── 512k-flash
│ │ ├── README.md
│ │ ├── blank512k.bin
│ │ ├── nodemcu_512k_20141212.bin
│ │ └── nodemcu_512k_20141219.bin
│ ├── 2M-flash
│ │ ├── blank.bin
│ │ ├── eagle.app.v6.flash.bin
│ │ ├── esp_init_data_default.bin
│ │ ├── nodemcu_2M_20141219.bin
│ │ ├── eagle.app.v6.irom0text.bin
│ │ └── README.md
│ ├── 4M-flash
│ │ ├── blank.bin
│ │ ├── eagle.app.v6.flash.bin
│ │ ├── esp_init_data_default.bin
│ │ ├── eagle.app.v6.irom0text.bin
│ │ └── README.md
│ └── 1M-flash
│ │ ├── nodemcu_1M_20141219.bin
│ │ └── README.md
├── 0.9.4
│ ├── 512k-flash
│ │ ├── README.md
│ │ ├── blank512k.bin
│ │ ├── nodemcu_512k_latest.bin
│ │ ├── nodemcu_512k_20141222.bin
│ │ └── nodemcu_512k_20141226.bin
│ ├── 1M-flash
│ │ └── README.md
│ ├── 2M-flash
│ │ └── README.md
│ └── 4M-flash
│ │ └── README.md
├── latest
│ └── nodemcu_latest.bin
└── 0.9.5
│ ├── nodemcu_20150106.bin
│ ├── nodemcu_20150107.bin
│ ├── nodemcu_20150108.bin
│ ├── nodemcu_20150118.bin
│ ├── nodemcu_20150123.bin
│ ├── nodemcu_20150126.bin
│ ├── nodemcu_20150127.bin
│ ├── nodemcu_20150212.bin
│ └── nodemcu_20150213.bin
├── tools
├── xxd.exe
├── .gitattributes
└── makefile.sh
├── CONTRIBUTING.md
├── include
├── mem.h
├── os_type.h
├── smartconfig.h
├── spi_flash.h
├── ping.h
├── upgrade.h
└── osapi.h
├── lua_modules
├── hdc1000
│ ├── HDC1000-example.lua
│ └── README.md
├── ds3231
│ ├── ds3231-example.lua
│ ├── ds3231-web.lua
│ └── ds3231.lua
├── ds18b20
│ ├── ds18b20-example.lua
│ └── ds18b20-web.lua
├── si7021
│ ├── si7021-example.lua
│ └── si7021-lewei.lua
├── bh1750
│ ├── bh1750_Example1.lua
│ ├── bh1750.lua
│ ├── bh1750_Example2.lua
│ ├── bh1750_CN.md
│ └── bh1750_EN.md
├── base64
│ └── base64.lua
├── http
│ └── http-example.lua
└── dht22
│ └── README.md
├── .settings
├── org.eclipse.cdt.core.prefs
└── language.settings.xml
├── .project
├── LICENSE
└── .travis.yml
/app/include/arch/sys_arch.h:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/app/spiffs/docs/IMPLEMENTING:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/lua_examples/u8glib/u8g_rook.bm:
--------------------------------------------------------------------------------
1 | U>>>>
--------------------------------------------------------------------------------
/examples/user.lua:
--------------------------------------------------------------------------------
1 | print("hello NodeMCU")
2 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | *.output*
2 | mapfile
3 | !.gitignore
4 |
--------------------------------------------------------------------------------
/app/cjson/tests/types.json:
--------------------------------------------------------------------------------
1 | { "array": [ 10, true, null ] }
2 |
--------------------------------------------------------------------------------
/app/include/ssl/ssl_version.h:
--------------------------------------------------------------------------------
1 | #define AXTLS_VERSION "1.4.9"
2 |
--------------------------------------------------------------------------------
/lib/libm.a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AllAboutEE/nodemcu-firmware/HEAD/lib/libm.a
--------------------------------------------------------------------------------
/lib/libat.a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AllAboutEE/nodemcu-firmware/HEAD/lib/libat.a
--------------------------------------------------------------------------------
/lib/libphy.a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AllAboutEE/nodemcu-firmware/HEAD/lib/libphy.a
--------------------------------------------------------------------------------
/lib/libpp.a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AllAboutEE/nodemcu-firmware/HEAD/lib/libpp.a
--------------------------------------------------------------------------------
/lib/libssl.a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AllAboutEE/nodemcu-firmware/HEAD/lib/libssl.a
--------------------------------------------------------------------------------
/lib/libwpa.a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AllAboutEE/nodemcu-firmware/HEAD/lib/libwpa.a
--------------------------------------------------------------------------------
/bin/blank.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AllAboutEE/nodemcu-firmware/HEAD/bin/blank.bin
--------------------------------------------------------------------------------
/lib/libjson.a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AllAboutEE/nodemcu-firmware/HEAD/lib/libjson.a
--------------------------------------------------------------------------------
/lib/liblwip.a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AllAboutEE/nodemcu-firmware/HEAD/lib/liblwip.a
--------------------------------------------------------------------------------
/lib/libmain.a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AllAboutEE/nodemcu-firmware/HEAD/lib/libmain.a
--------------------------------------------------------------------------------
/pre_build/README.md:
--------------------------------------------------------------------------------
1 | [Downloads](https://github.com/nodemcu/nodemcu-firmware/releases/latest)
--------------------------------------------------------------------------------
/tools/xxd.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AllAboutEE/nodemcu-firmware/HEAD/tools/xxd.exe
--------------------------------------------------------------------------------
/lib/libnet80211.a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AllAboutEE/nodemcu-firmware/HEAD/lib/libnet80211.a
--------------------------------------------------------------------------------
/lib/libupgrade.a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AllAboutEE/nodemcu-firmware/HEAD/lib/libupgrade.a
--------------------------------------------------------------------------------
/app/lwip/api/tcpip.c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AllAboutEE/nodemcu-firmware/HEAD/app/lwip/api/tcpip.c
--------------------------------------------------------------------------------
/lib/libsmartconfig.a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AllAboutEE/nodemcu-firmware/HEAD/lib/libsmartconfig.a
--------------------------------------------------------------------------------
/app/lwip/api/netbuf.c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AllAboutEE/nodemcu-firmware/HEAD/app/lwip/api/netbuf.c
--------------------------------------------------------------------------------
/app/lwip/core/tcp_in.c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AllAboutEE/nodemcu-firmware/HEAD/app/lwip/core/tcp_in.c
--------------------------------------------------------------------------------
/pre_build/0.9.2/512k-flash/README.md:
--------------------------------------------------------------------------------
1 | #Flash the firmware
2 | nodemcu_512k_xxxxx.bin: 0x00000
3 |
4 |
--------------------------------------------------------------------------------
/pre_build/0.9.4/512k-flash/README.md:
--------------------------------------------------------------------------------
1 | #Flash the firmware
2 | nodemcu_512k_xxxxx.bin: 0x00000
3 |
4 |
--------------------------------------------------------------------------------
/app/include/lwip/icmp.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AllAboutEE/nodemcu-firmware/HEAD/app/include/lwip/icmp.h
--------------------------------------------------------------------------------
/app/include/lwip/netif.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AllAboutEE/nodemcu-firmware/HEAD/app/include/lwip/netif.h
--------------------------------------------------------------------------------
/app/include/mem_manager.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AllAboutEE/nodemcu-firmware/HEAD/app/include/mem_manager.h
--------------------------------------------------------------------------------
/app/lwip/core/ipv4/icmp.c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AllAboutEE/nodemcu-firmware/HEAD/app/lwip/core/ipv4/icmp.c
--------------------------------------------------------------------------------
/app/lwip/core/tcp_out.c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AllAboutEE/nodemcu-firmware/HEAD/app/lwip/core/tcp_out.c
--------------------------------------------------------------------------------
/app/spiffs/docs/TODO:
--------------------------------------------------------------------------------
1 | * When mending lost pages, also see if they fit into length specified in object index header
--------------------------------------------------------------------------------
/app/u8glib/u8g_font_data.c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AllAboutEE/nodemcu-firmware/HEAD/app/u8glib/u8g_font_data.c
--------------------------------------------------------------------------------
/bin/esp_init_data_default.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AllAboutEE/nodemcu-firmware/HEAD/bin/esp_init_data_default.bin
--------------------------------------------------------------------------------
/bin/.gitignore:
--------------------------------------------------------------------------------
1 | *
2 | *.S
3 | *.dump
4 | *.bin
5 | *.bin_rep
6 | !.gitignore
7 | !blank.bin
8 | !esp_init_data_default.bin
9 |
--------------------------------------------------------------------------------
/app/cjson/tests/octets-escaped.dat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AllAboutEE/nodemcu-firmware/HEAD/app/cjson/tests/octets-escaped.dat
--------------------------------------------------------------------------------
/app/libc/c_signal.h:
--------------------------------------------------------------------------------
1 | #ifndef _C_SIGNAL_H_
2 | #define _C_SIGNAL_H_
3 |
4 | #include
5 |
6 | #endif /* _C_SIGNAL_H_ */
7 |
--------------------------------------------------------------------------------
/lua_examples/u8glib/u8glib_logo.xbm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AllAboutEE/nodemcu-firmware/HEAD/lua_examples/u8glib/u8glib_logo.xbm
--------------------------------------------------------------------------------
/pre_build/0.9.2/2M-flash/blank.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AllAboutEE/nodemcu-firmware/HEAD/pre_build/0.9.2/2M-flash/blank.bin
--------------------------------------------------------------------------------
/pre_build/0.9.2/4M-flash/blank.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AllAboutEE/nodemcu-firmware/HEAD/pre_build/0.9.2/4M-flash/blank.bin
--------------------------------------------------------------------------------
/pre_build/latest/nodemcu_latest.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AllAboutEE/nodemcu-firmware/HEAD/pre_build/latest/nodemcu_latest.bin
--------------------------------------------------------------------------------
/pre_build/0.9.5/nodemcu_20150106.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AllAboutEE/nodemcu-firmware/HEAD/pre_build/0.9.5/nodemcu_20150106.bin
--------------------------------------------------------------------------------
/pre_build/0.9.5/nodemcu_20150107.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AllAboutEE/nodemcu-firmware/HEAD/pre_build/0.9.5/nodemcu_20150107.bin
--------------------------------------------------------------------------------
/pre_build/0.9.5/nodemcu_20150108.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AllAboutEE/nodemcu-firmware/HEAD/pre_build/0.9.5/nodemcu_20150108.bin
--------------------------------------------------------------------------------
/pre_build/0.9.5/nodemcu_20150118.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AllAboutEE/nodemcu-firmware/HEAD/pre_build/0.9.5/nodemcu_20150118.bin
--------------------------------------------------------------------------------
/pre_build/0.9.5/nodemcu_20150123.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AllAboutEE/nodemcu-firmware/HEAD/pre_build/0.9.5/nodemcu_20150123.bin
--------------------------------------------------------------------------------
/pre_build/0.9.5/nodemcu_20150126.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AllAboutEE/nodemcu-firmware/HEAD/pre_build/0.9.5/nodemcu_20150126.bin
--------------------------------------------------------------------------------
/pre_build/0.9.5/nodemcu_20150127.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AllAboutEE/nodemcu-firmware/HEAD/pre_build/0.9.5/nodemcu_20150127.bin
--------------------------------------------------------------------------------
/pre_build/0.9.5/nodemcu_20150212.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AllAboutEE/nodemcu-firmware/HEAD/pre_build/0.9.5/nodemcu_20150212.bin
--------------------------------------------------------------------------------
/pre_build/0.9.5/nodemcu_20150213.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AllAboutEE/nodemcu-firmware/HEAD/pre_build/0.9.5/nodemcu_20150213.bin
--------------------------------------------------------------------------------
/pre_build/0.9.2/512k-flash/blank512k.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AllAboutEE/nodemcu-firmware/HEAD/pre_build/0.9.2/512k-flash/blank512k.bin
--------------------------------------------------------------------------------
/pre_build/0.9.4/512k-flash/blank512k.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AllAboutEE/nodemcu-firmware/HEAD/pre_build/0.9.4/512k-flash/blank512k.bin
--------------------------------------------------------------------------------
/app/libc/c_fcntl.h:
--------------------------------------------------------------------------------
1 | #ifndef __c_fcntl_h
2 | #define __c_fcntl_h
3 |
4 | #include
5 |
6 | #endif
7 |
8 | /* end of c_fcntl.h */
9 |
10 |
--------------------------------------------------------------------------------
/pre_build/0.9.2/2M-flash/eagle.app.v6.flash.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AllAboutEE/nodemcu-firmware/HEAD/pre_build/0.9.2/2M-flash/eagle.app.v6.flash.bin
--------------------------------------------------------------------------------
/pre_build/0.9.2/4M-flash/eagle.app.v6.flash.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AllAboutEE/nodemcu-firmware/HEAD/pre_build/0.9.2/4M-flash/eagle.app.v6.flash.bin
--------------------------------------------------------------------------------
/app/cjson/tests/README:
--------------------------------------------------------------------------------
1 | These JSON examples were taken from the JSON website
2 | (http://json.org/example.html) and RFC 4627.
3 |
4 | Used with permission.
5 |
--------------------------------------------------------------------------------
/pre_build/0.9.2/1M-flash/nodemcu_1M_20141219.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AllAboutEE/nodemcu-firmware/HEAD/pre_build/0.9.2/1M-flash/nodemcu_1M_20141219.bin
--------------------------------------------------------------------------------
/pre_build/0.9.2/2M-flash/esp_init_data_default.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AllAboutEE/nodemcu-firmware/HEAD/pre_build/0.9.2/2M-flash/esp_init_data_default.bin
--------------------------------------------------------------------------------
/pre_build/0.9.2/2M-flash/nodemcu_2M_20141219.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AllAboutEE/nodemcu-firmware/HEAD/pre_build/0.9.2/2M-flash/nodemcu_2M_20141219.bin
--------------------------------------------------------------------------------
/pre_build/0.9.2/4M-flash/esp_init_data_default.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AllAboutEE/nodemcu-firmware/HEAD/pre_build/0.9.2/4M-flash/esp_init_data_default.bin
--------------------------------------------------------------------------------
/pre_build/0.9.4/512k-flash/nodemcu_512k_latest.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AllAboutEE/nodemcu-firmware/HEAD/pre_build/0.9.4/512k-flash/nodemcu_512k_latest.bin
--------------------------------------------------------------------------------
/pre_build/0.9.2/2M-flash/eagle.app.v6.irom0text.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AllAboutEE/nodemcu-firmware/HEAD/pre_build/0.9.2/2M-flash/eagle.app.v6.irom0text.bin
--------------------------------------------------------------------------------
/pre_build/0.9.2/4M-flash/eagle.app.v6.irom0text.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AllAboutEE/nodemcu-firmware/HEAD/pre_build/0.9.2/4M-flash/eagle.app.v6.irom0text.bin
--------------------------------------------------------------------------------
/pre_build/0.9.2/512k-flash/nodemcu_512k_20141212.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AllAboutEE/nodemcu-firmware/HEAD/pre_build/0.9.2/512k-flash/nodemcu_512k_20141212.bin
--------------------------------------------------------------------------------
/pre_build/0.9.2/512k-flash/nodemcu_512k_20141219.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AllAboutEE/nodemcu-firmware/HEAD/pre_build/0.9.2/512k-flash/nodemcu_512k_20141219.bin
--------------------------------------------------------------------------------
/pre_build/0.9.4/512k-flash/nodemcu_512k_20141222.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AllAboutEE/nodemcu-firmware/HEAD/pre_build/0.9.4/512k-flash/nodemcu_512k_20141222.bin
--------------------------------------------------------------------------------
/pre_build/0.9.4/512k-flash/nodemcu_512k_20141226.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AllAboutEE/nodemcu-firmware/HEAD/pre_build/0.9.4/512k-flash/nodemcu_512k_20141226.bin
--------------------------------------------------------------------------------
/app/spiffs/test/main.c:
--------------------------------------------------------------------------------
1 | #include "testrunner.h"
2 | #include
3 |
4 | int main(int argc, char **args) {
5 | run_tests(argc, args);
6 | exit(EXIT_SUCCESS);
7 | }
8 |
--------------------------------------------------------------------------------
/app/cjson/tests/numbers.json:
--------------------------------------------------------------------------------
1 | [ 0.110001,
2 | 0.12345678910111,
3 | 0.412454033640,
4 | 2.6651441426902,
5 | 2.718281828459,
6 | 3.1415926535898,
7 | 2.1406926327793 ]
8 |
--------------------------------------------------------------------------------
/app/wofs/romfiles.h:
--------------------------------------------------------------------------------
1 | // Generated by mkfs.lua
2 | // DO NOT MODIFY
3 |
4 | #ifndef __ROMFILES_H__
5 | #define __ROMFILES_H__
6 |
7 | const unsigned char romfiles_fs[] =
8 | {
9 | 0xFF
10 | };
11 |
12 | #endif
13 |
--------------------------------------------------------------------------------
/app/include/driver/gpio16.h:
--------------------------------------------------------------------------------
1 | #ifndef __GPIO16_H__
2 | #define __GPIO16_H__
3 |
4 | void gpio16_output_conf(void);
5 | void gpio16_output_set(uint8 value);
6 | void gpio16_input_conf(void);
7 | uint8 gpio16_input_get(void);
8 |
9 | #endif
10 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | ## Contributing
2 |
3 | Thank you everyone for contributing to this project.
4 |
5 | Pull requests for new features and major fixes should be opened against the `dev` branch.
6 |
7 | *Note that the `pre_build` bin in the dev branch is never up-to-date.*
8 |
--------------------------------------------------------------------------------
/pre_build/0.9.2/1M-flash/README.md:
--------------------------------------------------------------------------------
1 | #Flash the firmware
2 | nodemcu_1M_xxxxx.bin: 0x00000
3 |
4 |
5 | #Or
6 | eagle.app.v6.flash.bin: 0x00000
7 | eagle.app.v6.irom0text.bin: 0x10000
8 | esp_init_data_default.bin: 0xfc000
9 | blank.bin: 0xfe000
10 |
--------------------------------------------------------------------------------
/pre_build/0.9.4/1M-flash/README.md:
--------------------------------------------------------------------------------
1 | #Flash the firmware
2 | nodemcu_1M_xxxxx.bin: 0x00000
3 |
4 |
5 | #Or
6 | eagle.app.v6.flash.bin: 0x00000
7 | eagle.app.v6.irom0text.bin: 0x10000
8 | esp_init_data_default.bin: 0xfc000
9 | blank.bin: 0xfe000
10 |
--------------------------------------------------------------------------------
/pre_build/0.9.2/2M-flash/README.md:
--------------------------------------------------------------------------------
1 | #Flash the firmware
2 | nodemcu_2M_xxxxx.bin: 0x00000
3 |
4 |
5 | #Or
6 | eagle.app.v6.flash.bin: 0x00000
7 | eagle.app.v6.irom0text.bin: 0x10000
8 | esp_init_data_default.bin: 0x1fc000
9 | blank.bin: 0x1fe000
10 |
--------------------------------------------------------------------------------
/pre_build/0.9.4/2M-flash/README.md:
--------------------------------------------------------------------------------
1 | #Flash the firmware
2 | nodemcu_2M_xxxxx.bin: 0x00000
3 |
4 |
5 | #Or
6 | eagle.app.v6.flash.bin: 0x00000
7 | eagle.app.v6.irom0text.bin: 0x10000
8 | esp_init_data_default.bin: 0x1fc000
9 | blank.bin: 0x1fe000
10 |
--------------------------------------------------------------------------------
/app/cjson/THANKS:
--------------------------------------------------------------------------------
1 | The following people have helped with bug reports, testing and/or
2 | suggestions:
3 |
4 | - Louis-Philippe Perron (@loopole)
5 | - Ondřej Jirman
6 | - Steve Donovan
7 | - Zhang "agentzh" Yichun
8 |
9 | Thanks!
10 |
--------------------------------------------------------------------------------
/app/include/pp/esf_buf.h:
--------------------------------------------------------------------------------
1 | /*
2 | * copyright (c) 2008 - 2012 Espressif System
3 | *
4 | * esf buffer data structure
5 | */
6 |
7 | #ifndef _ESF_BUF_H_
8 | #define _ESF_BUF_H_
9 |
10 | #define EP_OFFSET 36 /* see comments in pbuf.h */
11 |
12 | #endif /* _ESF_BUF_H_ */
13 |
--------------------------------------------------------------------------------
/app/lwip/core/sys_arch.c:
--------------------------------------------------------------------------------
1 | /*
2 | * copyright (c) 2010 - 2011 espressif system
3 | */
4 |
5 | #include "c_types.h"
6 | #include "ets_sys.h"
7 | #include "osapi.h"
8 | #include "os_type.h"
9 |
10 | #include "lwip/opt.h"
11 | #include "lwip/sys.h"
12 |
13 | #include "eagle_soc.h"
14 |
--------------------------------------------------------------------------------
/tools/.gitattributes:
--------------------------------------------------------------------------------
1 | # Enforce Unix newlines
2 | *.css text eol=lf
3 | *.html text eol=lf
4 | *.js text eol=lf
5 | *.json text eol=lf
6 | *.less text eol=lf
7 | *.md text eol=lf
8 | *.svg text eol=lf
9 | *.yml text eol=lf
10 | *.py text eol=lf
11 | *.sh text eol=lf
12 |
--------------------------------------------------------------------------------
/pre_build/0.9.2/4M-flash/README.md:
--------------------------------------------------------------------------------
1 | #Flash the firmware
2 |
3 | eagle.app.v6.flash.bin: 0x00000
4 | eagle.app.v6.irom0text.bin: 0x10000
5 | esp_init_data_default.bin: 0x3fc000
6 | blank.bin: 0x3fe000
7 |
8 | ###ESP8266's bootloader doesn't support flashing a single file 4Mbytes.
9 |
--------------------------------------------------------------------------------
/pre_build/0.9.4/4M-flash/README.md:
--------------------------------------------------------------------------------
1 | #Flash the firmware
2 |
3 | eagle.app.v6.flash.bin: 0x00000
4 | eagle.app.v6.irom0text.bin: 0x10000
5 | esp_init_data_default.bin: 0x3fc000
6 | blank.bin: 0x3fe000
7 |
8 | ###ESP8266's bootloader doesn't support flashing a single file 4Mbytes.
9 |
--------------------------------------------------------------------------------
/app/coap/coap_server.h:
--------------------------------------------------------------------------------
1 | #ifndef _COAP_SERVER_H
2 | #define _COAP_SERVER_H 1
3 |
4 | #ifdef __cplusplus
5 | extern "C" {
6 | #endif
7 |
8 | size_t coap_server_respond(char *req, unsigned short reqlen, char *rsp, unsigned short rsplen);
9 |
10 | #ifdef __cplusplus
11 | }
12 | #endif
13 |
14 | #endif
15 |
--------------------------------------------------------------------------------
/lua_examples/myfile.lua:
--------------------------------------------------------------------------------
1 | --myfile.lua
2 |
3 | local myfile = {}
4 | function myfile.print(name)
5 | file.open(name)
6 | repeat
7 | local line=file.readline()
8 | if line then line=(string.gsub(line,"\n","")) print(line) end
9 | until not line
10 | file.close()
11 | end
12 | return myfile
13 |
--------------------------------------------------------------------------------
/app/cjson/tests/example2.json:
--------------------------------------------------------------------------------
1 | {"menu": {
2 | "id": "file",
3 | "value": "File",
4 | "popup": {
5 | "menuitem": [
6 | {"value": "New", "onclick": "CreateNewDoc()"},
7 | {"value": "Open", "onclick": "OpenDoc()"},
8 | {"value": "Close", "onclick": "CloseDoc()"}
9 | ]
10 | }
11 | }}
12 |
--------------------------------------------------------------------------------
/include/mem.h:
--------------------------------------------------------------------------------
1 | #ifndef __MEM_H__
2 | #define __MEM_H__
3 |
4 | //void *pvPortMalloc( size_t xWantedSize );
5 | //void vPortFree( void *pv );
6 | //void *pvPortZalloc(size_t size);
7 |
8 | #define os_malloc pvPortMalloc
9 | #define os_free vPortFree
10 | #define os_zalloc pvPortZalloc
11 |
12 | #endif
13 |
--------------------------------------------------------------------------------
/app/lua/legc.c:
--------------------------------------------------------------------------------
1 | // Lua EGC (Emergeny Garbage Collector) interface
2 |
3 | #include "legc.h"
4 | #include "lstate.h"
5 | #include "c_types.h"
6 |
7 | void legc_set_mode(lua_State *L, int mode, unsigned limit) {
8 | global_State *g = G(L);
9 |
10 | g->egcmode = mode;
11 | g->memlimit = limit;
12 | }
13 |
14 |
--------------------------------------------------------------------------------
/app/spiffs/test/testsuites.c:
--------------------------------------------------------------------------------
1 | /*
2 | * testsuites.c
3 | *
4 | * Created on: Jun 19, 2013
5 | * Author: petera
6 | */
7 |
8 | #include "testrunner.h"
9 |
10 | void add_suites() {
11 | //ADD_SUITE(dev_tests);
12 | ADD_SUITE(check_tests);
13 | ADD_SUITE(hydrogen_tests)
14 | ADD_SUITE(bug_tests)
15 | }
16 |
--------------------------------------------------------------------------------
/app/coap/coap_client.h:
--------------------------------------------------------------------------------
1 | #ifndef _COAP_CLIENT_H
2 | #define _COAP_CLIENT_H 1
3 |
4 | #ifdef __cplusplus
5 | extern "C" {
6 | #endif
7 |
8 | void coap_client_response_handler(char *data, unsigned short len, unsigned short size, const uint32_t ip, const uint32_t port);
9 |
10 | #ifdef __cplusplus
11 | }
12 | #endif
13 |
14 | #endif
15 |
--------------------------------------------------------------------------------
/app/lua/lapi.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** $Id: lapi.h,v 2.2.1.1 2007/12/27 13:02:25 roberto Exp $
3 | ** Auxiliary functions from Lua API
4 | ** See Copyright Notice in lua.h
5 | */
6 |
7 | #ifndef lapi_h
8 | #define lapi_h
9 |
10 |
11 | #include "lobject.h"
12 |
13 |
14 | LUAI_FUNC void luaA_pushobject (lua_State *L, const TValue *o);
15 |
16 | #endif
17 |
--------------------------------------------------------------------------------
/app/include/driver/spi_master.h:
--------------------------------------------------------------------------------
1 | #ifndef __SPI_MASTER_H__
2 | #define __SPI_MASTER_H__
3 |
4 | #include "driver/spi_register.h"
5 |
6 | /*SPI number define*/
7 | #define SPI 0
8 | #define HSPI 1
9 |
10 | void spi_master_init(uint8 spi_no);
11 | void spi_master_9bit_write(uint8 spi_no, uint8 high_bit, uint8 low_8bit);
12 |
13 | #endif
14 |
--------------------------------------------------------------------------------
/app/include/user_version.h:
--------------------------------------------------------------------------------
1 | #ifndef __USER_VERSION_H__
2 | #define __USER_VERSION_H__
3 |
4 | #define NODE_VERSION_MAJOR 0U
5 | #define NODE_VERSION_MINOR 9U
6 | #define NODE_VERSION_REVISION 5U
7 | #define NODE_VERSION_INTERNAL 0U
8 |
9 | #define NODE_VERSION "NodeMCU 0.9.5"
10 | #define BUILD_DATE "build 20150403"
11 |
12 | #endif /* __USER_VERSION_H__ */
13 |
--------------------------------------------------------------------------------
/app/libc/c_errno.h:
--------------------------------------------------------------------------------
1 | #ifndef __c_errno_h
2 | #define __c_errno_h
3 |
4 | #include
5 | // #ifndef errno
6 | // extern int errno;
7 | // #endif
8 |
9 | // #define EDOM 1
10 | // #define ERANGE 2
11 | // #define EILSEQ 4
12 | // #define ESIGNUM 3
13 | // #define EINVAL 5
14 | // #define ENOMEM 6
15 |
16 | #endif
17 |
18 | /* end of c_errno.h */
19 |
20 |
--------------------------------------------------------------------------------
/tools/makefile.sh:
--------------------------------------------------------------------------------
1 |
2 | #
3 | # Generate the certificates and keys for encrypt.
4 | #
5 |
6 | # set default cert for use in the client
7 | xxd -i client.cer | sed -e \
8 | "s/client_cer/default_certificate/" > cert.h
9 | # set default key for use in the server
10 | xxd -i server.key_1024 | sed -e \
11 | "s/server_key_1024/default_private_key/" > private_key.h
12 |
--------------------------------------------------------------------------------
/app/cjson/tests/rfc-example1.json:
--------------------------------------------------------------------------------
1 | {
2 | "Image": {
3 | "Width": 800,
4 | "Height": 600,
5 | "Title": "View from 15th Floor",
6 | "Thumbnail": {
7 | "Url": "http://www.example.com/image/481989943",
8 | "Height": 125,
9 | "Width": "100"
10 | },
11 | "IDs": [116, 943, 234, 38793]
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/app/cjson/lua/json2lua.lua:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env lua
2 |
3 | -- usage: json2lua.lua [json_file]
4 | --
5 | -- Eg:
6 | -- echo '[ "testing" ]' | ./json2lua.lua
7 | -- ./json2lua.lua test.json
8 |
9 | local json = require "cjson"
10 | local util = require "cjson.util"
11 |
12 | local json_text = util.file_load(arg[1])
13 | local t = json.decode(json_text)
14 | print(util.serialise_value(t))
15 |
--------------------------------------------------------------------------------
/app/platform/common.h:
--------------------------------------------------------------------------------
1 | // Common platform functions
2 |
3 | #ifndef __COMMON_H__
4 | #define __COMMON_H__
5 |
6 | #include "platform.h"
7 |
8 | // Functions exported by the common platform layer
9 | void cmn_platform_init(void);
10 |
11 | // Timer-specific functions
12 |
13 | // System timer generic implemenation
14 |
15 | // Filesystem-related functions
16 |
17 | #endif // #ifndef __COMMON_H__
18 |
19 |
--------------------------------------------------------------------------------
/lua_examples/tcp2uart.lua:
--------------------------------------------------------------------------------
1 | uart.setup(0,9600,8,0,1,0)
2 | sv=net.createServer(net.TCP, 60)
3 | global_c = nil
4 | sv:listen(9999, function(c)
5 | if global_c~=nil then
6 | global_c:close()
7 | end
8 | global_c=c
9 | c:on("receive",function(sck,pl) uart.write(0,pl) end)
10 | end)
11 |
12 | uart.on("data",4, function(data)
13 | if global_c~=nil then
14 | global_c:send(data)
15 | end
16 | end, 0)
17 |
--------------------------------------------------------------------------------
/app/coap/coap_io.h:
--------------------------------------------------------------------------------
1 | #ifndef _COAP_IO_H
2 | #define _COAP_IO_H 1
3 |
4 | #ifdef __cplusplus
5 | extern "C" {
6 | #endif
7 |
8 | #include "espconn.h"
9 | #include "pdu.h"
10 | #include "hash.h"
11 |
12 | coap_tid_t coap_send(struct espconn *pesp_conn, coap_pdu_t *pdu);
13 |
14 | coap_tid_t coap_send_confirmed(struct espconn *pesp_conn, coap_pdu_t *pdu);
15 |
16 | #ifdef __cplusplus
17 | }
18 | #endif
19 |
20 | #endif
21 |
--------------------------------------------------------------------------------
/app/libc/c_string.c:
--------------------------------------------------------------------------------
1 | #include "c_string.h"
2 |
3 | // const char *c_strstr(const char * __s1, const char * __s2){
4 | // }
5 |
6 | // char *c_strncat(char * s1, const char * s2, size_t n){
7 | // }
8 |
9 | // size_t c_strcspn(const char * s1, const char * s2){
10 | // }
11 |
12 | // const char *c_strpbrk(const char * s1, const char * s2){
13 | // }
14 |
15 | // int c_strcoll(const char * s1, const char * s2){
16 | // }
17 |
--------------------------------------------------------------------------------
/include/os_type.h:
--------------------------------------------------------------------------------
1 | /*
2 | * copyright (c) Espressif System 2010
3 | *
4 | * mapping to ETS structures
5 | *
6 | */
7 | #ifndef _OS_TYPES_H_
8 | #define _OS_TYPES_H_
9 |
10 | #include "ets_sys.h"
11 |
12 | #define os_signal_t ETSSignal
13 | #define os_param_t ETSParam
14 | #define os_event_t ETSEvent
15 | #define os_task_t ETSTask
16 | #define os_timer_t ETSTimer
17 | #define os_timer_func_t ETSTimerFunc
18 |
19 | #endif
20 |
--------------------------------------------------------------------------------
/app/libc/c_ctype.c:
--------------------------------------------------------------------------------
1 | #include "c_ctype.h"
2 | #include "c_types.h"
3 |
4 | // int isalnum(int c){}
5 | // int isalpha(int c){}
6 | // int iscntrl(int c){}
7 | // int isdigit(int c){}
8 | // // int isgraph(int c){}
9 | // int islower(int c){}
10 | // int isprint(int c){}
11 | // int ispunct(int c){}
12 | // int isspace(int c){}
13 | // int isupper(int c){}
14 | // int isxdigit(int c){}
15 | // int tolower(int c){}
16 | // int toupper(int c){}
17 |
--------------------------------------------------------------------------------
/lua_modules/hdc1000/HDC1000-example.lua:
--------------------------------------------------------------------------------
1 | HDC1000 = require("HDC1000")
2 |
3 | sda = 1
4 | scl = 2
5 | drdyn = false
6 |
7 | HDC1000.init(sda, scl, drdyn)
8 | HDC1000.config() -- default values are used if called with no arguments. prototype is config(address, resolution, heater)
9 |
10 | print(string.format("Temperature: %.2f °C\nHumidity: %.2f %%", HDC1000.getTemp(), HDC1000.getHumi()))
11 |
12 | HDC1000 = nil
13 | package.loaded["HDC1000"]=nil
--------------------------------------------------------------------------------
/lua_modules/ds3231/ds3231-example.lua:
--------------------------------------------------------------------------------
1 | require("ds3231")
2 |
3 | -- ESP-01 GPIO Mapping
4 | gpio0, gpio2 = 3, 4
5 |
6 | ds3231.init(gpio0, gpio2)
7 |
8 | second, minute, hour, day, date, month, year = ds3231.getTime();
9 |
10 | -- Get current time
11 | print(string.format("Time & Date: %s:%s:%s %s/%s/%s", hour, minute, second, date, month, year))
12 |
13 | -- Don't forget to release it after use
14 | ds3231 = nil
15 | package.loaded["ds3231"]=nil
16 |
--------------------------------------------------------------------------------
/app/platform/pin_map.h:
--------------------------------------------------------------------------------
1 |
2 | #ifndef __PIN_MAP_H__
3 | #define __PIN_MAP_H__
4 |
5 | #include "c_types.h"
6 | #include "user_config.h"
7 | #include "gpio.h"
8 |
9 | #define GPIO_PIN_NUM 13
10 |
11 | extern uint8_t pin_num[GPIO_PIN_NUM];
12 | extern uint8_t pin_func[GPIO_PIN_NUM];
13 | extern uint32_t pin_mux[GPIO_PIN_NUM];
14 | #ifdef GPIO_INTERRUPT_ENABLE
15 | extern GPIO_INT_TYPE pin_int_type[GPIO_PIN_NUM];
16 | #endif
17 | #endif // #ifndef __PIN_MAP_H__
18 |
--------------------------------------------------------------------------------
/lua_modules/ds18b20/ds18b20-example.lua:
--------------------------------------------------------------------------------
1 | t = require("ds18b20")
2 |
3 | -- ESP-01 GPIO Mapping
4 | gpio0 = 3
5 | gpio2 = 4
6 |
7 | t.setup(gpio0)
8 | addrs = t.addrs()
9 | if (addrs ~= nil) then
10 | print("Total DS18B20 sensors: "..table.getn(addrs))
11 | end
12 |
13 | -- Just read temperature
14 | print("Temperature: "..t.read().."'C")
15 |
16 | -- Don't forget to release it after use
17 | t = nil
18 | ds18b20 = nil
19 | package.loaded["ds18b20"]=nil
20 |
--------------------------------------------------------------------------------
/app/cjson/lua/lua2json.lua:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env lua
2 |
3 | -- usage: lua2json.lua [lua_file]
4 | --
5 | -- Eg:
6 | -- echo '{ "testing" }' | ./lua2json.lua
7 | -- ./lua2json.lua test.lua
8 |
9 | local json = require "cjson"
10 | local util = require "cjson.util"
11 |
12 | local env = {
13 | json = { null = json.null },
14 | null = json.null
15 | }
16 |
17 | local t = util.run_script("data = " .. util.file_load(arg[1]), env)
18 | print(json.encode(t.data))
19 |
20 | -- vi:ai et sw=4 ts=4:
21 |
--------------------------------------------------------------------------------
/app/coap/pdu.h:
--------------------------------------------------------------------------------
1 | #ifndef _PDU_H
2 | #define _PDU_H 1
3 |
4 | #ifdef __cplusplus
5 | extern "C" {
6 | #endif
7 |
8 | #include "coap.h"
9 |
10 | /** Header structure for CoAP PDUs */
11 | typedef struct {
12 | coap_rw_buffer_t scratch;
13 | coap_packet_t *pkt;
14 | coap_rw_buffer_t msg; /**< the CoAP msg to send */
15 | } coap_pdu_t;
16 |
17 | coap_pdu_t *coap_new_pdu(void);
18 |
19 | void coap_delete_pdu(coap_pdu_t *pdu);
20 |
21 | #ifdef __cplusplus
22 | }
23 | #endif
24 |
25 | #endif
26 |
--------------------------------------------------------------------------------
/app/coap/hash.h:
--------------------------------------------------------------------------------
1 | #ifndef _HASH_H
2 | #define _HASH_H 1
3 |
4 | #ifdef __cplusplus
5 | extern "C" {
6 | #endif
7 |
8 | #include "coap.h"
9 |
10 | typedef unsigned char coap_key_t[4];
11 |
12 | /* CoAP transaction id */
13 | /*typedef unsigned short coap_tid_t; */
14 | typedef int coap_tid_t;
15 | #define COAP_INVALID_TID -1
16 |
17 | void coap_transaction_id(const uint32_t ip, const uint32_t port, const coap_packet_t *pkt, coap_tid_t *id);
18 |
19 | #ifdef __cplusplus
20 | }
21 | #endif
22 |
23 | #endif
24 |
--------------------------------------------------------------------------------
/app/libc/c_stdarg.h:
--------------------------------------------------------------------------------
1 | #ifndef __c_stdarg_h
2 | #define __c_stdarg_h
3 |
4 | #if defined(__GNUC__)
5 |
6 | #include
7 |
8 | #else
9 |
10 | typedef char * va_list;
11 |
12 | #define _INTSIZEOF(n) ((sizeof(n) + sizeof(int) - 1) & ~(sizeof(int) - 1))
13 |
14 | #define va_start(ap,v) (ap = (va_list)&v + _INTSIZEOF(v))
15 | #define va_arg(ap,t) (*(t *)((ap += _INTSIZEOF(t)) - _INTSIZEOF(t)))
16 | #define va_end(ap) (ap = (va_list)0)
17 |
18 | #endif
19 |
20 | #endif
21 |
22 | /* end of c_stdarg.h */
23 |
--------------------------------------------------------------------------------
/app/lua/legc.h:
--------------------------------------------------------------------------------
1 | // Lua EGC (Emergeny Garbage Collector) interface
2 |
3 | #ifndef __LEGC_H__
4 | #define __LEGC_H__
5 |
6 | #include "lstate.h"
7 |
8 | // EGC operations modes
9 | #define EGC_NOT_ACTIVE 0 // EGC disabled
10 | #define EGC_ON_ALLOC_FAILURE 1 // run EGC on allocation failure
11 | #define EGC_ON_MEM_LIMIT 2 // run EGC when an upper memory limit is hit
12 | #define EGC_ALWAYS 4 // always run EGC before an allocation
13 |
14 | void legc_set_mode(lua_State *L, int mode, unsigned limit);
15 |
16 | #endif
17 |
18 |
--------------------------------------------------------------------------------
/examples/init.lua:
--------------------------------------------------------------------------------
1 | --init.lua, something like this
2 | countdown = 3
3 | tmr.alarm(0,1000,1,function()
4 | print(countdown)
5 | countdown = countdown-1
6 | if countdown<1 then
7 | tmr.stop(0)
8 | countdown = nil
9 | local s,err
10 | if file.open("user.lc") then
11 | file.close()
12 | s,err = pcall(function() dofile("user.lc") end)
13 | else
14 | s,err = pcall(function() dofile("user.lua") end)
15 | end
16 | if not s then print(err) end
17 | end
18 | end)
19 |
--------------------------------------------------------------------------------
/app/cjson/tests/rfc-example2.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "precision": "zip",
4 | "Latitude": 37.7668,
5 | "Longitude": -122.3959,
6 | "Address": "",
7 | "City": "SAN FRANCISCO",
8 | "State": "CA",
9 | "Zip": "94107",
10 | "Country": "US"
11 | },
12 | {
13 | "precision": "zip",
14 | "Latitude": 37.371991,
15 | "Longitude": -122.026020,
16 | "Address": "",
17 | "City": "SUNNYVALE",
18 | "State": "CA",
19 | "Zip": "94085",
20 | "Country": "US"
21 | }
22 | ]
23 |
--------------------------------------------------------------------------------
/app/include/u8g_config.h:
--------------------------------------------------------------------------------
1 | #ifndef __U8G_CONFIG_H__
2 | #define __U8G_CONFIG_H__
3 |
4 |
5 | // Configure U8glib fonts
6 | // add a U8G_FONT_TABLE_ENTRY for each font you want to compile into the image
7 | #define U8G_FONT_TABLE_ENTRY(font)
8 | #define U8G_FONT_TABLE \
9 | U8G_FONT_TABLE_ENTRY(font_6x10) \
10 | U8G_FONT_TABLE_ENTRY(font_chikita)
11 | #undef U8G_FONT_TABLE_ENTRY
12 |
13 |
14 | // Enable display drivers
15 | #define U8G_SSD1306_128x64_I2C
16 | #define U8G_SSD1306_128x64_SPI
17 | // untested
18 | #undef U8G_PCD8544_84x48
19 |
20 |
21 | #endif /* __U8G_CONFIG_H__ */
22 |
--------------------------------------------------------------------------------
/app/libc/c_stddef.h:
--------------------------------------------------------------------------------
1 | #ifndef __c_stddef_h
2 | #define __c_stddef_h
3 |
4 | typedef signed int ptrdiff_t;
5 |
6 | #if !defined(offsetof)
7 | #define offsetof(s, m) (size_t)&(((s *)0)->m)
8 | #endif
9 |
10 | #if !defined(__size_t)
11 | #define __size_t 1
12 | typedef unsigned int size_t; /* others (e.g. ) also define */
13 | /* the unsigned integral type of the result of the sizeof operator. */
14 | #endif
15 |
16 | #undef NULL /* others (e.g. ) also define */
17 | #define NULL 0
18 | /* null pointer constant. */
19 |
20 | #endif
21 |
22 | /* end of c_stddef.h */
23 |
24 |
--------------------------------------------------------------------------------
/.settings/org.eclipse.cdt.core.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | environment/project/cdt.managedbuild.toolchain.gnu.cross.base.992255352/PATH/delimiter=;
3 | environment/project/cdt.managedbuild.toolchain.gnu.cross.base.992255352/PATH/operation=append
4 | environment/project/cdt.managedbuild.toolchain.gnu.cross.base.992255352/PATH/value=C\:\\Espressif\\xtensa-lx106-elf\\bin;C\:\\MinGW\\bin;C\:\\MinGW\\msys\\1.0\\bin;C\:\\Python27
5 | environment/project/cdt.managedbuild.toolchain.gnu.cross.base.992255352/append=true
6 | environment/project/cdt.managedbuild.toolchain.gnu.cross.base.992255352/appendContributed=true
7 |
--------------------------------------------------------------------------------
/app/cjson/fpconv.h:
--------------------------------------------------------------------------------
1 | /* Lua CJSON floating point conversion routines */
2 |
3 | /* Buffer required to store the largest string representation of a double.
4 | *
5 | * Longest double printed with %.14g is 21 characters long:
6 | * -1.7976931348623e+308 */
7 | # define FPCONV_G_FMT_BUFSIZE 32
8 |
9 | #ifdef USE_INTERNAL_FPCONV
10 | static inline void fpconv_init()
11 | {
12 | /* Do nothing - not required */
13 | }
14 | #else
15 | extern inline void fpconv_init();
16 | #endif
17 |
18 | extern int fpconv_g_fmt(char*, double, int);
19 | extern double fpconv_strtod(const char*, char**);
20 |
21 | /* vi:ai et sw=4 ts=4:
22 | */
23 |
--------------------------------------------------------------------------------
/app/coap/str.c:
--------------------------------------------------------------------------------
1 | /* str.c -- strings to be used in the CoAP library
2 | *
3 | * Copyright (C) 2010,2011 Olaf Bergmann
4 | *
5 | * This file is part of the CoAP library libcoap. Please see
6 | * README for terms of use.
7 | */
8 |
9 | #include "c_stdlib.h"
10 | #include "c_types.h"
11 |
12 | #include "str.h"
13 |
14 | str * coap_new_string(size_t size) {
15 | str *s = (str *)c_malloc(sizeof(str) + size + 1);
16 | if ( !s ) {
17 | return NULL;
18 | }
19 |
20 | c_memset(s, 0, sizeof(str));
21 | s->s = ((unsigned char *)s) + sizeof(str);
22 | return s;
23 | }
24 |
25 | void coap_delete_string(str *s) {
26 | c_free(s);
27 | }
28 |
29 |
--------------------------------------------------------------------------------
/app/include/netif/wlan_lwip_if.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010-2011 Espressif System
3 | *
4 | */
5 |
6 | #ifndef _WLAN_LWIP_IF_H_
7 | #define _WLAN_LWIP_IF_H_
8 |
9 | #define LWIP_IF0_PRIO 28
10 | #define LWIP_IF1_PRIO 29
11 |
12 | enum {
13 | SIG_LWIP_RX = 0,
14 | };
15 |
16 | struct netif * eagle_lwip_if_alloc(struct ieee80211_conn *conn, const uint8 *macaddr, struct ip_info *info);
17 | struct netif * eagle_lwip_getif(uint8 index);
18 |
19 | #ifndef IOT_SIP_MODE
20 | sint8 ieee80211_output_pbuf(struct netif *ifp, struct pbuf* pb);
21 | #else
22 | sint8 ieee80211_output_pbuf(struct ieee80211_conn *conn, esf_buf *eb);
23 | #endif
24 |
25 | #endif /* _WLAN_LWIP_IF_H_ */
26 |
--------------------------------------------------------------------------------
/include/smartconfig.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 -2018 Espressif System
3 | *
4 | */
5 |
6 | #ifndef __SMARTCONFIG_H__
7 | #define __SMARTCONFIG_H__
8 |
9 | typedef void (*sc_callback_t)(void *data);
10 |
11 | typedef enum {
12 | SC_STATUS_FIND_CHANNEL = 0,
13 | SC_STATUS_GETTING_SSID_PSWD,
14 | SC_STATUS_GOT_SSID_PSWD,
15 | SC_STATUS_LINK,
16 | } sc_status;
17 |
18 | typedef enum {
19 | SC_TYPE_ESPTOUCH = 0,
20 | SC_TYPE_AIRKISS,
21 | } sc_type;
22 |
23 | sc_status smartconfig_get_status(void);
24 | const char *smartconfig_get_version(void);
25 | bool smartconfig_start(sc_type type, sc_callback_t cb);
26 | bool smartconfig_stop(void);
27 |
28 | #endif
29 |
--------------------------------------------------------------------------------
/examples/tel.lua:
--------------------------------------------------------------------------------
1 | -- a simple telnet server
2 | s=net.createServer(net.TCP,180)
3 | s:listen(2323,function(c)
4 | function s_output(str)
5 | if(c~=nil)
6 | then c:send(str)
7 | end
8 | end
9 | node.output(s_output, 0) -- re-direct output to function s_ouput.
10 | c:on("receive",function(c,l)
11 | node.input(l) -- works like pcall(loadstring(l)) but support multiple separate line
12 | end)
13 | c:on("disconnection",function(c)
14 | node.output(nil) -- un-regist the redirect output function, output goes to serial
15 | end)
16 | print("Welcome to NodeMcu world.")
17 | end)
--------------------------------------------------------------------------------
/lua_examples/telnet2.lua:
--------------------------------------------------------------------------------
1 | -- a simple telnet server
2 | s=net.createServer(net.TCP,180)
3 | s:listen(2323,function(c)
4 | function s_output(str)
5 | if(c~=nil)
6 | then c:send(str)
7 | end
8 | end
9 | node.output(s_output, 0) -- re-direct output to function s_ouput.
10 | c:on("receive",function(c,l)
11 | node.input(l) -- works like pcall(loadstring(l)) but support multiple separate line
12 | end)
13 | c:on("disconnection",function(c)
14 | node.output(nil) -- un-regist the redirect output function, output goes to serial
15 | end)
16 | print("Welcome to NodeMcu world.")
17 | end)
--------------------------------------------------------------------------------
/app/include/driver/key.h:
--------------------------------------------------------------------------------
1 | #ifndef __KEY_H__
2 | #define __KEY_H__
3 |
4 | #include "gpio.h"
5 |
6 | typedef void (* key_function)(void);
7 |
8 | struct single_key_param {
9 | uint8 key_level;
10 | uint8 gpio_id;
11 | uint8 gpio_func;
12 | uint32 gpio_name;
13 | os_timer_t key_5s;
14 | os_timer_t key_50ms;
15 | key_function short_press;
16 | key_function long_press;
17 | };
18 |
19 | struct keys_param {
20 | uint8 key_num;
21 | struct single_key_param **single_key;
22 | };
23 |
24 | struct single_key_param *key_init_single(uint8 gpio_id, uint32 gpio_name, uint8 gpio_func, key_function long_press, key_function short_press);
25 | void key_init(struct keys_param *key);
26 |
27 | #endif
28 |
--------------------------------------------------------------------------------
/app/mqtt/msg_queue.h:
--------------------------------------------------------------------------------
1 | #ifndef _MSG_QUEUE_H
2 | #define _MSG_QUEUE_H 1
3 | #include "mqtt_msg.h"
4 | #ifdef __cplusplus
5 | extern "C" {
6 | #endif
7 |
8 | struct msg_queue_t;
9 |
10 | typedef struct msg_queue_t {
11 | struct msg_queue_t *next;
12 | mqtt_message_t msg;
13 | uint16_t msg_id;
14 | int msg_type;
15 | int publish_qos;
16 | } msg_queue_t;
17 |
18 | msg_queue_t * msg_enqueue(msg_queue_t **head, mqtt_message_t *msg, uint16_t msg_id, int msg_type, int publish_qos);
19 | void msg_destroy(msg_queue_t *node);
20 | msg_queue_t * msg_dequeue(msg_queue_t **head);
21 | msg_queue_t * msg_peek(msg_queue_t **head);
22 | int msg_size(msg_queue_t **head);
23 |
24 | #ifdef __cplusplus
25 | }
26 | #endif
27 |
28 | #endif
29 |
--------------------------------------------------------------------------------
/app/cjson/tests/example3.json:
--------------------------------------------------------------------------------
1 | {"widget": {
2 | "debug": "on",
3 | "window": {
4 | "title": "Sample Konfabulator Widget",
5 | "name": "main_window",
6 | "width": 500,
7 | "height": 500
8 | },
9 | "image": {
10 | "src": "Images/Sun.png",
11 | "name": "sun1",
12 | "hOffset": 250,
13 | "vOffset": 250,
14 | "alignment": "center"
15 | },
16 | "text": {
17 | "data": "Click Here",
18 | "size": 36,
19 | "style": "bold",
20 | "name": "text1",
21 | "hOffset": 250,
22 | "vOffset": 100,
23 | "alignment": "center",
24 | "onMouseUp": "sun1.opacity = (sun1.opacity / 100) * 90;"
25 | }
26 | }}
27 |
--------------------------------------------------------------------------------
/lua_modules/si7021/si7021-example.lua:
--------------------------------------------------------------------------------
1 |
2 | tmr.alarm(0, 60000, 1, function()
3 |
4 | SDA_PIN = 6 -- sda pin, GPIO12
5 | SCL_PIN = 5 -- scl pin, GPIO14
6 |
7 | si7021 = require("si7021")
8 | si7021.init(SDA_PIN, SCL_PIN)
9 | si7021.read(OSS)
10 | h = si7021.getHumidity()
11 | t = si7021.getTemperature()
12 |
13 | -- pressure in differents units
14 | print("Humidity: "..(h / 100).."."..(h % 100).." %")
15 |
16 | -- temperature in degrees Celsius and Farenheit
17 | print("Temperature: "..(t/100).."."..(t%100).." deg C")
18 | print("Temperature: "..(9 * t / 500 + 32).."."..(9 * t / 50 % 10).." deg F")
19 |
20 | -- release module
21 | si7021 = nil
22 | package.loaded["si7021"]=nil
23 |
24 | end)
25 |
--------------------------------------------------------------------------------
/.settings/language.settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/app/cjson/tests/genutf8.pl:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env perl
2 |
3 | # Create test comparison data using a different UTF-8 implementation.
4 |
5 | # The generated utf8.dat file must have the following MD5 sum:
6 | # cff03b039d850f370a7362f3313e5268
7 |
8 | use strict;
9 |
10 | # 0xD800 - 0xDFFF are used to encode supplementary codepoints
11 | # 0x10000 - 0x10FFFF are supplementary codepoints
12 | my (@codepoints) = (0 .. 0xD7FF, 0xE000 .. 0x10FFFF);
13 |
14 | my $utf8 = pack("U*", @codepoints);
15 | defined($utf8) or die "Unable create UTF-8 string\n";
16 |
17 | open(FH, ">:utf8", "utf8.dat")
18 | or die "Unable to open utf8.dat: $!\n";
19 | print FH $utf8
20 | or die "Unable to write utf8.dat\n";
21 | close(FH);
22 |
23 | # vi:ai et sw=4 ts=4:
24 |
--------------------------------------------------------------------------------
/app/coap/coap_timer.h:
--------------------------------------------------------------------------------
1 | #ifndef _COAP_TIMER_H
2 | #define _COAP_TIMER_H 1
3 |
4 | #ifdef __cplusplus
5 | extern "C" {
6 | #endif
7 |
8 | #include "node.h"
9 |
10 | #define SYS_TIME_MAX (0xFFFFFFFF / 1000)
11 |
12 | #define COAP_DEFAULT_RESPONSE_TIMEOUT 2 /* response timeout in seconds */
13 | #define COAP_DEFAULT_MAX_RETRANSMIT 4 /* max number of retransmissions */
14 | #define COAP_TICKS_PER_SECOND 1000 // ms
15 | #define DEFAULT_MAX_TRANSMIT_WAIT 90
16 |
17 | void coap_timer_elapsed(coap_tick_t *diff);
18 |
19 | void coap_timer_setup(coap_queue_t ** queue, coap_tick_t t);
20 |
21 | void coap_timer_stop(void);
22 |
23 | void coap_timer_update(coap_queue_t ** queue);
24 |
25 | void coap_timer_start(coap_queue_t ** queue);
26 |
27 | #ifdef __cplusplus
28 | }
29 | #endif
30 |
31 | #endif
32 |
--------------------------------------------------------------------------------
/lua_modules/bh1750/bh1750_Example1.lua:
--------------------------------------------------------------------------------
1 | -- ***************************************************************************
2 | -- BH1750 Example Program for ESP8266 with nodeMCU
3 | -- BH1750 compatible tested 2015-1-30
4 | --
5 | -- Written by xiaohu
6 | --
7 | -- MIT license, http://opensource.org/licenses/MIT
8 | -- ***************************************************************************
9 | tmr.alarm(0, 10000, 1, function()
10 |
11 | SDA_PIN = 6 -- sda pin, GPIO12
12 | SCL_PIN = 5 -- scl pin, GPIO14
13 |
14 | bh1750 = require("bh1750")
15 | bh1750.init(SDA_PIN, SCL_PIN)
16 | bh1750.read(OSS)
17 | l = bh1750.getlux()
18 | print("lux: "..(l / 100).."."..(l % 100).." lx")
19 |
20 | -- release module
21 | bh1750 = nil
22 | package.loaded["bh1750"]=nil
23 |
24 | end)
25 |
--------------------------------------------------------------------------------
/include/spi_flash.h:
--------------------------------------------------------------------------------
1 | /*
2 | * copyright (c) Espressif System 2010
3 | *
4 | */
5 |
6 | #ifndef SPI_FLASH_H
7 | #define SPI_FLASH_H
8 |
9 | typedef enum {
10 | SPI_FLASH_RESULT_OK,
11 | SPI_FLASH_RESULT_ERR,
12 | SPI_FLASH_RESULT_TIMEOUT
13 | } SpiFlashOpResult;
14 |
15 | typedef struct{
16 | uint32 deviceId;
17 | uint32 chip_size; // chip size in byte
18 | uint32 block_size;
19 | uint32 sector_size;
20 | uint32 page_size;
21 | uint32 status_mask;
22 | } SpiFlashChip;
23 |
24 | #define SPI_FLASH_SEC_SIZE 4096
25 |
26 | uint32 spi_flash_get_id(void);
27 | SpiFlashOpResult spi_flash_erase_sector(uint16 sec);
28 | SpiFlashOpResult spi_flash_write(uint32 des_addr, uint32 *src_addr, uint32 size);
29 | SpiFlashOpResult spi_flash_read(uint32 src_addr, uint32 *des_addr, uint32 size);
30 |
31 | #endif
32 |
--------------------------------------------------------------------------------
/include/ping.h:
--------------------------------------------------------------------------------
1 | #ifndef __PING_H__
2 | #define __PING_H__
3 |
4 |
5 | typedef void (* ping_recv_function)(void* arg, void *pdata);
6 | typedef void (* ping_sent_function)(void* arg, void *pdata);
7 |
8 | struct ping_option{
9 | uint32 count;
10 | uint32 ip;
11 | uint32 coarse_time;
12 | ping_recv_function recv_function;
13 | ping_sent_function sent_function;
14 | void* reverse;
15 | };
16 |
17 | struct ping_resp{
18 | uint32 total_count;
19 | uint32 resp_time;
20 | uint32 seqno;
21 | uint32 timeout_count;
22 | uint32 bytes;
23 | uint32 total_bytes;
24 | uint32 total_time;
25 | sint8 ping_err;
26 | };
27 |
28 | bool ping_start(struct ping_option *ping_opt);
29 | bool ping_regist_recv(struct ping_option *ping_opt, ping_recv_function ping_recv);
30 | bool ping_regist_sent(struct ping_option *ping_opt, ping_sent_function ping_sent);
31 |
32 | #endif /* __PING_H__ */
33 |
--------------------------------------------------------------------------------
/app/coap/str.h:
--------------------------------------------------------------------------------
1 | /* str.h -- strings to be used in the CoAP library
2 | *
3 | * Copyright (C) 2010,2011 Olaf Bergmann
4 | *
5 | * This file is part of the CoAP library libcoap. Please see
6 | * README for terms of use.
7 | */
8 |
9 | #ifndef _COAP_STR_H_
10 | #define _COAP_STR_H_
11 |
12 | #include "c_string.h"
13 |
14 | typedef struct {
15 | size_t length; /* length of string */
16 | unsigned char *s; /* string data */
17 | } str;
18 |
19 | #define COAP_SET_STR(st,l,v) { (st)->length = (l), (st)->s = (v); }
20 |
21 | /**
22 | * Returns a new string object with at least size bytes storage
23 | * allocated. The string must be released using coap_delete_string();
24 | */
25 | str *coap_new_string(size_t size);
26 |
27 | /** Deletes the given string and releases any memory allocated. */
28 | void coap_delete_string(str *);
29 |
30 | #endif /* _COAP_STR_H_ */
31 |
--------------------------------------------------------------------------------
/app/platform/flash_fs.c:
--------------------------------------------------------------------------------
1 | #include "flash_fs.h"
2 | #include "c_string.h"
3 |
4 | #if defined( BUILD_WOFS )
5 | #include "romfs.h"
6 | #elif defined( BUILD_SPIFFS )
7 | #include "spiffs.h"
8 | #endif
9 |
10 | int fs_mode2flag(const char *mode){
11 | if(c_strlen(mode)==1){
12 | if(c_strcmp(mode,"w")==0)
13 | return FS_WRONLY|FS_CREAT|FS_TRUNC;
14 | else if(c_strcmp(mode, "r")==0)
15 | return FS_RDONLY;
16 | else if(c_strcmp(mode, "a")==0)
17 | return FS_WRONLY|FS_CREAT|FS_APPEND;
18 | else
19 | return FS_RDONLY;
20 | } else if (c_strlen(mode)==2){
21 | if(c_strcmp(mode,"r+")==0)
22 | return FS_RDWR;
23 | else if(c_strcmp(mode, "w+")==0)
24 | return FS_RDWR|FS_CREAT|FS_TRUNC;
25 | else if(c_strcmp(mode, "a+")==0)
26 | return FS_RDWR|FS_CREAT|FS_APPEND;
27 | else
28 | return FS_RDONLY;
29 | } else {
30 | return FS_RDONLY;
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/lua_modules/ds18b20/ds18b20-web.lua:
--------------------------------------------------------------------------------
1 | require('ds18b20')
2 |
3 | port = 80
4 |
5 | -- ESP-01 GPIO Mapping
6 | gpio0, gpio2 = 3, 4
7 |
8 | ds18b20.setup(gpio0)
9 |
10 | srv=net.createServer(net.TCP)
11 | srv:listen(port,
12 | function(conn)
13 | conn:send("HTTP/1.1 200 OK\nContent-Type: text/html\nRefresh: 5\n\n" ..
14 | "" ..
15 | "" ..
16 | "ESP8266" ..
17 | "Temperature : " .. ds18b20.read() .. "
" ..
18 | "Node ChipID : " .. node.chipid() .. "
" ..
19 | "Node MAC : " .. wifi.sta.getmac() .. "
" ..
20 | "Node Heap : " .. node.heap() .. "
" ..
21 | "Timer Ticks : " .. tmr.now() .. "
" ..
22 | "")
23 | conn:on("sent",function(conn) conn:close() end)
24 | end
25 | )
26 |
27 |
28 |
--------------------------------------------------------------------------------
/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | nodemcu-firmware
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.cdt.managedbuilder.core.genmakebuilder
10 | clean,full,incremental,
11 |
12 |
13 |
14 |
15 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder
16 | full,incremental,
17 |
18 |
19 |
20 |
21 |
22 | org.eclipse.cdt.core.cnature
23 | org.eclipse.cdt.core.ccnature
24 | org.eclipse.cdt.managedbuilder.core.managedBuildNature
25 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
26 |
27 |
28 |
--------------------------------------------------------------------------------
/app/cjson/tests/example1.json:
--------------------------------------------------------------------------------
1 | {
2 | "glossary": {
3 | "title": "example glossary",
4 | "GlossDiv": {
5 | "title": "S",
6 | "GlossList": {
7 | "GlossEntry": {
8 | "ID": "SGML",
9 | "SortAs": "SGML",
10 | "GlossTerm": "Standard Generalized Mark up Language",
11 | "Acronym": "SGML",
12 | "Abbrev": "ISO 8879:1986",
13 | "GlossDef": {
14 | "para": "A meta-markup language, used to create markup languages such as DocBook.",
15 | "GlossSeeAlso": ["GML", "XML"]
16 | },
17 | "GlossSee": "markup"
18 | }
19 | }
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/app/cjson/tests/example5.json:
--------------------------------------------------------------------------------
1 | {"menu": {
2 | "header": "SVG Viewer",
3 | "items": [
4 | {"id": "Open"},
5 | {"id": "OpenNew", "label": "Open New"},
6 | null,
7 | {"id": "ZoomIn", "label": "Zoom In"},
8 | {"id": "ZoomOut", "label": "Zoom Out"},
9 | {"id": "OriginalView", "label": "Original View"},
10 | null,
11 | {"id": "Quality"},
12 | {"id": "Pause"},
13 | {"id": "Mute"},
14 | null,
15 | {"id": "Find", "label": "Find..."},
16 | {"id": "FindAgain", "label": "Find Again"},
17 | {"id": "Copy"},
18 | {"id": "CopyAgain", "label": "Copy Again"},
19 | {"id": "CopySVG", "label": "Copy SVG"},
20 | {"id": "ViewSVG", "label": "View SVG"},
21 | {"id": "ViewSource", "label": "View Source"},
22 | {"id": "SaveAs", "label": "Save As"},
23 | null,
24 | {"id": "Help"},
25 | {"id": "About", "label": "About Adobe CVG Viewer..."}
26 | ]
27 | }}
28 |
--------------------------------------------------------------------------------
/app/coap/hash.c:
--------------------------------------------------------------------------------
1 | #include "hash.h"
2 | #include "c_string.h"
3 | /* Caution: When changing this, update COAP_DEFAULT_WKC_HASHKEY
4 | * accordingly (see int coap_hash_path());
5 | */
6 | void coap_hash(const unsigned char *s, unsigned int len, coap_key_t h) {
7 | size_t j;
8 |
9 | while (len--) {
10 | j = sizeof(coap_key_t)-1;
11 |
12 | while (j) {
13 | h[j] = ((h[j] << 7) | (h[j-1] >> 1)) + h[j];
14 | --j;
15 | }
16 |
17 | h[0] = (h[0] << 7) + h[0] + *s++;
18 | }
19 | }
20 |
21 | void coap_transaction_id(const uint32_t ip, const uint32_t port, const coap_packet_t *pkt, coap_tid_t *id) {
22 | coap_key_t h;
23 | c_memset(h, 0, sizeof(coap_key_t));
24 |
25 | /* Compare the transport address. */
26 | coap_hash((const unsigned char *)&(port), sizeof(port), h);
27 | coap_hash((const unsigned char *)&(ip), sizeof(ip), h);
28 | coap_hash((const unsigned char *)(pkt->hdr.id), sizeof(pkt->hdr.id), h);
29 | *id = ((h[0] << 8) | h[1]) ^ ((h[2] << 8) | h[3]);
30 | }
31 |
--------------------------------------------------------------------------------
/app/libc/c_ctype.h:
--------------------------------------------------------------------------------
1 | #ifndef _C_CTYPE_H_
2 | #define _C_CTYPE_H_
3 |
4 | #if 0
5 | int isalnum(int);
6 | int isalpha(int);
7 | int iscntrl(int);
8 | int isdigit(int);
9 | // int isgraph(int);
10 | int islower(int);
11 | int isprint(int);
12 | int ispunct(int);
13 | int isspace(int);
14 | int isupper(int);
15 | int isxdigit(int);
16 | int tolower(int);
17 | int toupper(int);
18 |
19 | #if !defined(__STRICT_ANSI__) || defined(__cplusplus) || __STDC_VERSION__ >= 199901L
20 | // int isblank(int);
21 | #endif
22 |
23 | #ifndef __STRICT_ANSI__
24 | // int isascii(int);
25 | // int toascii(int);
26 | #define _tolower(__c) ((unsigned char)(__c) - 'A' + 'a')
27 | #define _toupper(__c) ((unsigned char)(__c) - 'a' + 'A')
28 | #endif
29 |
30 | #define _U 01
31 | #define _L 02
32 | #define _N 04
33 | #define _S 010
34 | #define _P 020
35 | #define _C 040
36 | #define _X 0100
37 | #define _B 0200
38 |
39 | /* For C++ backward-compatibility only. */
40 | // extern char _ctype_[];
41 | #endif
42 | #endif /* _C_CTYPE_H_ */
43 |
--------------------------------------------------------------------------------
/app/spiffs/test/params_test.h:
--------------------------------------------------------------------------------
1 | /*
2 | * params_test.h
3 | *
4 | * Created on: May 26, 2013
5 | * Author: petera
6 | */
7 |
8 | #ifndef PARAMS_TEST_H_
9 | #define PARAMS_TEST_H_
10 |
11 | // total emulated spi flash size
12 | #define PHYS_FLASH_SIZE (16*1024*1024)
13 | // spiffs file system size
14 | #define SPIFFS_FLASH_SIZE (2*1024*1024)
15 | // spiffs file system offset in emulated spi flash
16 | #define SPIFFS_PHYS_ADDR (4*1024*1024)
17 |
18 | #define SECTOR_SIZE 65536
19 | #define LOG_BLOCK (SECTOR_SIZE*2)
20 | #define LOG_PAGE (SECTOR_SIZE/256)
21 |
22 | #define FD_BUF_SIZE 64*6
23 | #define CACHE_BUF_SIZE (LOG_PAGE + 32)*8
24 |
25 | #define ASSERT(c, m) real_assert((c),(m), __FILE__, __LINE__);
26 |
27 | typedef signed int s32_t;
28 | typedef unsigned int u32_t;
29 | typedef signed short s16_t;
30 | typedef unsigned short u16_t;
31 | typedef signed char s8_t;
32 | typedef unsigned char u8_t;
33 |
34 | void real_assert(int c, const char *n, const char *file, int l);
35 |
36 | #endif /* PARAMS_TEST_H_ */
37 |
--------------------------------------------------------------------------------
/lua_examples/telnet.lua:
--------------------------------------------------------------------------------
1 | print("====Wicon, a LUA console over wifi.==========")
2 | print("Author: openthings@163.com. copyright&GPL V2.")
3 | print("Last modified 2014-11-19. V0.2")
4 | print("Wicon Server starting ......")
5 |
6 | function connected(conn)
7 | print("Wifi console connected.")
8 | function s_output(str)
9 | if (conn~=nil) then
10 | conn:send(str)
11 | end
12 | end
13 | node.output(s_output,0)
14 | conn:on("receive", function(conn, pl)
15 | node.input(pl)
16 | end)
17 | conn:on("disconnection",function(conn)
18 | node.output(nil)
19 | end)
20 | print("Welcome to NodeMcu world.")
21 | end
22 |
23 | function startServer()
24 | print("Wifi AP connected. Wicon IP:")
25 | print(wifi.sta.getip())
26 | sv=net.createServer(net.TCP, 180)
27 | sv:listen(2323, connected)
28 | print("Telnet Server running at :2323")
29 | print("===Now, logon and input LUA.====")
30 | end
31 |
32 | tmr.alarm(1, 1000, 1, function()
33 | if wifi.sta.getip()=="0.0.0.0" then
34 | print("Connect AP, Waiting...")
35 | else
36 | startServer()
37 | tmr.stop(1)
38 | end
39 | end)
40 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2014 zeroday nodemcu.com
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
23 |
--------------------------------------------------------------------------------
/app/spiffs/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2013-2015 Peter Andersson (pelleplutt1976gmail.com)
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy of
6 | this software and associated documentation files (the "Software"), to deal in
7 | the Software without restriction, including without limitation the rights to
8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9 | the Software, and to permit persons to whom the Software is furnished to do so,
10 | subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 |
--------------------------------------------------------------------------------
/app/lua/ldebug.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** $Id: ldebug.h,v 2.3.1.1 2007/12/27 13:02:25 roberto Exp $
3 | ** Auxiliary functions from Debug Interface module
4 | ** See Copyright Notice in lua.h
5 | */
6 |
7 | #ifndef ldebug_h
8 | #define ldebug_h
9 |
10 |
11 | #include "lstate.h"
12 |
13 |
14 | #define pcRel(pc, p) (cast(int, (pc) - (p)->code) - 1)
15 |
16 | #define getline(f,pc) (((f)->lineinfo) ? (f)->lineinfo[pc] : 0)
17 |
18 | #define resethookcount(L) (L->hookcount = L->basehookcount)
19 |
20 |
21 | LUAI_FUNC void luaG_typeerror (lua_State *L, const TValue *o,
22 | const char *opname);
23 | LUAI_FUNC void luaG_concaterror (lua_State *L, StkId p1, StkId p2);
24 | LUAI_FUNC void luaG_aritherror (lua_State *L, const TValue *p1,
25 | const TValue *p2);
26 | LUAI_FUNC int luaG_ordererror (lua_State *L, const TValue *p1,
27 | const TValue *p2);
28 | LUAI_FUNC void luaG_runerror (lua_State *L, const char *fmt, ...);
29 | LUAI_FUNC void luaG_errormsg (lua_State *L);
30 | LUAI_FUNC int luaG_checkcode (const Proto *pt);
31 | LUAI_FUNC int luaG_checkopenop (Instruction i);
32 |
33 | #endif
34 |
--------------------------------------------------------------------------------
/app/coap/LICENSE.txt:
--------------------------------------------------------------------------------
1 | Copyright (c) 2013 Toby Jaffey
2 | 2015 Zeroday Hong nodemcu.com
3 |
4 | Permission is hereby granted, free of charge, to any person obtaining a copy
5 | of this software and associated documentation files (the "Software"), to deal
6 | in the Software without restriction, including without limitation the rights
7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | copies of the Software, and to permit persons to whom the Software is
9 | furnished to do so, subject to the following conditions:
10 |
11 | The above copyright notice and this permission notice shall be included in
12 | all copies or substantial portions of the Software.
13 |
14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 | THE SOFTWARE.
21 |
--------------------------------------------------------------------------------
/app/cjson/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2010-2012 Mark Pulford
2 | 2015 Zeroday Hong nodemcu.com
3 |
4 | Permission is hereby granted, free of charge, to any person obtaining
5 | a copy of this software and associated documentation files (the
6 | "Software"), to deal in the Software without restriction, including
7 | without limitation the rights to use, copy, modify, merge, publish,
8 | distribute, sublicense, and/or sell copies of the Software, and to
9 | permit persons to whom the Software is furnished to do so, subject to
10 | the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be
13 | included in all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
19 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
20 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
21 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 |
--------------------------------------------------------------------------------
/app/include/driver/pwm.h:
--------------------------------------------------------------------------------
1 | #ifndef __PWM_H__
2 | #define __PWM_H__
3 |
4 | #define PWM_CHANNEL 6
5 |
6 | struct pwm_single_param {
7 | uint16 gpio_set;
8 | uint16 gpio_clear;
9 | uint32 h_time;
10 | };
11 |
12 | struct pwm_param {
13 | uint32 period;
14 | uint16 freq;
15 | uint16 duty[PWM_CHANNEL];
16 | };
17 |
18 | #define PWM_DEPTH 1023
19 | #define PWM_FREQ_MAX 1000
20 |
21 | #define PWM_1S 1000000
22 |
23 | // #define PWM_0_OUT_IO_MUX PERIPHS_IO_MUX_MTMS_U
24 | // #define PWM_0_OUT_IO_NUM 14
25 | // #define PWM_0_OUT_IO_FUNC FUNC_GPIO14
26 |
27 | // #define PWM_1_OUT_IO_MUX PERIPHS_IO_MUX_MTDI_U
28 | // #define PWM_1_OUT_IO_NUM 12
29 | // #define PWM_1_OUT_IO_FUNC FUNC_GPIO12
30 |
31 | // #define PWM_2_OUT_IO_MUX PERIPHS_IO_MUX_MTCK_U
32 | // #define PWM_2_OUT_IO_NUM 13
33 | // #define PWM_2_OUT_IO_FUNC FUNC_GPIO13
34 |
35 | void pwm_init(uint16 freq, uint16 *duty);
36 | void pwm_start(void);
37 |
38 | void pwm_set_duty(uint16 duty, uint8 channel);
39 | uint16 pwm_get_duty(uint8 channel);
40 | void pwm_set_freq(uint16 freq, uint8 channel);
41 | uint16 pwm_get_freq(uint8 channel);
42 | bool pwm_add(uint8 channel);
43 | bool pwm_delete(uint8 channel);
44 | bool pwm_exist(uint8 channel);
45 | #endif
46 |
47 |
--------------------------------------------------------------------------------
/app/libc/c_string.h:
--------------------------------------------------------------------------------
1 | /*
2 | * c_string.h
3 | *
4 | * Definitions for memory and string functions.
5 | */
6 |
7 | #ifndef _C_STRING_H_
8 | #define _C_STRING_H_
9 | #include "c_stddef.h"
10 | #include "osapi.h"
11 |
12 | #ifndef NULL
13 | #define NULL 0
14 | #endif
15 |
16 | #define c_memcmp os_memcmp
17 | #define c_memcpy os_memcpy
18 | #define c_memset os_memset
19 |
20 | #define c_strcat os_strcat
21 | #define c_strchr os_strchr
22 | #define c_strcmp os_strcmp
23 | #define c_strcpy os_strcpy
24 | #define c_strlen os_strlen
25 | #define c_strncmp os_strncmp
26 | #define c_strncpy os_strncpy
27 | // #define c_strstr os_strstr
28 | #define c_strncasecmp c_strncmp
29 |
30 | #define c_strstr strstr
31 | #define c_strncat strncat
32 | #define c_strcspn strcspn
33 | #define c_strpbrk strpbrk
34 | #define c_strcoll strcoll
35 | #define c_strrchr strrchr
36 |
37 | // const char *c_strstr(const char * __s1, const char * __s2);
38 | // char *c_strncat(char * __restrict /*s1*/, const char * __restrict /*s2*/, size_t n);
39 | // size_t c_strcspn(const char * s1, const char * s2);
40 | // const char *c_strpbrk(const char * /*s1*/, const char * /*s2*/);
41 | // int c_strcoll(const char * /*s1*/, const char * /*s2*/);
42 |
43 | #endif /* _C_STRING_H_ */
44 |
--------------------------------------------------------------------------------
/app/include/user_modules.h:
--------------------------------------------------------------------------------
1 | #ifndef __USER_MODULES_H__
2 | #define __USER_MODULES_H__
3 |
4 | #define LUA_USE_BUILTIN_STRING // for string.xxx()
5 | #define LUA_USE_BUILTIN_TABLE // for table.xxx()
6 | #define LUA_USE_BUILTIN_COROUTINE // for coroutine.xxx()
7 | #define LUA_USE_BUILTIN_MATH // for math.xxx(), partially work
8 | // #define LUA_USE_BUILTIN_IO // for io.xxx(), partially work
9 |
10 | // #define LUA_USE_BUILTIN_OS // for os.xxx(), not work
11 | // #define LUA_USE_BUILTIN_DEBUG // for debug.xxx(), not work
12 |
13 | #define LUA_USE_MODULES
14 |
15 | #ifdef LUA_USE_MODULES
16 | #define LUA_USE_MODULES_NODE
17 | #define LUA_USE_MODULES_FILE
18 | #define LUA_USE_MODULES_GPIO
19 | #define LUA_USE_MODULES_WIFI
20 | #define LUA_USE_MODULES_NET
21 | #define LUA_USE_MODULES_PWM
22 | #define LUA_USE_MODULES_I2C
23 | #define LUA_USE_MODULES_SPI
24 | #define LUA_USE_MODULES_TMR
25 | #define LUA_USE_MODULES_ADC
26 | #define LUA_USE_MODULES_UART
27 | #define LUA_USE_MODULES_OW
28 | #define LUA_USE_MODULES_BIT
29 | #define LUA_USE_MODULES_MQTT
30 | #define LUA_USE_MODULES_COAP
31 | #define LUA_USE_MODULES_U8G
32 | #define LUA_USE_MODULES_WS2812
33 | #define LUA_USE_MODULES_CJSON
34 | #endif /* LUA_USE_MODULES */
35 |
36 | #endif /* __USER_MODULES_H__ */
37 |
--------------------------------------------------------------------------------
/examples/telnet.lua:
--------------------------------------------------------------------------------
1 | print("====Wicon, a LUA console over wifi.==========")
2 | print("Author: openthings@163.com. copyright&GPL V2.")
3 | print("Last modified 2014-11-19. V0.2")
4 | print("Wicon Server starting ......")
5 |
6 | function startServer()
7 | print("Wifi AP connected. Wicon IP:")
8 | print(wifi.sta.getip())
9 | sv=net.createServer(net.TCP, 180)
10 | sv:listen(8080, function(conn)
11 | print("Wifi console connected.")
12 |
13 | function s_output(str)
14 | if (conn~=nil) then
15 | conn:send(str)
16 | end
17 | end
18 | node.output(s_output,0)
19 |
20 | conn:on("receive", function(conn, pl)
21 | node.input(pl)
22 | if (conn==nil) then
23 | print("conn is nil.")
24 | end
25 | end)
26 | conn:on("disconnection",function(conn)
27 | node.output(nil)
28 | end)
29 | end)
30 | print("Wicon Server running at :8080")
31 | print("===Now,Using xcon_tcp logon and input LUA.====")
32 | end
33 |
34 | tmr.alarm(0, 1000, 1, function()
35 | if wifi.sta.getip()=="0.0.0.0" then
36 | print("Connect AP, Waiting...")
37 | else
38 | startServer()
39 | tmr.stop()
40 | end
41 | end)
42 |
--------------------------------------------------------------------------------
/app/lua/lualib.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** $Id: lualib.h,v 1.36.1.1 2007/12/27 13:02:25 roberto Exp $
3 | ** Lua standard libraries
4 | ** See Copyright Notice in lua.h
5 | */
6 |
7 |
8 | #ifndef lualib_h
9 | #define lualib_h
10 |
11 | #include "lua.h"
12 |
13 |
14 | /* Key to file-handle type */
15 | #define LUA_FILEHANDLE "INT"
16 |
17 |
18 | #define LUA_COLIBNAME "coroutine"
19 | LUALIB_API int (luaopen_base) (lua_State *L);
20 |
21 | #define LUA_TABLIBNAME "table"
22 | LUALIB_API int (luaopen_table) (lua_State *L);
23 |
24 | #define LUA_IOLIBNAME "io"
25 | LUALIB_API int (luaopen_io) (lua_State *L);
26 |
27 | #define LUA_OSLIBNAME "os"
28 | LUALIB_API int (luaopen_os) (lua_State *L);
29 |
30 | #define LUA_STRLIBNAME "string"
31 | LUALIB_API int (luaopen_string) (lua_State *L);
32 |
33 | #define LUA_MATHLIBNAME "math"
34 | LUALIB_API int (luaopen_math) (lua_State *L);
35 |
36 | #define LUA_DBLIBNAME "debug"
37 | LUALIB_API int (luaopen_debug) (lua_State *L);
38 |
39 | #define LUA_LOADLIBNAME "package"
40 | LUALIB_API int (luaopen_package) (lua_State *L);
41 |
42 |
43 | /* open all previous libraries */
44 | LUALIB_API void (luaL_openlibs) (lua_State *L);
45 |
46 |
47 |
48 | #ifndef lua_assert
49 | #define lua_assert(x) ((void)0)
50 | #endif
51 |
52 |
53 | #endif
54 |
--------------------------------------------------------------------------------
/app/lua/lstring.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** $Id: lstring.h,v 1.43.1.1 2007/12/27 13:02:25 roberto Exp $
3 | ** String table (keep all strings handled by Lua)
4 | ** See Copyright Notice in lua.h
5 | */
6 |
7 | #ifndef lstring_h
8 | #define lstring_h
9 |
10 |
11 | #include "lgc.h"
12 | #include "lobject.h"
13 | #include "lstate.h"
14 |
15 |
16 | #define sizestring(s) (sizeof(union TString)+(luaS_isreadonly(s) ? sizeof(char **) : ((s)->len+1)*sizeof(char)))
17 |
18 | #define sizeudata(u) (sizeof(union Udata)+(u)->len)
19 |
20 | #define luaS_new(L, s) (luaS_newlstr(L, s, c_strlen(s)))
21 | #define luaS_newro(L, s) (luaS_newrolstr(L, s, c_strlen(s)))
22 | #define luaS_newliteral(L, s) (luaS_newlstr(L, "" s, \
23 | (sizeof(s)/sizeof(char))-1))
24 |
25 | #define luaS_fix(s) l_setbit((s)->tsv.marked, FIXEDBIT)
26 | #define luaS_readonly(s) l_setbit((s)->tsv.marked, READONLYBIT)
27 | #define luaS_isreadonly(s) testbit((s)->marked, READONLYBIT)
28 |
29 | LUAI_FUNC void luaS_resize (lua_State *L, int newsize);
30 | LUAI_FUNC Udata *luaS_newudata (lua_State *L, size_t s, Table *e);
31 | LUAI_FUNC TString *luaS_newlstr (lua_State *L, const char *str, size_t l);
32 | LUAI_FUNC TString *luaS_newrolstr (lua_State *L, const char *str, size_t l);
33 |
34 | #endif
35 |
--------------------------------------------------------------------------------
/app/cjson/devel/json_parser_outline.txt:
--------------------------------------------------------------------------------
1 | parser:
2 | - call parse_value
3 | - next_token
4 | ? nop.
5 |
6 | parse_value:
7 | - next_token
8 | ? call parse_object.
9 | ? call parse_array.
10 | ? push. return.
11 | ? push. return.
12 | ? push. return.
13 | ? push. return.
14 |
15 | parse_object:
16 | - push table
17 | - next_token
18 | ? push.
19 | - next_token
20 | ? nop.
21 | - call parse_value
22 | - set table
23 | - next_token
24 | ? return.
25 | ? loop parse_object.
26 |
27 | parse_array:
28 | - push table
29 | - call parse_value
30 | - table append
31 | - next_token
32 | ? loop parse_array.
33 | ? ] return.
34 |
35 | next_token:
36 | - check next character
37 | ? { return
38 | ? } return
39 | ? [ return
40 | ? ] return
41 | ? , return
42 | ? : return
43 | ? [-0-9] gobble number. return
44 | ? " gobble string. return
45 | ? [ \t\n] eat whitespace.
46 | ? n Check "null". return or
47 | ? t Check "true". return or
48 | ? f Check "false". return or
49 | ? . return
50 | ? \0 return
51 |
--------------------------------------------------------------------------------
/app/lua/ltm.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** $Id: ltm.h,v 2.6.1.1 2007/12/27 13:02:25 roberto Exp $
3 | ** Tag methods
4 | ** See Copyright Notice in lua.h
5 | */
6 |
7 | #ifndef ltm_h
8 | #define ltm_h
9 |
10 |
11 | #include "lobject.h"
12 |
13 |
14 | /*
15 | * WARNING: if you change the order of this enumeration,
16 | * grep "ORDER TM"
17 | */
18 | typedef enum {
19 | TM_INDEX,
20 | TM_NEWINDEX,
21 | TM_GC,
22 | TM_MODE,
23 | TM_EQ, /* last tag method with `fast' access */
24 | TM_ADD,
25 | TM_SUB,
26 | TM_MUL,
27 | TM_DIV,
28 | TM_MOD,
29 | TM_POW,
30 | TM_UNM,
31 | TM_LEN,
32 | TM_LT,
33 | TM_LE,
34 | TM_CONCAT,
35 | TM_CALL,
36 | TM_N /* number of elements in the enum */
37 | } TMS;
38 |
39 |
40 |
41 | #define gfasttm(g,et,e) ((et) == NULL ? NULL : \
42 | !luaR_isrotable(et) && ((et)->flags & (1u<<(e))) ? NULL : luaT_gettm(et, e, (g)->tmname[e]))
43 |
44 | #define fasttm(l,et,e) gfasttm(G(l), et, e)
45 |
46 | LUAI_DATA const char *const luaT_typenames[];
47 |
48 |
49 | LUAI_FUNC const TValue *luaT_gettm (Table *events, TMS event, TString *ename);
50 | LUAI_FUNC const TValue *luaT_gettmbyobj (lua_State *L, const TValue *o,
51 | TMS event);
52 | LUAI_FUNC void luaT_init (lua_State *L);
53 |
54 | #endif
55 |
--------------------------------------------------------------------------------
/app/lua/lrodefs.h:
--------------------------------------------------------------------------------
1 | /* Read-only tables helper */
2 |
3 | #ifndef lrodefs_h
4 | #define lrodefs_h
5 |
6 | #include "lrotable.h"
7 |
8 | #undef LUA_REG_TYPE
9 | #undef LSTRKEY
10 | #undef LNILKEY
11 | #undef LNUMKEY
12 | #undef LFUNCVAL
13 | #undef LNUMVAL
14 | #undef LROVAL
15 | #undef LNILVAL
16 | #undef LREGISTER
17 |
18 | #if (MIN_OPT_LEVEL > 0) && (LUA_OPTIMIZE_MEMORY >= MIN_OPT_LEVEL)
19 | #define LUA_REG_TYPE luaR_entry ICACHE_RODATA_ATTR
20 | #define LSTRKEY LRO_STRKEY
21 | #define LNUMKEY LRO_NUMKEY
22 | #define LNILKEY LRO_NILKEY
23 | #define LFUNCVAL LRO_FUNCVAL
24 | #define LUDATA LRO_LUDATA
25 | #define LNUMVAL LRO_NUMVAL
26 | #define LROVAL LRO_ROVAL
27 | #define LNILVAL LRO_NILVAL
28 | #define LREGISTER(L, name, table)\
29 | return 0
30 | #else
31 | #define LUA_REG_TYPE luaL_reg
32 | #define LSTRKEY(x) x
33 | #define LNILKEY NULL
34 | #define LFUNCVAL(x) x
35 | #define LNILVAL NULL
36 | #define LREGISTER(L, name, table)\
37 | luaL_register(L, name, table);\
38 | return 1
39 | #endif
40 |
41 | #endif /* lrodefs_h */
42 |
43 |
--------------------------------------------------------------------------------
/app/lua/lvm.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** $Id: lvm.h,v 2.5.1.1 2007/12/27 13:02:25 roberto Exp $
3 | ** Lua virtual machine
4 | ** See Copyright Notice in lua.h
5 | */
6 |
7 | #ifndef lvm_h
8 | #define lvm_h
9 |
10 |
11 | #include "ldo.h"
12 | #include "lobject.h"
13 | #include "ltm.h"
14 |
15 |
16 | #define tostring(L,o) ((ttype(o) == LUA_TSTRING) || (luaV_tostring(L, o)))
17 |
18 | #define tonumber(o,n) (ttype(o) == LUA_TNUMBER || \
19 | (((o) = luaV_tonumber(o,n)) != NULL))
20 |
21 | #define equalobj(L,o1,o2) \
22 | (ttype(o1) == ttype(o2) && luaV_equalval(L, o1, o2))
23 |
24 |
25 | LUAI_FUNC int luaV_lessthan (lua_State *L, const TValue *l, const TValue *r);
26 | LUAI_FUNC int luaV_equalval (lua_State *L, const TValue *t1, const TValue *t2);
27 | LUAI_FUNC const TValue *luaV_tonumber (const TValue *obj, TValue *n);
28 | LUAI_FUNC int luaV_tostring (lua_State *L, StkId obj);
29 | LUAI_FUNC void luaV_gettable (lua_State *L, const TValue *t, TValue *key,
30 | StkId val);
31 | LUAI_FUNC void luaV_settable (lua_State *L, const TValue *t, TValue *key,
32 | StkId val);
33 | LUAI_FUNC void luaV_execute (lua_State *L, int nexeccalls);
34 | LUAI_FUNC void luaV_concat (lua_State *L, int total, int last);
35 |
36 | #endif
37 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: cpp
2 | before_install:
3 | - sudo apt-get install -y python-serial srecord
4 | install:
5 | - wget https://github.com/GeorgeHahn/nodemcu-firmware/raw/travis/tools/esp-open-sdk.tar.gz -O tools/esp-open-sdk.tar.gz
6 | - tar -zxvf tools/esp-open-sdk.tar.gz
7 | - export PATH=$PATH:$PWD/esp-open-sdk/sdk:$PWD/esp-open-sdk/xtensa-lx106-elf/bin
8 | script:
9 | - make all
10 | - cd bin/
11 | - file_name_float="nodemcu_float_${TRAVIS_TAG}.bin"
12 | - srec_cat -output ${file_name_float} -binary 0x00000.bin -binary -fill 0xff 0x00000 0x10000 0x10000.bin -binary -offset 0x10000
13 | - cd ../
14 | - make clean
15 | - make EXTRA_CCFLAGS="-DLUA_NUMBER_INTEGRAL"
16 | - cd bin/
17 | - file_name_integer="nodemcu_integer_${TRAVIS_TAG}.bin"
18 | - srec_cat -output ${file_name_integer} -binary 0x00000.bin -binary -fill 0xff 0x00000 0x10000 0x10000.bin -binary -offset 0x10000
19 | deploy:
20 | provider: releases
21 | api_key:
22 | secure: Swecz5lWvsuSbchSbVQ1rmCPN9nQIN5p/HlZNIEdEgAgnoLcJxRV4P8poVTB37jiA8Pck+8x2nWXpg74Rqik0i3KlPNvDfg5o4rIazWLNs4bc1Tbcpt44XAzFKKLYnDnWQUGcqjk7BcAXuNAF2X/fPBCVhFbHVg3Z7cDb32RsNw=
23 | file:
24 | - "$TRAVIS_BUILD_DIR/bin/${file_name_float}"
25 | - "$TRAVIS_BUILD_DIR/bin/${file_name_integer}"
26 | skip_cleanup: true
27 | on:
28 | tags: true
29 | repo: nodemcu/nodemcu-firmware
30 |
--------------------------------------------------------------------------------
/lua_examples/webap_toggle_pin.lua:
--------------------------------------------------------------------------------
1 | wifi.setmode(wifi.SOFTAP);
2 | wifi.ap.config({ssid="test",pwd="12345678"});
3 | gpio.mode(1, gpio.OUTPUT)
4 | srv=net.createServer(net.TCP)
5 | srv:listen(80,function(conn)
6 | conn:on("receive", function(client,request)
7 | local buf = "";
8 | local _, _, method, path, vars = string.find(request, "([A-Z]+) (.+)?(.+) HTTP");
9 | if(method == nil)then
10 | _, _, method, path = string.find(request, "([A-Z]+) (.+) HTTP");
11 | end
12 | local _GET = {}
13 | if (vars ~= nil)then
14 | for k, v in string.gmatch(vars, "(%w+)=(%w+)&*") do
15 | _GET[k] = v
16 | end
17 | end
18 | buf = buf.." Hello, NodeMcu.
";
28 | client:send(buf);
29 | client:close();
30 | collectgarbage();
31 | end)
32 | end)
33 |
--------------------------------------------------------------------------------
/lua_modules/base64/base64.lua:
--------------------------------------------------------------------------------
1 | -- Lua 5.1+ base64 v3.0 (c) 2009 by Alex Kloss
2 | -- licensed under the terms of the LGPL2
3 |
4 | local moduleName = ...
5 | local M = {}
6 | _G[moduleName] = M
7 |
8 | -- character table string
9 | local b='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
10 |
11 | -- encoding
12 | function M.enc(data)
13 | return ((data:gsub('.', function(x)
14 | local r,b='',x:byte()
15 | for i=8,1,-1 do r=r..(b%2^i-b%2^(i-1)>0 and '1' or '0') end
16 | return r;
17 | end)..'0000'):gsub('%d%d%d?%d?%d?%d?', function(x)
18 | if (#x < 6) then return '' end
19 | local c=0
20 | for i=1,6 do c=c+(x:sub(i,i)=='1' and 2^(6-i) or 0) end
21 | return b:sub(c+1,c+1)
22 | end)..({ '', '==', '=' })[#data%3+1])
23 | end
24 |
25 | -- decoding
26 | function M.dec(data)
27 | data = string.gsub(data, '[^'..b..'=]', '')
28 | return (data:gsub('.', function(x)
29 | if (x == '=') then return '' end
30 | local r,f='',(b:find(x)-1)
31 | for i=6,1,-1 do r=r..(f%2^i-f%2^(i-1)>0 and '1' or '0') end
32 | return r;
33 | end):gsub('%d%d%d?%d?%d?%d?%d?%d?', function(x)
34 | if (#x ~= 8) then return '' end
35 | local c=0
36 | for i=1,8 do c=c+(x:sub(i,i)=='1' and 2^(7-i) or 0) end
37 | return string.char(c)
38 | end))
39 | end
40 |
41 | return M
42 |
--------------------------------------------------------------------------------
/lua_modules/si7021/si7021-lewei.lua:
--------------------------------------------------------------------------------
1 |
2 | --创建一个定时器
3 | tmr.alarm(0, 60000, 1, function()
4 |
5 | SDA_PIN = 6 -- sda pin, GPIO12
6 | SCL_PIN = 5 -- scl pin, GPIO14
7 |
8 | si7021 = require("si7021")
9 | si7021.init(SDA_PIN, SCL_PIN)
10 | si7021.read(OSS)
11 | Hum = si7021.getHumidity()
12 | Temp = si7021.getTemperature()
13 |
14 | --定义数据变量格式
15 | PostData = "[{\"Name\":\"T\",\"Value\":\"" .. (Temp/100).."."..(Temp%100) .. "\"},{\"Name\":\"H\",\"Value\":\"" .. (Hum/100).."."..(Hum%100) .. "\"}]"
16 | --创建一个TCP连接
17 | socket=net.createConnection(net.TCP, 0)
18 | --域名解析IP地址并赋值
19 | socket:dns("www.lewei50.com", function(conn, ip)
20 | ServerIP = ip
21 | print("Connection IP:" .. ServerIP)
22 | end)
23 | --开始连接服务器
24 | socket:connect(80, ServerIP)
25 | socket:on("connection", function(sck) end)
26 | --HTTP请求头定义
27 | socket:send("POST /api/V1/gateway/UpdateSensors/yourID HTTP/1.1\r\n" ..
28 | "Host: www.lewei50.com\r\n" ..
29 | "Content-Length: " .. string.len(PostData) .. "\r\n" ..
30 | "userkey: yourKEY\r\n\r\n" ..
31 | PostData .. "\r\n")
32 | --HTTP响应内容
33 | socket:on("receive", function(sck, response)
34 | print(response)
35 | end)
36 |
37 | -- release module
38 | si7021 = nil
39 | package.loaded["si7021"]=nil
40 |
41 | end)
42 |
--------------------------------------------------------------------------------
/app/lua/lfunc.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** $Id: lfunc.h,v 2.4.1.1 2007/12/27 13:02:25 roberto Exp $
3 | ** Auxiliary functions to manipulate prototypes and closures
4 | ** See Copyright Notice in lua.h
5 | */
6 |
7 | #ifndef lfunc_h
8 | #define lfunc_h
9 |
10 |
11 | #include "lobject.h"
12 |
13 | #include "lgc.h"
14 |
15 | #define sizeCclosure(n) (cast(int, sizeof(CClosure)) + \
16 | cast(int, sizeof(TValue)*((n)-1)))
17 |
18 | #define sizeLclosure(n) (cast(int, sizeof(LClosure)) + \
19 | cast(int, sizeof(TValue *)*((n)-1)))
20 |
21 | #define proto_readonly(p) l_setbit((p)->marked, READONLYBIT)
22 | #define proto_is_readonly(p) testbit((p)->marked, READONLYBIT)
23 |
24 | LUAI_FUNC Proto *luaF_newproto (lua_State *L);
25 | LUAI_FUNC Closure *luaF_newCclosure (lua_State *L, int nelems, Table *e);
26 | LUAI_FUNC Closure *luaF_newLclosure (lua_State *L, int nelems, Table *e);
27 | LUAI_FUNC UpVal *luaF_newupval (lua_State *L);
28 | LUAI_FUNC UpVal *luaF_findupval (lua_State *L, StkId level);
29 | LUAI_FUNC void luaF_close (lua_State *L, StkId level);
30 | LUAI_FUNC void luaF_freeproto (lua_State *L, Proto *f);
31 | LUAI_FUNC void luaF_freeclosure (lua_State *L, Closure *c);
32 | LUAI_FUNC void luaF_freeupval (lua_State *L, UpVal *uv);
33 | LUAI_FUNC const char *luaF_getlocalname (const Proto *func, int local_number,
34 | int pc);
35 |
36 |
37 | #endif
38 |
--------------------------------------------------------------------------------
/include/upgrade.h:
--------------------------------------------------------------------------------
1 | #ifndef __UPGRADE_H__
2 | #define __UPGRADE_H__
3 |
4 | #define SPI_FLASH_SEC_SIZE 4096
5 |
6 | #define USER_BIN1 0x00
7 | #define USER_BIN2 0x01
8 |
9 | #define UPGRADE_FLAG_IDLE 0x00
10 | #define UPGRADE_FLAG_START 0x01
11 | #define UPGRADE_FLAG_FINISH 0x02
12 |
13 | #define UPGRADE_FW_BIN1 0x00
14 | #define UPGRADE_FW_BIN2 0x01
15 |
16 | typedef void (*upgrade_states_check_callback)(void * arg);
17 |
18 | //#define UPGRADE_SSL_ENABLE
19 |
20 | struct upgrade_server_info {
21 | uint8 ip[4];
22 | uint16 port;
23 |
24 | uint8 upgrade_flag;
25 |
26 | uint8 pre_version[16];
27 | uint8 upgrade_version[16];
28 |
29 | uint32 check_times;
30 | uint8 *url;
31 |
32 | upgrade_states_check_callback check_cb;
33 | struct espconn *pespconn;
34 | };
35 |
36 | #define UPGRADE_FLAG_IDLE 0x00
37 | #define UPGRADE_FLAG_START 0x01
38 | #define UPGRADE_FLAG_FINISH 0x02
39 |
40 | //bool system_upgrade_start(struct upgrade_server_info *server);
41 | bool system_upgrade_start_ssl(struct upgrade_server_info *server);
42 | void system_upgrade_init();
43 | void system_upgrade_deinit();
44 | bool system_upgrade(uint8 *data, uint16 len);
45 |
46 | #ifdef UPGRADE_SSL_ENABLE
47 | bool system_upgrade_start_ssl(struct upgrade_server_info *server);
48 | #else
49 | bool system_upgrade_start(struct upgrade_server_info *server);
50 | #endif
51 | #endif
52 |
--------------------------------------------------------------------------------
/app/libc/c_locale.h:
--------------------------------------------------------------------------------
1 | /*
2 | c_locale.h
3 | Values appropriate for the formatting of monetary and other
4 | numberic quantities.
5 | */
6 |
7 | #ifndef _C_LOCALE_H_
8 | #define _C_LOCALE_H_
9 |
10 | #include
11 |
12 | #if 0
13 | #ifndef NULL
14 | #define NULL 0
15 | #endif
16 |
17 | #define LC_ALL 0
18 | #define LC_COLLATE 1
19 | #define LC_CTYPE 2
20 | #define LC_MONETARY 3
21 | #define LC_NUMERIC 4
22 | #define LC_TIME 5
23 | #define LC_MESSAGES 6
24 |
25 | struct lconv
26 | {
27 | char *decimal_point;
28 | char *thousands_sep;
29 | char *grouping;
30 | char *int_curr_symbol;
31 | char *currency_symbol;
32 | char *mon_decimal_point;
33 | char *mon_thousands_sep;
34 | char *mon_grouping;
35 | char *positive_sign;
36 | char *negative_sign;
37 | char int_frac_digits;
38 | char frac_digits;
39 | char p_cs_precedes;
40 | char p_sep_by_space;
41 | char n_cs_precedes;
42 | char n_sep_by_space;
43 | char p_sign_posn;
44 | char n_sign_posn;
45 | char int_n_cs_precedes;
46 | char int_n_sep_by_space;
47 | char int_n_sign_posn;
48 | char int_p_cs_precedes;
49 | char int_p_sep_by_space;
50 | char int_p_sign_posn;
51 | };
52 |
53 | #ifndef _REENT_ONLY
54 | // char *setlocale(int category, const char *locale);
55 | struct lconv *localeconv(void);
56 | #endif
57 |
58 | // struct _reent;
59 | // char *_setlocale_r(struct _reent *, int category, const char *locale);
60 | // struct lconv *_localeconv_r(struct _reent *);
61 | #endif
62 | #endif /* _C_LOCALE_H_ */
63 |
--------------------------------------------------------------------------------
/app/include/driver/spi.h:
--------------------------------------------------------------------------------
1 | #ifndef SPI_APP_H
2 | #define SPI_APP_H
3 |
4 | #include "spi_register.h"
5 | #include "ets_sys.h"
6 | #include "osapi.h"
7 | #include "uart.h"
8 | #include "os_type.h"
9 |
10 | /*SPI number define*/
11 | #define SPI 0
12 | #define HSPI 1
13 |
14 |
15 |
16 | //lcd drive function
17 | void spi_lcd_mode_init(uint8 spi_no);
18 | void spi_lcd_9bit_write(uint8 spi_no,uint8 high_bit,uint8 low_8bit);
19 |
20 | //spi master init funtion
21 | void spi_master_init(uint8 spi_no, unsigned cpol, unsigned cpha, unsigned databits, uint32_t clock);
22 | //use spi send 8bit data
23 | void spi_mast_byte_write(uint8 spi_no,uint8 *data);
24 |
25 | //transmit data to esp8266 slave buffer,which needs 16bit transmission ,
26 | //first byte is master command 0x04, second byte is master data
27 | void spi_byte_write_espslave(uint8 spi_no,uint8 data);
28 | //read data from esp8266 slave buffer,which needs 16bit transmission ,
29 | //first byte is master command 0x06, second byte is to read slave data
30 | void spi_byte_read_espslave(uint8 spi_no,uint8 *data);
31 |
32 | //esp8266 slave mode initial
33 | void spi_slave_init(uint8 spi_no);
34 | //esp8266 slave isr handle funtion,tiggered when any transmission is finished.
35 | //the function is registered in spi_slave_init.
36 | void spi_slave_isr_handler(void *para);
37 |
38 |
39 | //hspi test function, used to test esp8266 spi slave
40 | void hspi_master_readwrite_repeat(void);
41 |
42 |
43 | void ICACHE_FLASH_ATTR
44 | spi_test_init(void);
45 |
46 |
47 | #endif
48 |
49 |
--------------------------------------------------------------------------------
/app/libc/c_math.h:
--------------------------------------------------------------------------------
1 | #ifndef _C_MATH_H_
2 | #define _C_MATH_H_
3 | #include
4 |
5 | double floor(double);
6 | double pow(double, double);
7 |
8 | #if 0
9 | #ifndef HUGE_VAL
10 | #define HUGE_VAL (1.0e99)
11 | #endif
12 |
13 | #ifndef HUGE_VALF
14 | #define HUGE_VALF (1.0e999999999F)
15 | #endif
16 |
17 | #if !defined(HUGE_VALL) && defined(_HAVE_LONG_DOUBLE)
18 | #define HUGE_VALL (1.0e999999999L)
19 | #endif
20 |
21 | #if !defined(INFINITY)
22 | #define INFINITY (HUGE_VALF)
23 | #endif
24 |
25 |
26 | /* Reentrant ANSI C functions. */
27 |
28 | #ifndef __math_68881
29 | // double atan(double);
30 | // double cos(double);
31 | // double sin(double);
32 | // double tan(double);
33 | // double tanh(double);
34 | // double frexp(double, int *);
35 | // double modf(double, double *);
36 | // double ceil(double);
37 | // double fabs(double);
38 | // double floor(double);
39 | #endif /* ! defined (__math_68881) */
40 |
41 | /* Non reentrant ANSI C functions. */
42 |
43 | #ifndef _REENT_ONLY
44 | #ifndef __math_68881
45 | // double acos(double);
46 | // double asin(double);
47 | // double atan2(double, double);
48 | // double cosh(double);
49 | // double sinh(double);
50 | // double exp(double);
51 | // double ldexp(double, int);
52 | // double log(double);
53 | // double log10(double);
54 | // double pow(double, double);
55 | // double sqrt(double);
56 | // double fmod(double, double);
57 | #endif /* ! defined (__math_68881) */
58 | #endif /* ! defined (_REENT_ONLY) */
59 |
60 | #endif
61 |
62 | #endif /* _MATH_H_ */
63 |
--------------------------------------------------------------------------------
/lua_modules/http/http-example.lua:
--------------------------------------------------------------------------------
1 | ------------------------------------------------------------------------------
2 | -- HTTP server Hello world example
3 | --
4 | -- LICENCE: http://opensource.org/licenses/MIT
5 | -- Vladimir Dronnikov
6 | ------------------------------------------------------------------------------
7 | require("http").createServer(80, function(req, res)
8 | -- analyse method and url
9 | print("+R", req.method, req.url, node.heap())
10 | -- setup handler of headers, if any
11 | req.onheader = function(self, name, value)
12 | -- print("+H", name, value)
13 | -- E.g. look for "content-type" header,
14 | -- setup body parser to particular format
15 | -- if name == "content-type" then
16 | -- if value == "application/json" then
17 | -- req.ondata = function(self, chunk) ... end
18 | -- elseif value == "application/x-www-form-urlencoded" then
19 | -- req.ondata = function(self, chunk) ... end
20 | -- end
21 | -- end
22 | end
23 | -- setup handler of body, if any
24 | req.ondata = function(self, chunk)
25 | print("+B", chunk and #chunk, node.heap())
26 | -- request ended?
27 | if not chunk then
28 | -- reply
29 | --res:finish("")
30 | res:send(nil, 200)
31 | res:send_header("Connection", "close")
32 | res:send("Hello, world!")
33 | res:finish()
34 | end
35 | end
36 | -- or just do something not waiting till body (if any) comes
37 | --res:finish("Hello, world!")
38 | --res:finish("Salut, monde!")
39 | end)
40 |
--------------------------------------------------------------------------------
/app/driver/gpio16.c:
--------------------------------------------------------------------------------
1 | #include "ets_sys.h"
2 | #include "osapi.h"
3 | #include "driver/gpio16.h"
4 |
5 | void ICACHE_FLASH_ATTR
6 | gpio16_output_conf(void)
7 | {
8 | WRITE_PERI_REG(PAD_XPD_DCDC_CONF,
9 | (READ_PERI_REG(PAD_XPD_DCDC_CONF) & 0xffffffbc) | (uint32)0x1); // mux configuration for XPD_DCDC to output rtc_gpio0
10 |
11 | WRITE_PERI_REG(RTC_GPIO_CONF,
12 | (READ_PERI_REG(RTC_GPIO_CONF) & (uint32)0xfffffffe) | (uint32)0x0); //mux configuration for out enable
13 |
14 | WRITE_PERI_REG(RTC_GPIO_ENABLE,
15 | (READ_PERI_REG(RTC_GPIO_ENABLE) & (uint32)0xfffffffe) | (uint32)0x1); //out enable
16 | }
17 |
18 | void ICACHE_FLASH_ATTR
19 | gpio16_output_set(uint8 value)
20 | {
21 | WRITE_PERI_REG(RTC_GPIO_OUT,
22 | (READ_PERI_REG(RTC_GPIO_OUT) & (uint32)0xfffffffe) | (uint32)(value & 1));
23 | }
24 |
25 | void ICACHE_FLASH_ATTR
26 | gpio16_input_conf(void)
27 | {
28 | WRITE_PERI_REG(PAD_XPD_DCDC_CONF,
29 | (READ_PERI_REG(PAD_XPD_DCDC_CONF) & 0xffffffbc) | (uint32)0x1); // mux configuration for XPD_DCDC and rtc_gpio0 connection
30 |
31 | WRITE_PERI_REG(RTC_GPIO_CONF,
32 | (READ_PERI_REG(RTC_GPIO_CONF) & (uint32)0xfffffffe) | (uint32)0x0); //mux configuration for out enable
33 |
34 | WRITE_PERI_REG(RTC_GPIO_ENABLE,
35 | READ_PERI_REG(RTC_GPIO_ENABLE) & (uint32)0xfffffffe); //out disable
36 | }
37 |
38 | uint8 ICACHE_FLASH_ATTR
39 | gpio16_input_get(void)
40 | {
41 | return (uint8)(READ_PERI_REG(RTC_GPIO_IN_DATA) & 1);
42 | }
43 |
--------------------------------------------------------------------------------
/lua_modules/ds3231/ds3231-web.lua:
--------------------------------------------------------------------------------
1 | require('ds3231')
2 |
3 | port = 80
4 |
5 | -- ESP-01 GPIO Mapping
6 | gpio0, gpio2 = 3, 4
7 |
8 | days = {
9 | [1] = "Sunday",
10 | [2] = "Monday",
11 | [3] = "Tuesday",
12 | [4] = "Wednesday",
13 | [5] = "Thursday",
14 | [6] = "Friday",
15 | [7] = "Saturday"
16 | }
17 |
18 | months = {
19 | [1] = "January",
20 | [2] = "Febuary",
21 | [3] = "March",
22 | [4] = "April",
23 | [5] = "May",
24 | [6] = "June",
25 | [7] = "July",
26 | [8] = "August",
27 | [9] = "September",
28 | [10] = "October",
29 | [11] = "November",
30 | [12] = "December"
31 | }
32 |
33 | ds3231.init(gpio0, gpio2)
34 |
35 | srv=net.createServer(net.TCP)
36 | srv:listen(port,
37 | function(conn)
38 |
39 | second, minute, hour, day, date, month, year = ds3231.getTime()
40 | prettyTime = string.format("%s, %s %s %s %s:%s:%s", days[day], date, months[month], year, hour, minute, second)
41 |
42 | conn:send("HTTP/1.1 200 OK\nContent-Type: text/html\nRefresh: 5\n\n" ..
43 | "" ..
44 | "" ..
45 | "ESP8266" ..
46 | "Time and Date: " .. prettyTime .. "
" ..
47 | "Node ChipID : " .. node.chipid() .. "
" ..
48 | "Node MAC : " .. wifi.sta.getmac() .. "
" ..
49 | "Node Heap : " .. node.heap() .. "
" ..
50 | "Timer Ticks : " .. tmr.now() .. "
" ..
51 | "")
52 | conn:on("sent",function(conn) conn:close() end)
53 | end
54 | )
--------------------------------------------------------------------------------
/app/coap/coap_server.c:
--------------------------------------------------------------------------------
1 | #include "user_config.h"
2 | #include "c_types.h"
3 | #include "c_stdlib.h"
4 |
5 | #include "coap.h"
6 |
7 | size_t coap_server_respond(char *req, unsigned short reqlen, char *rsp, unsigned short rsplen)
8 | {
9 | NODE_DBG("coap_server_respond is called.\n");
10 | size_t rlen = rsplen;
11 | coap_packet_t pkt;
12 | pkt.content.p = NULL;
13 | pkt.content.len = 0;
14 | uint8_t scratch_raw[4];
15 | coap_rw_buffer_t scratch_buf = {scratch_raw, sizeof(scratch_raw)};
16 | int rc;
17 |
18 | #ifdef COAP_DEBUG
19 | NODE_DBG("Received: ");
20 | coap_dump(req, reqlen, true);
21 | NODE_DBG("\n");
22 | #endif
23 |
24 | if (0 != (rc = coap_parse(&pkt, req, reqlen))){
25 | NODE_DBG("Bad packet rc=%d\n", rc);
26 | return 0;
27 | }
28 | else
29 | {
30 | coap_packet_t rsppkt;
31 | rsppkt.content.p = NULL;
32 | rsppkt.content.len = 0;
33 | #ifdef COAP_DEBUG
34 | coap_dumpPacket(&pkt);
35 | #endif
36 | coap_handle_req(&scratch_buf, &pkt, &rsppkt);
37 | if (0 != (rc = coap_build(rsp, &rlen, &rsppkt))){
38 | NODE_DBG("coap_build failed rc=%d\n", rc);
39 | // return 0;
40 | rlen = 0;
41 | }
42 | else
43 | {
44 | #ifdef COAP_DEBUG
45 | NODE_DBG("Responding: ");
46 | coap_dump(rsp, rlen, true);
47 | NODE_DBG("\n");
48 | #endif
49 | #ifdef COAP_DEBUG
50 | coap_dumpPacket(&rsppkt);
51 | #endif
52 | }
53 | if(rsppkt.content.p){
54 | c_free(rsppkt.content.p);
55 | rsppkt.content.p = NULL;
56 | rsppkt.content.len = 0;
57 | }
58 | return rlen;
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/app/modules/adc.c:
--------------------------------------------------------------------------------
1 | // Module for interfacing with adc
2 |
3 | //#include "lua.h"
4 | #include "lualib.h"
5 | #include "lauxlib.h"
6 | #include "platform.h"
7 | #include "auxmods.h"
8 | #include "lrotable.h"
9 |
10 | #include "c_types.h"
11 | #include "user_interface.h"
12 |
13 | // Lua: read(id) , return system adc
14 | static int adc_sample( lua_State* L )
15 | {
16 | unsigned id = luaL_checkinteger( L, 1 );
17 | MOD_CHECK_ID( adc, id );
18 | unsigned val = 0xFFFF & system_adc_read();
19 | lua_pushinteger( L, val );
20 | return 1;
21 | }
22 |
23 | // Lua: readvdd33()
24 | static int adc_readvdd33( lua_State* L )
25 | {
26 | uint32_t vdd33 = 0;
27 | if(STATION_MODE == wifi_get_opmode())
28 | {
29 | // Bug fix
30 | wifi_set_opmode( STATIONAP_MODE );
31 | vdd33 = readvdd33();
32 | wifi_set_opmode( STATION_MODE );
33 | }
34 | else
35 | {
36 | vdd33 = readvdd33();
37 | }
38 |
39 | lua_pushinteger(L, vdd33);
40 | return 1;
41 | }
42 |
43 | // Module function map
44 | #define MIN_OPT_LEVEL 2
45 | #include "lrodefs.h"
46 | const LUA_REG_TYPE adc_map[] =
47 | {
48 | { LSTRKEY( "read" ), LFUNCVAL( adc_sample ) },
49 | { LSTRKEY( "readvdd33" ), LFUNCVAL( adc_readvdd33) },
50 | #if LUA_OPTIMIZE_MEMORY > 0
51 |
52 | #endif
53 | { LNILKEY, LNILVAL }
54 | };
55 |
56 | LUALIB_API int luaopen_adc( lua_State *L )
57 | {
58 | #if LUA_OPTIMIZE_MEMORY > 0
59 | return 0;
60 | #else // #if LUA_OPTIMIZE_MEMORY > 0
61 | luaL_register( L, AUXLIB_ADC, adc_map );
62 | // Add constants
63 |
64 | return 1;
65 | #endif // #if LUA_OPTIMIZE_MEMORY > 0
66 | }
67 |
--------------------------------------------------------------------------------
/lua_modules/dht22/README.md:
--------------------------------------------------------------------------------
1 | # DHT22 module
2 |
3 | This module is compatible with DHT22 and DHT21.
4 | Supports nodemcu with or without floating point.
5 | No need to use a resistor to connect the pin data of DHT22 to ESP8266.
6 |
7 | ## Example
8 | ```lua
9 | PIN = 4 -- data pin, GPIO2
10 |
11 | dht22 = require("dht22")
12 | dht22.read(PIN)
13 | t = dht22.getTemperature()
14 | h = dht22.getHumidity()
15 |
16 | if h == nil then
17 | print("Error reading from DHT22")
18 | else
19 | -- temperature in degrees Celsius and Farenheit
20 | -- floating point and integer version:
21 | print("Temperature: "..((t-(t % 10)) / 10).."."..(t % 10).." deg C")
22 | -- only integer version:
23 | print("Temperature: "..(9 * t / 50 + 32).."."..(9 * t / 5 % 10).." deg F")
24 | -- only float point version:
25 | print("Temperature: "..(9 * t / 50 + 32).." deg F")
26 |
27 | -- humidity
28 | -- floating point and integer version
29 | print("Humidity: "..((h - (h % 10)) / 10).."."..(h % 10).."%")
30 | end
31 |
32 | -- release module
33 | dht22 = nil
34 | package.loaded["dht22"]=nil
35 | ```
36 | ## Functions
37 | ### read
38 | read(pin)
39 | Read humidity and temperature from DHT22.
40 |
41 | **Parameters:**
42 |
43 | * pin - ESP8266 pin connect to data pin in DHT22
44 |
45 | ### getHumidity
46 | getHumidity()
47 | Returns the humidity of the last reading.
48 |
49 | **Returns:**
50 | * last humidity reading in per thousand
51 |
52 | ### getTemperature
53 | getTemperature()
54 | Returns the temperature of the last reading.
55 |
56 | **Returns:**
57 | * last temperature reading in 0.1ºC
58 |
59 |
--------------------------------------------------------------------------------
/app/coap/pdu.c:
--------------------------------------------------------------------------------
1 | #include "c_stdlib.h"
2 | #include "pdu.h"
3 |
4 | coap_pdu_t * coap_new_pdu(void) {
5 | coap_pdu_t *pdu = NULL;
6 | pdu = (coap_pdu_t *)c_zalloc(sizeof(coap_pdu_t));
7 | if(!pdu){
8 | NODE_DBG("coap_new_pdu malloc error.\n");
9 | return NULL;
10 | }
11 |
12 | pdu->scratch.p = (uint8_t *)c_zalloc(MAX_REQ_SCRATCH_SIZE);
13 | if(!pdu->scratch.p){
14 | NODE_DBG("coap_new_pdu malloc error.\n");
15 | c_free(pdu);
16 | return NULL;
17 | }
18 | pdu->scratch.len = MAX_REQ_SCRATCH_SIZE;
19 |
20 | pdu->pkt = (coap_packet_t *)c_zalloc(sizeof(coap_packet_t));
21 | if(!pdu->pkt){
22 | NODE_DBG("coap_new_pdu malloc error.\n");
23 | c_free(pdu->scratch.p);
24 | c_free(pdu);
25 | return NULL;
26 | }
27 | pdu->pkt->content.p = NULL;
28 | pdu->pkt->content.len = 0;
29 |
30 | pdu->msg.p = (uint8_t *)c_zalloc(MAX_REQUEST_SIZE+1); // +1 for string '\0'
31 | if(!pdu->msg.p){
32 | NODE_DBG("coap_new_pdu malloc error.\n");
33 | c_free(pdu->pkt);
34 | c_free(pdu->scratch.p);
35 | c_free(pdu);
36 | return NULL;
37 | }
38 | pdu->msg.len = MAX_REQUEST_SIZE;
39 | return pdu;
40 | }
41 |
42 | void coap_delete_pdu(coap_pdu_t *pdu){
43 | if(!pdu)
44 | return;
45 |
46 | if(pdu->scratch.p){
47 | c_free(pdu->scratch.p);
48 | pdu->scratch.p = NULL;
49 | pdu->scratch.len = 0;
50 | }
51 |
52 | if(pdu->pkt){
53 | c_free(pdu->pkt);
54 | pdu->pkt = NULL;
55 | }
56 |
57 | if(pdu->msg.p){
58 | c_free(pdu->msg.p);
59 | pdu->msg.p = NULL;
60 | pdu->msg.len = 0;
61 | }
62 |
63 | c_free(pdu);
64 | pdu = NULL;
65 | }
66 |
--------------------------------------------------------------------------------
/lua_modules/bh1750/bh1750.lua:
--------------------------------------------------------------------------------
1 | -- ***************************************************************************
2 | -- BH1750 module for ESP8266 with nodeMCU
3 | -- BH1750 compatible tested 2015-1-22
4 | --
5 | -- Written by xiaohu
6 | --
7 | -- MIT license, http://opensource.org/licenses/MIT
8 | -- ***************************************************************************
9 | local moduleName = ...
10 | local M = {}
11 | _G[moduleName] = M
12 | --I2C slave address of GY-30
13 | local GY_30_address = 0x23
14 | -- i2c interface ID
15 | local id = 0
16 | --LUX
17 | local l
18 | --CMD
19 | local CMD = 0x10
20 | local init = false
21 | --Make it more faster
22 | local i2c = i2c
23 | function M.init(sda, scl)
24 | i2c.setup(id, sda, scl, i2c.SLOW)
25 | --print("i2c ok..")
26 | init = true
27 | end
28 | local function read_data(ADDR, commands, length)
29 | i2c.start(id)
30 | i2c.address(id, ADDR, i2c.TRANSMITTER)
31 | i2c.write(id, commands)
32 | i2c.stop(id)
33 | i2c.start(id)
34 | i2c.address(id, ADDR,i2c.RECEIVER)
35 | tmr.delay(200000)
36 | c = i2c.read(id, length)
37 | i2c.stop(id)
38 | return c
39 | end
40 | local function read_lux()
41 | dataT = read_data(GY_30_address, CMD, 2)
42 | --Make it more faster
43 | UT = dataT:byte(1) * 256 + dataT:byte(2)
44 | l = (UT*1000/12)
45 | return(l)
46 | end
47 | function M.read()
48 | if (not init) then
49 | print("init() must be called before read.")
50 | else
51 | read_lux()
52 | end
53 | end
54 | function M.getlux()
55 | return l
56 | end
57 | return M
58 |
--------------------------------------------------------------------------------
/app/json/Makefile:
--------------------------------------------------------------------------------
1 |
2 | #############################################################
3 | # Required variables for each makefile
4 | # Discard this section from all parent makefiles
5 | # Expected variables (with automatic defaults):
6 | # CSRCS (all "C" files in the dir)
7 | # SUBDIRS (all subdirs with a Makefile)
8 | # GEN_LIBS - list of libs to be generated ()
9 | # GEN_IMAGES - list of images to be generated ()
10 | # COMPONENTS_xxx - a list of libs/objs in the form
11 | # subdir/lib to be extracted and rolled up into
12 | # a generated lib/image xxx.a ()
13 | #
14 | ifndef PDIR
15 |
16 | GEN_LIBS = libjson.a
17 |
18 | endif
19 |
20 |
21 | #############################################################
22 | # Configuration i.e. compile options etc.
23 | # Target specific stuff (defines etc.) goes in here!
24 | # Generally values applying to a tree are captured in the
25 | # makefile at its root level - these are then overridden
26 | # for a subtree within the makefile rooted therein
27 | #
28 | #DEFINES +=
29 |
30 | #############################################################
31 | # Recursion Magic - Don't touch this!!
32 | #
33 | # Each subtree potentially has an include directory
34 | # corresponding to the common APIs applicable to modules
35 | # rooted at that subtree. Accordingly, the INCLUDE PATH
36 | # of a module can only contain the include directories up
37 | # its parent path, and not its siblings
38 | #
39 | # Required for each makefile to inherit from the parent
40 | #
41 |
42 | INCLUDES := $(INCLUDES) -I $(PDIR)include
43 | INCLUDES += -I ./
44 | PDIR := ../$(PDIR)
45 | sinclude $(PDIR)Makefile
46 |
47 |
--------------------------------------------------------------------------------
/app/lwip/api/Makefile:
--------------------------------------------------------------------------------
1 |
2 | #############################################################
3 | # Required variables for each makefile
4 | # Discard this section from all parent makefiles
5 | # Expected variables (with automatic defaults):
6 | # CSRCS (all "C" files in the dir)
7 | # SUBDIRS (all subdirs with a Makefile)
8 | # GEN_LIBS - list of libs to be generated ()
9 | # GEN_IMAGES - list of images to be generated ()
10 | # COMPONENTS_xxx - a list of libs/objs in the form
11 | # subdir/lib to be extracted and rolled up into
12 | # a generated lib/image xxx.a ()
13 | #
14 | ifndef PDIR
15 |
16 | GEN_LIBS = liblwipapi.a
17 |
18 | endif
19 |
20 |
21 | #############################################################
22 | # Configuration i.e. compile options etc.
23 | # Target specific stuff (defines etc.) goes in here!
24 | # Generally values applying to a tree are captured in the
25 | # makefile at its root level - these are then overridden
26 | # for a subtree within the makefile rooted therein
27 | #
28 | #DEFINES +=
29 |
30 | #############################################################
31 | # Recursion Magic - Don't touch this!!
32 | #
33 | # Each subtree potentially has an include directory
34 | # corresponding to the common APIs applicable to modules
35 | # rooted at that subtree. Accordingly, the INCLUDE PATH
36 | # of a module can only contain the include directories up
37 | # its parent path, and not its siblings
38 | #
39 | # Required for each makefile to inherit from the parent
40 | #
41 |
42 | INCLUDES := $(INCLUDES) -I $(PDIR)include
43 | INCLUDES += -I ./
44 | PDIR := ../$(PDIR)
45 | sinclude $(PDIR)Makefile
46 |
47 |
--------------------------------------------------------------------------------
/app/lwip/app/Makefile:
--------------------------------------------------------------------------------
1 |
2 | #############################################################
3 | # Required variables for each makefile
4 | # Discard this section from all parent makefiles
5 | # Expected variables (with automatic defaults):
6 | # CSRCS (all "C" files in the dir)
7 | # SUBDIRS (all subdirs with a Makefile)
8 | # GEN_LIBS - list of libs to be generated ()
9 | # GEN_IMAGES - list of images to be generated ()
10 | # COMPONENTS_xxx - a list of libs/objs in the form
11 | # subdir/lib to be extracted and rolled up into
12 | # a generated lib/image xxx.a ()
13 | #
14 | ifndef PDIR
15 |
16 | GEN_LIBS = liblwipapp.a
17 |
18 | endif
19 |
20 |
21 | #############################################################
22 | # Configuration i.e. compile options etc.
23 | # Target specific stuff (defines etc.) goes in here!
24 | # Generally values applying to a tree are captured in the
25 | # makefile at its root level - these are then overridden
26 | # for a subtree within the makefile rooted therein
27 | #
28 | #DEFINES +=
29 |
30 | #############################################################
31 | # Recursion Magic - Don't touch this!!
32 | #
33 | # Each subtree potentially has an include directory
34 | # corresponding to the common APIs applicable to modules
35 | # rooted at that subtree. Accordingly, the INCLUDE PATH
36 | # of a module can only contain the include directories up
37 | # its parent path, and not its siblings
38 | #
39 | # Required for each makefile to inherit from the parent
40 | #
41 |
42 | INCLUDES := $(INCLUDES) -I $(PDIR)include
43 | INCLUDES += -I ./
44 | PDIR := ../$(PDIR)
45 | sinclude $(PDIR)Makefile
46 |
47 |
--------------------------------------------------------------------------------
/app/lwip/core/Makefile:
--------------------------------------------------------------------------------
1 |
2 | #############################################################
3 | # Required variables for each makefile
4 | # Discard this section from all parent makefiles
5 | # Expected variables (with automatic defaults):
6 | # CSRCS (all "C" files in the dir)
7 | # SUBDIRS (all subdirs with a Makefile)
8 | # GEN_LIBS - list of libs to be generated ()
9 | # GEN_IMAGES - list of images to be generated ()
10 | # COMPONENTS_xxx - a list of libs/objs in the form
11 | # subdir/lib to be extracted and rolled up into
12 | # a generated lib/image xxx.a ()
13 | #
14 | ifndef PDIR
15 |
16 | GEN_LIBS = liblwipcore.a
17 |
18 | endif
19 |
20 |
21 | #############################################################
22 | # Configuration i.e. compile options etc.
23 | # Target specific stuff (defines etc.) goes in here!
24 | # Generally values applying to a tree are captured in the
25 | # makefile at its root level - these are then overridden
26 | # for a subtree within the makefile rooted therein
27 | #
28 | #DEFINES +=
29 |
30 | #############################################################
31 | # Recursion Magic - Don't touch this!!
32 | #
33 | # Each subtree potentially has an include directory
34 | # corresponding to the common APIs applicable to modules
35 | # rooted at that subtree. Accordingly, the INCLUDE PATH
36 | # of a module can only contain the include directories up
37 | # its parent path, and not its siblings
38 | #
39 | # Required for each makefile to inherit from the parent
40 | #
41 |
42 | INCLUDES := $(INCLUDES) -I $(PDIR)include
43 | INCLUDES += -I ./
44 | PDIR := ../$(PDIR)
45 | sinclude $(PDIR)Makefile
46 |
47 |
--------------------------------------------------------------------------------
/app/mqtt/Makefile:
--------------------------------------------------------------------------------
1 |
2 | #############################################################
3 | # Required variables for each makefile
4 | # Discard this section from all parent makefiles
5 | # Expected variables (with automatic defaults):
6 | # CSRCS (all "C" files in the dir)
7 | # SUBDIRS (all subdirs with a Makefile)
8 | # GEN_LIBS - list of libs to be generated ()
9 | # GEN_IMAGES - list of images to be generated ()
10 | # COMPONENTS_xxx - a list of libs/objs in the form
11 | # subdir/lib to be extracted and rolled up into
12 | # a generated lib/image xxx.a ()
13 | #
14 | ifndef PDIR
15 | GEN_LIBS = mqtt.a
16 | endif
17 |
18 | #############################################################
19 | # Configuration i.e. compile options etc.
20 | # Target specific stuff (defines etc.) goes in here!
21 | # Generally values applying to a tree are captured in the
22 | # makefile at its root level - these are then overridden
23 | # for a subtree within the makefile rooted therein
24 | #
25 | #DEFINES +=
26 |
27 | #############################################################
28 | # Recursion Magic - Don't touch this!!
29 | #
30 | # Each subtree potentially has an include directory
31 | # corresponding to the common APIs applicable to modules
32 | # rooted at that subtree. Accordingly, the INCLUDE PATH
33 | # of a module can only contain the include directories up
34 | # its parent path, and not its siblings
35 | #
36 | # Required for each makefile to inherit from the parent
37 | #
38 |
39 | INCLUDES := $(INCLUDES) -I $(PDIR)include
40 | INCLUDES += -I ./
41 | INCLUDES += -I ../libc
42 | PDIR := ../$(PDIR)
43 | sinclude $(PDIR)Makefile
44 |
45 |
--------------------------------------------------------------------------------
/app/smart/Makefile:
--------------------------------------------------------------------------------
1 |
2 | #############################################################
3 | # Required variables for each makefile
4 | # Discard this section from all parent makefiles
5 | # Expected variables (with automatic defaults):
6 | # CSRCS (all "C" files in the dir)
7 | # SUBDIRS (all subdirs with a Makefile)
8 | # GEN_LIBS - list of libs to be generated ()
9 | # GEN_IMAGES - list of images to be generated ()
10 | # COMPONENTS_xxx - a list of libs/objs in the form
11 | # subdir/lib to be extracted and rolled up into
12 | # a generated lib/image xxx.a ()
13 | #
14 | ifndef PDIR
15 | GEN_LIBS = smart.a
16 | endif
17 |
18 | #############################################################
19 | # Configuration i.e. compile options etc.
20 | # Target specific stuff (defines etc.) goes in here!
21 | # Generally values applying to a tree are captured in the
22 | # makefile at its root level - these are then overridden
23 | # for a subtree within the makefile rooted therein
24 | #
25 | #DEFINES +=
26 |
27 | #############################################################
28 | # Recursion Magic - Don't touch this!!
29 | #
30 | # Each subtree potentially has an include directory
31 | # corresponding to the common APIs applicable to modules
32 | # rooted at that subtree. Accordingly, the INCLUDE PATH
33 | # of a module can only contain the include directories up
34 | # its parent path, and not its siblings
35 | #
36 | # Required for each makefile to inherit from the parent
37 | #
38 |
39 | INCLUDES := $(INCLUDES) -I $(PDIR)include
40 | INCLUDES += -I ./
41 | INCLUDES += -I ../libc
42 | PDIR := ../$(PDIR)
43 | sinclude $(PDIR)Makefile
44 |
45 |
--------------------------------------------------------------------------------
/app/ssl/app/Makefile:
--------------------------------------------------------------------------------
1 |
2 | #############################################################
3 | # Required variables for each makefile
4 | # Discard this section from all parent makefiles
5 | # Expected variables (with automatic defaults):
6 | # CSRCS (all "C" files in the dir)
7 | # SUBDIRS (all subdirs with a Makefile)
8 | # GEN_LIBS - list of libs to be generated ()
9 | # GEN_IMAGES - list of images to be generated ()
10 | # COMPONENTS_xxx - a list of libs/objs in the form
11 | # subdir/lib to be extracted and rolled up into
12 | # a generated lib/image xxx.a ()
13 | #
14 | ifndef PDIR
15 |
16 | GEN_LIBS = libsslapp.a
17 |
18 | endif
19 |
20 |
21 | #############################################################
22 | # Configuration i.e. compile options etc.
23 | # Target specific stuff (defines etc.) goes in here!
24 | # Generally values applying to a tree are captured in the
25 | # makefile at its root level - these are then overridden
26 | # for a subtree within the makefile rooted therein
27 | #
28 | #DEFINES +=
29 |
30 | #############################################################
31 | # Recursion Magic - Don't touch this!!
32 | #
33 | # Each subtree potentially has an include directory
34 | # corresponding to the common APIs applicable to modules
35 | # rooted at that subtree. Accordingly, the INCLUDE PATH
36 | # of a module can only contain the include directories up
37 | # its parent path, and not its siblings
38 | #
39 | # Required for each makefile to inherit from the parent
40 | #
41 |
42 | INCLUDES := $(INCLUDES) -I $(PDIR)include
43 | INCLUDES += -I ./
44 | PDIR := ../$(PDIR)
45 | sinclude $(PDIR)Makefile
46 |
47 |
--------------------------------------------------------------------------------
/app/ssl/ssl/Makefile:
--------------------------------------------------------------------------------
1 |
2 | #############################################################
3 | # Required variables for each makefile
4 | # Discard this section from all parent makefiles
5 | # Expected variables (with automatic defaults):
6 | # CSRCS (all "C" files in the dir)
7 | # SUBDIRS (all subdirs with a Makefile)
8 | # GEN_LIBS - list of libs to be generated ()
9 | # GEN_IMAGES - list of images to be generated ()
10 | # COMPONENTS_xxx - a list of libs/objs in the form
11 | # subdir/lib to be extracted and rolled up into
12 | # a generated lib/image xxx.a ()
13 | #
14 | ifndef PDIR
15 |
16 | GEN_LIBS = libsslssl.a
17 |
18 | endif
19 |
20 |
21 | #############################################################
22 | # Configuration i.e. compile options etc.
23 | # Target specific stuff (defines etc.) goes in here!
24 | # Generally values applying to a tree are captured in the
25 | # makefile at its root level - these are then overridden
26 | # for a subtree within the makefile rooted therein
27 | #
28 | #DEFINES +=
29 |
30 | #############################################################
31 | # Recursion Magic - Don't touch this!!
32 | #
33 | # Each subtree potentially has an include directory
34 | # corresponding to the common APIs applicable to modules
35 | # rooted at that subtree. Accordingly, the INCLUDE PATH
36 | # of a module can only contain the include directories up
37 | # its parent path, and not its siblings
38 | #
39 | # Required for each makefile to inherit from the parent
40 | #
41 |
42 | INCLUDES := $(INCLUDES) -I $(PDIR)include
43 | INCLUDES += -I ./
44 | PDIR := ../$(PDIR)
45 | sinclude $(PDIR)Makefile
46 |
47 |
--------------------------------------------------------------------------------
/app/libc/Makefile:
--------------------------------------------------------------------------------
1 |
2 | #############################################################
3 | # Required variables for each makefile
4 | # Discard this section from all parent makefiles
5 | # Expected variables (with automatic defaults):
6 | # CSRCS (all "C" files in the dir)
7 | # SUBDIRS (all subdirs with a Makefile)
8 | # GEN_LIBS - list of libs to be generated ()
9 | # GEN_IMAGES - list of images to be generated ()
10 | # COMPONENTS_xxx - a list of libs/objs in the form
11 | # subdir/lib to be extracted and rolled up into
12 | # a generated lib/image xxx.a ()
13 | #
14 | ifndef PDIR
15 | GEN_LIBS = liblibc.a
16 | endif
17 |
18 | #############################################################
19 | # Configuration i.e. compile options etc.
20 | # Target specific stuff (defines etc.) goes in here!
21 | # Generally values applying to a tree are captured in the
22 | # makefile at its root level - these are then overridden
23 | # for a subtree within the makefile rooted therein
24 | #
25 | #DEFINES +=
26 |
27 | #############################################################
28 | # Recursion Magic - Don't touch this!!
29 | #
30 | # Each subtree potentially has an include directory
31 | # corresponding to the common APIs applicable to modules
32 | # rooted at that subtree. Accordingly, the INCLUDE PATH
33 | # of a module can only contain the include directories up
34 | # its parent path, and not its siblings
35 | #
36 | # Required for each makefile to inherit from the parent
37 | #
38 |
39 | INCLUDES := $(INCLUDES) -I $(PDIR)include
40 | INCLUDES += -I ./
41 | INCLUDES += -I ../wofs
42 | PDIR := ../$(PDIR)
43 | sinclude $(PDIR)Makefile
44 |
45 |
--------------------------------------------------------------------------------
/app/lwip/core/ipv4/Makefile:
--------------------------------------------------------------------------------
1 |
2 | #############################################################
3 | # Required variables for each makefile
4 | # Discard this section from all parent makefiles
5 | # Expected variables (with automatic defaults):
6 | # CSRCS (all "C" files in the dir)
7 | # SUBDIRS (all subdirs with a Makefile)
8 | # GEN_LIBS - list of libs to be generated ()
9 | # GEN_IMAGES - list of images to be generated ()
10 | # COMPONENTS_xxx - a list of libs/objs in the form
11 | # subdir/lib to be extracted and rolled up into
12 | # a generated lib/image xxx.a ()
13 | #
14 | ifndef PDIR
15 |
16 | GEN_LIBS = liblwipipv4.a
17 |
18 | endif
19 |
20 |
21 | #############################################################
22 | # Configuration i.e. compile options etc.
23 | # Target specific stuff (defines etc.) goes in here!
24 | # Generally values applying to a tree are captured in the
25 | # makefile at its root level - these are then overridden
26 | # for a subtree within the makefile rooted therein
27 | #
28 | #DEFINES +=
29 |
30 | #############################################################
31 | # Recursion Magic - Don't touch this!!
32 | #
33 | # Each subtree potentially has an include directory
34 | # corresponding to the common APIs applicable to modules
35 | # rooted at that subtree. Accordingly, the INCLUDE PATH
36 | # of a module can only contain the include directories up
37 | # its parent path, and not its siblings
38 | #
39 | # Required for each makefile to inherit from the parent
40 | #
41 |
42 | INCLUDES := $(INCLUDES) -I $(PDIR)include
43 | INCLUDES += -I ./
44 | PDIR := ../$(PDIR)
45 | sinclude $(PDIR)Makefile
46 |
47 |
--------------------------------------------------------------------------------
/app/lwip/netif/Makefile:
--------------------------------------------------------------------------------
1 |
2 | #############################################################
3 | # Required variables for each makefile
4 | # Discard this section from all parent makefiles
5 | # Expected variables (with automatic defaults):
6 | # CSRCS (all "C" files in the dir)
7 | # SUBDIRS (all subdirs with a Makefile)
8 | # GEN_LIBS - list of libs to be generated ()
9 | # GEN_IMAGES - list of images to be generated ()
10 | # COMPONENTS_xxx - a list of libs/objs in the form
11 | # subdir/lib to be extracted and rolled up into
12 | # a generated lib/image xxx.a ()
13 | #
14 | ifndef PDIR
15 |
16 | GEN_LIBS = liblwipnetif.a
17 |
18 | endif
19 |
20 |
21 | #############################################################
22 | # Configuration i.e. compile options etc.
23 | # Target specific stuff (defines etc.) goes in here!
24 | # Generally values applying to a tree are captured in the
25 | # makefile at its root level - these are then overridden
26 | # for a subtree within the makefile rooted therein
27 | #
28 | #DEFINES +=
29 |
30 | #############################################################
31 | # Recursion Magic - Don't touch this!!
32 | #
33 | # Each subtree potentially has an include directory
34 | # corresponding to the common APIs applicable to modules
35 | # rooted at that subtree. Accordingly, the INCLUDE PATH
36 | # of a module can only contain the include directories up
37 | # its parent path, and not its siblings
38 | #
39 | # Required for each makefile to inherit from the parent
40 | #
41 |
42 | INCLUDES := $(INCLUDES) -I $(PDIR)include
43 | INCLUDES += -I ./
44 | PDIR := ../$(PDIR)
45 | sinclude $(PDIR)Makefile
46 |
47 |
--------------------------------------------------------------------------------
/app/ssl/crypto/Makefile:
--------------------------------------------------------------------------------
1 |
2 | #############################################################
3 | # Required variables for each makefile
4 | # Discard this section from all parent makefiles
5 | # Expected variables (with automatic defaults):
6 | # CSRCS (all "C" files in the dir)
7 | # SUBDIRS (all subdirs with a Makefile)
8 | # GEN_LIBS - list of libs to be generated ()
9 | # GEN_IMAGES - list of images to be generated ()
10 | # COMPONENTS_xxx - a list of libs/objs in the form
11 | # subdir/lib to be extracted and rolled up into
12 | # a generated lib/image xxx.a ()
13 | #
14 | ifndef PDIR
15 |
16 | GEN_LIBS = libsslcrypto.a
17 |
18 | endif
19 |
20 |
21 | #############################################################
22 | # Configuration i.e. compile options etc.
23 | # Target specific stuff (defines etc.) goes in here!
24 | # Generally values applying to a tree are captured in the
25 | # makefile at its root level - these are then overridden
26 | # for a subtree within the makefile rooted therein
27 | #
28 | #DEFINES +=
29 |
30 | #############################################################
31 | # Recursion Magic - Don't touch this!!
32 | #
33 | # Each subtree potentially has an include directory
34 | # corresponding to the common APIs applicable to modules
35 | # rooted at that subtree. Accordingly, the INCLUDE PATH
36 | # of a module can only contain the include directories up
37 | # its parent path, and not its siblings
38 | #
39 | # Required for each makefile to inherit from the parent
40 | #
41 |
42 | INCLUDES := $(INCLUDES) -I $(PDIR)include
43 | INCLUDES += -I ./
44 | PDIR := ../$(PDIR)
45 | sinclude $(PDIR)Makefile
46 |
47 |
--------------------------------------------------------------------------------
/app/u8glib/Makefile:
--------------------------------------------------------------------------------
1 |
2 | #############################################################
3 | # Required variables for each makefile
4 | # Discard this section from all parent makefiles
5 | # Expected variables (with automatic defaults):
6 | # CSRCS (all "C" files in the dir)
7 | # SUBDIRS (all subdirs with a Makefile)
8 | # GEN_LIBS - list of libs to be generated ()
9 | # GEN_IMAGES - list of images to be generated ()
10 | # COMPONENTS_xxx - a list of libs/objs in the form
11 | # subdir/lib to be extracted and rolled up into
12 | # a generated lib/image xxx.a ()
13 | #
14 | ifndef PDIR
15 | GEN_LIBS = u8glib.a
16 | endif
17 |
18 | #############################################################
19 | # Configuration i.e. compile options etc.
20 | # Target specific stuff (defines etc.) goes in here!
21 | # Generally values applying to a tree are captured in the
22 | # makefile at its root level - these are then overridden
23 | # for a subtree within the makefile rooted therein
24 | #
25 | #DEFINES +=
26 |
27 | #############################################################
28 | # Recursion Magic - Don't touch this!!
29 | #
30 | # Each subtree potentially has an include directory
31 | # corresponding to the common APIs applicable to modules
32 | # rooted at that subtree. Accordingly, the INCLUDE PATH
33 | # of a module can only contain the include directories up
34 | # its parent path, and not its siblings
35 | #
36 | # Required for each makefile to inherit from the parent
37 | #
38 |
39 | INCLUDES := $(INCLUDES) -I $(PDIR)include
40 | INCLUDES += -I ./
41 | INCLUDES += -I ../libc
42 | PDIR := ../$(PDIR)
43 | sinclude $(PDIR)Makefile
44 |
45 |
--------------------------------------------------------------------------------
/app/libc/c_stdlib.h:
--------------------------------------------------------------------------------
1 | /*
2 | * c_stdlib.h
3 | *
4 | * Definitions for common types, variables, and functions.
5 | */
6 |
7 | #ifndef _C_STDLIB_H_
8 | #define _C_STDLIB_H_
9 |
10 | #include "c_stddef.h"
11 | #include "mem.h"
12 |
13 | #define EXIT_FAILURE 1
14 | #define EXIT_SUCCESS 0
15 |
16 | #define __INT_MAX__ 2147483647
17 | #undef __RAND_MAX
18 | #if __INT_MAX__ == 32767
19 | #define __RAND_MAX 32767
20 | #else
21 | #define __RAND_MAX 0x7fffffff
22 | #endif
23 | #define RAND_MAX __RAND_MAX
24 |
25 | #ifndef mem_realloc
26 | #define mem_realloc pvPortRealloc
27 | #endif
28 | #ifndef os_realloc
29 | #define os_realloc(p, s) mem_realloc((p), (s))
30 | #endif
31 |
32 | #define c_free os_free
33 | #define c_malloc os_malloc
34 | #define c_zalloc os_zalloc
35 | #define c_realloc os_realloc
36 |
37 | #define c_abs abs
38 | #define c_atoi atoi
39 | //#define c_strtod strtod
40 | #define c_strtol strtol
41 | #define c_strtoul strtoul
42 |
43 | // int c_abs(int);
44 |
45 | // void c_exit(int);
46 |
47 | // c_getenv() get env "LUA_INIT" string for lua initialization.
48 | const char *c_getenv(const char *__string);
49 |
50 | // void *c_malloc(size_t __size);
51 | // void *c_zalloc(size_t __size);
52 | // void c_free(void *);
53 |
54 | // int c_rand(void);
55 | // void c_srand(unsigned int __seed);
56 |
57 | // int c_atoi(const char *__nptr);
58 | double c_strtod(const char *__n, char **__end_PTR);
59 | // // long c_strtol(const char *__n, char **__end_PTR, int __base);
60 | // unsigned long c_strtoul(const char *__n, char **__end_PTR, int __base);
61 | // // long long c_strtoll(const char *__n, char **__end_PTR, int __base);
62 |
63 | #endif /* _C_STDLIB_H_ */
64 |
--------------------------------------------------------------------------------
/app/lua/ltable.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** $Id: ltable.h,v 2.10.1.1 2007/12/27 13:02:25 roberto Exp $
3 | ** Lua tables (hash)
4 | ** See Copyright Notice in lua.h
5 | */
6 |
7 | #ifndef ltable_h
8 | #define ltable_h
9 |
10 | #include "lobject.h"
11 |
12 |
13 | #define gnode(t,i) (&(t)->node[i])
14 | #define gkey(n) (&(n)->i_key.tvk)
15 | #define gval(n) (&(n)->i_val)
16 | #define gnext(n) ((n)->i_key.nk.next)
17 |
18 | #define key2tval(n) (&(n)->i_key.tvk)
19 |
20 |
21 | LUAI_FUNC const TValue *luaH_getnum (Table *t, int key);
22 | LUAI_FUNC const TValue *luaH_getnum_ro (void *t, int key);
23 | LUAI_FUNC TValue *luaH_setnum (lua_State *L, Table *t, int key);
24 | LUAI_FUNC const TValue *luaH_getstr (Table *t, TString *key);
25 | LUAI_FUNC const TValue *luaH_getstr_ro (void *t, TString *key);
26 | LUAI_FUNC TValue *luaH_setstr (lua_State *L, Table *t, TString *key);
27 | LUAI_FUNC const TValue *luaH_get (Table *t, const TValue *key);
28 | LUAI_FUNC const TValue *luaH_get_ro (void *t, const TValue *key);
29 | LUAI_FUNC TValue *luaH_set (lua_State *L, Table *t, const TValue *key);
30 | LUAI_FUNC Table *luaH_new (lua_State *L, int narray, int lnhash);
31 | LUAI_FUNC void luaH_resizearray (lua_State *L, Table *t, int nasize);
32 | LUAI_FUNC void luaH_free (lua_State *L, Table *t);
33 | LUAI_FUNC int luaH_next (lua_State *L, Table *t, StkId key);
34 | LUAI_FUNC int luaH_next_ro (lua_State *L, void *t, StkId key);
35 | LUAI_FUNC int luaH_getn (Table *t);
36 | LUAI_FUNC int luaH_getn_ro (void *t);
37 |
38 | #if defined(LUA_DEBUG)
39 | LUAI_FUNC Node *luaH_mainposition (const Table *t, const TValue *key);
40 | LUAI_FUNC int luaH_isdummy (Node *n);
41 | #endif
42 |
43 |
44 | #endif
45 |
--------------------------------------------------------------------------------
/app/driver/Makefile:
--------------------------------------------------------------------------------
1 |
2 | #############################################################
3 | # Required variables for each makefile
4 | # Discard this section from all parent makefiles
5 | # Expected variables (with automatic defaults):
6 | # CSRCS (all "C" files in the dir)
7 | # SUBDIRS (all subdirs with a Makefile)
8 | # GEN_LIBS - list of libs to be generated ()
9 | # GEN_IMAGES - list of images to be generated ()
10 | # COMPONENTS_xxx - a list of libs/objs in the form
11 | # subdir/lib to be extracted and rolled up into
12 | # a generated lib/image xxx.a ()
13 | #
14 | ifndef PDIR
15 | GEN_LIBS = libdriver.a
16 | endif
17 |
18 |
19 | #############################################################
20 | # Configuration i.e. compile options etc.
21 | # Target specific stuff (defines etc.) goes in here!
22 | # Generally values applying to a tree are captured in the
23 | # makefile at its root level - these are then overridden
24 | # for a subtree within the makefile rooted therein
25 | #
26 | #DEFINES +=
27 |
28 | #############################################################
29 | # Recursion Magic - Don't touch this!!
30 | #
31 | # Each subtree potentially has an include directory
32 | # corresponding to the common APIs applicable to modules
33 | # rooted at that subtree. Accordingly, the INCLUDE PATH
34 | # of a module can only contain the include directories up
35 | # its parent path, and not its siblings
36 | #
37 | # Required for each makefile to inherit from the parent
38 | #
39 |
40 | INCLUDES := $(INCLUDES) -I $(PDIR)include
41 | INCLUDES += -I ./
42 | INCLUDES += -I ../platform
43 | PDIR := ../$(PDIR)
44 | sinclude $(PDIR)Makefile
45 |
46 |
--------------------------------------------------------------------------------
/app/cjson/Makefile:
--------------------------------------------------------------------------------
1 |
2 | #############################################################
3 | # Required variables for each makefile
4 | # Discard this section from all parent makefiles
5 | # Expected variables (with automatic defaults):
6 | # CSRCS (all "C" files in the dir)
7 | # SUBDIRS (all subdirs with a Makefile)
8 | # GEN_LIBS - list of libs to be generated ()
9 | # GEN_IMAGES - list of images to be generated ()
10 | # COMPONENTS_xxx - a list of libs/objs in the form
11 | # subdir/lib to be extracted and rolled up into
12 | # a generated lib/image xxx.a ()
13 | #
14 | ifndef PDIR
15 |
16 | GEN_LIBS = libcjson.a
17 |
18 | endif
19 |
20 |
21 | #############################################################
22 | # Configuration i.e. compile options etc.
23 | # Target specific stuff (defines etc.) goes in here!
24 | # Generally values applying to a tree are captured in the
25 | # makefile at its root level - these are then overridden
26 | # for a subtree within the makefile rooted therein
27 | #
28 | #DEFINES +=
29 |
30 | #############################################################
31 | # Recursion Magic - Don't touch this!!
32 | #
33 | # Each subtree potentially has an include directory
34 | # corresponding to the common APIs applicable to modules
35 | # rooted at that subtree. Accordingly, the INCLUDE PATH
36 | # of a module can only contain the include directories up
37 | # its parent path, and not its siblings
38 | #
39 | # Required for each makefile to inherit from the parent
40 | #
41 |
42 | INCLUDES := $(INCLUDES) -I $(PDIR)include
43 | INCLUDES += -I ./
44 | INCLUDES += -I ../libc
45 | PDIR := ../$(PDIR)
46 | sinclude $(PDIR)Makefile
47 |
48 |
--------------------------------------------------------------------------------
/app/coap/Makefile:
--------------------------------------------------------------------------------
1 |
2 | #############################################################
3 | # Required variables for each makefile
4 | # Discard this section from all parent makefiles
5 | # Expected variables (with automatic defaults):
6 | # CSRCS (all "C" files in the dir)
7 | # SUBDIRS (all subdirs with a Makefile)
8 | # GEN_LIBS - list of libs to be generated ()
9 | # GEN_IMAGES - list of images to be generated ()
10 | # COMPONENTS_xxx - a list of libs/objs in the form
11 | # subdir/lib to be extracted and rolled up into
12 | # a generated lib/image xxx.a ()
13 | #
14 | ifndef PDIR
15 | GEN_LIBS = coap.a
16 | endif
17 |
18 | #############################################################
19 | # Configuration i.e. compile options etc.
20 | # Target specific stuff (defines etc.) goes in here!
21 | # Generally values applying to a tree are captured in the
22 | # makefile at its root level - these are then overridden
23 | # for a subtree within the makefile rooted therein
24 | #
25 | #DEFINES +=
26 |
27 | #############################################################
28 | # Recursion Magic - Don't touch this!!
29 | #
30 | # Each subtree potentially has an include directory
31 | # corresponding to the common APIs applicable to modules
32 | # rooted at that subtree. Accordingly, the INCLUDE PATH
33 | # of a module can only contain the include directories up
34 | # its parent path, and not its siblings
35 | #
36 | # Required for each makefile to inherit from the parent
37 | #
38 |
39 | INCLUDES := $(INCLUDES) -I $(PDIR)include
40 | INCLUDES += -I ./
41 | INCLUDES += -I ../libc
42 | INCLUDES += -I ../lua
43 | PDIR := ../$(PDIR)
44 | sinclude $(PDIR)Makefile
45 |
46 |
--------------------------------------------------------------------------------
/app/wofs/Makefile:
--------------------------------------------------------------------------------
1 |
2 | #############################################################
3 | # Required variables for each makefile
4 | # Discard this section from all parent makefiles
5 | # Expected variables (with automatic defaults):
6 | # CSRCS (all "C" files in the dir)
7 | # SUBDIRS (all subdirs with a Makefile)
8 | # GEN_LIBS - list of libs to be generated ()
9 | # GEN_IMAGES - list of images to be generated ()
10 | # COMPONENTS_xxx - a list of libs/objs in the form
11 | # subdir/lib to be extracted and rolled up into
12 | # a generated lib/image xxx.a ()
13 | #
14 | ifndef PDIR
15 | GEN_LIBS = wofs.a
16 | endif
17 |
18 | #############################################################
19 | # Configuration i.e. compile options etc.
20 | # Target specific stuff (defines etc.) goes in here!
21 | # Generally values applying to a tree are captured in the
22 | # makefile at its root level - these are then overridden
23 | # for a subtree within the makefile rooted therein
24 | #
25 | #DEFINES +=
26 |
27 | #############################################################
28 | # Recursion Magic - Don't touch this!!
29 | #
30 | # Each subtree potentially has an include directory
31 | # corresponding to the common APIs applicable to modules
32 | # rooted at that subtree. Accordingly, the INCLUDE PATH
33 | # of a module can only contain the include directories up
34 | # its parent path, and not its siblings
35 | #
36 | # Required for each makefile to inherit from the parent
37 | #
38 |
39 | INCLUDES := $(INCLUDES) -I $(PDIR)include
40 | INCLUDES += -I ./
41 | INCLUDES += -I ../libc
42 | INCLUDES += -I ../platform
43 | PDIR := ../$(PDIR)
44 | sinclude $(PDIR)Makefile
45 |
--------------------------------------------------------------------------------
/app/spiffs/Makefile:
--------------------------------------------------------------------------------
1 |
2 | #############################################################
3 | # Required variables for each makefile
4 | # Discard this section from all parent makefiles
5 | # Expected variables (with automatic defaults):
6 | # CSRCS (all "C" files in the dir)
7 | # SUBDIRS (all subdirs with a Makefile)
8 | # GEN_LIBS - list of libs to be generated ()
9 | # GEN_IMAGES - list of images to be generated ()
10 | # COMPONENTS_xxx - a list of libs/objs in the form
11 | # subdir/lib to be extracted and rolled up into
12 | # a generated lib/image xxx.a ()
13 | #
14 | ifndef PDIR
15 | GEN_LIBS = spiffs.a
16 | endif
17 |
18 | #############################################################
19 | # Configuration i.e. compile options etc.
20 | # Target specific stuff (defines etc.) goes in here!
21 | # Generally values applying to a tree are captured in the
22 | # makefile at its root level - these are then overridden
23 | # for a subtree within the makefile rooted therein
24 | #
25 | #DEFINES +=
26 |
27 | #############################################################
28 | # Recursion Magic - Don't touch this!!
29 | #
30 | # Each subtree potentially has an include directory
31 | # corresponding to the common APIs applicable to modules
32 | # rooted at that subtree. Accordingly, the INCLUDE PATH
33 | # of a module can only contain the include directories up
34 | # its parent path, and not its siblings
35 | #
36 | # Required for each makefile to inherit from the parent
37 | #
38 |
39 | INCLUDES := $(INCLUDES) -I $(PDIR)include
40 | INCLUDES += -I ./
41 | INCLUDES += -I ../libc
42 | INCLUDES += -I ../platform
43 | PDIR := ../$(PDIR)
44 | sinclude $(PDIR)Makefile
45 |
--------------------------------------------------------------------------------
/app/upgrade/Makefile:
--------------------------------------------------------------------------------
1 |
2 | #############################################################
3 | # Required variables for each makefile
4 | # Discard this section from all parent makefiles
5 | # Expected variables (with automatic defaults):
6 | # CSRCS (all "C" files in the dir)
7 | # SUBDIRS (all subdirs with a Makefile)
8 | # GEN_LIBS - list of libs to be generated ()
9 | # GEN_IMAGES - list of images to be generated ()
10 | # COMPONENTS_xxx - a list of libs/objs in the form
11 | # subdir/lib to be extracted and rolled up into
12 | # a generated lib/image xxx.a ()
13 | #
14 | ifndef PDIR
15 |
16 | GEN_LIBS = libupgrade.a
17 |
18 | endif
19 |
20 |
21 | #############################################################
22 | # Configuration i.e. compile options etc.
23 | # Target specific stuff (defines etc.) goes in here!
24 | # Generally values applying to a tree are captured in the
25 | # makefile at its root level - these are then overridden
26 | # for a subtree within the makefile rooted therein
27 | #
28 | #DEFINES +=
29 |
30 | #############################################################
31 | # Recursion Magic - Don't touch this!!
32 | #
33 | # Each subtree potentially has an include directory
34 | # corresponding to the common APIs applicable to modules
35 | # rooted at that subtree. Accordingly, the INCLUDE PATH
36 | # of a module can only contain the include directories up
37 | # its parent path, and not its siblings
38 | #
39 | # Required for each makefile to inherit from the parent
40 | #
41 |
42 | INCLUDES := $(INCLUDES) -I $(PDIR)include
43 | INCLUDES += -I ./
44 | INCLUDES += -I ../../include/ets
45 | PDIR := ../$(PDIR)
46 | sinclude $(PDIR)Makefile
47 |
48 |
--------------------------------------------------------------------------------
/lua_modules/hdc1000/README.md:
--------------------------------------------------------------------------------
1 | HDC1000 NodeMCU module
2 | =======================
3 |
4 | Here's my NodeMCU module for the TI HDC1000 temperature and humidity sensor. It should work with the HDC1008 too but I haven't tested it.
5 |
6 | ### Setup your sensor:
7 | First, require it:
8 |
9 | `HDC1000 = require("HDC1000")`
10 |
11 | Then, initialize it:
12 |
13 | `HDC1000.init(sda, scl, drdyn)`
14 |
15 | If you don't want to use the DRDYn pin, set it to false: a 20ms delay will be automatically set after each read request.
16 |
17 | `HDC1000.init(sda, scl, false)`
18 |
19 | Configure it:
20 |
21 | `HDC1000.config()`
22 |
23 | Default options set the address to 0x40 and enable both temperature and humidity readings at 14-bit resolution, with the integrated heater on. You can change them by initializing your sensor like this:
24 |
25 | `HDC1000.config(address, resolution, heater);`
26 |
27 | "resolution" can be set to 14 bits for both temperature and humidity (0x00 - default) 11 bits for temperature (0x40), 11 bits for humidity (0x01), 8 bits for humidity (0x20)
28 | "heater" can be set to ON (0x20 - default) or OFF (0x00)
29 |
30 | ### Read some values
31 | You can read temperature and humidity by using the following commands:
32 |
33 | `temperature = HDC1000.getTemp()` in Celsius degrees.
34 |
35 | `humidity = HDC1000.getHumi()` in %
36 |
37 | ### Check your battery
38 |
39 | The following code returns true if the battery voltage is <2.8V, false otherwise.
40 |
41 | `isDead = HDC1000.batteryDead();`
42 |
43 | Happy making! Also, check out my Breakout Board and Arduino library for this chip: http://b.truzzi.me/hdc1000-temperature-and-humidity-sensor-breakout-with-arduino-library/.
44 |
--------------------------------------------------------------------------------
/app/lua/lmem.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** $Id: lmem.h,v 1.31.1.1 2007/12/27 13:02:25 roberto Exp $
3 | ** Interface to Memory Manager
4 | ** See Copyright Notice in lua.h
5 | */
6 |
7 | #ifndef lmem_h
8 | #define lmem_h
9 |
10 |
11 | //#include "c_stddef.h"
12 |
13 | #include "llimits.h"
14 | #include "lua.h"
15 |
16 | #define MEMERRMSG "not enough memory"
17 |
18 |
19 | #define luaM_reallocv(L,b,on,n,e) \
20 | ((cast(size_t, (n)+1) <= MAX_SIZET/(e)) ? /* +1 to avoid warnings */ \
21 | luaM_realloc_(L, (b), (on)*(e), (n)*(e)) : \
22 | luaM_toobig(L))
23 |
24 | #define luaM_freemem(L, b, s) luaM_realloc_(L, (b), (s), 0)
25 | #define luaM_free(L, b) luaM_realloc_(L, (b), sizeof(*(b)), 0)
26 | #define luaM_freearray(L, b, n, t) luaM_reallocv(L, (b), n, 0, sizeof(t))
27 |
28 | #define luaM_malloc(L,t) luaM_realloc_(L, NULL, 0, (t))
29 | #define luaM_new(L,t) cast(t *, luaM_malloc(L, sizeof(t)))
30 | #define luaM_newvector(L,n,t) \
31 | cast(t *, luaM_reallocv(L, NULL, 0, n, sizeof(t)))
32 |
33 | #define luaM_growvector(L,v,nelems,size,t,limit,e) \
34 | if ((nelems)+1 > (size)) \
35 | ((v)=cast(t *, luaM_growaux_(L,v,&(size),sizeof(t),limit,e)))
36 |
37 | #define luaM_reallocvector(L, v,oldn,n,t) \
38 | ((v)=cast(t *, luaM_reallocv(L, v, oldn, n, sizeof(t))))
39 |
40 |
41 | LUAI_FUNC void *luaM_realloc_ (lua_State *L, void *block, size_t oldsize,
42 | size_t size);
43 | LUAI_FUNC void *luaM_toobig (lua_State *L);
44 | LUAI_FUNC void *luaM_growaux_ (lua_State *L, void *block, int *size,
45 | size_t size_elem, int limit,
46 | const char *errormsg);
47 |
48 | #endif
49 |
50 |
--------------------------------------------------------------------------------
/app/lua/compiler.h:
--------------------------------------------------------------------------------
1 | /**
2 | * define start/end address of ro data.
3 | * different compiler with different implementation.
4 | */
5 |
6 | #ifndef __COMPILER_H__
7 | #define __COMPILER_H__
8 |
9 | #if defined(__CC_ARM) // armcc
10 |
11 | //#warning "Please check scatter file to ensure rodata is in ER_IROM1 region."
12 |
13 | /* symbols reference to the scatter file */
14 | extern char Image$$ER_IROM1$$Base;
15 | extern char Image$$ER_IROM1$$Limit;
16 |
17 | #define RODATA_START_ADDRESS (&Image$$ER_IROM1$$Base)
18 | #define RODATA_END_ADDRESS (&Image$$ER_IROM1$$Limit)
19 |
20 | #elif defined(__GNUC__) // gcc
21 |
22 | //#warning "Please check linker script to ensure rodata is between _stext and _etext."
23 |
24 | /* symbols defined in linker script */
25 | // extern char _rodata_start;
26 | // extern char _rodata_end;
27 | extern char _irom0_text_start;
28 | extern char _irom0_text_end;
29 | // modify linker script to ensure rodata and rodata1 is between _rodata_start and _rodata_end.
30 | // #define RODATA_START_ADDRESS (&_rodata_start)
31 | // #define RODATA_END_ADDRESS (&_rodata_end)
32 | #define RODATA_START_ADDRESS (&_irom0_text_start)
33 | #define RODATA_END_ADDRESS (&_irom0_text_end)
34 |
35 | #else // other compilers
36 |
37 | /* Firstly, modify rodata's start/end address. Then, comment the line below */
38 | #error "Please modify RODATA_START_ADDRESS and RODATA_END_ADDRESS below."
39 |
40 | /* Perhaps you can use start/end address of flash */
41 | #define RODATA_START_ADDRESS ((char*)0x40200000)
42 | #define RODATA_END_ADDRESS ((char*)0x40280000)
43 |
44 | #endif
45 |
46 | #endif // __COMPILER_H__
47 |
48 |
--------------------------------------------------------------------------------
/lua_examples/mcp23008/mcp23008_leds.lua:
--------------------------------------------------------------------------------
1 | ---
2 | -- @description Shows control of 8 GPIO pins/LEDs via I2C with the MCP23008 I/O expander.
3 | -- Tested on odeMCU 0.9.5 build 20150213.
4 | -- @date March 02, 2015
5 | -- @circuit Connect 8 LEDs withs resistors to the GPIO pins of the MCP23008.
6 | -- Connect GPIO0 of the ESP8266-01 module to the SCL pin of the MCP23008.
7 | -- Connect GPIO2 of the ESP8266-01 module to the SDA pin of the MCP23008.
8 | -- Connect two 4.7k pull-up resistors on SDA and SCL
9 | -- Use 3.3V for VCC.
10 | -- @author Miguel (AllAboutEE)
11 | -- GitHub: https://github.com/AllAboutEE
12 | -- Working Example Video: https://www.youtube.com/watch?v=KphAJMZZed0
13 | -- Website: http://AllAboutEE.com
14 | ---------------------------------------------------------------------------------------------
15 |
16 | require ("mcp23008")
17 |
18 | -- ESP-01 GPIO Mapping as per GPIO Table in https://github.com/nodemcu/nodemcu-firmware
19 | gpio0, gpio2 = 3, 4
20 |
21 | -- Setup MCP23008
22 | mcp23008.begin(0x0,gpio2,gpio0,i2c.SLOW)
23 |
24 | mcp23008.writeIODIR(0x00) -- make all GPIO pins as outputs
25 | mcp23008.writeGPIO(0x00) -- make all GIPO pins off/low
26 |
27 | ---
28 | -- @name count()
29 | -- @description Reads the value from the GPIO register, increases the read value by 1
30 | -- and writes it back so the LEDs will display a binary count up to 255 or 0xFF in hex.
31 | local function count()
32 |
33 | local gpio = 0x00
34 |
35 | gpio = mcp23008.readGPIO()
36 |
37 | if(gpio<0xff) then
38 | mcp23008.writeGPIO(gpio+1)
39 | else
40 | mcp23008.writeGPIO(0x00)
41 | end
42 |
43 | end
44 | -- Run count() every 100ms
45 | tmr.alarm(0,100,1,count)
46 |
--------------------------------------------------------------------------------
/app/platform/Makefile:
--------------------------------------------------------------------------------
1 |
2 | #############################################################
3 | # Required variables for each makefile
4 | # Discard this section from all parent makefiles
5 | # Expected variables (with automatic defaults):
6 | # CSRCS (all "C" files in the dir)
7 | # SUBDIRS (all subdirs with a Makefile)
8 | # GEN_LIBS - list of libs to be generated ()
9 | # GEN_IMAGES - list of images to be generated ()
10 | # COMPONENTS_xxx - a list of libs/objs in the form
11 | # subdir/lib to be extracted and rolled up into
12 | # a generated lib/image xxx.a ()
13 | #
14 | ifndef PDIR
15 | GEN_LIBS = libplatform.a
16 | endif
17 |
18 | #############################################################
19 | # Configuration i.e. compile options etc.
20 | # Target specific stuff (defines etc.) goes in here!
21 | # Generally values applying to a tree are captured in the
22 | # makefile at its root level - these are then overridden
23 | # for a subtree within the makefile rooted therein
24 | #
25 | #DEFINES +=
26 |
27 | #############################################################
28 | # Recursion Magic - Don't touch this!!
29 | #
30 | # Each subtree potentially has an include directory
31 | # corresponding to the common APIs applicable to modules
32 | # rooted at that subtree. Accordingly, the INCLUDE PATH
33 | # of a module can only contain the include directories up
34 | # its parent path, and not its siblings
35 | #
36 | # Required for each makefile to inherit from the parent
37 | #
38 |
39 | INCLUDES := $(INCLUDES) -I $(PDIR)include
40 | INCLUDES += -I ./
41 | INCLUDES += -I ../wofs
42 | INCLUDES += -I ../spiffs
43 | INCLUDES += -I ../libc
44 | INCLUDES += -I ../lua
45 | PDIR := ../$(PDIR)
46 | sinclude $(PDIR)Makefile
47 |
48 |
--------------------------------------------------------------------------------
/app/ssl/Makefile:
--------------------------------------------------------------------------------
1 |
2 | #############################################################
3 | # Required variables for each makefile
4 | # Discard this section from all parent makefiles
5 | # Expected variables (with automatic defaults):
6 | # CSRCS (all "C" files in the dir)
7 | # SUBDIRS (all subdirs with a Makefile)
8 | # GEN_LIBS - list of libs to be generated ()
9 | # GEN_IMAGES - list of images to be generated ()
10 | # COMPONENTS_xxx - a list of libs/objs in the form
11 | # subdir/lib to be extracted and rolled up into
12 | # a generated lib/image xxx.a ()
13 | #
14 | ifndef PDIR
15 | UP_EXTRACT_DIR = ..
16 | GEN_LIBS = libssl.a
17 | COMPONENTS_libssl = crypto/libsslcrypto.a \
18 | ssl/libsslssl.a \
19 | app/libsslapp.a
20 | endif
21 |
22 |
23 | #############################################################
24 | # Configuration i.e. compile options etc.
25 | # Target specific stuff (defines etc.) goes in here!
26 | # Generally values applying to a tree are captured in the
27 | # makefile at its root level - these are then overridden
28 | # for a subtree within the makefile rooted therein
29 | #
30 | #DEFINES +=
31 |
32 | #############################################################
33 | # Recursion Magic - Don't touch this!!
34 | #
35 | # Each subtree potentially has an include directory
36 | # corresponding to the common APIs applicable to modules
37 | # rooted at that subtree. Accordingly, the INCLUDE PATH
38 | # of a module can only contain the include directories up
39 | # its parent path, and not its siblings
40 | #
41 | # Required for each makefile to inherit from the parent
42 | #
43 |
44 | INCLUDES := $(INCLUDES) -I $(PDIR)include
45 | INCLUDES += -I ./
46 | PDIR := ../$(PDIR)
47 | sinclude $(PDIR)Makefile
48 |
49 |
--------------------------------------------------------------------------------
/lua_examples/onewire-ds18b20.lua:
--------------------------------------------------------------------------------
1 | --'
2 | -- 18b20 one wire example for NODEMCU
3 | -- NODEMCU TEAM
4 | -- LICENCE: http://opensource.org/licenses/MIT
5 | -- Vowstar
6 | --'
7 |
8 | pin = 9
9 | ow.setup(pin)
10 | count = 0
11 | repeat
12 | count = count + 1
13 | addr = ow.reset_search(pin)
14 | addr = ow.search(pin)
15 | tmr.wdclr()
16 | until((addr ~= nil) or (count > 100))
17 | if (addr == nil) then
18 | print("No more addresses.")
19 | else
20 | print(addr:byte(1,8))
21 | crc = ow.crc8(string.sub(addr,1,7))
22 | if (crc == addr:byte(8)) then
23 | if ((addr:byte(1) == 0x10) or (addr:byte(1) == 0x28)) then
24 | print("Device is a DS18S20 family device.")
25 | repeat
26 | ow.reset(pin)
27 | ow.select(pin, addr)
28 | ow.write(pin, 0x44, 1)
29 | tmr.delay(1000000)
30 | present = ow.reset(pin)
31 | ow.select(pin, addr)
32 | ow.write(pin,0xBE,1)
33 | print("P="..present)
34 | data = nil
35 | data = string.char(ow.read(pin))
36 | for i = 1, 8 do
37 | data = data .. string.char(ow.read(pin))
38 | end
39 | print(data:byte(1,9))
40 | crc = ow.crc8(string.sub(data,1,8))
41 | print("CRC="..crc)
42 | if (crc == data:byte(9)) then
43 | t = (data:byte(1) + data:byte(2) * 256) * 625
44 | t1 = t / 10000
45 | t2 = t % 10000
46 | print("Temperature= "..t1.."."..t2.." Centigrade")
47 | end
48 | tmr.wdclr()
49 | until false
50 | else
51 | print("Device family is not recognized.")
52 | end
53 | else
54 | print("CRC is not valid!")
55 | end
56 | end
57 |
--------------------------------------------------------------------------------
/app/lua/Makefile:
--------------------------------------------------------------------------------
1 |
2 | #############################################################
3 | # Required variables for each makefile
4 | # Discard this section from all parent makefiles
5 | # Expected variables (with automatic defaults):
6 | # CSRCS (all "C" files in the dir)
7 | # SUBDIRS (all subdirs with a Makefile)
8 | # GEN_LIBS - list of libs to be generated ()
9 | # GEN_IMAGES - list of images to be generated ()
10 | # COMPONENTS_xxx - a list of libs/objs in the form
11 | # subdir/lib to be extracted and rolled up into
12 | # a generated lib/image xxx.a ()
13 | #
14 | ifndef PDIR
15 | GEN_LIBS = liblua.a
16 | endif
17 |
18 | #############################################################
19 | # Configuration i.e. compile options etc.
20 | # Target specific stuff (defines etc.) goes in here!
21 | # Generally values applying to a tree are captured in the
22 | # makefile at its root level - these are then overridden
23 | # for a subtree within the makefile rooted therein
24 | #
25 | #DEFINES +=
26 |
27 | #############################################################
28 | # Recursion Magic - Don't touch this!!
29 | #
30 | # Each subtree potentially has an include directory
31 | # corresponding to the common APIs applicable to modules
32 | # rooted at that subtree. Accordingly, the INCLUDE PATH
33 | # of a module can only contain the include directories up
34 | # its parent path, and not its siblings
35 | #
36 | # Required for each makefile to inherit from the parent
37 | #
38 |
39 | INCLUDES := $(INCLUDES) -I $(PDIR)include
40 | INCLUDES += -I ./
41 | INCLUDES += -I ../wofs
42 | INCLUDES += -I ../spiffs
43 | INCLUDES += -I ../libc
44 | INCLUDES += -I ../modules
45 | INCLUDES += -I ../platform
46 | PDIR := ../$(PDIR)
47 | sinclude $(PDIR)Makefile
48 |
49 |
--------------------------------------------------------------------------------
/app/include/lwip/app/espconn_tcp.h:
--------------------------------------------------------------------------------
1 | #ifndef __ESPCONN_TCP_H__
2 | #define __ESPCONN_TCP_H__
3 |
4 | #ifndef ESPCONN_TCP_DEBUG
5 | #define ESPCONN_TCP_DEBUG LWIP_DBG_OFF
6 | #endif
7 | #include "lwip/app/espconn.h"
8 |
9 | #ifndef ESPCONN_TCP_TIMER
10 | #define ESPCONN_TCP_TIMER 40
11 | #endif
12 |
13 | /******************************************************************************
14 | * FunctionName : espconn_tcp_disconnect
15 | * Description : A new incoming connection has been disconnected.
16 | * Parameters : espconn -- the espconn used to disconnect with host
17 | * Returns : none
18 | *******************************************************************************/
19 |
20 | extern void espconn_tcp_disconnect(espconn_msg *pdiscon);
21 |
22 | /******************************************************************************
23 | * FunctionName : espconn_tcp_client
24 | * Description : Initialize the client: set up a connect PCB and bind it to
25 | * the defined port
26 | * Parameters : espconn -- the espconn used to build client
27 | * Returns : none
28 | *******************************************************************************/
29 |
30 | extern sint8 espconn_tcp_client(struct espconn* espconn);
31 |
32 | /******************************************************************************
33 | * FunctionName : espconn_tcp_server
34 | * Description : Initialize the server: set up a listening PCB and bind it to
35 | * the defined port
36 | * Parameters : espconn -- the espconn used to build server
37 | * Returns : none
38 | *******************************************************************************/
39 |
40 | extern sint8 espconn_tcp_server(struct espconn *espconn);
41 |
42 | #endif /* __CLIENT_TCP_H__ */
43 |
44 |
--------------------------------------------------------------------------------
/include/osapi.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010 Espressif System
3 | */
4 |
5 | #ifndef _OSAPI_H_
6 | #define _OSAPI_H_
7 |
8 | #include
9 | #include "user_config.h"
10 |
11 | #define os_bzero ets_bzero
12 | #define os_delay_us ets_delay_us
13 | #define os_install_putc1 ets_install_putc1
14 | #define os_install_putc2 ets_install_putc2
15 | #define os_intr_lock ets_intr_lock
16 | #define os_intr_unlock ets_intr_unlock
17 | #define os_isr_attach ets_isr_attach
18 | #define os_isr_mask ets_isr_mask
19 | #define os_isr_unmask ets_isr_unmask
20 | #define os_memcmp ets_memcmp
21 | #define os_memcpy ets_memcpy
22 | #define os_memmove ets_memmove
23 | #define os_memset ets_memset
24 | #define os_putc ets_putc
25 | #define os_str2macaddr ets_str2macaddr
26 | #define os_strcat strcat
27 | #define os_strchr strchr
28 | #define os_strcmp ets_strcmp
29 | #define os_strcpy ets_strcpy
30 | #define os_strlen ets_strlen
31 | #define os_strncmp ets_strncmp
32 | #define os_strncpy ets_strncpy
33 | #define os_strstr ets_strstr
34 | #ifdef USE_US_TIMER
35 | #define os_timer_arm_us(a, b, c) ets_timer_arm_new(a, b, c, 0)
36 | #endif
37 | #define os_timer_arm(a, b, c) ets_timer_arm_new(a, b, c, 1)
38 | #define os_timer_disarm ets_timer_disarm
39 | #define os_timer_done ets_timer_done
40 | #define os_timer_handler_isr ets_timer_handler_isr
41 | #define os_timer_init ets_timer_init
42 | #define os_timer_setfn ets_timer_setfn
43 |
44 | #define os_sprintf ets_sprintf
45 | #define os_update_cpu_frequency ets_update_cpu_frequency
46 |
47 | #ifdef USE_OPTIMIZE_PRINTF
48 | #define os_printf(fmt, ...) do { \
49 | static const char flash_str[] ICACHE_RODATA_ATTR = fmt; \
50 | os_printf_plus(flash_str, ##__VA_ARGS__); \
51 | } while(0)
52 | #else
53 | #define os_printf os_printf_plus
54 | #endif
55 |
56 | #endif
57 |
58 |
--------------------------------------------------------------------------------
/app/include/user_config.h:
--------------------------------------------------------------------------------
1 | #ifndef __USER_CONFIG_H__
2 | #define __USER_CONFIG_H__
3 |
4 | // #define DEVKIT_VERSION_0_9 1 // define this only if you use NodeMCU devkit v0.9
5 |
6 | // #define FLASH_512K
7 | // #define FLASH_1M
8 | // #define FLASH_2M
9 | // #define FLASH_4M
10 | // #define FLASH_8M
11 | // #define FLASH_16M
12 | #define FLASH_AUTOSIZE
13 | #define FLASH_SAFE_API
14 | // #define DEVELOP_VERSION
15 | #define FULL_VERSION_FOR_USER
16 |
17 | #define USE_OPTIMIZE_PRINTF
18 |
19 | #ifdef DEVELOP_VERSION
20 | #define NODE_DEBUG
21 | #define COAP_DEBUG
22 | #endif /* DEVELOP_VERSION */
23 |
24 | #define NODE_ERROR
25 |
26 | #ifdef NODE_DEBUG
27 | #define NODE_DBG c_printf
28 | #else
29 | #define NODE_DBG
30 | #endif /* NODE_DEBUG */
31 |
32 | #ifdef NODE_ERROR
33 | #define NODE_ERR c_printf
34 | #else
35 | #define NODE_ERR
36 | #endif /* NODE_ERROR */
37 |
38 | #define ICACHE_STORE_TYPEDEF_ATTR __attribute__((aligned(4),packed))
39 | #define ICACHE_STORE_ATTR __attribute__((aligned(4)))
40 | #define ICACHE_RAM_ATTR __attribute__((section(".iram0.text")))
41 |
42 | #define CLIENT_SSL_ENABLE
43 | #define GPIO_INTERRUPT_ENABLE
44 |
45 | // #define BUILD_WOFS 1
46 | #define BUILD_SPIFFS 1
47 |
48 | // #define LUA_NUMBER_INTEGRAL
49 |
50 | #define LUA_OPTRAM
51 | #ifdef LUA_OPTRAM
52 | #define LUA_OPTIMIZE_MEMORY 2
53 | #else
54 | #define LUA_OPTIMIZE_MEMORY 0
55 | #endif /* LUA_OPTRAM */
56 |
57 | #define READLINE_INTERVAL 80
58 |
59 | #ifdef DEVKIT_VERSION_0_9
60 | #define KEY_SHORT_MS 200
61 | #define KEY_LONG_MS 3000
62 | #define KEY_SHORT_COUNT (KEY_SHORT_MS / READLINE_INTERVAL)
63 | #define KEY_LONG_COUNT (KEY_LONG_MS / READLINE_INTERVAL)
64 |
65 | #define LED_HIGH_COUNT_DEFAULT 10
66 | #define LED_LOW_COUNT_DEFAULT 0
67 | #endif
68 |
69 | #endif /* __USER_CONFIG_H__ */
70 |
--------------------------------------------------------------------------------
/app/user/Makefile:
--------------------------------------------------------------------------------
1 |
2 | #############################################################
3 | # Required variables for each makefile
4 | # Discard this section from all parent makefiles
5 | # Expected variables (with automatic defaults):
6 | # CSRCS (all "C" files in the dir)
7 | # SUBDIRS (all subdirs with a Makefile)
8 | # GEN_LIBS - list of libs to be generated ()
9 | # GEN_IMAGES - list of images to be generated ()
10 | # COMPONENTS_xxx - a list of libs/objs in the form
11 | # subdir/lib to be extracted and rolled up into
12 | # a generated lib/image xxx.a ()
13 | #
14 | ifndef PDIR
15 | GEN_LIBS = libuser.a
16 | endif
17 |
18 |
19 | #############################################################
20 | # Configuration i.e. compile options etc.
21 | # Target specific stuff (defines etc.) goes in here!
22 | # Generally values applying to a tree are captured in the
23 | # makefile at its root level - these are then overridden
24 | # for a subtree within the makefile rooted therein
25 | #
26 | #DEFINES +=
27 |
28 | #############################################################
29 | # Recursion Magic - Don't touch this!!
30 | #
31 | # Each subtree potentially has an include directory
32 | # corresponding to the common APIs applicable to modules
33 | # rooted at that subtree. Accordingly, the INCLUDE PATH
34 | # of a module can only contain the include directories up
35 | # its parent path, and not its siblings
36 | #
37 | # Required for each makefile to inherit from the parent
38 | #
39 |
40 | INCLUDES := $(INCLUDES) -I $(PDIR)include
41 | INCLUDES += -I ./
42 | INCLUDES += -I ../../include/ets
43 | INCLUDES += -I ../libc
44 | INCLUDES += -I ../platform
45 | INCLUDES += -I ../lua
46 | INCLUDES += -I ../wofs
47 | INCLUDES += -I ../spiffs
48 | PDIR := ../$(PDIR)
49 | sinclude $(PDIR)Makefile
50 |
51 |
--------------------------------------------------------------------------------
/app/lua/lundump.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** $Id: lundump.h,v 1.37.1.1 2007/12/27 13:02:25 roberto Exp $
3 | ** load precompiled Lua chunks
4 | ** See Copyright Notice in lua.h
5 | */
6 |
7 | #ifndef lundump_h
8 | #define lundump_h
9 |
10 | #include "c_stdint.h"
11 |
12 | #include "lobject.h"
13 | #include "lzio.h"
14 |
15 | typedef uint32_t strsize_t;
16 |
17 | /* info about target machine for cross-compilation */
18 | typedef struct {
19 | int little_endian;
20 | int sizeof_int;
21 | int sizeof_strsize_t;
22 | int sizeof_lua_Number;
23 | int lua_Number_integral;
24 | int is_arm_fpa;
25 | } DumpTargetInfo;
26 |
27 | /* load one chunk; from lundump.c */
28 | LUAI_FUNC Proto* luaU_undump (lua_State* L, ZIO* Z, Mbuffer* buff, const char* name);
29 |
30 | /* make header; from lundump.c */
31 | LUAI_FUNC void luaU_header (char* h);
32 |
33 | /* dump one chunk to a different target; from ldump.c */
34 | int luaU_dump_crosscompile (lua_State* L, const Proto* f, lua_Writer w, void* data, int strip, DumpTargetInfo target);
35 |
36 | /* dump one chunk; from ldump.c */
37 | LUAI_FUNC int luaU_dump (lua_State* L, const Proto* f, lua_Writer w, void* data, int strip);
38 |
39 | #ifdef luac_c
40 | /* print one chunk; from print.c */
41 | LUAI_FUNC void luaU_print (const Proto* f, int full);
42 | #endif
43 |
44 | /* for header of binary files -- this is Lua 5.1 */
45 | #define LUAC_VERSION 0x51
46 |
47 | /* for header of binary files -- this is the official format */
48 | #define LUAC_FORMAT 0
49 |
50 | /* size of header of binary files */
51 | #define LUAC_HEADERSIZE 12
52 |
53 | /* error codes from cross-compiler */
54 | /* target integer is too small to hold a value */
55 | #define LUA_ERR_CC_INTOVERFLOW 101
56 |
57 | /* target lua_Number is integral but a constant is non-integer */
58 | #define LUA_ERR_CC_NOTINTEGER 102
59 |
60 | #endif
61 |
--------------------------------------------------------------------------------
/app/lwip/Makefile:
--------------------------------------------------------------------------------
1 |
2 | #############################################################
3 | # Required variables for each makefile
4 | # Discard this section from all parent makefiles
5 | # Expected variables (with automatic defaults):
6 | # CSRCS (all "C" files in the dir)
7 | # SUBDIRS (all subdirs with a Makefile)
8 | # GEN_LIBS - list of libs to be generated ()
9 | # GEN_IMAGES - list of images to be generated ()
10 | # COMPONENTS_xxx - a list of libs/objs in the form
11 | # subdir/lib to be extracted and rolled up into
12 | # a generated lib/image xxx.a ()
13 | #
14 | ifndef PDIR
15 | UP_EXTRACT_DIR = ..
16 | GEN_LIBS = liblwip.a
17 | COMPONENTS_liblwip = api/liblwipapi.a \
18 | app/liblwipapp.a \
19 | core/liblwipcore.a \
20 | core/ipv4/liblwipipv4.a \
21 | netif/liblwipnetif.a
22 | endif
23 |
24 |
25 | #############################################################
26 | # Configuration i.e. compile options etc.
27 | # Target specific stuff (defines etc.) goes in here!
28 | # Generally values applying to a tree are captured in the
29 | # makefile at its root level - these are then overridden
30 | # for a subtree within the makefile rooted therein
31 | #
32 | #DEFINES +=
33 |
34 | #############################################################
35 | # Recursion Magic - Don't touch this!!
36 | #
37 | # Each subtree potentially has an include directory
38 | # corresponding to the common APIs applicable to modules
39 | # rooted at that subtree. Accordingly, the INCLUDE PATH
40 | # of a module can only contain the include directories up
41 | # its parent path, and not its siblings
42 | #
43 | # Required for each makefile to inherit from the parent
44 | #
45 |
46 | INCLUDES := $(INCLUDES) -I $(PDIR)include
47 | INCLUDES += -I ./
48 | PDIR := ../$(PDIR)
49 | sinclude $(PDIR)Makefile
50 |
51 |
--------------------------------------------------------------------------------
/lua_modules/bh1750/bh1750_Example2.lua:
--------------------------------------------------------------------------------
1 | -- ***************************************************************************
2 | -- BH1750 Example Program for ESP8266 with nodeMCU
3 | -- BH1750 compatible tested 2015-1-30
4 | --
5 | -- Written by xiaohu
6 | --
7 | -- MIT license, http://opensource.org/licenses/MIT
8 | -- ***************************************************************************
9 | --Updata to Lelian
10 |
11 | --Ps 需要改动的地方LW_GATEWAY(乐联的设备标示),USERKEY(乐联userkey)
12 | --Ps You nees to rewrite the LW_GATEWAY(Lelian's Device ID),USERKEY(Lelian's userkey)
13 |
14 | tmr.alarm(0, 60000, 1, function()
15 | SDA_PIN = 6 -- sda pin, GPIO12
16 | SCL_PIN = 5 -- scl pin, GPIO14
17 |
18 | BH1750 = require("BH1750")
19 | BH1750.init(SDA_PIN, SCL_PIN)
20 | BH1750.read(OSS)
21 | l = BH1750.getlux()
22 |
23 | --定义数据变量格式 Define the veriables formate
24 | PostData = "[{\"Name\":\"T\",\"Value\":\"" ..(l / 100).."."..(l % 100).."\"}]"
25 | --创建一个TCP连接 Create a TCP Connection
26 | socket=net.createConnection(net.TCP, 0)
27 | --域名解析IP地址并赋值 DNS...it
28 | socket:dns("www.lewei50.com", function(conn, ip)
29 | ServerIP = ip
30 | print("Connection IP:" .. ServerIP)
31 | end)
32 |
33 | --开始连接服务器 Connect the sever
34 | socket:connect(80, ServerIP)
35 | socket:on("connection", function(sck) end)
36 |
37 | --HTTP请求头定义 HTTP Head
38 | socket:send("POST /api/V1/gateway/UpdateSensors/LW_GATEWAY HTTP/1.1\r\n" ..
39 | "Host: www.lewei50.com\r\n" ..
40 | "Content-Length: " .. string.len(PostData) .. "\r\n" ..
41 | "userkey: USERKEY\r\n\r\n" ..
42 | PostData .. "\r\n")
43 |
44 | --HTTP响应内容 Print the HTTP response
45 | socket:on("receive", function(sck, response)
46 | print(response)
47 | end)
48 | end)
49 |
50 |
51 |
52 |
--------------------------------------------------------------------------------
/app/coap/node.h:
--------------------------------------------------------------------------------
1 | #ifndef _NODE_H
2 | #define _NODE_H 1
3 |
4 | #ifdef __cplusplus
5 | extern "C" {
6 | #endif
7 |
8 | #include "hash.h"
9 | #include "pdu.h"
10 |
11 | struct coap_queue_t;
12 | typedef uint32_t coap_tick_t;
13 |
14 | /*
15 | 1. queue(first)->t store when to send PDU for the next time, it's a base(absolute) time
16 | 2. queue->next->t store the delta between time and base-time. queue->next->t = timeout + now - basetime
17 | 3. node->next->t store the delta between time and previous->t. node->next->t = timeout + now - node->t - basetime
18 | 4. time to fire: 10, 15, 18, 25
19 | node->t: 10, 5, 3, 7
20 | */
21 |
22 | typedef struct coap_queue_t {
23 | struct coap_queue_t *next;
24 |
25 | coap_tick_t t; /**< when to send PDU for the next time */
26 | unsigned char retransmit_cnt; /**< retransmission counter, will be removed when zero */
27 | unsigned int timeout; /**< the randomized timeout value */
28 |
29 | coap_tid_t id; /**< unique transaction id */
30 |
31 | // coap_packet_t *pkt;
32 | coap_pdu_t *pdu; /**< the CoAP PDU to send */
33 | struct espconn *pconn;
34 | } coap_queue_t;
35 |
36 | void coap_free_node(coap_queue_t *node);
37 |
38 | /** Adds node to given queue, ordered by node->t. */
39 | int coap_insert_node(coap_queue_t **queue, coap_queue_t *node);
40 |
41 | /** Destroys specified node. */
42 | int coap_delete_node(coap_queue_t *node);
43 |
44 | /** Removes all items from given queue and frees the allocated storage. */
45 | void coap_delete_all(coap_queue_t *queue);
46 |
47 | /** Creates a new node suitable for adding to the CoAP sendqueue. */
48 | coap_queue_t *coap_new_node(void);
49 |
50 | coap_queue_t *coap_pop_next( coap_queue_t **queue );
51 |
52 | int coap_remove_node( coap_queue_t **queue, const coap_tid_t id);
53 |
54 | #ifdef __cplusplus
55 | }
56 | #endif
57 |
58 | #endif
59 |
--------------------------------------------------------------------------------
/lua_modules/bh1750/bh1750_CN.md:
--------------------------------------------------------------------------------
1 | # BH1750 模块
2 |
3 | ##引用
4 | ```lua
5 | bh1750 = require("bh1750")
6 | ```
7 | ## 释放
8 | ```lua
9 | bh1750 = nil
10 | package.loaded["bh1750"]=nil
11 | ```
12 |
13 | ##init()
14 | ####描述
15 | 设置BH1750所在的I2C引脚
16 |
17 | ####语法
18 | init(sda, scl)
19 |
20 | ####参数
21 | sda: 1~12, IO index.
22 | scl: 1~12, IO index.
23 |
24 | ####返回值
25 | nil
26 |
27 | ####示例
28 | ```lua
29 | SDA_PIN = 6 -- sda pin, GPIO12
30 | SCL_PIN = 5 -- scl pin, GPIO14
31 |
32 | bh1750 = require("bh1750")
33 | bh1750.init(SDA_PIN, SCL_PIN)
34 |
35 | -- release module
36 | bh1750 = nil
37 | package.loaded["bh1750"]=nil
38 | ```
39 |
40 | ####参见
41 | **-** []()
42 |
43 |
44 | ##read()
45 | ####描述
46 | 从bh1750中读取光线传感器数据(Lux勒克斯).
47 |
48 | ####语法
49 | read()
50 |
51 | ####参数
52 | nil.
53 |
54 | ####返回值
55 | nil.
56 |
57 | ####示例
58 | ```lua
59 | SDA_PIN = 6 -- sda pin, GPIO12
60 | SCL_PIN = 5 -- scl pin, GPIO14
61 |
62 | bh1750 = require("bh1750")
63 | bh1750.init(SDA_PIN, SCL_PIN)
64 | bh1750.read()
65 |
66 | -- release module
67 | bh1750 = nil
68 | package.loaded["bh1750"]=nil
69 | ```
70 |
71 | ####参见
72 | **-** []()
73 |
74 |
75 | ##getlux()
76 | ####描述
77 | 从BH1750中提取数据.
78 |
79 | ####语法
80 | getlux()
81 |
82 | ####参数
83 | nil.
84 |
85 | ####返回值
86 | l: 整数,Lux计数
87 | ####示例
88 | ```lua
89 | SDA_PIN = 6 -- sda pin, GPIO12
90 | SCL_PIN = 5 -- scl pin, GPIO14
91 |
92 | bh1750 = require("bh1750")
93 | bh1750.init(SDA_PIN, SCL_PIN)
94 | bh1750.read()
95 | l = bh1750.getlux()
96 | print("lux: "..(l / 100).."."..(l % 100).." lx")
97 |
98 | -- release module
99 | bh1750 = nil
100 | package.loaded["bh1750"]=nil
101 | ```
102 |
103 | ####参见
104 | **-** []()
105 |
--------------------------------------------------------------------------------
/app/modules/Makefile:
--------------------------------------------------------------------------------
1 |
2 | #############################################################
3 | # Required variables for each makefile
4 | # Discard this section from all parent makefiles
5 | # Expected variables (with automatic defaults):
6 | # CSRCS (all "C" files in the dir)
7 | # SUBDIRS (all subdirs with a Makefile)
8 | # GEN_LIBS - list of libs to be generated ()
9 | # GEN_IMAGES - list of images to be generated ()
10 | # COMPONENTS_xxx - a list of libs/objs in the form
11 | # subdir/lib to be extracted and rolled up into
12 | # a generated lib/image xxx.a ()
13 | #
14 | ifndef PDIR
15 | GEN_LIBS = libmodules.a
16 | endif
17 |
18 | #############################################################
19 | # Configuration i.e. compile options etc.
20 | # Target specific stuff (defines etc.) goes in here!
21 | # Generally values applying to a tree are captured in the
22 | # makefile at its root level - these are then overridden
23 | # for a subtree within the makefile rooted therein
24 | #
25 | #DEFINES +=
26 |
27 | #############################################################
28 | # Recursion Magic - Don't touch this!!
29 | #
30 | # Each subtree potentially has an include directory
31 | # corresponding to the common APIs applicable to modules
32 | # rooted at that subtree. Accordingly, the INCLUDE PATH
33 | # of a module can only contain the include directories up
34 | # its parent path, and not its siblings
35 | #
36 | # Required for each makefile to inherit from the parent
37 | #
38 |
39 | INCLUDES := $(INCLUDES) -I $(PDIR)include
40 | INCLUDES += -I ./
41 | INCLUDES += -I ../libc
42 | INCLUDES += -I ../coap
43 | INCLUDES += -I ../mqtt
44 | INCLUDES += -I ../u8glib
45 | INCLUDES += -I ../lua
46 | INCLUDES += -I ../platform
47 | INCLUDES += -I ../wofs
48 | INCLUDES += -I ../spiffs
49 | INCLUDES += -I ../smart
50 | INCLUDES += -I ../cjson
51 | PDIR := ../$(PDIR)
52 | sinclude $(PDIR)Makefile
53 |
54 |
--------------------------------------------------------------------------------
/app/lwip/core/ipv4/inet.c:
--------------------------------------------------------------------------------
1 | /**
2 | * @file
3 | * Functions common to all TCP/IPv4 modules, such as the byte order functions.
4 | *
5 | */
6 |
7 | /*
8 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
9 | * All rights reserved.
10 | *
11 | * Redistribution and use in source and binary forms, with or without modification,
12 | * are permitted provided that the following conditions are met:
13 | *
14 | * 1. Redistributions of source code must retain the above copyright notice,
15 | * this list of conditions and the following disclaimer.
16 | * 2. Redistributions in binary form must reproduce the above copyright notice,
17 | * this list of conditions and the following disclaimer in the documentation
18 | * and/or other materials provided with the distribution.
19 | * 3. The name of the author may not be used to endorse or promote products
20 | * derived from this software without specific prior written permission.
21 | *
22 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
23 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
24 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
25 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
26 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
27 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
30 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
31 | * OF SUCH DAMAGE.
32 | *
33 | * This file is part of the lwIP TCP/IP stack.
34 | *
35 | * Author: Adam Dunkels
36 | *
37 | */
38 |
39 | #include "lwip/opt.h"
40 |
41 | #include "lwip/inet.h"
42 |
43 |
--------------------------------------------------------------------------------
/app/include/arch/perf.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2001, Swedish Institute of Computer Science.
3 | * All rights reserved.
4 | *
5 | * Redistribution and use in source and binary forms, with or without
6 | * modification, are permitted provided that the following conditions
7 | * are met:
8 | * 1. Redistributions of source code must retain the above copyright
9 | * notice, this list of conditions and the following disclaimer.
10 | * 2. Redistributions in binary form must reproduce the above copyright
11 | * notice, this list of conditions and the following disclaimer in the
12 | * documentation and/or other materials provided with the distribution.
13 | * 3. Neither the name of the Institute nor the names of its contributors
14 | * may be used to endorse or promote products derived from this software
15 | * without specific prior written permission.
16 | *
17 | * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 | * SUCH DAMAGE.
28 | *
29 | * This file is part of the lwIP TCP/IP stack.
30 | *
31 | * Author: Adam Dunkels
32 | *
33 | */
34 | #ifndef __PERF_H__
35 | #define __PERF_H__
36 |
37 | #define PERF_START /* null definition */
38 | #define PERF_STOP(x) /* null definition */
39 |
40 | #endif /* __PERF_H__ */
41 |
--------------------------------------------------------------------------------
/app/include/ssl/app/espconn_secure.h:
--------------------------------------------------------------------------------
1 | #ifndef __ESPCONN_ENCRY_H__
2 | #define __ESPCONN_ENCRY_H__
3 |
4 | #include "espconn/espconn.h"
5 |
6 | /******************************************************************************
7 | * FunctionName : espconn_encry_connect
8 | * Description : The function given as connection
9 | * Parameters : espconn -- the espconn used to connect with the host
10 | * Returns : none
11 | *******************************************************************************/
12 |
13 | sint8 espconn_secure_connect(struct espconn *espconn);
14 |
15 | /******************************************************************************
16 | * FunctionName : espconn_encry_disconnect
17 | * Description : The function given as the disconnection
18 | * Parameters : espconn -- the espconn used to disconnect with the host
19 | * Returns : none
20 | *******************************************************************************/
21 |
22 | extern sint8 espconn_secure_disconnect(struct espconn *espconn);
23 |
24 | /******************************************************************************
25 | * FunctionName : espconn_encry_sent
26 | * Description : sent data for client or server
27 | * Parameters : espconn -- espconn to set for client or server
28 | * psent -- data to send
29 | * length -- length of data to send
30 | * Returns : none
31 | *******************************************************************************/
32 |
33 | extern sint8 espconn_secure_sent(struct espconn *espconn, uint8 *psent, uint16 length);
34 |
35 | /******************************************************************************
36 | * FunctionName : espconn_secure_accept
37 | * Description : The function given as the listen
38 | * Parameters : espconn -- the espconn used to listen the connection
39 | * Returns : none
40 | *******************************************************************************/
41 |
42 | extern sint8 espconn_secure_accept(struct espconn *espconn);
43 |
44 | #endif
45 |
46 |
47 |
--------------------------------------------------------------------------------
/lua_modules/bh1750/bh1750_EN.md:
--------------------------------------------------------------------------------
1 | # bh1750 Module
2 |
3 | ##Require
4 | ```lua
5 | bh1750 = require("bh1750")
6 | ```
7 | ## Release
8 | ```lua
9 | bh1750 = nil
10 | package.loaded["bh1750"]=nil
11 | ```
12 |
13 | ##init()
14 | ####Description
15 | Setting the I2C pin of bh1750.
16 |
17 | ####Syntax
18 | init(sda, scl)
19 |
20 | ####Parameters
21 | sda: 1~12, IO index.
22 | scl: 1~12, IO index.
23 |
24 | ####Returns
25 | nil
26 |
27 | ####Example
28 | ```lua
29 | SDA_PIN = 6 -- sda pin, GPIO12
30 | SCL_PIN = 5 -- scl pin, GPIO14
31 |
32 | bh1750 = require("bh1750")
33 | bh1750.init(SDA_PIN, SCL_PIN)
34 |
35 | -- release module
36 | bh1750 = nil
37 | package.loaded["bh1750"]=nil
38 | ```
39 |
40 | ####See also
41 | **-** []()
42 |
43 |
44 | ##read()
45 | ####Description
46 | Read Lux data from bh1750.
47 |
48 | ####Syntax
49 | read()
50 |
51 | ####Parameters
52 | nil.
53 |
54 | ####Returns
55 | nil.
56 |
57 | ####Example
58 | ```lua
59 | SDA_PIN = 6 -- sda pin, GPIO12
60 | SCL_PIN = 5 -- scl pin, GPIO14
61 |
62 | bh1750 = require("bh1750")
63 | bh1750.init(SDA_PIN, SCL_PIN)
64 | bh1750.read()
65 |
66 | -- release module
67 | bh1750 = nil
68 | package.loaded["bh1750"]=nil
69 | ```
70 |
71 | ####See also
72 | **-** []()
73 |
74 |
75 | ##getlux()
76 | ####Description
77 | Get lux from bh1750.
78 |
79 | ####Syntax
80 | getlux()
81 |
82 | ####Parameters
83 | nil.
84 |
85 | ####Returns
86 | l: Integer, getlux from bh1750.
87 |
88 | ####Example
89 | ```lua
90 | SDA_PIN = 6 -- sda pin, GPIO12
91 | SCL_PIN = 5 -- scl pin, GPIO14
92 |
93 | bh1750 = require("bh1750")
94 | bh1750.init(SDA_PIN, SCL_PIN)
95 | bh1750.read()
96 | l = bh1750.getlux()
97 | print("lux: "..(l / 100).."."..(l % 100).." lx")
98 |
99 | -- release module
100 | bh1750 = nil
101 | package.loaded["bh1750"]=nil
102 | ```
103 |
104 | ####See also
105 | **-** []()
106 |
--------------------------------------------------------------------------------
/app/lua/lzio.c:
--------------------------------------------------------------------------------
1 | /*
2 | ** $Id: lzio.c,v 1.31.1.1 2007/12/27 13:02:25 roberto Exp $
3 | ** a generic input stream interface
4 | ** See Copyright Notice in lua.h
5 | */
6 |
7 |
8 | #include "c_string.h"
9 |
10 | #define lzio_c
11 | #define LUA_CORE
12 |
13 | #include "lua.h"
14 |
15 | #include "llimits.h"
16 | #include "lmem.h"
17 | #include "lstate.h"
18 | #include "lzio.h"
19 |
20 |
21 | int luaZ_fill (ZIO *z) {
22 | size_t size;
23 | lua_State *L = z->L;
24 | const char *buff;
25 | lua_unlock(L);
26 | buff = z->reader(L, z->data, &size);
27 | lua_lock(L);
28 | if (buff == NULL || size == 0) return EOZ;
29 | z->n = size - 1;
30 | z->p = buff;
31 | return char2int(*(z->p++));
32 | }
33 |
34 |
35 | int luaZ_lookahead (ZIO *z) {
36 | if (z->n == 0) {
37 | if (luaZ_fill(z) == EOZ)
38 | return EOZ;
39 | else {
40 | z->n++; /* luaZ_fill removed first byte; put back it */
41 | z->p--;
42 | }
43 | }
44 | return char2int(*z->p);
45 | }
46 |
47 |
48 | void luaZ_init (lua_State *L, ZIO *z, lua_Reader reader, void *data) {
49 | z->L = L;
50 | z->reader = reader;
51 | z->data = data;
52 | z->n = z->i = 0;
53 | z->p = NULL;
54 | }
55 |
56 |
57 | /* --------------------------------------------------------------- read --- */
58 | size_t luaZ_read (ZIO *z, void *b, size_t n) {
59 | while (n) {
60 | size_t m;
61 | if (luaZ_lookahead(z) == EOZ)
62 | return n; /* return number of missing bytes */
63 | m = (n <= z->n) ? n : z->n; /* min. between n and z->n */
64 | if (b)
65 | c_memcpy(b, z->p, m);
66 | z->n -= m;
67 | z->i += m;
68 | z->p += m;
69 | if (b)
70 | b = (char *)b + m;
71 | n -= m;
72 | }
73 | return 0;
74 | }
75 |
76 | /* ------------------------------------------------------------------------ */
77 | char *luaZ_openspace (lua_State *L, Mbuffer *buff, size_t n) {
78 | if (n > buff->buffsize) {
79 | if (n < LUA_MINBUFFER) n = LUA_MINBUFFER;
80 | luaZ_resizebuffer(L, buff, n);
81 | }
82 | return buff->buffer;
83 | }
84 |
85 |
86 |
--------------------------------------------------------------------------------
/lua_examples/mcp23008/mcp23008_buttons.lua:
--------------------------------------------------------------------------------
1 | ---
2 | -- @description Shows how to read 8 GPIO pins/buttons via I2C with the MCP23008 I/O expander.
3 | -- Tested on NodeMCU 0.9.5 build 20150213.
4 | -- @circuit
5 | -- Connect GPIO0 of the ESP8266-01 module to the SCL pin of the MCP23008.
6 | -- Connect GPIO2 of the ESP8266-01 module to the SDA pin of the MCP23008.
7 | -- Use 3.3V for VCC.
8 | -- Connect switches or buttons to the GPIOs of the MCP23008 and GND.
9 | -- Connect two 4.7k pull-up resistors on SDA and SCL
10 | -- We will enable the internal pull up resistors for the GPIOS of the MCP23008.
11 | -- @author Miguel (AllAboutEE)
12 | -- GitHub: https://github.com/AllAboutEE
13 | -- YouTube: https://www.youtube.com/user/AllAboutEE
14 | -- Website: http://AllAboutEE.com
15 | ---------------------------------------------------------------------------------------------
16 |
17 | require ("mcp23008")
18 |
19 | -- ESP-01 GPIO Mapping as per GPIO Table in https://github.com/nodemcu/nodemcu-firmware
20 | gpio0, gpio2 = 3, 4
21 |
22 | -- Setup the MCP23008
23 | mcp23008.begin(0x0,gpio2,gpio0,i2c.SLOW)
24 |
25 | mcp23008.writeIODIR(0xff)
26 | mcp23008.writeGPPU(0xff)
27 |
28 | ---
29 | -- @name showButtons
30 | -- @description Shows the state of each GPIO pin
31 | -- @return void
32 | ---------------------------------------------------------
33 | function showButtons()
34 |
35 | local gpio = mcp23008.readGPIO() -- read the GPIO/buttons states
36 |
37 | -- get/extract the state of one pin at a time
38 | for pin=0,7 do
39 |
40 | local pinState = bit.band(bit.rshift(gpio,pin),0x1) -- extract one pin state
41 |
42 | -- change to string state (HIGH, LOW) instead of 1 or 0 respectively
43 | if(pinState == mcp23008.HIGH) then
44 | pinState = "HIGH"
45 | else
46 | pinState = "LOW"
47 | end
48 |
49 | print("Pin ".. pin .. ": ".. pinState)
50 | end
51 | print("\r\n")
52 | end
53 |
54 | tmr.alarm(0,2000,1,showButtons) -- run showButtons() every 2 seconds
55 |
56 |
57 |
58 |
--------------------------------------------------------------------------------
/app/mqtt/msg_queue.c:
--------------------------------------------------------------------------------
1 | #include "c_string.h"
2 | #include "c_stdlib.h"
3 | #include "c_stdio.h"
4 | #include "msg_queue.h"
5 |
6 | msg_queue_t *msg_enqueue(msg_queue_t **head, mqtt_message_t *msg, uint16_t msg_id, int msg_type, int publish_qos){
7 | if(!head){
8 | return NULL;
9 | }
10 | if (!msg || !msg->data || msg->length == 0){
11 | NODE_DBG("empty message\n");
12 | return NULL;
13 | }
14 | msg_queue_t *node = (msg_queue_t *)c_zalloc(sizeof(msg_queue_t));
15 | if(!node){
16 | NODE_DBG("not enough memory\n");
17 | return NULL;
18 | }
19 |
20 | node->msg.data = (uint8_t *)c_zalloc(msg->length);
21 | if(!node->msg.data){
22 | NODE_DBG("not enough memory\n");
23 | c_free(node);
24 | return NULL;
25 | }
26 | c_memcpy(node->msg.data, msg->data, msg->length);
27 | node->msg.length = msg->length;
28 | node->next = NULL;
29 | node->msg_id = msg_id;
30 | node->msg_type = msg_type;
31 | node->publish_qos = publish_qos;
32 |
33 | msg_queue_t *tail = *head;
34 | if(tail){
35 | while(tail->next!=NULL) tail = tail->next;
36 | tail->next = node;
37 | } else {
38 | *head = node;
39 | }
40 | return node;
41 | }
42 |
43 | void msg_destroy(msg_queue_t *node){
44 | if(!node) return;
45 | if(node->msg.data){
46 | c_free(node->msg.data);
47 | node->msg.data = NULL;
48 | }
49 | c_free(node);
50 | }
51 |
52 | msg_queue_t * msg_dequeue(msg_queue_t **head){
53 | if(!head || !*head){
54 | return NULL;
55 | }
56 | msg_queue_t *node = *head; // fetch head.
57 | *head = node->next; // update head.
58 | node->next = NULL;
59 | return node;
60 | }
61 |
62 | msg_queue_t * msg_peek(msg_queue_t **head){
63 | if(!head || !*head){
64 | return NULL;
65 | }
66 | return *head; // fetch head.
67 | }
68 |
69 | int msg_size(msg_queue_t **head){
70 | if(!head || !*head){
71 | return 0;
72 | }
73 | int i = 1;
74 | msg_queue_t *tail = *head;
75 | if(tail){
76 | while(tail->next!=NULL){
77 | tail = tail->next;
78 | i++;
79 | }
80 | }
81 | return i;
82 | }
83 |
--------------------------------------------------------------------------------
/app/lua/ldo.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** $Id: ldo.h,v 2.7.1.1 2007/12/27 13:02:25 roberto Exp $
3 | ** Stack and Call structure of Lua
4 | ** See Copyright Notice in lua.h
5 | */
6 |
7 | #ifndef ldo_h
8 | #define ldo_h
9 |
10 |
11 | #include "lobject.h"
12 | #include "lstate.h"
13 | #include "lzio.h"
14 |
15 |
16 | #define luaD_checkstack(L,n) \
17 | if ((char *)L->stack_last - (char *)L->top <= (n)*(int)sizeof(TValue)) \
18 | luaD_growstack(L, n); \
19 | else condhardstacktests(luaD_reallocstack(L, L->stacksize - EXTRA_STACK - 1));
20 |
21 |
22 | #define incr_top(L) {luaD_checkstack(L,1); L->top++;}
23 |
24 | #define savestack(L,p) ((char *)(p) - (char *)L->stack)
25 | #define restorestack(L,n) ((TValue *)((char *)L->stack + (n)))
26 |
27 | #define saveci(L,p) ((char *)(p) - (char *)L->base_ci)
28 | #define restoreci(L,n) ((CallInfo *)((char *)L->base_ci + (n)))
29 |
30 |
31 | /* results from luaD_precall */
32 | #define PCRLUA 0 /* initiated a call to a Lua function */
33 | #define PCRC 1 /* did a call to a C function */
34 | #define PCRYIELD 2 /* C funtion yielded */
35 |
36 |
37 | /* type of protected functions, to be ran by `runprotected' */
38 | typedef void (*Pfunc) (lua_State *L, void *ud);
39 |
40 | LUAI_FUNC int luaD_protectedparser (lua_State *L, ZIO *z, const char *name);
41 | LUAI_FUNC void luaD_callhook (lua_State *L, int event, int line);
42 | LUAI_FUNC int luaD_precall (lua_State *L, StkId func, int nresults);
43 | LUAI_FUNC void luaD_call (lua_State *L, StkId func, int nResults);
44 | LUAI_FUNC int luaD_pcall (lua_State *L, Pfunc func, void *u,
45 | ptrdiff_t oldtop, ptrdiff_t ef);
46 | LUAI_FUNC int luaD_poscall (lua_State *L, StkId firstResult);
47 | LUAI_FUNC void luaD_reallocCI (lua_State *L, int newsize);
48 | LUAI_FUNC void luaD_reallocstack (lua_State *L, int newsize);
49 | LUAI_FUNC void luaD_growstack (lua_State *L, int n);
50 |
51 | LUAI_FUNC void luaD_throw (lua_State *L, int errcode);
52 | LUAI_FUNC int luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud);
53 |
54 | LUAI_FUNC void luaD_seterrorobj (lua_State *L, int errcode, StkId oldtop);
55 |
56 | #endif
57 |
58 |
--------------------------------------------------------------------------------
/lua_examples/irsend.lua:
--------------------------------------------------------------------------------
1 | ------------------------------------------------------------------------------
2 | -- IR send module
3 | --
4 | -- LICENCE: http://opensource.org/licenses/MIT
5 | -- Vladimir Dronnikov
6 | --
7 | -- Example:
8 | -- dofile("irsend.lua").nec(4, 0x00ff00ff)
9 | ------------------------------------------------------------------------------
10 | local M
11 | do
12 | -- const
13 | local NEC_PULSE_US = 1000000 / 38000
14 | local NEC_HDR_MARK = 9000
15 | local NEC_HDR_SPACE = 4500
16 | local NEC_BIT_MARK = 560
17 | local NEC_ONE_SPACE = 1600
18 | local NEC_ZERO_SPACE = 560
19 | local NEC_RPT_SPACE = 2250
20 | -- cache
21 | local gpio, bit = gpio, bit
22 | local mode, write = gpio.mode, gpio.write
23 | local waitus = tmr.delay
24 | local isset = bit.isset
25 | -- NB: poorman 38kHz PWM with 1/3 duty. Touch with care! )
26 | local carrier = function(pin, c)
27 | c = c / NEC_PULSE_US
28 | while c > 0 do
29 | write(pin, 1)
30 | write(pin, 0)
31 | c = c + 0
32 | c = c + 0
33 | c = c + 0
34 | c = c + 0
35 | c = c + 0
36 | c = c + 0
37 | c = c * 1
38 | c = c * 1
39 | c = c * 1
40 | c = c - 1
41 | end
42 | end
43 | -- tsop signal simulator
44 | local pull = function(pin, c)
45 | write(pin, 0)
46 | waitus(c)
47 | write(pin, 1)
48 | end
49 | -- NB: tsop mode allows to directly connect pin
50 | -- inplace of TSOP input
51 | local nec = function(pin, code, tsop)
52 | local pulse = tsop and pull or carrier
53 | -- setup transmitter
54 | mode(pin, 1)
55 | write(pin, tsop and 1 or 0)
56 | -- header
57 | pulse(pin, NEC_HDR_MARK)
58 | waitus(NEC_HDR_SPACE)
59 | -- sequence, lsb first
60 | for i = 31, 0, -1 do
61 | pulse(pin, NEC_BIT_MARK)
62 | waitus(isset(code, i) and NEC_ONE_SPACE or NEC_ZERO_SPACE)
63 | end
64 | -- trailer
65 | pulse(pin, NEC_BIT_MARK)
66 | -- done transmitter
67 | --mode(pin, 0, tsop and 1 or 0)
68 | end
69 | -- expose
70 | M = {
71 | nec = nec,
72 | }
73 | end
74 | return M
75 |
--------------------------------------------------------------------------------
/app/u8glib/u8g_com_null.c:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | u8g_com_null.c
4 |
5 | communication null device
6 |
7 | Universal 8bit Graphics Library
8 |
9 | Copyright (c) 2011, olikraus@gmail.com
10 | All rights reserved.
11 |
12 | Redistribution and use in source and binary forms, with or without modification,
13 | are permitted provided that the following conditions are met:
14 |
15 | * Redistributions of source code must retain the above copyright notice, this list
16 | of conditions and the following disclaimer.
17 |
18 | * Redistributions in binary form must reproduce the above copyright notice, this
19 | list of conditions and the following disclaimer in the documentation and/or other
20 | materials provided with the distribution.
21 |
22 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
23 | CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
24 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
25 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
27 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
29 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
31 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
32 | STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
34 | ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 |
36 |
37 | */
38 |
39 | #include "u8g.h"
40 |
41 | uint8_t u8g_com_null_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr)
42 | {
43 | switch(msg)
44 | {
45 | case U8G_COM_MSG_INIT:
46 | break;
47 | case U8G_COM_MSG_STOP:
48 | break;
49 |
50 |
51 | case U8G_COM_MSG_CHIP_SELECT:
52 | /* arg_val contains the chip number, which should be enabled */
53 | break;
54 |
55 |
56 | case U8G_COM_MSG_WRITE_BYTE:
57 | break;
58 | case U8G_COM_MSG_WRITE_SEQ:
59 | break;
60 | }
61 | return 1;
62 | }
63 |
64 |
--------------------------------------------------------------------------------
/app/include/ssl/private_key.h:
--------------------------------------------------------------------------------
1 | unsigned char default_private_key[] = {
2 | 0x30, 0x82, 0x01, 0x3a, 0x02, 0x01, 0x00, 0x02, 0x41, 0x00, 0xb9, 0x83,
3 | 0x30, 0xca, 0xfb, 0xec, 0x11, 0x9e, 0x94, 0xb7, 0x89, 0xf2, 0x84, 0x2c,
4 | 0xda, 0xe1, 0x9a, 0x53, 0x3a, 0x1b, 0x6e, 0xc9, 0x85, 0x81, 0xf9, 0xa3,
5 | 0x41, 0xdb, 0xe2, 0x82, 0x3b, 0xfa, 0x80, 0x22, 0x3b, 0x81, 0x6d, 0x25,
6 | 0x73, 0x7e, 0xf6, 0x49, 0xcc, 0x69, 0x3c, 0x6c, 0xd8, 0x05, 0xfb, 0x92,
7 | 0x02, 0xcf, 0x19, 0x2a, 0x10, 0x7d, 0x69, 0x7a, 0xd8, 0x9d, 0xd3, 0xcf,
8 | 0x6c, 0xef, 0x02, 0x03, 0x01, 0x00, 0x01, 0x02, 0x40, 0x1d, 0x13, 0x92,
9 | 0xf2, 0x3d, 0xca, 0x22, 0x78, 0xd8, 0x96, 0x6b, 0xe8, 0xb7, 0x0e, 0xd0,
10 | 0xbf, 0xcb, 0x90, 0x7f, 0xeb, 0x0c, 0xd2, 0x49, 0x3a, 0xb6, 0x06, 0x00,
11 | 0xac, 0x96, 0x34, 0x13, 0x72, 0x4b, 0x8c, 0xd2, 0xb9, 0x35, 0xf5, 0x64,
12 | 0x18, 0xb2, 0x47, 0x5b, 0x9f, 0xbb, 0xf2, 0x5b, 0x2f, 0x66, 0x78, 0x2d,
13 | 0x0a, 0x76, 0x44, 0xc5, 0x4f, 0xdb, 0x7d, 0x13, 0xcf, 0xa5, 0x08, 0xdc,
14 | 0x01, 0x02, 0x21, 0x00, 0xdf, 0x9a, 0x89, 0xd0, 0xef, 0x23, 0xcf, 0x12,
15 | 0xac, 0x8a, 0x63, 0x1a, 0x8c, 0xc0, 0x3f, 0xf4, 0x38, 0x52, 0x3c, 0x9f,
16 | 0x19, 0x0a, 0x37, 0xd2, 0xcb, 0x5d, 0xeb, 0xb6, 0x2a, 0x33, 0xb0, 0x91,
17 | 0x02, 0x21, 0x00, 0xd4, 0x63, 0xd9, 0x6a, 0x18, 0x5b, 0xe8, 0xa8, 0x57,
18 | 0x4d, 0xd1, 0x9a, 0xa8, 0xd7, 0xe1, 0x65, 0x75, 0xb3, 0xb9, 0x5c, 0x94,
19 | 0x14, 0xca, 0x98, 0x41, 0x47, 0x9c, 0x0a, 0x22, 0x38, 0x05, 0x7f, 0x02,
20 | 0x20, 0x6a, 0xce, 0xfd, 0xef, 0xe0, 0x9b, 0x61, 0x49, 0x91, 0x43, 0x95,
21 | 0x6d, 0x54, 0x38, 0x6d, 0x14, 0x32, 0x67, 0x0d, 0xf0, 0x0d, 0x5c, 0xf5,
22 | 0x27, 0x6a, 0xdf, 0x55, 0x3d, 0xb1, 0xd0, 0xf9, 0x11, 0x02, 0x21, 0x00,
23 | 0xba, 0x94, 0xa0, 0xf9, 0xb0, 0x3e, 0x85, 0x8b, 0xe5, 0x6e, 0x4a, 0x95,
24 | 0x88, 0x80, 0x65, 0xd5, 0x00, 0xea, 0x8b, 0x0b, 0x46, 0x57, 0x61, 0x87,
25 | 0x11, 0xc9, 0xfb, 0xcd, 0x77, 0x34, 0x29, 0xb7, 0x02, 0x20, 0x06, 0x8d,
26 | 0x41, 0x11, 0x47, 0x93, 0xcb, 0xad, 0xda, 0x5d, 0xe1, 0x9d, 0x49, 0x8d,
27 | 0xe0, 0xab, 0x48, 0xe6, 0x18, 0x28, 0x4a, 0x94, 0xae, 0xf9, 0xad, 0xc5,
28 | 0x5b, 0x0b, 0x15, 0xc6, 0x73, 0x17
29 | };
30 | unsigned int default_private_key_len = 318;
31 |
--------------------------------------------------------------------------------
/app/coap/coap_client.c:
--------------------------------------------------------------------------------
1 | #include "user_config.h"
2 | #include "c_types.h"
3 |
4 | #include "coap.h"
5 | #include "hash.h"
6 | #include "node.h"
7 |
8 | extern coap_queue_t *gQueue;
9 |
10 | void coap_client_response_handler(char *data, unsigned short len, unsigned short size, const uint32_t ip, const uint32_t port)
11 | {
12 | NODE_DBG("coap_client_response_handler is called.\n");
13 | coap_packet_t pkt;
14 | pkt.content.p = NULL;
15 | pkt.content.len = 0;
16 | int rc;
17 |
18 | if (0 != (rc = coap_parse(&pkt, data, len))){
19 | NODE_DBG("Bad packet rc=%d\n", rc);
20 | }
21 | else
22 | {
23 | #ifdef COAP_DEBUG
24 | coap_dumpPacket(&pkt);
25 | #endif
26 | /* check if this is a response to our original request */
27 | if (!check_token(&pkt)) {
28 | /* drop if this was just some message, or send RST in case of notification */
29 | if (pkt.hdr.t == COAP_TYPE_CON || pkt.hdr.t == COAP_TYPE_NONCON){
30 | // coap_send_rst(pkt); // send RST response
31 | // or, just ignore it.
32 | }
33 | goto end;
34 | }
35 |
36 | if (pkt.hdr.t == COAP_TYPE_RESET) {
37 | NODE_DBG("got RST\n");
38 | goto end;
39 | }
40 |
41 | coap_tid_t id = COAP_INVALID_TID;
42 | coap_transaction_id(ip, port, &pkt, &id);
43 | /* transaction done, remove the node from queue */
44 | // stop timer
45 | coap_timer_stop();
46 | // remove the node
47 | coap_remove_node(&gQueue, id);
48 | // calculate time elapsed
49 | coap_timer_update(&gQueue);
50 | coap_timer_start(&gQueue);
51 |
52 | if (COAP_RESPONSE_CLASS(pkt.hdr.code) == 2)
53 | {
54 | /* There is no block option set, just read the data and we are done. */
55 | NODE_DBG("%d.%02d\t", (pkt.hdr.code >> 5), pkt.hdr.code & 0x1F);
56 | NODE_DBG((char *)(pkt.payload.p));
57 | }
58 | else if (COAP_RESPONSE_CLASS(pkt.hdr.code) >= 4)
59 | {
60 | NODE_DBG("%d.%02d\t", (pkt.hdr.code >> 5), pkt.hdr.code & 0x1F);
61 | NODE_DBG((char *)(pkt.payload.p));
62 | }
63 | }
64 |
65 | end:
66 | if(!gQueue){ // if there is no node pending in the queue, disconnect from host.
67 |
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/app/include/lwip/app/espconn_udp.h:
--------------------------------------------------------------------------------
1 | #ifndef __ESPCONN_UDP_H__
2 | #define __ESPCONN_UDP_H__
3 |
4 | #ifndef ESPCONN_UDP_DEBUG
5 | #define ESPCONN_UDP_DEBUG LWIP_DBG_OFF
6 | #endif
7 |
8 | #include "lwip/app/espconn.h"
9 |
10 | /******************************************************************************
11 | * FunctionName : espconn_udp_client
12 | * Description : Initialize the client: set up a PCB and bind it to the port
13 | * Parameters : pespconn -- the espconn used to build client
14 | * Returns : none
15 | *******************************************************************************/
16 |
17 | extern sint8 espconn_udp_client(struct espconn *pespconn);
18 |
19 | /******************************************************************************
20 | * FunctionName : espconn_udp_disconnect
21 | * Description : A new incoming connection has been disconnected.
22 | * Parameters : espconn -- the espconn used to disconnect with host
23 | * Returns : none
24 | *******************************************************************************/
25 |
26 | extern void espconn_udp_disconnect(espconn_msg *pdiscon);
27 |
28 | /******************************************************************************
29 | * FunctionName : espconn_udp_server
30 | * Description : Initialize the server: set up a PCB and bind it to the port
31 | * Parameters : pespconn -- the espconn used to build server
32 | * Returns : none
33 | *******************************************************************************/
34 |
35 | extern sint8 espconn_udp_server(struct espconn *espconn);
36 |
37 | /******************************************************************************
38 | * FunctionName : espconn_udp_sent
39 | * Description : sent data for client or server
40 | * Parameters : void *arg -- client or server to send
41 | * uint8* psent -- Data to send
42 | * uint16 length -- Length of data to send
43 | * Returns : none
44 | *******************************************************************************/
45 |
46 | extern void espconn_udp_sent(void *arg, uint8 *psent, uint16 length);
47 |
48 |
49 | #endif /* __ESPCONN_UDP_H__ */
50 |
51 |
52 |
--------------------------------------------------------------------------------
/app/u8glib/u8g_u16toa.c:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | u8g_u16toa.c
4 |
5 |
6 | Universal 8bit Graphics Library
7 |
8 | Copyright (c) 2012, olikraus@gmail.com
9 | All rights reserved.
10 |
11 | Redistribution and use in source and binary forms, with or without modification,
12 | are permitted provided that the following conditions are met:
13 |
14 | * Redistributions of source code must retain the above copyright notice, this list
15 | of conditions and the following disclaimer.
16 |
17 | * Redistributions in binary form must reproduce the above copyright notice, this
18 | list of conditions and the following disclaimer in the documentation and/or other
19 | materials provided with the distribution.
20 |
21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
22 | CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
23 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
24 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
25 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
26 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
28 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
30 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
31 | STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
33 | ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 |
35 | */
36 |
37 |
38 | #include "u8g.h"
39 |
40 | const char *u8g_u16toap(char * dest, uint16_t v)
41 | {
42 | uint8_t pos;
43 | uint8_t d;
44 | uint16_t c;
45 | c = 10000;
46 | for( pos = 0; pos < 5; pos++ )
47 | {
48 | d = '0';
49 | while( v >= c )
50 | {
51 | v -= c;
52 | d++;
53 | }
54 | dest[pos] = d;
55 | c /= 10;
56 | }
57 | dest[5] = '\0';
58 | return dest;
59 | }
60 |
61 | /* v = value, d = number of digits */
62 | const char *u8g_u16toa(uint16_t v, uint8_t d)
63 | {
64 | static char buf[6];
65 | d = 5-d;
66 | return u8g_u16toap(buf, v) + d;
67 | }
68 |
69 |
--------------------------------------------------------------------------------
/app/platform/flash_fs.h:
--------------------------------------------------------------------------------
1 |
2 | #ifndef __FLASH_FS_H__
3 | #define __FLASH_FS_H__
4 |
5 | #include "user_config.h"
6 |
7 | #if defined( BUILD_WOFS )
8 | #include "romfs.h"
9 |
10 | #define FS_OPEN_OK 0
11 |
12 | #define FS_RDONLY O_RDONLY
13 | #define FS_WRONLY O_WRONLY
14 | #define FS_RDWR O_RDWR
15 | #define FS_APPEND O_APPEND
16 | #define FS_TRUNC O_TRUNC
17 | #define FS_CREAT O_CREAT
18 | #define FS_EXCL O_EXCL
19 |
20 | #define FS_SEEK_SET SEEK_SET
21 | #define FS_SEEK_CUR SEEK_CUR
22 | #define FS_SEEK_END SEEK_END
23 |
24 | #define fs_open wofs_open
25 | #define fs_close wofs_close
26 | #define fs_write wofs_write
27 | #define fs_read wofs_read
28 | #define fs_seek wofs_lseek
29 | #define fs_eof wofs_eof
30 | #define fs_getc wofs_getc
31 | #define fs_ungetc wofs_ungetc
32 |
33 | #define fs_format wofs_format
34 | #define fs_next wofs_next
35 |
36 | #define FS_NAME_MAX_LENGTH MAX_FNAME_LENGTH
37 |
38 | #elif defined( BUILD_SPIFFS )
39 |
40 | #include "spiffs.h"
41 |
42 | #define FS_OPEN_OK 1
43 |
44 | #define FS_RDONLY SPIFFS_RDONLY
45 | #define FS_WRONLY SPIFFS_WRONLY
46 | #define FS_RDWR SPIFFS_RDWR
47 | #define FS_APPEND SPIFFS_APPEND
48 | #define FS_TRUNC SPIFFS_TRUNC
49 | #define FS_CREAT SPIFFS_CREAT
50 | #define FS_EXCL SPIFFS_EXCL
51 |
52 | #define FS_SEEK_SET SPIFFS_SEEK_SET
53 | #define FS_SEEK_CUR SPIFFS_SEEK_CUR
54 | #define FS_SEEK_END SPIFFS_SEEK_END
55 |
56 | #define fs_open myspiffs_open
57 | #define fs_close myspiffs_close
58 | #define fs_write myspiffs_write
59 | #define fs_read myspiffs_read
60 | #define fs_seek myspiffs_lseek
61 | #define fs_eof myspiffs_eof
62 | #define fs_getc myspiffs_getc
63 | #define fs_ungetc myspiffs_ungetc
64 | #define fs_flush myspiffs_flush
65 | #define fs_error myspiffs_error
66 | #define fs_clearerr myspiffs_clearerr
67 | #define fs_tell myspiffs_tell
68 |
69 | #define fs_format myspiffs_format
70 | #define fs_check myspiffs_check
71 | #define fs_rename myspiffs_rename
72 | #define fs_size myspiffs_size
73 |
74 | #define fs_mount myspiffs_mount
75 | #define fs_unmount myspiffs_unmount
76 |
77 | #define FS_NAME_MAX_LENGTH SPIFFS_OBJ_NAME_LEN
78 |
79 | #endif
80 |
81 | int fs_mode2flag(const char *mode);
82 |
83 | #endif // #ifndef __FLASH_FS_H__
84 |
--------------------------------------------------------------------------------
/lua_modules/ds3231/ds3231.lua:
--------------------------------------------------------------------------------
1 | --------------------------------------------------------------------------------
2 | -- DS3231 I2C module for NODEMCU
3 | -- NODEMCU TEAM
4 | -- LICENCE: http://opensource.org/licenses/MIT
5 | -- Tobie Booth
6 | --------------------------------------------------------------------------------
7 |
8 | local moduleName = ...
9 | local M = {}
10 | _G[moduleName] = M
11 |
12 | -- Default value for i2c communication
13 | local id = 0
14 |
15 | --device address
16 | local dev_addr = 0x68
17 |
18 | local function decToBcd(val)
19 | return((val/10*16) + (val%10))
20 | end
21 |
22 | local function bcdToDec(val)
23 | return((val/16*10) + (val%16))
24 | end
25 |
26 | -- initialize i2c
27 | --parameters:
28 | --d: sda
29 | --l: scl
30 | function M.init(d, l)
31 | if (d ~= nil) and (l ~= nil) and (d >= 0) and (d <= 11) and (l >= 0) and ( l <= 11) and (d ~= l) then
32 | sda = d
33 | scl = l
34 | else
35 | print("iic config failed!") return nil
36 | end
37 | print("init done")
38 | i2c.setup(id, sda, scl, i2c.SLOW)
39 | end
40 |
41 | --get time from DS3231
42 | function M.getTime()
43 | i2c.start(id)
44 | i2c.address(id, dev_addr, i2c.TRANSMITTER)
45 | i2c.write(id, 0x00)
46 | i2c.stop(id)
47 | i2c.start(id)
48 | i2c.address(id, dev_addr, i2c.RECEIVER)
49 | local c=i2c.read(id, 7)
50 | i2c.stop(id)
51 | return bcdToDec(tonumber(string.byte(c, 1))),
52 | bcdToDec(tonumber(string.byte(c, 2))),
53 | bcdToDec(tonumber(string.byte(c, 3))),
54 | bcdToDec(tonumber(string.byte(c, 4))),
55 | bcdToDec(tonumber(string.byte(c, 5))),
56 | bcdToDec(tonumber(string.byte(c, 6))),
57 | bcdToDec(tonumber(string.byte(c, 7)))
58 | end
59 |
60 | --set time for DS3231
61 | function M.setTime(second, minute, hour, day, date, month, year)
62 | i2c.start(id)
63 | i2c.address(id, dev_addr, i2c.TRANSMITTER)
64 | i2c.write(id, 0x00)
65 | i2c.write(id, decToBcd(second))
66 | i2c.write(id, decToBcd(minute))
67 | i2c.write(id, decToBcd(hour))
68 | i2c.write(id, decToBcd(day))
69 | i2c.write(id, decToBcd(date))
70 | i2c.write(id, decToBcd(month))
71 | i2c.write(id, decToBcd(year))
72 | i2c.stop(id)
73 | end
74 |
75 | return M
76 |
--------------------------------------------------------------------------------
/app/include/lwip/app/ping.h:
--------------------------------------------------------------------------------
1 | #ifndef __PING_H__
2 | #define __PING_H__
3 | #include "lwip/ip_addr.h"
4 | #include "lwip/icmp.h"
5 | /**
6 | * PING_USE_SOCKETS: Set to 1 to use sockets, otherwise the raw api is used
7 | */
8 | #ifndef PING_USE_SOCKETS
9 | #define PING_USE_SOCKETS LWIP_SOCKET
10 | #endif
11 |
12 | /**
13 | * PING_DEBUG: Enable debugging for PING.
14 | */
15 | #ifndef PING_DEBUG
16 | #define PING_DEBUG LWIP_DBG_OFF
17 | #endif
18 |
19 | /** ping receive timeout - in milliseconds */
20 | #ifndef PING_RCV_TIMEO
21 | #define PING_RCV_TIMEO 1000
22 | #endif
23 |
24 | /** ping delay - in milliseconds */
25 | #ifndef PING_COARSE
26 | #define PING_COARSE 1000
27 | #endif
28 |
29 | /** ping identifier - must fit on a u16_t */
30 | #ifndef PING_ID
31 | #define PING_ID 0xAFAF
32 | #endif
33 |
34 | /** ping additional data size to include in the packet */
35 | #ifndef PING_DATA_SIZE
36 | #define PING_DATA_SIZE 32
37 | #endif
38 |
39 | /** ping result action - no default action */
40 | #ifndef PING_RESULT
41 | #define PING_RESULT(ping_ok)
42 | #endif
43 |
44 | #define DEFAULT_PING_MAX_COUNT 4
45 | #define PING_TIMEOUT_MS 1000
46 |
47 | typedef void (* ping_recv_function)(void* arg, void *pdata);
48 | typedef void (* ping_sent_function)(void* arg, void *pdata);
49 |
50 | struct ping_option{
51 | uint32 count;
52 | uint32 ip;
53 | uint32 coarse_time;
54 | ping_recv_function recv_function;
55 | ping_sent_function sent_function;
56 | void* reverse;
57 | };
58 |
59 | struct ping_msg{
60 | struct ping_option *ping_opt;
61 | struct raw_pcb *ping_pcb;
62 | uint32 ping_start;
63 | uint32 ping_sent;
64 | uint32 timeout_count;
65 | uint32 max_count;
66 | uint32 sent_count;
67 | uint32 coarse_time;
68 | };
69 |
70 | struct ping_resp{
71 | uint32 total_count;
72 | uint32 resp_time;
73 | uint32 seqno;
74 | uint32 timeout_count;
75 | uint32 bytes;
76 | uint32 total_bytes;
77 | uint32 total_time;
78 | sint8 ping_err;
79 | };
80 |
81 | bool ping_start(struct ping_option *ping_opt);
82 | bool ping_regist_recv(struct ping_option *ping_opt, ping_recv_function ping_recv);
83 | bool ping_regist_sent(struct ping_option *ping_opt, ping_sent_function ping_sent);
84 |
85 | #endif /* __PING_H__ */
86 |
--------------------------------------------------------------------------------
/app/lua/lzio.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** $Id: lzio.h,v 1.21.1.1 2007/12/27 13:02:25 roberto Exp $
3 | ** Buffered streams
4 | ** See Copyright Notice in lua.h
5 | */
6 |
7 |
8 | #ifndef lzio_h
9 | #define lzio_h
10 |
11 | #include "lua.h"
12 |
13 | #include "lmem.h"
14 |
15 |
16 | #define EOZ (-1) /* end of stream */
17 |
18 | typedef struct Zio ZIO;
19 |
20 | #define char2int(c) cast(int, cast(unsigned char, (c)))
21 |
22 | #define zgetc(z) (((z)->n--)>0 ? char2int(*(z)->p++) : luaZ_fill(z))
23 |
24 | typedef struct Mbuffer {
25 | char *buffer;
26 | size_t n;
27 | size_t buffsize;
28 | } Mbuffer;
29 |
30 | #define luaZ_initbuffer(L, buff) ((buff)->buffer = NULL, (buff)->n = 0, (buff)->buffsize = 0)
31 |
32 | #define luaZ_buffer(buff) ((buff)->buffer)
33 | #define luaZ_sizebuffer(buff) ((buff)->buffsize)
34 | #define luaZ_bufflen(buff) ((buff)->n)
35 |
36 | #define luaZ_resetbuffer(buff) ((buff)->n = 0)
37 |
38 |
39 | #define luaZ_resizebuffer(L, buff, size) \
40 | (luaM_reallocvector(L, (buff)->buffer, (buff)->buffsize, size, char), \
41 | (buff)->buffsize = size)
42 |
43 | #define luaZ_freebuffer(L, buff) luaZ_resizebuffer(L, buff, 0)
44 |
45 | #define luaZ_freebuffer(L, buff) luaZ_resizebuffer(L, buff, 0)
46 | #define luaZ_get_base_address(zio) ((const char *)((zio)->reader(NULL, (zio)->data, NULL)))
47 | #define luaZ_direct_mode(zio) (luaZ_get_base_address(zio) != NULL)
48 | #define luaZ_get_crt_address(zio) (luaZ_get_base_address(zio) + (zio)->i)
49 |
50 | LUAI_FUNC char *luaZ_openspace (lua_State *L, Mbuffer *buff, size_t n);
51 | LUAI_FUNC void luaZ_init (lua_State *L, ZIO *z, lua_Reader reader,
52 | void *data);
53 | LUAI_FUNC size_t luaZ_read (ZIO* z, void* b, size_t n); /* read next n bytes */
54 | LUAI_FUNC int luaZ_lookahead (ZIO *z);
55 |
56 |
57 |
58 | /* --------- Private Part ------------------ */
59 |
60 | struct Zio {
61 | size_t n; /* bytes still unread */
62 | size_t i; /* buffer offset */
63 | const char *p; /* current position in buffer */
64 | lua_Reader reader;
65 | void* data; /* additional data */
66 | lua_State *L; /* Lua state (for reader) */
67 | };
68 |
69 |
70 | LUAI_FUNC int luaZ_fill (ZIO *z);
71 |
72 | #endif
73 |
--------------------------------------------------------------------------------
/app/cjson/dtoa_config.h:
--------------------------------------------------------------------------------
1 | #ifndef _DTOA_CONFIG_H
2 | #define _DTOA_CONFIG_H
3 | #if 0
4 | #include
5 | #include
6 | #include
7 |
8 | /* Ensure dtoa.c does not USE_LOCALE. Lua CJSON must not use locale
9 | * aware conversion routines. */
10 | #undef USE_LOCALE
11 |
12 | /* dtoa.c should not touch errno, Lua CJSON does not use it, and it
13 | * may not be threadsafe */
14 | #define NO_ERRNO
15 |
16 | #define Long int32_t
17 | #define ULong uint32_t
18 | #define Llong int64_t
19 | #define ULLong uint64_t
20 |
21 | #ifdef IEEE_BIG_ENDIAN
22 | #define IEEE_MC68k
23 | #else
24 | #define IEEE_8087
25 | #endif
26 |
27 | #define MALLOC(n) xmalloc(n)
28 |
29 | static void *xmalloc(size_t size)
30 | {
31 | void *p;
32 |
33 | p = malloc(size);
34 | if (!p) {
35 | fprintf(stderr, "Out of memory");
36 | abort();
37 | }
38 |
39 | return p;
40 | }
41 |
42 | #ifdef MULTIPLE_THREADS
43 |
44 | /* Enable locking to support multi-threaded applications */
45 |
46 | #include
47 |
48 | static pthread_mutex_t private_dtoa_lock[2] = {
49 | PTHREAD_MUTEX_INITIALIZER,
50 | PTHREAD_MUTEX_INITIALIZER
51 | };
52 |
53 | #define ACQUIRE_DTOA_LOCK(n) do { \
54 | int r = pthread_mutex_lock(&private_dtoa_lock[n]); \
55 | if (r) { \
56 | fprintf(stderr, "pthread_mutex_lock failed with %d\n", r); \
57 | abort(); \
58 | } \
59 | } while (0)
60 |
61 | #define FREE_DTOA_LOCK(n) do { \
62 | int r = pthread_mutex_unlock(&private_dtoa_lock[n]); \
63 | if (r) { \
64 | fprintf(stderr, "pthread_mutex_unlock failed with %d\n", r);\
65 | abort(); \
66 | } \
67 | } while (0)
68 |
69 | #endif /* MULTIPLE_THREADS */
70 | #endif
71 | #endif /* _DTOA_CONFIG_H */
72 |
73 | /* vi:ai et sw=4 ts=4:
74 | */
75 |
--------------------------------------------------------------------------------
/app/u8glib/u8g_u8toa.c:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | u8g_u8toa.c
4 |
5 |
6 | Universal 8bit Graphics Library
7 |
8 | Copyright (c) 2011, olikraus@gmail.com
9 | All rights reserved.
10 |
11 | Redistribution and use in source and binary forms, with or without modification,
12 | are permitted provided that the following conditions are met:
13 |
14 | * Redistributions of source code must retain the above copyright notice, this list
15 | of conditions and the following disclaimer.
16 |
17 | * Redistributions in binary form must reproduce the above copyright notice, this
18 | list of conditions and the following disclaimer in the documentation and/or other
19 | materials provided with the distribution.
20 |
21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
22 | CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
23 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
24 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
25 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
26 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
28 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
30 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
31 | STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
33 | ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 |
35 | */
36 |
37 |
38 | #include "u8g.h"
39 |
40 | static const unsigned char u8g_u8toa_tab[3] = { 100, 10, 1 } ;
41 | const char *u8g_u8toap(char * dest, uint8_t v)
42 | {
43 | uint8_t pos;
44 | uint8_t d;
45 | uint8_t c;
46 | for( pos = 0; pos < 3; pos++ )
47 | {
48 | d = '0';
49 | c = *(u8g_u8toa_tab+pos);
50 | while( v >= c )
51 | {
52 | v -= c;
53 | d++;
54 | }
55 | dest[pos] = d;
56 | }
57 | dest[3] = '\0';
58 | return dest;
59 | }
60 |
61 | /* v = value, d = number of digits */
62 | const char *u8g_u8toa(uint8_t v, uint8_t d)
63 | {
64 | static char buf[4];
65 | d = 3-d;
66 | return u8g_u8toap(buf, v) + d;
67 | }
68 |
69 |
--------------------------------------------------------------------------------