├── .gdbinit ├── .gdbinitlua ├── .github ├── ISSUE_TEMPLATE.md └── PULL_REQUEST_TEMPLATE.md ├── .gitignore ├── .gitmodules ├── .travis.yml ├── CONTRIBUTING.md ├── LICENSE ├── Makefile ├── README.md ├── app ├── .gitignore ├── Makefile ├── coap │ ├── LICENSE.txt │ ├── Makefile │ ├── coap.c │ ├── coap.h │ ├── coap_client.c │ ├── coap_client.h │ ├── coap_io.c │ ├── coap_io.h │ ├── coap_server.c │ ├── coap_server.h │ ├── coap_timer.c │ ├── coap_timer.h │ ├── endpoints.c │ ├── hash.c │ ├── hash.h │ ├── node.c │ ├── node.h │ ├── pdu.c │ ├── pdu.h │ ├── str.c │ ├── str.h │ ├── uri.c │ └── uri.h ├── crypto │ ├── Makefile │ ├── digests.c │ ├── digests.h │ ├── mech.c │ ├── mech.h │ ├── sdk-aes.h │ ├── sha2.c │ └── sha2.h ├── dht │ ├── Makefile │ ├── dht.c │ └── dht.h ├── driver │ ├── Makefile │ ├── gpio16.c │ ├── i2c_master.c │ ├── key.c │ ├── onewire.c │ ├── pwm.c │ ├── readline.c │ ├── rotary.c │ ├── sigma_delta.c │ ├── spi.c │ ├── switec.c │ └── uart.c ├── esp-gdbstub │ ├── License │ ├── Makefile │ ├── gdbstub-cfg.h │ ├── gdbstub-entry.S │ ├── gdbstub-entry.h │ ├── gdbstub.c │ └── gdbstub.h ├── fatfs │ ├── 00history.txt │ ├── 00readme.txt │ ├── Makefile │ ├── diskio.c │ ├── diskio.h │ ├── fatfs_prefix_lib.h │ ├── ff.c │ ├── ff.h │ ├── ffconf.h │ ├── ffsystem.c │ ├── ffunicode.c │ └── myfatfs.c ├── http │ ├── Makefile │ ├── httpclient.c │ └── httpclient.h ├── include │ ├── arch │ │ ├── cc.h │ │ ├── perf.h │ │ └── sys_arch.h │ ├── driver │ │ ├── gpio16.h │ │ ├── i2c_master.h │ │ ├── key.h │ │ ├── onewire.h │ │ ├── pwm.h │ │ ├── readline.h │ │ ├── rotary.h │ │ ├── sigma_delta.h │ │ ├── spi.h │ │ ├── spi_register.h │ │ ├── switec.h │ │ ├── uart.h │ │ └── uart_register.h │ ├── fatfs_config.h │ ├── lwip │ │ ├── api.h │ │ ├── api_msg.h │ │ ├── app │ │ │ ├── dhcpserver.h │ │ │ ├── espconn.h │ │ │ ├── espconn_buf.h │ │ │ ├── espconn_tcp.h │ │ │ ├── espconn_udp.h │ │ │ └── ping.h │ │ ├── arch.h │ │ ├── autoip.h │ │ ├── debug.h │ │ ├── def.h │ │ ├── dhcp.h │ │ ├── dns.h │ │ ├── err.h │ │ ├── icmp.h │ │ ├── igmp.h │ │ ├── inet.h │ │ ├── inet_chksum.h │ │ ├── init.h │ │ ├── ip.h │ │ ├── ip_addr.h │ │ ├── ip_frag.h │ │ ├── mdns.h │ │ ├── mem.h │ │ ├── memp.h │ │ ├── memp_std.h │ │ ├── netbuf.h │ │ ├── netdb.h │ │ ├── netif.h │ │ ├── netifapi.h │ │ ├── opt.h │ │ ├── pbuf.h │ │ ├── puck_def.h │ │ ├── raw.h │ │ ├── sio.h │ │ ├── snmp.h │ │ ├── snmp_asn1.h │ │ ├── snmp_msg.h │ │ ├── snmp_structs.h │ │ ├── sockets.h │ │ ├── stats.h │ │ ├── sys.h │ │ ├── tcp.h │ │ ├── tcp_impl.h │ │ ├── tcpip.h │ │ ├── timers.h │ │ └── udp.h │ ├── lwipopts.h │ ├── mbedtls │ │ ├── aes.h │ │ ├── aesni.h │ │ ├── arc4.h │ │ ├── asn1.h │ │ ├── asn1write.h │ │ ├── base64.h │ │ ├── bignum.h │ │ ├── blowfish.h │ │ ├── bn_mul.h │ │ ├── camellia.h │ │ ├── ccm.h │ │ ├── certs.h │ │ ├── check_config.h │ │ ├── cipher.h │ │ ├── cipher_internal.h │ │ ├── cmac.h │ │ ├── compat-1.3.h │ │ ├── config.h │ │ ├── ctr_drbg.h │ │ ├── debug.h │ │ ├── des.h │ │ ├── dhm.h │ │ ├── ecdh.h │ │ ├── ecdsa.h │ │ ├── ecjpake.h │ │ ├── ecp.h │ │ ├── ecp_internal.h │ │ ├── entropy.h │ │ ├── entropy_poll.h │ │ ├── error.h │ │ ├── gcm.h │ │ ├── havege.h │ │ ├── hmac_drbg.h │ │ ├── md.h │ │ ├── md2.h │ │ ├── md4.h │ │ ├── md5.h │ │ ├── md_internal.h │ │ ├── memory_buffer_alloc.h │ │ ├── net.h │ │ ├── net_sockets.h │ │ ├── oid.h │ │ ├── padlock.h │ │ ├── pem.h │ │ ├── pk.h │ │ ├── pk_internal.h │ │ ├── pkcs11.h │ │ ├── pkcs12.h │ │ ├── pkcs5.h │ │ ├── platform.h │ │ ├── platform_time.h │ │ ├── ripemd160.h │ │ ├── rsa.h │ │ ├── rsa_internal.h │ │ ├── sha1.h │ │ ├── sha256.h │ │ ├── sha512.h │ │ ├── ssl.h │ │ ├── ssl_cache.h │ │ ├── ssl_ciphersuites.h │ │ ├── ssl_cookie.h │ │ ├── ssl_internal.h │ │ ├── ssl_ticket.h │ │ ├── threading.h │ │ ├── timing.h │ │ ├── version.h │ │ ├── x509.h │ │ ├── x509_crl.h │ │ ├── x509_crt.h │ │ ├── x509_csr.h │ │ └── xtea.h │ ├── module.h │ ├── netif │ │ ├── etharp.h │ │ ├── if_llc.h │ │ ├── ppp_oe.h │ │ └── wlan_lwip_if.h │ ├── nodemcu_mdns.h │ ├── pm │ │ ├── pmSleep.h │ │ └── swtimer.h │ ├── rom.h │ ├── rtc │ │ ├── rtcaccess.h │ │ ├── rtcfifo.h │ │ ├── rtctime.h │ │ └── rtctime_internal.h │ ├── sections.h │ ├── sys │ │ ├── Espconn_mem.h │ │ ├── espconn_mbedtls.h │ │ ├── network_80211.h │ │ ├── ringbuf.h │ │ └── socket.h │ ├── task │ │ └── task.h │ ├── u8g2_displays.h │ ├── u8g2_fonts.h │ ├── ucg_config.h │ ├── user_config.h │ ├── user_mbedtls.h │ ├── user_modules.h │ └── user_version.h ├── libc │ ├── Makefile │ ├── c_ctype.c │ ├── c_ctype.h │ ├── c_errno.h │ ├── c_fcntl.h │ ├── c_limits.h │ ├── c_locale.h │ ├── c_math.c │ ├── c_math.h │ ├── c_signal.h │ ├── c_stdarg.h │ ├── c_stddef.h │ ├── c_stdint.h │ ├── c_stdio.c │ ├── c_stdio.h │ ├── c_stdlib.c │ ├── c_stdlib.h │ ├── c_string.c │ ├── c_string.h │ └── dbg_printf.c ├── lua │ ├── Makefile │ ├── lapi.c │ ├── lapi.h │ ├── lauxlib.c │ ├── lauxlib.h │ ├── lbaselib.c │ ├── lcode.c │ ├── lcode.h │ ├── ldblib.c │ ├── ldebug.c │ ├── ldebug.h │ ├── ldo.c │ ├── ldo.h │ ├── ldump.c │ ├── legc.c │ ├── legc.h │ ├── lflash.c │ ├── lflash.h │ ├── lfunc.c │ ├── lfunc.h │ ├── lgc.c │ ├── lgc.h │ ├── linit.c │ ├── llex.c │ ├── llex.h │ ├── llimits.h │ ├── lmathlib.c │ ├── lmem.c │ ├── lmem.h │ ├── loadlib.c │ ├── lobject.c │ ├── lobject.h │ ├── lopcodes.c │ ├── lopcodes.h │ ├── lparser.c │ ├── lparser.h │ ├── lrodefs.h │ ├── lrotable.c │ ├── lrotable.h │ ├── lstate.c │ ├── lstate.h │ ├── lstring.c │ ├── lstring.h │ ├── lstrlib.c │ ├── ltable.c │ ├── ltable.h │ ├── ltablib.c │ ├── ltm.c │ ├── ltm.h │ ├── lua.c │ ├── lua.h │ ├── luac_cross.h │ ├── luac_cross │ │ ├── Makefile │ │ ├── lflashimg.c │ │ ├── liolib.c │ │ ├── loslib.c │ │ ├── luac.c │ │ └── print.c │ ├── luaconf.h │ ├── lualib.h │ ├── lundump.c │ ├── lundump.h │ ├── lvm.c │ ├── lvm.h │ ├── lzio.c │ └── lzio.h ├── lwip │ ├── Makefile │ ├── api │ │ ├── Makefile │ │ ├── api_lib.c │ │ ├── api_msg.c │ │ ├── err.c │ │ ├── netbuf.c │ │ ├── netdb.c │ │ ├── netifapi.c │ │ ├── sockets.c │ │ └── tcpip.c │ ├── app │ │ ├── Makefile │ │ ├── dhcpserver.c │ │ ├── espconn.c │ │ ├── espconn_buf.c │ │ ├── espconn_mdns.c │ │ ├── espconn_tcp.c │ │ ├── espconn_udp.c │ │ ├── netio.c │ │ └── ping.c │ ├── core │ │ ├── Makefile │ │ ├── def.c │ │ ├── dhcp.c │ │ ├── dns.c │ │ ├── init.c │ │ ├── ipv4 │ │ │ ├── Makefile │ │ │ ├── autoip.c │ │ │ ├── icmp.c │ │ │ ├── igmp.c │ │ │ ├── inet.c │ │ │ ├── inet_chksum.c │ │ │ ├── ip.c │ │ │ ├── ip_addr.c │ │ │ └── ip_frag.c │ │ ├── mdns.c │ │ ├── mem.c │ │ ├── memp.c │ │ ├── netif.c │ │ ├── pbuf.c │ │ ├── raw.c │ │ ├── stats.c │ │ ├── sys.c │ │ ├── sys_arch.c │ │ ├── tcp.c │ │ ├── tcp_in.c │ │ ├── tcp_out.c │ │ ├── timers.c │ │ └── udp.c │ └── netif │ │ ├── Makefile │ │ └── etharp.c ├── mbedtls │ ├── Makefile │ ├── app │ │ ├── Espconn_mem.c │ │ ├── Makefile │ │ ├── espconn_mbedtls.c │ │ ├── espconn_secure.c │ │ ├── lwIPBuffer.c │ │ ├── lwIPFile.c │ │ └── lwIPSocket.c │ ├── library │ │ ├── Makefile │ │ ├── aes.c │ │ ├── aesni.c │ │ ├── arc4.c │ │ ├── asn1parse.c │ │ ├── asn1write.c │ │ ├── base64.c │ │ ├── bignum.c │ │ ├── blowfish.c │ │ ├── camellia.c │ │ ├── ccm.c │ │ ├── certs.c │ │ ├── cipher.c │ │ ├── cipher_wrap.c │ │ ├── cmac.c │ │ ├── ctr_drbg.c │ │ ├── debug.c │ │ ├── des.c │ │ ├── dhm.c │ │ ├── ecdh.c │ │ ├── ecdsa.c │ │ ├── ecjpake.c │ │ ├── ecp.c │ │ ├── ecp_curves.c │ │ ├── entropy.c │ │ ├── entropy_poll.c │ │ ├── error.c │ │ ├── gcm.c │ │ ├── havege.c │ │ ├── hmac_drbg.c │ │ ├── md.c │ │ ├── md2.c │ │ ├── md4.c │ │ ├── md5.c │ │ ├── md_wrap.c │ │ ├── memory_buffer_alloc.c │ │ ├── oid.c │ │ ├── padlock.c │ │ ├── pem.c │ │ ├── pk.c │ │ ├── pk_wrap.c │ │ ├── pkcs11.c │ │ ├── pkcs12.c │ │ ├── pkcs5.c │ │ ├── pkparse.c │ │ ├── pkwrite.c │ │ ├── platform.c │ │ ├── ripemd160.c │ │ ├── rsa.c │ │ ├── rsa_internal.c │ │ ├── sha1.c │ │ ├── sha256.c │ │ ├── sha512.c │ │ ├── ssl_cache.c │ │ ├── ssl_ciphersuites.c │ │ ├── ssl_cli.c │ │ ├── ssl_cookie.c │ │ ├── ssl_srv.c │ │ ├── ssl_ticket.c │ │ ├── ssl_tls.c │ │ ├── threading.c │ │ ├── timing.c │ │ ├── version.c │ │ ├── version_features.c │ │ ├── x509.c │ │ ├── x509_create.c │ │ ├── x509_crl.c │ │ ├── x509_crt.c │ │ ├── x509_csr.c │ │ ├── x509write_crt.c │ │ ├── x509write_csr.c │ │ └── xtea.c │ └── platform │ │ ├── Makefile │ │ ├── esp_hardware.c │ │ └── mbedtls_net.c ├── modules │ ├── .gitignore │ ├── Makefile │ ├── adc.c │ ├── ads1115.c │ ├── adxl345.c │ ├── am2320.c │ ├── apa102.c │ ├── bit.c │ ├── bloom.c │ ├── bme280.c │ ├── bme680.c │ ├── bme680_defs.h │ ├── bmp085.c │ ├── coap.c │ ├── color_utils.c │ ├── color_utils.h │ ├── cron.c │ ├── crypto.c │ ├── dht.c │ ├── ds18b20.c │ ├── encoder.c │ ├── enduser_setup.c │ ├── eus │ │ ├── enduser_setup.html │ │ ├── enduser_setup.html.gz │ │ ├── http_html_backup.def │ │ └── prepare.sh │ ├── file.c │ ├── gdbstub.c │ ├── gpio.c │ ├── gpio_pulse.c │ ├── hdc1080.c │ ├── hmc5883l.c │ ├── http.c │ ├── hx711.c │ ├── i2c.c │ ├── l3g4200d.c │ ├── mcp4725.c │ ├── mdns.c │ ├── mqtt.c │ ├── net.c │ ├── node.c │ ├── ow.c │ ├── pcm.c │ ├── perf.c │ ├── pwm.c │ ├── rc.c │ ├── rfswitch.c │ ├── rotary.c │ ├── rtcfifo.c │ ├── rtcmem.c │ ├── rtctime.c │ ├── si7021.c │ ├── sigma_delta.c │ ├── sjson.c │ ├── sntp.c │ ├── somfy.c │ ├── spi.c │ ├── sqlite3.c │ ├── struct.c │ ├── switec.c │ ├── tcs34725.c │ ├── tls.c │ ├── tm1829.c │ ├── tmr.c │ ├── tsl2561.c │ ├── u8g2.c │ ├── uart.c │ ├── ucg.c │ ├── websocket.c │ ├── wifi.c │ ├── wifi_common.c │ ├── wifi_common.h │ ├── wifi_eventmon.c │ ├── wifi_monitor.c │ ├── wps.c │ ├── ws2801.c │ ├── ws2812.c │ ├── ws2812.h │ ├── ws2812_effects.c │ └── xpt2046.c ├── mqtt │ ├── Makefile │ ├── mqtt_msg.c │ ├── mqtt_msg.h │ ├── msg_queue.c │ └── msg_queue.h ├── net │ ├── Makefile │ └── nodemcu_mdns.c ├── pcm │ ├── Makefile │ ├── drv_sigma_delta.c │ ├── pcm.h │ ├── pcm_core.c │ └── pcm_drv.h ├── platform │ ├── Makefile │ ├── common.c │ ├── common.h │ ├── cpu_esp8266.h │ ├── flash_api.c │ ├── flash_api.h │ ├── hw_timer.c │ ├── hw_timer.h │ ├── pin_map.c │ ├── pin_map.h │ ├── platform.c │ ├── platform.h │ ├── sdcard.c │ ├── sdcard.h │ ├── u8x8_nodemcu_hal.c │ ├── u8x8_nodemcu_hal.h │ ├── ucg_nodemcu_hal.c │ ├── ucg_nodemcu_hal.h │ ├── vfs.c │ ├── vfs.h │ └── vfs_int.h ├── pm │ ├── Makefile │ ├── pmSleep.c │ └── swtimer.c ├── sjson │ ├── Makefile │ ├── json_config.h │ ├── jsonsl.c │ ├── jsonsl.h │ └── memcompat.h ├── smart │ ├── Makefile │ ├── smart.c │ └── smart.h ├── spiffs │ ├── LICENSE │ ├── Makefile │ ├── docs │ │ ├── IMPLEMENTING │ │ ├── TECH_SPEC │ │ └── TODO │ ├── myspiffs.h │ ├── nodemcu_spiffs.h │ ├── spiffs.c │ ├── spiffs.h │ ├── spiffs_cache.c │ ├── spiffs_check.c │ ├── spiffs_config.h │ ├── spiffs_gc.c │ ├── spiffs_hydrogen.c │ ├── spiffs_nucleus.c │ └── spiffs_nucleus.h ├── sqlite3 │ ├── Makefile │ ├── config.h │ ├── config_ext.h │ ├── esp8266.c │ ├── sqlite3.c │ ├── sqlite3.h │ └── sqlite3ext.h ├── task │ ├── Makefile │ └── task.c ├── tsl2561 │ ├── Makefile │ ├── tsl2561.c │ └── tsl2561.h ├── u8g2lib │ ├── Makefile │ └── u8x8_d_fbrle.c ├── ucglib │ └── Makefile ├── user │ ├── Makefile │ ├── user_exceptions.c │ ├── user_exceptions.h │ └── user_main.c ├── uzlib │ ├── Makefile │ ├── README.md │ ├── crc32.c │ ├── host │ │ ├── Makefile │ │ ├── uz_unzip.c │ │ └── uz_zip.c │ ├── uzlib.h │ ├── uzlib_deflate.c │ └── uzlib_inflate.c └── websocket │ ├── Makefile │ ├── websocketclient.c │ └── websocketclient.h ├── bin └── .gitignore ├── docs ├── build.md ├── compiling.md ├── css │ └── extra.css ├── extn-developer-faq.md ├── flash.md ├── getting-started.md ├── hardware-faq.md ├── img │ ├── ESPlorer.jpg │ ├── NodeMCU-PyFlasher.png │ ├── WiFi-softap-mode.png │ ├── WiFi-station-mode.png │ ├── WiFi-stationap-mode.png │ ├── enduser-setup.jpg │ ├── favicon-readme.txt │ ├── favicon.ico │ ├── favicon_package_v0.16.zip │ ├── logo-small.png │ ├── logo.png │ ├── micro_sd-small.jpg │ ├── micro_sd.jpg │ ├── micro_sd_shield-small.jpg │ ├── micro_sd_shield.jpg │ └── sigma_delta_audiofilter.png ├── index.md ├── js │ └── extra.js ├── lcd.md ├── lfs.md ├── lua-developer-faq.md ├── lua-modules │ ├── bh1750.md │ ├── ds18b20.md │ ├── ds3231.md │ ├── ftpserver.md │ ├── hdc1000.md │ ├── httpserver.md │ ├── imap.md │ ├── lm92.md │ ├── mcp23008.md │ ├── redis.md │ └── yeelink.md ├── modules │ ├── adc.md │ ├── ads1115.md │ ├── adxl345.md │ ├── am2320.md │ ├── apa102.md │ ├── bit.md │ ├── bloom.md │ ├── bme280.md │ ├── bme680.md │ ├── bmp085.md │ ├── cjson.md │ ├── coap.md │ ├── color-utils.md │ ├── cron.md │ ├── crypto.md │ ├── dht.md │ ├── ds18b20.md │ ├── encoder.md │ ├── enduser-setup.md │ ├── file.md │ ├── gdbstub.md │ ├── gpio.md │ ├── hdc1080.md │ ├── hmc5883l.md │ ├── http.md │ ├── hx711.md │ ├── i2c.md │ ├── l3g4200d.md │ ├── mcp4725.md │ ├── mdns.md │ ├── mqtt.md │ ├── net.md │ ├── node.md │ ├── ow.md │ ├── pcm.md │ ├── perf.md │ ├── pwm.md │ ├── rc.md │ ├── rfswitch.md │ ├── rotary.md │ ├── rtcfifo.md │ ├── rtcmem.md │ ├── rtctime.md │ ├── si7021.md │ ├── sigma-delta.md │ ├── sjson.md │ ├── sntp.md │ ├── somfy.md │ ├── spi.md │ ├── sqlite3.md │ ├── struct.md │ ├── switec.md │ ├── tcs34725.md │ ├── tls.md │ ├── tm1829.md │ ├── tmr.md │ ├── tsl2561.md │ ├── u8g2.md │ ├── uart.md │ ├── ucg.md │ ├── websocket.md │ ├── wifi.md │ ├── wifi_monitor.md │ ├── wps.md │ ├── ws2801.md │ ├── ws2812-effects.md │ ├── ws2812.md │ └── xpt2046.md ├── sdcard.md ├── spiffs.md ├── support.md └── upload.md ├── ld ├── defsym.rom └── nodemcu.ld ├── local ├── fs │ └── .gitignore └── lua │ └── .gitignore ├── lua_examples ├── adc_rgb.lua ├── email │ ├── read_email_imap.lua │ └── send_email_smtp.lua ├── irsend.lua ├── lfs │ ├── HTTP_OTA.lua │ ├── _init.lua │ ├── dummy_strings.lua │ └── lfs_fragments.lua ├── luaOTA │ ├── README.md │ ├── _doTick.lua │ ├── _init.lua │ ├── _provision.lua │ ├── check.lua │ ├── config.json │ ├── default.lua │ └── luaOTAserver.lua ├── make_phone_call.lua ├── mcp23008 │ ├── mcp23008_buttons.lua │ └── mcp23008_leds.lua ├── mqtt │ ├── mqtt2cloud.lua │ └── mqtt_file.lua ├── myfile.lua ├── pcm │ ├── jump_8k.u8 │ ├── play_file.lua │ └── play_network.lua ├── send_text_message.lua ├── sjson-streaming.lua ├── somfy.lua ├── tcp2uart.lua ├── telnet │ ├── README.md │ ├── simple_telnet.lua │ └── telnet.lua ├── timezone │ ├── README.md │ ├── alaska.zone │ ├── central.zone │ ├── eastern.zone │ ├── mountain.zone │ ├── pacific.zone │ └── tz.lua ├── u8g2 │ └── graphics_test.lua ├── ucglib │ ├── GT_box.lua │ ├── GT_clip.lua │ ├── GT_color_test.lua │ ├── GT_cross.lua │ ├── GT_fonts.lua │ ├── GT_gradient.lua │ ├── GT_graphics_test.lua │ ├── GT_pixel_and_lines.lua │ ├── GT_text.lua │ ├── GT_triangle.lua │ ├── GraphicsTest.lua │ ├── HelloWorld.lua │ └── UcgLogo.lua └── webap_toggle_pin.lua ├── lua_modules ├── bh1750 │ ├── README.md │ ├── bh1750.lua │ ├── bh1750_CN.md │ ├── bh1750_EN.md │ ├── bh1750_Example1.lua │ └── bh1750_Example2.lua ├── bmp085 │ └── README.md ├── dht_lib │ └── README.md ├── ds18b20 │ ├── README.md │ ├── ds18b20-example.lua │ ├── ds18b20-web.lua │ └── ds18b20.lua ├── ds3231 │ ├── README.md │ ├── ds3231-example.lua │ ├── ds3231-web.lua │ ├── ds3231.EN.md │ └── ds3231.lua ├── email │ ├── README.md │ └── imap.lua ├── ftp │ ├── README.md │ └── ftpserver.lua ├── hdc1000 │ ├── HDC1000-example.lua │ ├── HDC1000.lua │ └── README.md ├── http │ ├── README.md │ ├── http-example.lua │ └── httpserver.lua ├── lm92 │ ├── README.md │ └── lm92.lua ├── mcp23008 │ ├── README.md │ └── mcp23008.lua ├── redis │ ├── README.md │ └── redis.lua ├── si7021 │ └── README.md ├── tsl2561 │ └── README.md └── yeelink │ ├── Example_for_Yeelink_Lib.lua │ ├── README.md │ └── yeelink_lib.lua ├── mkdocs.yml ├── rtd-requirements.txt ├── sdk-overrides └── include │ ├── c_types.h │ ├── eagle_soc.h │ ├── ets_sys.h │ ├── mem.h │ ├── osapi.h │ └── user_interface.h └── tools ├── .gitattributes ├── .gitignore ├── Makefile ├── esptool.py ├── make_cert.py ├── make_server_cert.py ├── makefile.sh ├── pr-build.sh ├── spiffsimg ├── .gitignore ├── Makefile ├── README.md ├── main.c └── spiffs_typedefs.h ├── update_spiffs.sh └── xxd.exe /.gdbinit: -------------------------------------------------------------------------------- 1 | # 2 | # This is very much a work in progress to show how we can use macros to make the 3 | # GDB interface a lot more useable. For example the next / step commands only 4 | # work if the stepper doesn't leave the current scope. Beyond that you have a 5 | # single hardware breakpoint which can be used as an hb or a wa. You have to 6 | # remember to delete the previous one, so the br macro does this for you. 7 | # 8 | file app/.output/eagle/debug/image/eagle.app.v6.out 9 | #set remotedebug 1 10 | set remotelogfile gdb_rsp_logfile.txt 11 | set serial baud 115200 12 | set remote hardware-breakpoint-limit 1 13 | set remote hardware-watchpoint-limit 1 14 | #set debug xtensa 4 15 | target remote /dev/ttyUSB0 16 | 17 | set confirm off 18 | set print null-stop 19 | define br 20 | d 21 | hb $arg0 22 | end 23 | 24 | define upto 25 | d 26 | hb $arg0 27 | c 28 | end 29 | 30 | set pagination off 31 | set history filename ~/.gdb_history 32 | set history save on 33 | set history size 1000 34 | 35 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | Make sure you read and understand http://nodemcu.readthedocs.io/en/dev/en/support/. 2 | Use one of the two templates below and delete the rest. 3 | 4 | 8<------------------------ BUG REPORT ----------------------------------------- 5 | ### Expected behavior 6 | 7 | ### Actual behavior 8 | 9 | ### Test code 10 | Provide a [Minimal, Complete, and Verifiable example](http://stackoverflow.com/help/mcve) which will reproduce the problem. 11 | ```Lua 12 | -- add code here 13 | ``` 14 | ### NodeMCU version 15 | Which branch are you on? If you know the Git revision then add it here as well. 16 | 17 | ### Hardware 18 | Describe which ESP8266 device you use and document any special hardware setup 19 | required to reproduce the problem. 20 | 21 | 8<------------------------ END BUG REPORT ------------------------------------- 22 | 23 | 24 | 8<------------------------ FEATURE REQUEST ------------------------------------ 25 | ### Missing feature 26 | 27 | ### Justification 28 | Tell us why you would like to see this feature added. 29 | 30 | ### Workarounds 31 | Are there any workarounds you currently have in place because the feature is missing? 32 | 33 | 8<------------------------ END FEATURE REQUEST -------------------------------- 34 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | Fixes #\. 2 | 3 | Make sure all boxes are checked (add x inside the brackets) when you submit your contribution, remove this sentence before doing so. 4 | 5 | - [ ] This PR is for the `dev` branch rather than for `master`. 6 | - [ ] This PR is compliant with the [other contributing guidelines](https://github.com/nodemcu/nodemcu-firmware/blob/dev/CONTRIBUTING.md) as well (if not, please describe why). 7 | - [ ] I have thoroughly tested my contribution. 8 | - [ ] The code changes are reflected in the documentation at `docs/*`. 9 | 10 | \ 11 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .gdb_history 2 | sdk/ 3 | cache/ 4 | .ccache/ 5 | local/ 6 | user_config.h 7 | server-ca.crt 8 | luac.cross 9 | uz_unzip 10 | uz_zip 11 | tools/toolchains/ 12 | 13 | #ignore Eclipse project files 14 | .cproject 15 | .project 16 | .settings/ 17 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "app/u8g2lib/u8g2"] 2 | path = app/u8g2lib/u8g2 3 | url = https://github.com/olikraus/U8g2_Arduino.git 4 | [submodule "app/ucglib/ucg"] 5 | path = app/ucglib/ucg 6 | url = https://github.com/olikraus/Ucglib_Arduino.git 7 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: cpp 2 | addons: 3 | apt: 4 | packages: 5 | - python-serial 6 | - srecord 7 | cache: 8 | - directories: 9 | - cache 10 | script: 11 | - export BUILD_DATE=$(date +%Y%m%d) 12 | - make EXTRA_CCFLAGS="-DBUILD_DATE='\"'$BUILD_DATE'\"'" all 13 | - cd bin/ 14 | - file_name_float="nodemcu_float_${TRAVIS_TAG}.bin" 15 | - srec_cat -output ${file_name_float} -binary 0x00000.bin -binary -fill 0xff 0x00000 0x10000 0x10000.bin -binary -offset 0x10000 16 | - cd ../ 17 | - make clean 18 | - make EXTRA_CCFLAGS="-DLUA_NUMBER_INTEGRAL -DBUILD_DATE='\"'$BUILD_DATE'\"'" 19 | - cd bin/ 20 | - file_name_integer="nodemcu_integer_${TRAVIS_TAG}.bin" 21 | - srec_cat -output ${file_name_integer} -binary 0x00000.bin -binary -fill 0xff 0x00000 0x10000 0x10000.bin -binary -offset 0x10000 22 | # http://docs.travis-ci.com/user/environment-variables/#Convenience-Variables 23 | - if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then bash "$TRAVIS_BUILD_DIR"/tools/pr-build.sh; fi 24 | -------------------------------------------------------------------------------- /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/.gitignore: -------------------------------------------------------------------------------- 1 | *.output* 2 | mapfile 3 | !.gitignore 4 | -------------------------------------------------------------------------------- /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/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 = libcoap.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/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/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 "c_types.h" 9 | #include "lwip/ip_addr.h" 10 | #include "espconn.h" 11 | #include "pdu.h" 12 | #include "hash.h" 13 | 14 | coap_tid_t coap_send(struct espconn *pesp_conn, coap_pdu_t *pdu); 15 | 16 | coap_tid_t coap_send_confirmed(struct espconn *pesp_conn, coap_pdu_t *pdu); 17 | 18 | #ifdef __cplusplus 19 | } 20 | #endif 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/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/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 | -------------------------------------------------------------------------------- /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/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/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/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 | GEN_LIBS = libcrypto.a 16 | endif 17 | 18 | STD_CFLAGS=-std=gnu11 -Wimplicit 19 | 20 | ############################################################# 21 | # Configuration i.e. compile options etc. 22 | # Target specific stuff (defines etc.) goes in here! 23 | # Generally values applying to a tree are captured in the 24 | # makefile at its root level - these are then overridden 25 | # for a subtree within the makefile rooted therein 26 | # 27 | #DEFINES += 28 | 29 | ############################################################# 30 | # Recursion Magic - Don't touch this!! 31 | # 32 | # Each subtree potentially has an include directory 33 | # corresponding to the common APIs applicable to modules 34 | # rooted at that subtree. Accordingly, the INCLUDE PATH 35 | # of a module can only contain the include directories up 36 | # its parent path, and not its siblings 37 | # 38 | # Required for each makefile to inherit from the parent 39 | # 40 | 41 | INCLUDES := $(INCLUDES) -I $(PDIR)include 42 | INCLUDES += -I ./ 43 | INCLUDES += -I ../libc 44 | INCLUDES += -I ../platform 45 | PDIR := ../$(PDIR) 46 | sinclude $(PDIR)Makefile 47 | 48 | -------------------------------------------------------------------------------- /app/crypto/mech.h: -------------------------------------------------------------------------------- 1 | #ifndef _MECH_H_ 2 | #define _MECH_H_ 3 | 4 | #include "c_types.h" 5 | 6 | typedef struct 7 | { 8 | const char *key; 9 | size_t keylen; 10 | const char *iv; 11 | size_t ivlen; 12 | const char *data; 13 | size_t datalen; 14 | char *out; 15 | size_t outlen; 16 | enum { OP_ENCRYPT, OP_DECRYPT } op; 17 | } crypto_op_t; 18 | 19 | 20 | typedef struct 21 | { 22 | const char *name; 23 | bool (*run) (crypto_op_t *op); 24 | uint16_t block_size; 25 | } crypto_mech_t; 26 | 27 | 28 | const crypto_mech_t *crypto_encryption_mech (const char *name); 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /app/crypto/sdk-aes.h: -------------------------------------------------------------------------------- 1 | #ifndef _SDK_AES_H_ 2 | #define _SDK_AES_H_ 3 | 4 | #define AES_BLOCKSIZE 16 5 | 6 | void *aes_encrypt_init (const char *key, size_t len); 7 | void aes_encrypt (void *ctx, const char *plain, char *crypt); 8 | void aes_encrypt_deinit (void *ctx); 9 | 10 | void *aes_decrypt_init (const char *key, size_t len); 11 | void aes_decrypt (void *ctx, const char *crypt, char *plain); 12 | void aes_decrypt_deinit (void *ctx); 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /app/crypto/sha2.h: -------------------------------------------------------------------------------- 1 | #ifndef __SHA2_H__ 2 | #define __SHA2_H__ 3 | 4 | #include 5 | 6 | /************************************************************************** 7 | * SHA256/384/512 declarations 8 | **************************************************************************/ 9 | 10 | #define SHA256_BLOCK_LENGTH 64 11 | #define SHA256_DIGEST_LENGTH 32 12 | 13 | typedef struct 14 | { 15 | uint32_t state[8]; 16 | uint64_t bitcount; 17 | uint8_t buffer[SHA256_BLOCK_LENGTH]; 18 | } SHA256_CTX; 19 | 20 | 21 | void SHA256_Init(SHA256_CTX *); 22 | void SHA256_Update(SHA256_CTX *, const uint8_t *msg, size_t len); 23 | void SHA256_Final(uint8_t[SHA256_DIGEST_LENGTH], SHA256_CTX*); 24 | 25 | #define SHA384_BLOCK_LENGTH 128 26 | #define SHA384_DIGEST_LENGTH 48 27 | 28 | typedef struct 29 | { 30 | uint64_t state[8]; 31 | uint64_t bitcount[2]; 32 | uint8_t buffer[SHA384_BLOCK_LENGTH]; 33 | } SHA384_CTX; 34 | 35 | void SHA384_Init(SHA384_CTX*); 36 | void SHA384_Update(SHA384_CTX*, const uint8_t *msg, size_t len); 37 | void SHA384_Final(uint8_t[SHA384_DIGEST_LENGTH], SHA384_CTX*); 38 | 39 | #define SHA512_BLOCK_LENGTH 128 40 | #define SHA512_DIGEST_LENGTH 64 41 | typedef SHA384_CTX SHA512_CTX; 42 | 43 | void SHA512_Init(SHA512_CTX*); 44 | void SHA512_Update(SHA512_CTX*, const uint8_t *msg, size_t len); 45 | void SHA512_Final(uint8_t[SHA512_DIGEST_LENGTH], SHA512_CTX*); 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /app/dht/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 = libdht.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 43 | INCLUDES += -I ../include 44 | INCLUDES += -I ../../include 45 | INCLUDES += -I ../libc 46 | INCLUDES += -I ../platform 47 | PDIR := ../$(PDIR) 48 | sinclude $(PDIR)Makefile 49 | 50 | -------------------------------------------------------------------------------- /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 | STD_CFLAGS=-std=gnu11 -Wimplicit 19 | 20 | ############################################################# 21 | # Configuration i.e. compile options etc. 22 | # Target specific stuff (defines etc.) goes in here! 23 | # Generally values applying to a tree are captured in the 24 | # makefile at its root level - these are then overridden 25 | # for a subtree within the makefile rooted therein 26 | # 27 | #DEFINES += 28 | 29 | ############################################################# 30 | # Recursion Magic - Don't touch this!! 31 | # 32 | # Each subtree potentially has an include directory 33 | # corresponding to the common APIs applicable to modules 34 | # rooted at that subtree. Accordingly, the INCLUDE PATH 35 | # of a module can only contain the include directories up 36 | # its parent path, and not its siblings 37 | # 38 | # Required for each makefile to inherit from the parent 39 | # 40 | 41 | INCLUDES := $(INCLUDES) -I $(PDIR)include 42 | INCLUDES += -I ./ 43 | INCLUDES += -I ../platform 44 | PDIR := ../$(PDIR) 45 | sinclude $(PDIR)Makefile 46 | 47 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /app/driver/sigma_delta.c: -------------------------------------------------------------------------------- 1 | 2 | #include "platform.h" 3 | #include "driver/sigma_delta.h" 4 | 5 | 6 | void sigma_delta_setup( void ) 7 | { 8 | GPIO_REG_WRITE(GPIO_SIGMA_DELTA, 9 | GPIO_SIGMA_DELTA_SET(GPIO_SIGMA_DELTA_ENABLE) | 10 | GPIO_SIGMA_DELTA_TARGET_SET(0x00) | 11 | GPIO_SIGMA_DELTA_PRESCALE_SET(0x00)); 12 | } 13 | 14 | void sigma_delta_stop( void ) 15 | { 16 | GPIO_REG_WRITE(GPIO_SIGMA_DELTA, 17 | GPIO_SIGMA_DELTA_SET(GPIO_SIGMA_DELTA_DISABLE) | 18 | GPIO_SIGMA_DELTA_TARGET_SET(0x00) | 19 | GPIO_SIGMA_DELTA_PRESCALE_SET(0x00) ); 20 | } 21 | 22 | void ICACHE_RAM_ATTR sigma_delta_set_prescale_target( sint16 prescale, sint16 target ) 23 | { 24 | uint32_t prescale_mask, target_mask; 25 | 26 | prescale_mask = prescale >= 0 ? GPIO_SIGMA_DELTA_PRESCALE_MASK : 0x00; 27 | target_mask = target >= 0 ? GPIO_SIGMA_DELTA_TARGET_MASK : 0x00; 28 | 29 | // set prescale and target with one register access to avoid glitches 30 | GPIO_REG_WRITE(GPIO_SIGMA_DELTA, 31 | (GPIO_REG_READ(GPIO_SIGMA_DELTA) & ~(prescale_mask | target_mask)) | 32 | (GPIO_SIGMA_DELTA_PRESCALE_SET(prescale) & prescale_mask) | 33 | (GPIO_SIGMA_DELTA_TARGET_SET(target) & target_mask)); 34 | } 35 | -------------------------------------------------------------------------------- /app/esp-gdbstub/License: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devsaurus/nodemcu-firmware/27e9e6c085aaac8b7e78b7c1d9cd5afe39428ba0/app/esp-gdbstub/License -------------------------------------------------------------------------------- /app/esp-gdbstub/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 = libgdbstub.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 += -DGDBSTUB_REDIRECT_CONSOLE_OUTPUT 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 += -I $(PDIR)include 41 | INCLUDES += -I ./ 42 | INCLUDES += -I ../../include/ets 43 | PDIR := ../$(PDIR) 44 | sinclude $(PDIR)Makefile 45 | 46 | -------------------------------------------------------------------------------- /app/esp-gdbstub/gdbstub-entry.h: -------------------------------------------------------------------------------- 1 | #ifndef GDBSTUB_ENTRY_H 2 | #define GDBSTUB_ENTRY_H 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | void gdbstub_init_debug_entry(); 9 | void gdbstub_do_break(); 10 | void gdbstub_icount_ena_single_step(); 11 | void gdbstub_save_extra_sfrs_for_exception(); 12 | void gdbstub_uart_entry(); 13 | 14 | int gdbstub_set_hw_breakpoint(int addr, int len); 15 | int gdbstub_set_hw_watchpoint(int addr, int len, int type); 16 | int gdbstub_del_hw_breakpoint(int addr); 17 | int gdbstub_del_hw_watchpoint(int addr); 18 | 19 | extern void* gdbstub_do_break_breakpoint_addr; 20 | 21 | #ifdef __cplusplus 22 | { 23 | #endif 24 | 25 | #endif -------------------------------------------------------------------------------- /app/esp-gdbstub/gdbstub.h: -------------------------------------------------------------------------------- 1 | #ifndef GDBSTUB_H 2 | #define GDBSTUB_H 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | void gdbstub_init(); 9 | void gdbstub_redirect_output(int enable); 10 | 11 | #ifdef __cplusplus 12 | } 13 | #endif 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /app/fatfs/00readme.txt: -------------------------------------------------------------------------------- 1 | FatFs Module Source Files R0.13c 2 | 3 | 4 | FILES 5 | 6 | 00readme.txt This file. 7 | 00history.txt Revision history. 8 | ff.c FatFs module. 9 | ffconf.h Configuration file of FatFs module. 10 | ff.h Common include file for FatFs and application module. 11 | diskio.h Common include file for FatFs and disk I/O module. 12 | diskio.c An example of glue function to attach existing disk I/O module to FatFs. 13 | ffunicode.c Optional Unicode utility functions. 14 | ffsystem.c An example of optional O/S related functions. 15 | 16 | 17 | Low level disk I/O module is not included in this archive because the FatFs 18 | module is only a generic file system layer and it does not depend on any specific 19 | storage device. You need to provide a low level disk I/O module written to 20 | control the storage device that attached to the target system. 21 | 22 | -------------------------------------------------------------------------------- /app/fatfs/fatfs_prefix_lib.h: -------------------------------------------------------------------------------- 1 | #define f_chdir fatfslib_f_chdir 2 | #define f_chdrive fatfslib_f_chdrive 3 | #define f_chmod fatfslib_f_chmod 4 | #define f_close fatfslib_f_close 5 | #define f_closedir fatfslib_f_closedir 6 | #define f_getcwd fatfslib_f_getcwd 7 | #define f_getfree fatfslib_f_getfree 8 | #define f_getlabel fatfslib_f_getlabel 9 | #define f_lseek fatfslib_f_lseek 10 | #define f_mkdir fatfslib_f_mkdir 11 | #define f_mount fatfslib_f_mount 12 | #define f_open fatfslib_f_open 13 | #define f_opendir fatfslib_f_opendir 14 | #define f_read fatfslib_f_read 15 | #define f_readdir fatfslib_f_readdir 16 | #define f_rename fatfslib_f_rename 17 | #define f_setlabel fatfslib_f_setlabel 18 | #define f_stat fatfslib_f_stat 19 | #define f_sync fatfslib_f_sync 20 | #define f_truncate fatfslib_f_truncate 21 | #define f_unlink fatfslib_f_unlink 22 | #define f_utime fatfslib_f_utime 23 | #define f_write fatfslib_f_write 24 | -------------------------------------------------------------------------------- /app/http/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 = libhttp.a 16 | endif 17 | 18 | STD_CFLAGS=-std=gnu11 -Wimplicit 19 | 20 | ############################################################# 21 | # Configuration i.e. compile options etc. 22 | # Target specific stuff (defines etc.) goes in here! 23 | # Generally values applying to a tree are captured in the 24 | # makefile at its root level - these are then overridden 25 | # for a subtree within the makefile rooted therein 26 | # 27 | #DEFINES += 28 | 29 | ############################################################# 30 | # Recursion Magic - Don't touch this!! 31 | # 32 | # Each subtree potentially has an include directory 33 | # corresponding to the common APIs applicable to modules 34 | # rooted at that subtree. Accordingly, the INCLUDE PATH 35 | # of a module can only contain the include directories up 36 | # its parent path, and not its siblings 37 | # 38 | # Required for each makefile to inherit from the parent 39 | # 40 | 41 | INCLUDES := $(INCLUDES) -I $(PDIR)include 42 | INCLUDES += -I ./ 43 | INCLUDES += -I ./include 44 | INCLUDES += -I ../include 45 | INCLUDES += -I ../../include 46 | PDIR := ../$(PDIR) 47 | sinclude $(PDIR)Makefile 48 | 49 | -------------------------------------------------------------------------------- /app/include/arch/sys_arch.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devsaurus/nodemcu-firmware/27e9e6c085aaac8b7e78b7c1d9cd5afe39428ba0/app/include/arch/sys_arch.h -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/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 | bool 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/include/driver/readline.h: -------------------------------------------------------------------------------- 1 | #ifndef READLINE_APP_H 2 | #define READLINE_APP_H 3 | 4 | bool uart_getc(char *c); 5 | 6 | #endif /* READLINE_APP_H */ 7 | -------------------------------------------------------------------------------- /app/include/driver/rotary.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Definitions to access the Rotary driver 3 | */ 4 | #ifndef __ROTARY_H__ 5 | #define __ROTARY_H__ 6 | 7 | #include "c_types.h" 8 | 9 | #define ROTARY_CHANNEL_COUNT 3 10 | 11 | typedef struct { 12 | uint32_t pos; 13 | uint32_t time_us; 14 | } rotary_event_t; 15 | 16 | int rotary_setup(uint32_t channel, int phaseA, int phaseB, int press, task_handle_t tasknumber); 17 | 18 | bool rotary_getevent(uint32_t channel, rotary_event_t *result); 19 | 20 | bool rotary_has_queued_event(uint32_t channel); 21 | 22 | int rotary_getpos(uint32_t channel); 23 | 24 | int rotary_close(uint32_t channel); 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /app/include/driver/sigma_delta.h: -------------------------------------------------------------------------------- 1 | #ifndef SIGMA_DELTA_APP_H 2 | #define SIGMA_DELTA_APP_H 3 | 4 | #include "eagle_soc.h" 5 | #include "os_type.h" 6 | 7 | void sigma_delta_setup( void ); 8 | void sigma_delta_stop( void ); 9 | void sigma_delta_set_prescale_target( sint16 prescale, sint16 target ); 10 | 11 | #endif 12 | -------------------------------------------------------------------------------- /app/include/driver/switec.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Definitions to access the Switec driver 3 | */ 4 | #ifndef __SWITEC_H__ 5 | #define __SWITEC_H__ 6 | 7 | #include "c_types.h" 8 | 9 | #define SWITEC_CHANNEL_COUNT 3 10 | 11 | int switec_setup(uint32_t channel, int *pin, int max_deg_per_sec, task_handle_t taskNumber ); 12 | 13 | int switec_close(uint32_t channel); 14 | 15 | int switec_moveto(uint32_t channel, int pos); 16 | 17 | int switec_reset(uint32_t channel); 18 | 19 | int switec_getpos(uint32_t channel, int32_t *pos, int32_t *dir, int32_t *target); 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /app/include/fatfs_config.h: -------------------------------------------------------------------------------- 1 | #ifndef __FATFS_CONFIG_H__ 2 | #define __FATFS_CONFIG_H__ 3 | 4 | 5 | // don't redefine the PARTITION type 6 | #ifndef FF_DEFINED 7 | typedef struct { 8 | BYTE pd; /* Physical drive number */ 9 | BYTE pt; /* Partition: 0:Auto detect, 1-4:Forced partition) */ 10 | } PARTITION; 11 | #endif 12 | 13 | // Table to map physical drive & partition to a logical volume. 14 | // The first value is the physical drive and contains the GPIO pin for SS/CS of the SD card (default pin 8) 15 | // The second value is the partition number. 16 | #define NUM_LOGICAL_DRIVES 4 17 | PARTITION VolToPart[NUM_LOGICAL_DRIVES] = { 18 | {8, 1}, /* Logical drive "0:" ==> SS pin 8, 1st partition */ 19 | {8, 2}, /* Logical drive "1:" ==> SS pin 8, 2st partition */ 20 | {8, 3}, /* Logical drive "2:" ==> SS pin 8, 3st partition */ 21 | {8, 4} /* Logical drive "3:" ==> SS pin 8, 4st partition */ 22 | }; 23 | 24 | #endif /* __FATFS_CONFIG_H__ */ 25 | -------------------------------------------------------------------------------- /app/include/lwip/app/espconn_buf.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ringbuf.h 3 | * 4 | * Created on: Apr 22, 2016 5 | * Author: liuhan 6 | */ 7 | 8 | #ifndef _ESPCONN_BUF_H_ 9 | #define _ESPCONN_BUF_H_ 10 | 11 | /* 12 | * ringbuffer.c 13 | * 14 | * Created on: Apr 22, 2016 15 | * Author: liuhan 16 | */ 17 | #include "c_types.h" 18 | 19 | #include "ets_sys.h" 20 | #include "os_type.h" 21 | 22 | typedef struct ringbuf_t { 23 | uint8_t *buf; 24 | uint8_t *head, *tail; 25 | size_t size; 26 | } ringbuf, *ringbuf_t; 27 | 28 | ringbuf_t ringbuf_new(size_t capacity); 29 | 30 | size_t ringbuf_buffer_size(const struct ringbuf_t *rb); 31 | 32 | void ringbuf_reset(ringbuf_t rb); 33 | 34 | void ringbuf_free(ringbuf_t *rb); 35 | 36 | size_t ringbuf_capacity(const struct ringbuf_t *rb); 37 | 38 | size_t ringbuf_bytes_free(const struct ringbuf_t *rb); 39 | 40 | size_t ringbuf_bytes_used(const struct ringbuf_t *rb); 41 | 42 | int ringbuf_is_full(const struct ringbuf_t *rb); 43 | 44 | int ringbuf_is_empty(const struct ringbuf_t *rb); 45 | 46 | const void* ringbuf_tail(const struct ringbuf_t *rb); 47 | 48 | const void* ringbuf_head(const struct ringbuf_t *rb); 49 | 50 | static uint8_t *ringbuf_nextp(ringbuf_t rb, const uint8_t *p); 51 | 52 | size_t ringbuf_findchr(const struct ringbuf_t *rb, int c, size_t offset); 53 | 54 | size_t ringbuf_memset(ringbuf_t dst, int c, size_t len); 55 | 56 | void *ringbuf_memcpy_into(ringbuf_t dst, const void *src, size_t count); 57 | 58 | void *ringbuf_memcpy_from(void *dst, ringbuf_t src, size_t count); 59 | 60 | #endif /* RINGBUF_H_ */ 61 | -------------------------------------------------------------------------------- /app/include/lwip/icmp.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devsaurus/nodemcu-firmware/27e9e6c085aaac8b7e78b7c1d9cd5afe39428ba0/app/include/lwip/icmp.h -------------------------------------------------------------------------------- /app/include/lwip/netif.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devsaurus/nodemcu-firmware/27e9e6c085aaac8b7e78b7c1d9cd5afe39428ba0/app/include/lwip/netif.h -------------------------------------------------------------------------------- /app/include/lwip/puck_def.h: -------------------------------------------------------------------------------- 1 | /* 2 | * puck_def.h 3 | * 4 | * Created on: Jul 22, 2010 5 | * Author: dtoma 6 | */ 7 | 8 | #ifndef PUCK_DEF_H_ 9 | #define PUCK_DEF_H_ 10 | 11 | 12 | 13 | #define INSTRUMENT_PORT 8760 14 | 15 | #define INSTRUMENT_LENGTH 80 16 | 17 | #define MDNS_NAME_LENGTH 68 //68 18 | 19 | char* PUCK_SERVICE = NULL; 20 | //#define PUCK_SERVICE "_Escpressif._tcp.local" 21 | #define DNS_SD_SERVICE "_services._dns-sd._udp.local" 22 | #define SERVICE_DESCRIPTION "PUCK PROTOCOL" 23 | #define PUCK_SERVICE_LENGTH 30 24 | 25 | #define UUID_LEN 16 26 | #define DS_VERS_LEN 2 27 | #define DS_SIZE_LEN 2 28 | #define MAN_ID_LEN 4 29 | #define MAN_MODEL_LEN 2 30 | #define MAN_VERS_LEN 2 31 | #define SER_NUM_LEN 4 32 | #define NAME_LEN 64 33 | #define PUCK_DATASHEET_SIZE 96 34 | 35 | #define UUID_OFFSET 0 36 | #define DS_VERS_OFFSET UUID_LEN + UUID_OFFSET 37 | #define DS_SIZE_OFFSET DS_VERS_LEN + DS_VERS_OFFSET 38 | #define MAN_ID_OFFSET DS_SIZE_LEN + DS_SIZE_OFFSET 39 | #define MAN_MODEL_OFFSET MAN_ID_LEN + MAN_ID_OFFSET 40 | #define MAN_VERS_OFFSET MAN_MODEL_LEN + MAN_MODEL_OFFSET 41 | #define SER_NUM_OFFSET MAN_VERS_LEN + MAN_VERS_OFFSET 42 | #define NAME_OFFSET SER_NUM_LEN + SER_NUM_OFFSET 43 | 44 | #endif /* __PUCK_DEF_H__ */ 45 | -------------------------------------------------------------------------------- /app/include/mbedtls/net.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file net.h 3 | * 4 | * \brief Deprecated header file that includes net_sockets.h 5 | * 6 | * \deprecated Superseded by mbedtls/net_sockets.h 7 | */ 8 | /* 9 | * Copyright (C) 2006-2016, ARM Limited, All Rights Reserved 10 | * SPDX-License-Identifier: Apache-2.0 11 | * 12 | * Licensed under the Apache License, Version 2.0 (the "License"); you may 13 | * not use this file except in compliance with the License. 14 | * You may obtain a copy of the License at 15 | * 16 | * http://www.apache.org/licenses/LICENSE-2.0 17 | * 18 | * Unless required by applicable law or agreed to in writing, software 19 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 20 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 21 | * See the License for the specific language governing permissions and 22 | * limitations under the License. 23 | * 24 | * This file is part of mbed TLS (https://tls.mbed.org) 25 | */ 26 | 27 | #if !defined(MBEDTLS_DEPRECATED_REMOVED) 28 | #include "net_sockets.h" 29 | #if defined(MBEDTLS_DEPRECATED_WARNING) 30 | #warning "Deprecated header file: Superseded by mbedtls/net_sockets.h" 31 | #endif /* MBEDTLS_DEPRECATED_WARNING */ 32 | #endif /* !MBEDTLS_DEPRECATED_REMOVED */ 33 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /app/include/nodemcu_mdns.h: -------------------------------------------------------------------------------- 1 | #ifndef _NODEMCU_MDNS_H 2 | #define _NODEMCU_MDNS_H 3 | 4 | struct nodemcu_mdns_info { 5 | const char *host_name; 6 | const char *host_desc; 7 | const char *service_name; 8 | uint16 service_port; 9 | const char *txt_data[10]; 10 | }; 11 | 12 | void nodemcu_mdns_close(void); 13 | bool nodemcu_mdns_init(struct nodemcu_mdns_info *); 14 | 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /app/include/pm/swtimer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * swtimer.h 3 | * 4 | * Created on: Aug 4, 2017 5 | * Author: anonymous 6 | */ 7 | 8 | #ifndef APP_INCLUDE_PM_SWTIMER_H_ 9 | #define APP_INCLUDE_PM_SWTIMER_H_ 10 | 11 | void swtmr_cb_register(void* timer_cb_ptr, uint8 suspend_policy); 12 | 13 | #define SWTIMER_RESUME 0 //save remaining time 14 | #define SWTIMER_RESTART 1 //use timer_period as remaining time 15 | #define SWTIMER_IMMEDIATE 2 //fire timer immediately after resume 16 | #define SWTIMER_DROP 3 //disarm timer, do not resume 17 | 18 | #if defined(TIMER_SUSPEND_ENABLE) 19 | #define SWTIMER_REG_CB(cb_ptr, suspend_policy) do{ \ 20 | static bool cb_ptr##_registered_flag;\ 21 | if(!cb_ptr##_registered_flag){ \ 22 | cb_ptr##_registered_flag = true; \ 23 | swtmr_cb_register(cb_ptr, suspend_policy);\ 24 | } \ 25 | }while(0); 26 | #else 27 | #define SWTIMER_REG_CB(...) 28 | #endif 29 | 30 | #endif /* APP_INCLUDE_PM_SWTIMER_H_ */ 31 | -------------------------------------------------------------------------------- /app/include/rtc/rtcaccess.h: -------------------------------------------------------------------------------- 1 | #ifndef RTC_ACCESS_H 2 | #define RTC_ACCESS_H 3 | 4 | #include 5 | 6 | #define RTC_MMIO_BASE 0x60000700 7 | #define RTC_USER_MEM_BASE 0x60001200 8 | #define RTC_USER_MEM_NUM_DWORDS 128 9 | #define RTC_TARGET_ADDR 0x04 10 | #define RTC_COUNTER_ADDR 0x1c 11 | 12 | static inline uint32_t rtc_mem_read(uint32_t addr) 13 | { 14 | return ((uint32_t*)RTC_USER_MEM_BASE)[addr]; 15 | } 16 | 17 | static inline void rtc_mem_write(uint32_t addr, uint32_t val) 18 | { 19 | ((uint32_t*)RTC_USER_MEM_BASE)[addr]=val; 20 | } 21 | 22 | static inline uint64_t rtc_make64(uint32_t high, uint32_t low) 23 | { 24 | return (((uint64_t)high)<<32)|low; 25 | } 26 | 27 | static inline uint64_t rtc_mem_read64(uint32_t addr) 28 | { 29 | return rtc_make64(rtc_mem_read(addr+1),rtc_mem_read(addr)); 30 | } 31 | 32 | static inline void rtc_mem_write64(uint32_t addr, uint64_t val) 33 | { 34 | rtc_mem_write(addr+1,val>>32); 35 | rtc_mem_write(addr,val&0xffffffff); 36 | } 37 | 38 | static inline void rtc_memw(void) 39 | { 40 | asm volatile ("memw"); 41 | } 42 | 43 | static inline void rtc_reg_write(uint32_t addr, uint32_t val) 44 | { 45 | rtc_memw(); 46 | addr+=RTC_MMIO_BASE; 47 | *((volatile uint32_t*)addr)=val; 48 | rtc_memw(); 49 | } 50 | 51 | static inline uint32_t rtc_reg_read(uint32_t addr) 52 | { 53 | addr+=RTC_MMIO_BASE; 54 | rtc_memw(); 55 | return *((volatile uint32_t*)addr); 56 | } 57 | 58 | static inline void rtc_reg_write_and_loop(uint32_t addr, uint32_t val) 59 | { 60 | addr+=RTC_MMIO_BASE; 61 | rtc_memw(); 62 | asm("j 1f\n" 63 | ".align 32\n" 64 | "1:\n" 65 | "s32i.n %1,%0,0\n" 66 | "2:\n" 67 | "j 2b\n"::"r"(addr),"r"(val):); 68 | } 69 | 70 | #endif 71 | -------------------------------------------------------------------------------- /app/include/sections.h: -------------------------------------------------------------------------------- 1 | #ifndef _SECTIONS_H_ 2 | #define _SECTIONS_H_ 3 | 4 | #define TEXT_SECTION_ATTR __attribute__((section(".iram0.text"))) 5 | #define RAM_CONST_SECTION_ATTR __attribute((section(".rodata.dram"))) 6 | 7 | #endif 8 | -------------------------------------------------------------------------------- /app/include/sys/Espconn_mem.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ESPRSSIF MIT License 3 | * 4 | * Copyright (c) 2016 5 | * 6 | * Permission is hereby granted for use on ESPRESSIF SYSTEMS ESP8266 only, in which case, 7 | * it is free of charge, to any person obtaining a copy of this software and associated 8 | * documentation files (the "Software"), to deal in the Software without restriction, including 9 | * without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, 10 | * and/or sell copies of the Software, and to permit persons to whom the Software is furnished 11 | * to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all copies or 14 | * substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 18 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 19 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 20 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | * 23 | */ 24 | 25 | #ifndef ESPCONN_MEM_H_ 26 | #define ESPCONN_MEM_H_ 27 | 28 | void *espconn_memzalloc(size_t size); 29 | void espconn_memfree(void *fp); 30 | void *espconn_memcpy(void *dst, const void *src, size_t size); 31 | 32 | #endif 33 | 34 | -------------------------------------------------------------------------------- /app/include/sys/network_80211.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devsaurus/nodemcu-firmware/27e9e6c085aaac8b7e78b7c1d9cd5afe39428ba0/app/include/sys/network_80211.h -------------------------------------------------------------------------------- /app/include/sys/ringbuf.h: -------------------------------------------------------------------------------- 1 | #include "lwip/app/espconn_buf.h" -------------------------------------------------------------------------------- /app/include/task/task.h: -------------------------------------------------------------------------------- 1 | #ifndef _TASK_H_ 2 | #define _TASK_H_ 3 | 4 | #include "ets_sys.h" 5 | #include "osapi.h" 6 | #include "os_type.h" 7 | #include "user_interface.h" 8 | 9 | /* use LOW / MEDIUM / HIGH since it isn't clear from the docs which is higher */ 10 | 11 | #define TASK_PRIORITY_LOW 0 12 | #define TASK_PRIORITY_MEDIUM 1 13 | #define TASK_PRIORITY_HIGH 2 14 | #define TASK_PRIORITY_COUNT 3 15 | 16 | /* 17 | * Signals are a 32-bit number of the form header:14; count:16, priority:2. The header 18 | * is just a fixed fingerprint and the count is allocated serially by the task get_id() 19 | * function. 20 | */ 21 | #define task_post(priority,handle,param) system_os_post(priority, ((handle) | priority), param) 22 | #define task_post_low(handle,param) task_post(TASK_PRIORITY_LOW, handle, param) 23 | #define task_post_medium(handle,param) task_post(TASK_PRIORITY_MEDIUM, handle, param) 24 | #define task_post_high(handle,param) task_post(TASK_PRIORITY_HIGH, handle, param) 25 | 26 | #define task_handle_t os_signal_t 27 | #define task_param_t os_param_t 28 | 29 | typedef void (*task_callback_t)(task_param_t param, uint8 prio); 30 | 31 | bool task_init_handler(uint8 priority, uint8 qlen); 32 | task_handle_t task_get_id(task_callback_t t); 33 | 34 | #endif 35 | 36 | -------------------------------------------------------------------------------- /app/include/u8g2_fonts.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _U8G2_FONTS_H 3 | #define _U8G2_FONTS_H 4 | 5 | #define U8G2_FONT_TABLE_ENTRY(font) 6 | 7 | // *************************************************************************** 8 | // Configure U8glib fonts 9 | // 10 | #ifndef U8G2_FONT_TABLE_EXTRA 11 | // 12 | // Add a U8G2_FONT_TABLE_ENTRY for each font you want to compile into the image 13 | // See https://github.com/olikraus/u8g2/wiki/fntlistall for a complete list of 14 | // available fonts. Drop the 'u8g2_' prefix when you add them here. 15 | #define U8G2_FONT_TABLE \ 16 | U8G2_FONT_TABLE_ENTRY(font_6x10_tf) \ 17 | U8G2_FONT_TABLE_ENTRY(font_unifont_t_symbols) \ 18 | 19 | #else 20 | // 21 | // The font table can be defined in an external file. 22 | #define U8G2_FONT_TABLE \ 23 | U8G2_FONT_TABLE_EXTRA 24 | 25 | #endif 26 | // *************************************************************************** 27 | 28 | 29 | #endif /* _U8G2_FONTS_H */ 30 | -------------------------------------------------------------------------------- /app/include/user_version.h: -------------------------------------------------------------------------------- 1 | #ifndef __USER_VERSION_H__ 2 | #define __USER_VERSION_H__ 3 | 4 | #include "version.h" /* ESP firmware header */ 5 | 6 | #define NODE_VERSION_MAJOR ESP_SDK_VERSION_MAJOR 7 | #define NODE_VERSION_MINOR ESP_SDK_VERSION_MINOR 8 | #define NODE_VERSION_REVISION ESP_SDK_VERSION_PATCH 9 | #define NODE_VERSION_INTERNAL 0 10 | 11 | #define NODE_VERSION_STR(x) #x 12 | #define NODE_VERSION_XSTR(x) NODE_VERSION_STR(x) 13 | 14 | #define NODE_VERSION "NodeMCU " ESP_SDK_VERSION_STRING "." NODE_VERSION_XSTR(NODE_VERSION_INTERNAL) 15 | 16 | #ifndef BUILD_DATE 17 | #define BUILD_DATE "unspecified" 18 | #endif 19 | 20 | extern char SDK_VERSION[]; 21 | 22 | #endif /* __USER_VERSION_H__ */ 23 | -------------------------------------------------------------------------------- /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 | PDIR := ../$(PDIR) 42 | sinclude $(PDIR)Makefile 43 | 44 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /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 | #include 14 | 15 | #define EXIT_FAILURE 1 16 | #define EXIT_SUCCESS 0 17 | 18 | #define __INT_MAX__ 2147483647 19 | #undef __RAND_MAX 20 | #if __INT_MAX__ == 32767 21 | #define __RAND_MAX 32767 22 | #else 23 | #define __RAND_MAX 0x7fffffff 24 | #endif 25 | #define RAND_MAX __RAND_MAX 26 | 27 | #ifndef mem_realloc 28 | #define mem_realloc pvPortRealloc 29 | #endif 30 | #ifndef os_realloc 31 | #define os_realloc(p, s) mem_realloc((p), (s)) 32 | #endif 33 | 34 | #define c_free os_free 35 | #define c_malloc os_malloc 36 | #define c_zalloc os_zalloc 37 | #define c_realloc os_realloc 38 | 39 | #define c_abs abs 40 | #define c_atoi atoi 41 | //#define c_strtod strtod 42 | #define c_strtol strtol 43 | #define c_strtoul strtoul 44 | 45 | // int c_abs(int); 46 | 47 | // void c_exit(int); 48 | 49 | //const char *c_getenv(const char *__string); 50 | 51 | // void *c_malloc(size_t __size); 52 | // void *c_zalloc(size_t __size); 53 | // void c_free(void *); 54 | 55 | // int c_rand(void); 56 | // void c_srand(unsigned int __seed); 57 | 58 | // int c_atoi(const char *__nptr); 59 | double c_strtod(const char *__n, char **__end_PTR); 60 | // // long c_strtol(const char *__n, char **__end_PTR, int __base); 61 | // unsigned long c_strtoul(const char *__n, char **__end_PTR, int __base); 62 | // // long long c_strtoll(const char *__n, char **__end_PTR, int __base); 63 | 64 | #endif /* _C_STDLIB_H_ */ 65 | -------------------------------------------------------------------------------- /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 | 44 | extern size_t c_strlcpy(char *dst, const char *src, size_t siz); 45 | extern size_t c_strlcat(char *dst, const char *src, size_t siz); 46 | extern char *c_strdup(const char *src); 47 | 48 | 49 | #endif /* _C_STRING_H_ */ 50 | -------------------------------------------------------------------------------- /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/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, int limit) { 8 | global_State *g = G(L); 9 | 10 | g->egcmode = mode; 11 | g->memlimit = limit; 12 | } 13 | 14 | -------------------------------------------------------------------------------- /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, int limit); 15 | 16 | #endif 17 | 18 | -------------------------------------------------------------------------------- /app/lua/lflash.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** lflashe.h 3 | ** See Copyright Notice in lua.h 4 | */ 5 | 6 | #if defined(LUA_FLASH_STORE) && !defined(lflash_h) 7 | #define lflash_h 8 | 9 | #include "lobject.h" 10 | #include "lstate.h" 11 | #include "lzio.h" 12 | 13 | #ifdef LUA_NUMBER_INTEGRAL 14 | # define FLASH_SIG_B1 0x02 15 | #else 16 | # define FLASH_SIG_B1 0x00 17 | #endif 18 | #define FLASH_FORMAT_VERSION (1 << 8) 19 | #define FLASH_FORMAT_MASK 0xF00 20 | #ifdef LUA_PACK_TVALUES 21 | #ifdef LUA_NUMBER_INTEGRAL 22 | #error "LUA_PACK_TVALUES is only valid for Floating point builds" 23 | #endif 24 | # define FLASH_SIG_B2 0x04 25 | #else 26 | # define FLASH_SIG_B2 0x00 27 | #endif 28 | # define FLASH_SIG_B2_MASK 0x04 29 | #define FLASH_SIG_ABSOLUTE 0x01 30 | #define FLASH_SIG_IN_PROGRESS 0x08 31 | #define FLASH_SIG (0xfafaa050 | FLASH_FORMAT_VERSION |FLASH_SIG_B2 | FLASH_SIG_B1) 32 | 33 | typedef lu_int32 FlashAddr; 34 | typedef struct { 35 | lu_int32 flash_sig; /* a stabdard fingerprint identifying an LFS image */ 36 | lu_int32 flash_size; /* Size of LFS image */ 37 | FlashAddr mainProto; /* address of main Proto in Proto hierarchy */ 38 | FlashAddr pROhash; /* address of ROstrt hash */ 39 | lu_int32 nROuse; /* number of elements in ROstrt */ 40 | int nROsize; /* size of ROstrt */ 41 | lu_int32 fill1; /* reserved */ 42 | lu_int32 fill2; /* reserved */ 43 | } FlashHeader; 44 | 45 | LUAI_FUNC void luaN_init (lua_State *L); 46 | LUAI_FUNC int luaN_flashSetup (lua_State *L); 47 | LUAI_FUNC int luaN_reload_reboot (lua_State *L); 48 | LUAI_FUNC int luaN_index (lua_State *L); 49 | #endif 50 | 51 | -------------------------------------------------------------------------------- /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 | LUAI_FUNC Proto *luaF_newproto (lua_State *L); 22 | LUAI_FUNC Closure *luaF_newCclosure (lua_State *L, int nelems, Table *e); 23 | LUAI_FUNC Closure *luaF_newLclosure (lua_State *L, int nelems, Table *e); 24 | LUAI_FUNC UpVal *luaF_newupval (lua_State *L); 25 | LUAI_FUNC UpVal *luaF_findupval (lua_State *L, StkId level); 26 | LUAI_FUNC void luaF_close (lua_State *L, StkId level); 27 | LUAI_FUNC void luaF_freeproto (lua_State *L, Proto *f); 28 | LUAI_FUNC void luaF_freeclosure (lua_State *L, Closure *c); 29 | LUAI_FUNC void luaF_freeupval (lua_State *L, UpVal *uv); 30 | LUAI_FUNC const char *luaF_getlocalname (const Proto *func, int local_number, 31 | int pc); 32 | 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /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 | //#ifdef LUA_CROSS_COMPILER 12 | //#include 13 | //#else 14 | //#include "c_stddef.h" 15 | //#endif 16 | 17 | #include "llimits.h" 18 | #include "lua.h" 19 | 20 | #define MEMERRMSG "not enough memory" 21 | 22 | 23 | #define luaM_reallocv(L,b,on,n,e) \ 24 | ((cast(size_t, (n)+1) <= MAX_SIZET/(e)) ? /* +1 to avoid warnings */ \ 25 | luaM_realloc_(L, (b), (on)*(e), (n)*(e)) : \ 26 | luaM_toobig(L)) 27 | 28 | #define luaM_freemem(L, b, s) luaM_realloc_(L, (b), (s), 0) 29 | #define luaM_free(L, b) luaM_realloc_(L, (b), sizeof(*(b)), 0) 30 | #define luaM_freearray(L, b, n, t) luaM_reallocv(L, (b), n, 0, sizeof(t)) 31 | 32 | #define luaM_malloc(L,t) luaM_realloc_(L, NULL, 0, (t)) 33 | #define luaM_new(L,t) cast(t *, luaM_malloc(L, sizeof(t))) 34 | #define luaM_newvector(L,n,t) \ 35 | cast(t *, luaM_reallocv(L, NULL, 0, n, sizeof(t))) 36 | 37 | #define luaM_growvector(L,v,nelems,size,t,limit,e) \ 38 | if ((nelems)+1 > (size)) \ 39 | ((v)=cast(t *, luaM_growaux_(L,v,&(size),sizeof(t),limit,e))) 40 | 41 | #define luaM_reallocvector(L, v,oldn,n,t) \ 42 | ((v)=cast(t *, luaM_reallocv(L, v, oldn, n, sizeof(t)))) 43 | 44 | 45 | LUAI_FUNC void *luaM_realloc_ (lua_State *L, void *block, size_t oldsize, 46 | size_t size); 47 | LUAI_FUNC void *luaM_toobig (lua_State *L); 48 | LUAI_FUNC void *luaM_growaux_ (lua_State *L, void *block, int *size, 49 | size_t size_elem, int limit, 50 | const char *errormsg); 51 | 52 | #endif 53 | 54 | -------------------------------------------------------------------------------- /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 LUA_OPTIMIZE_MEMORY >=1 19 | #define LUA_REG_TYPE luaR_entry 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 | #define LROT_TABENTRY(n,t) {LSTRKEY(#n), LRO_ROVAL(t)} 42 | #define LROT_FUNCENTRY(n,f) {LSTRKEY(#n), LRO_FUNCVAL(f)} 43 | #define LROT_NUMENTRY(n,x) {LSTRKEY(#n), LRO_NUMVAL(x)} 44 | #define LROT_END {LNILKEY, LNILVAL} 45 | 46 | #endif /* lrodefs_h */ 47 | 48 | -------------------------------------------------------------------------------- /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)+(testbit(getmarked(s), READONLYBIT) ? 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_newliteral(L, s) (luaS_newlstr(L, "" s, \ 22 | (sizeof(s)/sizeof(char))-1)) 23 | 24 | LUAI_FUNC void luaS_resize (lua_State *L, int newsize); 25 | LUAI_FUNC Udata *luaS_newudata (lua_State *L, size_t s, Table *e); 26 | LUAI_FUNC TString *luaS_newlstr (lua_State *L, const char *str, size_t l); 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /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 | LUAI_FUNC int luaH_isdummy (Node *n); 38 | 39 | #if defined(LUA_DEBUG) 40 | LUAI_FUNC Node *luaH_mainposition (const Table *t, const TValue *key); 41 | #endif 42 | #endif 43 | -------------------------------------------------------------------------------- /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 | #include "lrotable.h" 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 | #define gfasttm(g,et,e) ((et) == NULL ? NULL : \ 40 | (!luaR_isrotable(et) && ((et)->flags & (1u<<(e)))) ? NULL : luaT_gettm(et, e, (g)->tmname[e])) 41 | 42 | #define fasttm(l,et,e) gfasttm(G(l), et, e) 43 | 44 | LUAI_DATA const char *const luaT_typenames[]; 45 | 46 | 47 | LUAI_FUNC const TValue *luaT_gettm (Table *events, TMS event, TString *ename); 48 | LUAI_FUNC const TValue *luaT_gettmbyobj (lua_State *L, const TValue *o, 49 | TMS event); 50 | LUAI_FUNC void luaT_init (lua_State *L); 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /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/api/netbuf.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devsaurus/nodemcu-firmware/27e9e6c085aaac8b7e78b7c1d9cd5afe39428ba0/app/lwip/api/netbuf.c -------------------------------------------------------------------------------- /app/lwip/api/tcpip.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devsaurus/nodemcu-firmware/27e9e6c085aaac8b7e78b7c1d9cd5afe39428ba0/app/lwip/api/tcpip.c -------------------------------------------------------------------------------- /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/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/core/ipv4/icmp.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devsaurus/nodemcu-firmware/27e9e6c085aaac8b7e78b7c1d9cd5afe39428ba0/app/lwip/core/ipv4/icmp.c -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/mbedtls/app/Espconn_mem.c: -------------------------------------------------------------------------------- 1 | #include "c_types.h" 2 | #include "mem.h" 3 | #include "user_interface.h" 4 | 5 | void *espconn_memzalloc(size_t size, char* file, int line) 6 | { 7 | void *mp = NULL; 8 | if ((mp = (void*)os_malloc(size)) == NULL){ 9 | 10 | } else{ 11 | //os_printf("%s %d %p %d\n",file, line, mp, size); 12 | os_memset(mp, 0, size); 13 | } 14 | return mp; 15 | } 16 | 17 | void espconn_memfree(void *fp, char* file, int line) 18 | { 19 | //os_printf("%s %d %p\n",file, line, fp); 20 | os_free(fp); 21 | fp = NULL; 22 | } 23 | 24 | void *espconn_memcpy(void *dst, const void *src, size_t size, char *file, int line) 25 | { 26 | char *psrc = NULL; 27 | char *pdst = NULL; 28 | 29 | if(NULL == dst || NULL == src) 30 | { 31 | return NULL; 32 | } 33 | //os_printf("%s %d %p %p %d\n",file, line, dst, src, size); 34 | if((src < dst) && (char *)src + size > (char *)dst) 35 | { 36 | psrc = (char *)src + size - 1; 37 | pdst = (char *)dst + size - 1; 38 | while(size--) 39 | { 40 | *pdst-- = *psrc--; 41 | } 42 | } 43 | else 44 | { 45 | psrc = (char *)src; 46 | pdst = (char *)dst; 47 | while(size--) 48 | { 49 | *pdst++ = *psrc++; 50 | } 51 | } 52 | 53 | return dst; 54 | 55 | } 56 | 57 | void *espconn_memcalloc(size_t count, size_t size) 58 | { 59 | void *cp = NULL; 60 | cp = espconn_memzalloc(count * size, __FILE__, __LINE__); 61 | return cp; 62 | } 63 | 64 | void espconn_memFree(void *fp) 65 | { 66 | espconn_memfree(fp, __FILE__, __LINE__); 67 | } 68 | 69 | void *espconn_memCpy(void *dst, const void *src, size_t size) 70 | { 71 | return espconn_memcpy(dst, src, size, __FILE__, __LINE__); 72 | } 73 | 74 | -------------------------------------------------------------------------------- /app/mbedtls/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 = libapp.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/mbedtls/library/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 = liblibrary.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/mbedtls/library/version.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Version information 3 | * 4 | * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved 5 | * SPDX-License-Identifier: Apache-2.0 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may 8 | * not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 15 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * 19 | * This file is part of mbed TLS (https://tls.mbed.org) 20 | */ 21 | 22 | #if !defined(MBEDTLS_CONFIG_FILE) 23 | #include "mbedtls/config.h" 24 | #else 25 | #include MBEDTLS_CONFIG_FILE 26 | #endif 27 | 28 | #if defined(MBEDTLS_VERSION_C) 29 | 30 | #include "mbedtls/version.h" 31 | #include 32 | 33 | unsigned int mbedtls_version_get_number() 34 | { 35 | return( MBEDTLS_VERSION_NUMBER ); 36 | } 37 | 38 | void mbedtls_version_get_string( char *string ) 39 | { 40 | memcpy( string, MBEDTLS_VERSION_STRING, 41 | sizeof( MBEDTLS_VERSION_STRING ) ); 42 | } 43 | 44 | void mbedtls_version_get_string_full( char *string ) 45 | { 46 | memcpy( string, MBEDTLS_VERSION_STRING_FULL, 47 | sizeof( MBEDTLS_VERSION_STRING_FULL ) ); 48 | } 49 | 50 | #endif /* MBEDTLS_VERSION_C */ 51 | -------------------------------------------------------------------------------- /app/mbedtls/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 | 16 | GEN_LIBS = libplatform.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/modules/.gitignore: -------------------------------------------------------------------------------- 1 | server-ca.crt.h 2 | -------------------------------------------------------------------------------- /app/modules/color_utils.h: -------------------------------------------------------------------------------- 1 | #ifndef APP_MODULES_COLOR_UTILS_H_ 2 | #define APP_MODULES_COLOR_UTILS_H_ 3 | 4 | #include "module.h" 5 | #include "lauxlib.h" 6 | #include "lmem.h" 7 | #include "platform.h" 8 | #include "c_stdlib.h" 9 | #include "c_math.h" 10 | #include "c_string.h" 11 | #include "user_interface.h" 12 | #include "osapi.h" 13 | 14 | /** 15 | * Convert hsv to grb 16 | * hue is 0-360, sat and val are 0-255 17 | */ 18 | uint32_t hsv2grb(uint16_t hue, uint8_t sat, uint8_t val); 19 | /** 20 | * Convert hsv to grbw 21 | * hue is 0-360, sat and val are 0-255 22 | */ 23 | uint32_t hsv2grbw(uint16_t hue, uint8_t sat, uint8_t val); 24 | /** 25 | * Convert grb to hsv 26 | * g, r, b are 0-255 27 | */ 28 | uint32_t grb2hsv(uint8_t g, uint8_t r, uint8_t b); 29 | 30 | 31 | /** 32 | * The color wheel function provides colors from r -> g -> b -> r. 33 | * They are fully saturated and with full brightness. 34 | * degree is from 0-360 35 | */ 36 | uint32_t color_wheel(uint16_t degree); 37 | 38 | 39 | #endif /* APP_MODULES_COLOR_UTILS_H_ */ 40 | -------------------------------------------------------------------------------- /app/modules/eus/enduser_setup.html.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devsaurus/nodemcu-firmware/27e9e6c085aaac8b7e78b7c1d9cd5afe39428ba0/app/modules/eus/enduser_setup.html.gz -------------------------------------------------------------------------------- /app/modules/eus/prepare.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Uses zopfli for better gzip compression 4 | # sudo apt-get install zopfli 5 | zopfli --gzip ./enduser_setup.html 6 | xxd -i ./enduser_setup.html.gz | sed 's/unsigned char/static const char/; s/__enduser_setup_html_gz/http_html_backup/' > http_html_backup.def 7 | 8 | -------------------------------------------------------------------------------- /app/modules/gdbstub.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This module, when enabled with the LUA_USE_MODULES_GDBSTUB define causes 3 | * the gdbstub code to be included and enabled to handle all fatal exceptions. 4 | * This allows you to use the lx106 gdb to catch the exception and then poke 5 | * around. You can continue from a break, but attempting to continue from an 6 | * exception usually fails. 7 | * 8 | * This should not be included in production builds as any exception will 9 | * put the nodemcu into a state where it is waiting for serial input and it has 10 | * the watchdog disabled. Good for debugging. Bad for unattended operation! 11 | * 12 | * See the docs for more information. 13 | * 14 | * Philip Gladstone, N1DQ 15 | */ 16 | 17 | #include "module.h" 18 | #include "lauxlib.h" 19 | #include "platform.h" 20 | #include "c_types.h" 21 | #include "user_interface.h" 22 | #include "../esp-gdbstub/gdbstub.h" 23 | 24 | // gdbstub.brk() just executes a break instruction. Enters gdb 25 | static int lgdbstub_break(lua_State *L) { 26 | asm("break 0,0" ::); 27 | return 0; 28 | } 29 | 30 | // gdbstub.gdboutput(1) switches the output to gdb format so that gdb can display it 31 | static int lgdbstub_gdboutput(lua_State *L) { 32 | gdbstub_redirect_output(lua_toboolean(L, 1)); 33 | return 0; 34 | } 35 | 36 | static int lgdbstub_open(lua_State *L) { 37 | gdbstub_init(); 38 | return 0; 39 | } 40 | 41 | // Module function map 42 | static const LUA_REG_TYPE gdbstub_map[] = { 43 | { LSTRKEY( "brk" ), LFUNCVAL( lgdbstub_break ) }, 44 | { LSTRKEY( "gdboutput" ), LFUNCVAL( lgdbstub_gdboutput) }, 45 | { LSTRKEY( "open" ), LFUNCVAL( lgdbstub_open) }, 46 | { LNILKEY, LNILVAL } 47 | }; 48 | 49 | NODEMCU_MODULE(GDBSTUB, "gdbstub", gdbstub_map, NULL); 50 | -------------------------------------------------------------------------------- /app/modules/rtcmem.c: -------------------------------------------------------------------------------- 1 | // Module for RTC user memory access 2 | 3 | #include "module.h" 4 | #include "lauxlib.h" 5 | #include "rtc/rtcaccess.h" 6 | 7 | static int rtcmem_read32 (lua_State *L) 8 | { 9 | int idx = luaL_checknumber (L, 1); 10 | int n = 1; 11 | if (lua_isnumber (L, 2)) 12 | n = lua_tonumber (L, 2); 13 | 14 | if (!lua_checkstack (L, n)) 15 | return 0; 16 | 17 | int ret = 0; 18 | while (n > 0 && idx >= 0 && idx < RTC_USER_MEM_NUM_DWORDS) 19 | { 20 | lua_pushinteger (L, rtc_mem_read (idx++)); 21 | --n; 22 | ++ret; 23 | } 24 | return ret; 25 | } 26 | 27 | 28 | static int rtcmem_write32 (lua_State *L) 29 | { 30 | int idx = luaL_checknumber (L, 1); 31 | int n = lua_gettop (L) - 1; 32 | luaL_argcheck ( 33 | L, idx + n <= RTC_USER_MEM_NUM_DWORDS, 1, "RTC mem would overrun"); 34 | int src = 2; 35 | while (n-- > 0) 36 | { 37 | rtc_mem_write (idx++, lua_tonumber (L, src++)); 38 | } 39 | return 0; 40 | } 41 | 42 | 43 | // Module function map 44 | static const LUA_REG_TYPE rtcmem_map[] = { 45 | { LSTRKEY("read32"), LFUNCVAL(rtcmem_read32) }, 46 | { LSTRKEY("write32"), LFUNCVAL(rtcmem_write32) }, 47 | { LNILKEY, LNILVAL } 48 | }; 49 | 50 | NODEMCU_MODULE(RTCMEM, "rtcmem", rtcmem_map, NULL); 51 | -------------------------------------------------------------------------------- /app/modules/wifi_common.c: -------------------------------------------------------------------------------- 1 | #include "wifi_common.h" 2 | 3 | void wifi_add_int_field(lua_State* L, char* name, lua_Integer integer) 4 | { 5 | lua_pushinteger(L, integer); 6 | lua_setfield(L, -2, name); 7 | } 8 | void wifi_add_sprintf_field(lua_State* L, char* name, char* string, ...) 9 | { 10 | char buffer[256]; 11 | va_list arglist; 12 | va_start( arglist, string ); 13 | c_vsprintf( buffer, string, arglist ); 14 | va_end( arglist ); 15 | lua_pushstring(L, buffer); 16 | lua_setfield(L, -2, name); 17 | } 18 | -------------------------------------------------------------------------------- /app/modules/ws2812.h: -------------------------------------------------------------------------------- 1 | #ifndef APP_MODULES_WS2812_H_ 2 | #define APP_MODULES_WS2812_H_ 3 | 4 | #include "module.h" 5 | #include "lauxlib.h" 6 | #include "lmem.h" 7 | #include "platform.h" 8 | #include "c_stdlib.h" 9 | #include "c_math.h" 10 | #include "c_string.h" 11 | #include "user_interface.h" 12 | #include "driver/uart.h" 13 | #include "osapi.h" 14 | 15 | #define FADE_IN 1 16 | #define FADE_OUT 0 17 | #define SHIFT_LOGICAL 0 18 | #define SHIFT_CIRCULAR 1 19 | 20 | 21 | typedef struct { 22 | int size; 23 | uint8_t colorsPerLed; 24 | uint8_t values[0]; 25 | } ws2812_buffer; 26 | 27 | 28 | void ICACHE_RAM_ATTR ws2812_write_data(const uint8_t *pixels, uint32_t length, const uint8_t *pixels2, uint32_t length2); 29 | int ws2812_buffer_shift(ws2812_buffer * buffer, int shiftValue, unsigned shift_type, int pos_start, int pos_end); 30 | int ws2812_buffer_fill(ws2812_buffer * buffer, int * colors); 31 | 32 | #endif /* APP_MODULES_WS2812_H_ */ 33 | -------------------------------------------------------------------------------- /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 = libmqtt.a 16 | endif 17 | 18 | STD_CFLAGS=-std=gnu11 -Wimplicit 19 | 20 | ############################################################# 21 | # Configuration i.e. compile options etc. 22 | # Target specific stuff (defines etc.) goes in here! 23 | # Generally values applying to a tree are captured in the 24 | # makefile at its root level - these are then overridden 25 | # for a subtree within the makefile rooted therein 26 | # 27 | #DEFINES += 28 | 29 | ############################################################# 30 | # Recursion Magic - Don't touch this!! 31 | # 32 | # Each subtree potentially has an include directory 33 | # corresponding to the common APIs applicable to modules 34 | # rooted at that subtree. Accordingly, the INCLUDE PATH 35 | # of a module can only contain the include directories up 36 | # its parent path, and not its siblings 37 | # 38 | # Required for each makefile to inherit from the parent 39 | # 40 | 41 | INCLUDES := $(INCLUDES) -I $(PDIR)include 42 | INCLUDES += -I ./ 43 | INCLUDES += -I ../libc 44 | PDIR := ../$(PDIR) 45 | sinclude $(PDIR)Makefile 46 | 47 | -------------------------------------------------------------------------------- /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/net/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 = libnodemcu_net.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/pcm/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 = libpcm.a 16 | endif 17 | 18 | STD_CFLAGS=-std=gnu11 -Wimplicit 19 | 20 | ############################################################# 21 | # Configuration i.e. compile options etc. 22 | # Target specific stuff (defines etc.) goes in here! 23 | # Generally values applying to a tree are captured in the 24 | # makefile at its root level - these are then overridden 25 | # for a subtree within the makefile rooted therein 26 | # 27 | #DEFINES += 28 | 29 | ############################################################# 30 | # Recursion Magic - Don't touch this!! 31 | # 32 | # Each subtree potentially has an include directory 33 | # corresponding to the common APIs applicable to modules 34 | # rooted at that subtree. Accordingly, the INCLUDE PATH 35 | # of a module can only contain the include directories up 36 | # its parent path, and not its siblings 37 | # 38 | # Required for each makefile to inherit from the parent 39 | # 40 | 41 | INCLUDES := $(INCLUDES) -I $(PDIR)include 42 | INCLUDES += -I ./ 43 | INCLUDES += -I ../lua 44 | INCLUDES += -I ../libc 45 | INCLUDES += -I ../platform 46 | PDIR := ../$(PDIR) 47 | sinclude $(PDIR)Makefile 48 | -------------------------------------------------------------------------------- /app/pcm/pcm_drv.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _PCM_DRV_H 3 | #define _PCM_DRV_H 4 | 5 | 6 | extern const drv_t pcm_drv_sd; 7 | 8 | 9 | #endif /* _PCM_DRV_H */ 10 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /app/platform/hw_timer.h: -------------------------------------------------------------------------------- 1 | #ifndef _HW_TIMER_H 2 | #define _HW_TIMER_H 3 | 4 | #if APB_CLK_FREQ == 80 * 1000000 5 | // 80 MHz divided by 16 is 5 MHz count rate. 6 | #define US_TO_RTC_TIMER_TICKS(t) ((t) * 5) 7 | #else 8 | #define US_TO_RTC_TIMER_TICKS(t) \ 9 | ((t) ? \ 10 | (((t) > 0x35A) ? \ 11 | (((t)>>2) * ((APB_CLK_FREQ>>4)/250000) + ((t)&0x3) * ((APB_CLK_FREQ>>4)/1000000)) : \ 12 | (((t) *(APB_CLK_FREQ>>4)) / 1000000)) : \ 13 | 0) 14 | #endif 15 | 16 | typedef enum { 17 | FRC1_SOURCE = 0, 18 | NMI_SOURCE = 1, 19 | } FRC1_TIMER_SOURCE_TYPE; 20 | 21 | bool ICACHE_RAM_ATTR platform_hw_timer_arm_ticks(os_param_t owner, uint32_t ticks); 22 | 23 | bool ICACHE_RAM_ATTR platform_hw_timer_arm_us(os_param_t owner, uint32_t microseconds); 24 | 25 | bool platform_hw_timer_set_func(os_param_t owner, void (* user_hw_timer_cb_set)(os_param_t), os_param_t arg); 26 | 27 | bool platform_hw_timer_init(os_param_t owner, FRC1_TIMER_SOURCE_TYPE source_type, bool autoload); 28 | 29 | bool ICACHE_RAM_ATTR platform_hw_timer_close(os_param_t owner); 30 | 31 | uint32_t ICACHE_RAM_ATTR platform_hw_timer_get_delay_ticks(os_param_t owner); 32 | 33 | #endif 34 | 35 | -------------------------------------------------------------------------------- /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 | #define GPIO_PIN_NUM_INV 17 11 | 12 | extern uint32_t pin_mux[GPIO_PIN_NUM]; 13 | extern uint8_t pin_num[GPIO_PIN_NUM]; 14 | extern uint8_t pin_func[GPIO_PIN_NUM]; 15 | #ifdef GPIO_INTERRUPT_ENABLE 16 | extern uint8_t pin_num_inv[GPIO_PIN_NUM_INV]; 17 | extern uint8_t pin_int_type[GPIO_PIN_NUM]; 18 | typedef struct { 19 | // These values have 15 bits of count, and the top bit 20 | // in 'seen' is set if we are missing a task post 21 | volatile uint16_t seen; 22 | volatile uint16_t reported; 23 | } GPIO_INT_COUNTER; 24 | extern GPIO_INT_COUNTER pin_counter[GPIO_PIN_NUM]; 25 | #endif 26 | 27 | void get_pin_map(void); 28 | 29 | #endif // #ifndef __PIN_MAP_H__ 30 | -------------------------------------------------------------------------------- /app/platform/sdcard.h: -------------------------------------------------------------------------------- 1 | #ifndef _SDCARD_H 2 | #define _SDCARD_H 3 | 4 | #include "c_types.h" 5 | 6 | int platform_sdcard_init( uint8_t spi_no, uint8_t ss_pin ); 7 | int platform_sdcard_status( void ); 8 | int platform_sdcard_error( void ); 9 | int platform_sdcard_type( void ); 10 | int platform_sdcard_read_block( uint8_t ss_pin, uint32_t block, uint8_t *dst ); 11 | int platform_sdcard_read_blocks( uint8_t ss_pin, uint32_t block, size_t num, uint8_t *dst ); 12 | int platform_sdcard_read_csd( uint8_t ss_pin, uint8_t *csd ); 13 | int platform_sdcard_read_cid( uint8_t ss_pin, uint8_t *cid ); 14 | int platform_sdcard_write_block( uint8_t ss_pin, uint32_t block, const uint8_t *src ); 15 | int platform_sdcard_write_blocks( uint8_t ss_pin, uint32_t block, size_t num, const uint8_t *src ); 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /app/platform/u8x8_nodemcu_hal.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _U8X8_NODEMCU_HAL_H 3 | #define _U8X8_NODEMCU_HAL_H 4 | 5 | #include "u8g2.h" 6 | 7 | 8 | // extend standard u8g2_t struct with info that's needed in the communication callbacks 9 | typedef struct { 10 | u8g2_t u8g2; 11 | void *hal; 12 | 13 | // elements for the overlay display driver 14 | struct { 15 | u8x8_msg_cb hardware_display_cb, template_display_cb; 16 | int rfb_cb_ref; 17 | uint8_t fb_update_ongoing; 18 | } overlay; 19 | } u8g2_nodemcu_t; 20 | 21 | 22 | uint8_t u8x8_gpio_and_delay_nodemcu(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr); 23 | uint8_t u8x8_byte_nodemcu_i2c(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr); 24 | uint8_t u8x8_byte_nodemcu_spi(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr); 25 | 26 | #endif /* _U8X8_NODEMCU_HAL_H */ 27 | -------------------------------------------------------------------------------- /app/platform/ucg_nodemcu_hal.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _UCG_NODEMCU_HAL_H 3 | #define _UCG_NODEMCU_HAL_H 4 | 5 | #include "ucg.h" 6 | 7 | 8 | // extend standard ucg_t struct with info that's needed in the communication callbacks 9 | typedef struct { 10 | ucg_t ucg; 11 | void *hal; 12 | } ucg_nodemcu_t; 13 | 14 | 15 | int16_t ucg_com_nodemcu_hw_spi(ucg_t *ucg, int16_t msg, uint16_t arg, uint8_t *data); 16 | 17 | #endif /* _UCG_NODEMCU_HAL_H */ 18 | -------------------------------------------------------------------------------- /app/sjson/Makefile: -------------------------------------------------------------------------------- 1 | ############################################################# 2 | # Required variables for each makefile 3 | # Discard this section from all parent makefiles 4 | # Expected variables (with automatic defaults): 5 | # CSRCS (all "C" files in the dir) 6 | # SUBDIRS (all subdirs with a Makefile) 7 | # GEN_LIBS - list of libs to be generated () 8 | # GEN_IMAGES - list of images to be generated () 9 | # COMPONENTS_xxx - a list of libs/objs in the form 10 | # subdir/lib to be extracted and rolled up into 11 | # a generated lib/image xxx.a () 12 | # 13 | ifndef PDIR 14 | GEN_LIBS = libsjson.a 15 | endif 16 | 17 | STD_CFLAGS=-std=gnu11 -Wimplicit 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 += -include memcompat.h -include json_config.h 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 43 | INCLUDES += -I ../include 44 | INCLUDES += -I ../../include 45 | PDIR := ../$(PDIR) 46 | sinclude $(PDIR)Makefile 47 | 48 | -------------------------------------------------------------------------------- /app/sjson/json_config.h: -------------------------------------------------------------------------------- 1 | #ifndef __JSON_CONFIG_H__ 2 | #define __JSON_CONFIG_H__ 3 | 4 | #define JSONSL_STATE_USER_FIELDS int lua_object_ref; int used_count; 5 | #define JSONSL_NO_JPR 6 | 7 | #endif 8 | -------------------------------------------------------------------------------- /app/sjson/memcompat.h: -------------------------------------------------------------------------------- 1 | #ifndef __MEMCOMPAT_H__ 2 | #define __MEMCOMPAT_H__ 3 | 4 | #include "c_types.h" 5 | #include "mem.h" 6 | 7 | static inline void *malloc(size_t sz) { return os_malloc(sz); } 8 | static inline void free(void *p) { return os_free(p); } 9 | static inline void *calloc(size_t n, size_t sz) { return os_zalloc(n*sz); } 10 | 11 | #endif 12 | -------------------------------------------------------------------------------- /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/spiffs/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2013-2017 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/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 += -Dprintf=c_printf 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/docs/IMPLEMENTING: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devsaurus/nodemcu-firmware/27e9e6c085aaac8b7e78b7c1d9cd5afe39428ba0/app/spiffs/docs/IMPLEMENTING -------------------------------------------------------------------------------- /app/spiffs/docs/TODO: -------------------------------------------------------------------------------- 1 | * When mending lost pages, also see if they fit into length specified in object index header 2 | 3 | SPIFFS2 thoughts 4 | 5 | * Instead of exact object id:s in the object lookup tables, use a hash of span index and object id. 6 | Eg. object id xor:ed with bit-reversed span index. 7 | This should decrease number of actual pages that needs to be visited when looking thru the obj lut. 8 | 9 | * Logical number of each block. When moving stuff in a garbage collected page, the free 10 | page is assigned the same number as the garbage collected. Thus, object index pages do not have to 11 | be rewritten. 12 | 13 | * Steal one page, use as a bit parity page. When starting an fs modification operation, write one bit 14 | as zero. When ending, write another bit as zero. On mount, if number of zeroes in page is uneven, a 15 | check is automatically run. -------------------------------------------------------------------------------- /app/spiffs/myspiffs.h: -------------------------------------------------------------------------------- 1 | #include "spiffs.h" 2 | bool myspiffs_mount(); 3 | void myspiffs_unmount(); 4 | int myspiffs_open(const char *name, int flags); 5 | int myspiffs_close( int fd ); 6 | size_t myspiffs_write( int fd, const void* ptr, size_t len ); 7 | size_t myspiffs_read( int fd, void* ptr, size_t len); 8 | int myspiffs_lseek( int fd, int off, int whence ); 9 | int myspiffs_eof( int fd ); 10 | int myspiffs_tell( int fd ); 11 | int myspiffs_getc( int fd ); 12 | int myspiffs_ungetc( int c, int fd ); 13 | int myspiffs_flush( int fd ); 14 | int myspiffs_error( int fd ); 15 | void myspiffs_clearerr( int fd ); 16 | int myspiffs_check( void ); 17 | int myspiffs_rename( const char *old, const char *newname ); 18 | size_t myspiffs_size( int fd ); 19 | int myspiffs_format (void); 20 | 21 | -------------------------------------------------------------------------------- /app/spiffs/nodemcu_spiffs.h: -------------------------------------------------------------------------------- 1 | #ifndef _NODEMCU_SPIFFS_H 2 | #define _NODEMCU_SPIFFS_H 3 | 4 | #ifndef NODEMCU_SPIFFS_NO_INCLUDE 5 | #include "c_stdint.h" 6 | #include "c_stddef.h" 7 | #include "c_stdio.h" 8 | #include "user_interface.h" 9 | typedef uint32_t intptr_t; 10 | #endif 11 | 12 | // Turn off stats 13 | #define SPIFFS_CACHE_STATS 0 14 | #define SPIFFS_GC_STATS 0 15 | 16 | // Needs to align stuff 17 | #define SPIFFS_ALIGNED_OBJECT_INDEX_TABLES 1 18 | 19 | // Enable magic so we can find the file system (but not yet) 20 | #define SPIFFS_USE_MAGIC 1 21 | #define SPIFFS_USE_MAGIC_LENGTH 1 22 | 23 | // Reduce the chance of returning disk full 24 | #define SPIFFS_GC_MAX_RUNS 256 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /app/sqlite3/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 = libsqlite3.a 16 | endif 17 | 18 | STD_CFLAGS= -std=gnu11 -Wimplicit -Wno-undef -include config_ext.h 19 | 20 | ############################################################# 21 | # Configuration i.e. compile options etc. 22 | # Target specific stuff (defines etc.) goes in here! 23 | # Generally values applying to a tree are captured in the 24 | # makefile at its root level - these are then overridden 25 | # for a subtree within the makefile rooted therein 26 | # 27 | #DEFINES += 28 | 29 | ############################################################# 30 | # Recursion Magic - Don't touch this!! 31 | # 32 | # Each subtree potentially has an include directory 33 | # corresponding to the common APIs applicable to modules 34 | # rooted at that subtree. Accordingly, the INCLUDE PATH 35 | # of a module can only contain the include directories up 36 | # its parent path, and not its siblings 37 | # 38 | # Required for each makefile to inherit from the parent 39 | # 40 | 41 | INCLUDES := $(INCLUDES) -I $(PDIR)include 42 | INCLUDES += -I ./ 43 | INCLUDES += -I ../libc 44 | INCLUDES += -I ../platform 45 | PDIR := ../$(PDIR) 46 | sinclude $(PDIR)Makefile 47 | -------------------------------------------------------------------------------- /app/task/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 = libtask.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/tsl2561/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 = libtsl2561.a 16 | endif 17 | 18 | STD_CFLAGS=-std=gnu11 -Wimplicit 19 | 20 | ############################################################# 21 | # Configuration i.e. compile options etc. 22 | # Target specific stuff (defines etc.) goes in here! 23 | # Generally values applying to a tree are captured in the 24 | # makefile at its root level - these are then overridden 25 | # for a subtree within the makefile rooted therein 26 | # 27 | #DEFINES += 28 | 29 | ############################################################# 30 | # Recursion Magic - Don't touch this!! 31 | # 32 | # Each subtree potentially has an include directory 33 | # corresponding to the common APIs applicable to modules 34 | # rooted at that subtree. Accordingly, the INCLUDE PATH 35 | # of a module can only contain the include directories up 36 | # its parent path, and not its siblings 37 | # 38 | # Required for each makefile to inherit from the parent 39 | # 40 | 41 | INCLUDES := $(INCLUDES) -I $(PDIR)include 42 | INCLUDES += -I ./ 43 | INCLUDES += -I ./include 44 | INCLUDES += -I ../include 45 | INCLUDES += -I ../../include 46 | INCLUDES += -I ../libc 47 | INCLUDES += -I ../platform 48 | PDIR := ../$(PDIR) 49 | sinclude $(PDIR)Makefile 50 | 51 | -------------------------------------------------------------------------------- /app/ucglib/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 = libucglib.a 16 | endif 17 | 18 | STD_CFLAGS=-std=gnu11 -Wimplicit 19 | 20 | ############################################################# 21 | # Configuration i.e. compile options etc. 22 | # Target specific stuff (defines etc.) goes in here! 23 | # Generally values applying to a tree are captured in the 24 | # makefile at its root level - these are then overridden 25 | # for a subtree within the makefile rooted therein 26 | # 27 | DEFINES += -DUSE_PIN_LIST 28 | 29 | ############################################################# 30 | # Recursion Magic - Don't touch this!! 31 | # 32 | # Each subtree potentially has an include directory 33 | # corresponding to the common APIs applicable to modules 34 | # rooted at that subtree. Accordingly, the INCLUDE PATH 35 | # of a module can only contain the include directories up 36 | # its parent path, and not its siblings 37 | # 38 | # Required for each makefile to inherit from the parent 39 | # 40 | 41 | CSRCS := $(wildcard ucg/src/clib/*.c *.c) 42 | 43 | INCLUDES := $(INCLUDES) -I $(PDIR)include 44 | INCLUDES += -I ucg/src/clib 45 | INCLUDES += -I ./ 46 | INCLUDES += -I ../libc 47 | PDIR := ../$(PDIR) 48 | sinclude $(PDIR)Makefile 49 | 50 | -------------------------------------------------------------------------------- /app/user/user_exceptions.h: -------------------------------------------------------------------------------- 1 | #include "sections.h" 2 | #include "rom.h" 3 | #include 4 | 5 | void load_non_32_wide_handler (struct exception_frame *ef, uint32_t cause) TEXT_SECTION_ATTR; 6 | void __real__xtos_set_exception_handler (uint32_t cause, exception_handler_fn fn); 7 | -------------------------------------------------------------------------------- /app/uzlib/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 = libuzlib.a 16 | SUBDIRS = host 17 | endif 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 ../libc 43 | PDIR := ../$(PDIR) 44 | sinclude $(PDIR)Makefile 45 | 46 | -------------------------------------------------------------------------------- /app/uzlib/README.md: -------------------------------------------------------------------------------- 1 | uzlib - Deflate/Zlib-compatible LZ77 compression library 2 | ====================================================== 3 | 4 | This is a heavily modified and cut down version of Paul Sokolovsky's 5 | uzlib library. This library has exported routines which 6 | 7 | - Can compress data to a Deflate-compatible bitstream, albeit with lower 8 | compression ratio than the Zlib Deflate algorithm as a static Deflate Huffman 9 | tree encoding is used for bitstream). Note that since this compression is 10 | in RAM and requires ~4 bytes per byte of the input record, should only be 11 | called for compressing small records on the ESP8266. 12 | 13 | - Can decompress any valid Deflate, Zlib, and Gzip (further called just 14 | "Deflate") bitstream less than 16Kb, and any arbitrary length stream 15 | compressed by the uzlib compressor. 16 | 17 | uzlib aims for minimal code size and runtime memory requirements, and thus 18 | is suitable for embedded systems and IoT devices such as the ESP8266. 19 | 20 | uzlib is based on: 21 | 22 | - tinf library by Joergen Ibsen (Deflate decompression) 23 | - Deflate Static Huffman tree routines by Simon Tatham 24 | - LZ77 compressor by Paul Sokolovsky provided my initial inspiration, but 25 | I ended up rewriting this following RFC 1951 to get improved compression 26 | performance. 27 | 28 | The above 16Kb limitation arises from the RFC 1951 use of a 32Kb dictionary, 29 | which is impractical on a chipset with only ~40 Kb RAM avialable to 30 | applications. 31 | 32 | The relevant copyright statements are provided in the source files which 33 | use this code. 34 | 35 | uzlib library is licensed under Zlib license. 36 | -------------------------------------------------------------------------------- /app/uzlib/host/uz_zip.c: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | * NodeMCU zip wrapper code for uzlib_compress 3 | */ 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include "uzlib.h" 9 | #define fwriterec(r) fwrite(&(r), sizeof(r), 1, fout); 10 | #define BAD_FILE (-1) 11 | 12 | int main (int argc, char **argv) { 13 | const char *in = argv[1], *out = argv[2]; 14 | if (argc!=3) 15 | return 1; 16 | printf ("Compressing in=%s out=%s\n", in, out); 17 | FILE *fin, *fout; 18 | int status = -1; 19 | uint32_t iLen, oLen; 20 | uint8_t *iBuf, *oBuf; 21 | 22 | if (!(fin = fopen(in, "rb")) || fseek(fin, 0, SEEK_END) || 23 | (iLen = ftell(fin)) <= 0 || fseek(fin, 0, SEEK_SET)) 24 | return 1; 25 | if ((fout = fopen(out, "wb")) == NULL || 26 | (iBuf = (uint8_t *) uz_malloc(iLen)) == NULL || 27 | fread(iBuf, 1, iLen, fin) != iLen) 28 | return 1; 29 | 30 | if (uzlib_compress (&oBuf, &oLen, iBuf, iLen) == UZLIB_OK && 31 | oLen == fwrite(oBuf, oLen, 1, fout)) 32 | status = UZLIB_OK; 33 | uz_free(iBuf); 34 | if (oBuf) uz_free(oBuf); 35 | 36 | fclose(fin); 37 | fclose(fout); 38 | 39 | if (status == UZLIB_OK) 40 | unlink(out); 41 | 42 | return (status == UZLIB_OK) ? 1: 0; 43 | } 44 | 45 | -------------------------------------------------------------------------------- /app/websocket/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 = libwebsocket.a 16 | endif 17 | 18 | STD_CFLAGS=-std=gnu11 -Wimplicit 19 | 20 | ############################################################# 21 | # Configuration i.e. compile options etc. 22 | # Target specific stuff (defines etc.) goes in here! 23 | # Generally values applying to a tree are captured in the 24 | # makefile at its root level - these are then overridden 25 | # for a subtree within the makefile rooted therein 26 | # 27 | #DEFINES += 28 | 29 | ############################################################# 30 | # Recursion Magic - Don't touch this!! 31 | # 32 | # Each subtree potentially has an include directory 33 | # corresponding to the common APIs applicable to modules 34 | # rooted at that subtree. Accordingly, the INCLUDE PATH 35 | # of a module can only contain the include directories up 36 | # its parent path, and not its siblings 37 | # 38 | # Required for each makefile to inherit from the parent 39 | # 40 | 41 | INCLUDES := $(INCLUDES) -I $(PDIR)include 42 | INCLUDES += -I ./ 43 | INCLUDES += -I ./include 44 | INCLUDES += -I ../include 45 | INCLUDES += -I ../libc 46 | INCLUDES += -I ../../include 47 | PDIR := ../$(PDIR) 48 | sinclude $(PDIR)Makefile 49 | 50 | -------------------------------------------------------------------------------- /bin/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | *.S 3 | *.dump 4 | *.bin 5 | *.bin_rep 6 | !.gitignore 7 | !blank.bin 8 | !esp_init_data_default.bin 9 | !esp_init_data_default_v05.bin 10 | -------------------------------------------------------------------------------- /docs/hardware-faq.md: -------------------------------------------------------------------------------- 1 | # Hardware FAQ 2 | 3 | This content is now maintained at [http://www.esp8266.com/wiki/doku.php?id=nodemcu-unofficial-faq](http://www.esp8266.com/wiki/doku.php?id=nodemcu-unofficial-faq). 4 | -------------------------------------------------------------------------------- /docs/img/ESPlorer.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devsaurus/nodemcu-firmware/27e9e6c085aaac8b7e78b7c1d9cd5afe39428ba0/docs/img/ESPlorer.jpg -------------------------------------------------------------------------------- /docs/img/NodeMCU-PyFlasher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devsaurus/nodemcu-firmware/27e9e6c085aaac8b7e78b7c1d9cd5afe39428ba0/docs/img/NodeMCU-PyFlasher.png -------------------------------------------------------------------------------- /docs/img/WiFi-softap-mode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devsaurus/nodemcu-firmware/27e9e6c085aaac8b7e78b7c1d9cd5afe39428ba0/docs/img/WiFi-softap-mode.png -------------------------------------------------------------------------------- /docs/img/WiFi-station-mode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devsaurus/nodemcu-firmware/27e9e6c085aaac8b7e78b7c1d9cd5afe39428ba0/docs/img/WiFi-station-mode.png -------------------------------------------------------------------------------- /docs/img/WiFi-stationap-mode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devsaurus/nodemcu-firmware/27e9e6c085aaac8b7e78b7c1d9cd5afe39428ba0/docs/img/WiFi-stationap-mode.png -------------------------------------------------------------------------------- /docs/img/enduser-setup.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devsaurus/nodemcu-firmware/27e9e6c085aaac8b7e78b7c1d9cd5afe39428ba0/docs/img/enduser-setup.jpg -------------------------------------------------------------------------------- /docs/img/favicon-readme.txt: -------------------------------------------------------------------------------- 1 | favicon.ico was generated using https://realfavicongenerator.net. favicon_package_v0.16.zip in this folder contains icons and instructions for all sorts of browsers and platforms (incl. mobile variants). However, without modifying the MkDocs theme/template they’re of no use. -------------------------------------------------------------------------------- /docs/img/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devsaurus/nodemcu-firmware/27e9e6c085aaac8b7e78b7c1d9cd5afe39428ba0/docs/img/favicon.ico -------------------------------------------------------------------------------- /docs/img/favicon_package_v0.16.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devsaurus/nodemcu-firmware/27e9e6c085aaac8b7e78b7c1d9cd5afe39428ba0/docs/img/favicon_package_v0.16.zip -------------------------------------------------------------------------------- /docs/img/logo-small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devsaurus/nodemcu-firmware/27e9e6c085aaac8b7e78b7c1d9cd5afe39428ba0/docs/img/logo-small.png -------------------------------------------------------------------------------- /docs/img/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devsaurus/nodemcu-firmware/27e9e6c085aaac8b7e78b7c1d9cd5afe39428ba0/docs/img/logo.png -------------------------------------------------------------------------------- /docs/img/micro_sd-small.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devsaurus/nodemcu-firmware/27e9e6c085aaac8b7e78b7c1d9cd5afe39428ba0/docs/img/micro_sd-small.jpg -------------------------------------------------------------------------------- /docs/img/micro_sd.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devsaurus/nodemcu-firmware/27e9e6c085aaac8b7e78b7c1d9cd5afe39428ba0/docs/img/micro_sd.jpg -------------------------------------------------------------------------------- /docs/img/micro_sd_shield-small.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devsaurus/nodemcu-firmware/27e9e6c085aaac8b7e78b7c1d9cd5afe39428ba0/docs/img/micro_sd_shield-small.jpg -------------------------------------------------------------------------------- /docs/img/micro_sd_shield.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devsaurus/nodemcu-firmware/27e9e6c085aaac8b7e78b7c1d9cd5afe39428ba0/docs/img/micro_sd_shield.jpg -------------------------------------------------------------------------------- /docs/img/sigma_delta_audiofilter.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devsaurus/nodemcu-firmware/27e9e6c085aaac8b7e78b7c1d9cd5afe39428ba0/docs/img/sigma_delta_audiofilter.png -------------------------------------------------------------------------------- /docs/lua-modules/bh1750.md: -------------------------------------------------------------------------------- 1 | # BH1750 Module 2 | | Since | Origin / Contributor | Maintainer | Source | 3 | | :----- | :-------------------- | :---------- | :------ | 4 | | 2015-01-30 | [Martin Han](https://github.com/MarsTechHAN) | [Martin Han](https://github.com/MarsTechHAN) | [bh1750.lua](../../lua_modules/bh1750/bh1750.lua) | 5 | 6 | This Lua module provides access to [BH1750](https://www.mouser.com/ds/2/348/bh1750fvi-e-186247.pdf) I²C ambient light sensor. 7 | 8 | !!! note 9 | This module requires `i2c` C module built into firmware. 10 | 11 | ### Require 12 | ```lua 13 | bh1750 = require("bh1750") 14 | ``` 15 | 16 | ### Release 17 | ```lua 18 | bh1750 = nil 19 | package.loaded["bh1750"] = nil 20 | ``` 21 | 22 | ## bh1750.init() 23 | Initializes the module and sets up I²C with hardcoded device address. 24 | 25 | #### Syntax 26 | `bh1750.init(sda, scl)` 27 | 28 | #### Parameters 29 | - `sda` SDA pin number. 30 | - `scl` SCL pin number. 31 | 32 | #### Returns 33 | `nil` 34 | 35 | ## bh1750.read() 36 | Reads lux value from the sensor. 37 | 38 | #### Syntax 39 | `bh1750.read()` 40 | 41 | #### Parameters 42 | None 43 | 44 | #### Returns 45 | Lux value. 46 | 47 | ## bh1750.getlux() 48 | Function used to return last read lux value. 49 | 50 | #### Syntax 51 | `bh1750.getlux()` 52 | 53 | #### Parameters 54 | None 55 | 56 | #### Returns 57 | Last known lux value. 58 | 59 | #### Example 60 | ```lua 61 | SDA_PIN = 6 -- sda pin, GPIO12 62 | SCL_PIN = 5 -- scl pin, GPIO14 63 | 64 | bh1750 = require("bh1750") 65 | bh1750.init(SDA_PIN, SCL_PIN) 66 | bh1750.read() 67 | l = bh1750.getlux() 68 | print("lux: "..(l / 100).."."..(l % 100).." lx") 69 | 70 | -- release module 71 | bh1750 = nil 72 | package.loaded["bh1750"] = nil 73 | ``` 74 | -------------------------------------------------------------------------------- /docs/lua-modules/yeelink.md: -------------------------------------------------------------------------------- 1 | # Yeelink Module 2 | | Since | Origin / Contributor | Maintainer | Source | 3 | | :----- | :-------------------- | :---------- | :------ | 4 | | 2015-04-14 | [Martin Han](https://github.com/MarsTechHAN) | [Martin Han](https://github.com/MarsTechHAN) | [yeelink_lib.lua](../../lua_modules/yeelink/yeelink_lib.lua) | 5 | 6 | This Lua module provides a simple implementation of an [Yeelink](http://www.yeelink.net/) client. 7 | 8 | ### Require 9 | ```lua 10 | yeelink = require("yeelink_lib") 11 | ``` 12 | 13 | ### Release 14 | ```lua 15 | yeelink = nil 16 | package.loaded["yeelink_lib"] = nil 17 | ``` 18 | 19 | ## yeelink.init() 20 | Initializes Yeelink client. 21 | 22 | #### Syntax 23 | `yeelink.init(device, sensor, apikey)` 24 | 25 | #### Parameters 26 | - `device`: device number 27 | - `sensor`: sensor number 28 | - `apikey`: Yeelink API key string 29 | 30 | #### Returns 31 | IP address of `api.yeelink.net`, if not obtained then `false` 32 | 33 | ## yeelink.getDNS() 34 | Function to check DNS resolution of `api.yeelink.net` status. 35 | 36 | #### Syntax 37 | `yeelink.getDNS()` 38 | 39 | #### Parameters 40 | None 41 | 42 | #### Returns 43 | IP address of `api.yeelink.net` or `nil` when name resolution failed. 44 | 45 | ## yeelink.update() 46 | Send data to Yeelink Sever. 47 | 48 | #### Syntax 49 | `yeelink.update(datapoint)` 50 | 51 | #### Parameters 52 | - `datapoint`: Data to send to Yeelink API 53 | 54 | #### Returns 55 | `nil` 56 | 57 | #### Notes 58 | Example of using this module can be found in [Example_for_Yeelink_Lib.lua](../../lua_modules/yeelink/Example_for_Yeelink_Lib.lua) file. 59 | -------------------------------------------------------------------------------- /docs/modules/adxl345.md: -------------------------------------------------------------------------------- 1 | # ADXL345 Module 2 | | Since | Origin / Contributor | Maintainer | Source | 3 | | :----- | :-------------------- | :---------- | :------ | 4 | | 2016-04-08 | [Jason Schmidlapp](https://github.com/jschmidlapp) | [Jason Schmidlapp](https://github.com/jschmidlapp) | [adxl345.c](../../app/modules/adxl345.c)| 5 | 6 | 7 | This module provides access to the [ADXL345](https://www.sparkfun.com/products/9836) triple axis accelerometer. 8 | 9 | ## adxl345.read() 10 | Samples the sensor and returns X,Y and Z data from the accelerometer. 11 | 12 | #### Syntax 13 | `adxl345.read()` 14 | 15 | #### Returns 16 | X,Y,Z data (integers) 17 | 18 | #### Example 19 | ```lua 20 | local sda, scl = 1, 2 21 | i2c.setup(0, sda, scl, i2c.SLOW) -- call i2c.setup() only once 22 | adxl345.setup() 23 | local x,y,z = adxl345.read() 24 | print(string.format("X = %d, Y = %d, Z = %d", x, y, z)) 25 | ``` 26 | 27 | ## adxl345.setup() 28 | Initializes the module. 29 | 30 | #### Syntax 31 | `adxl345.setup()` 32 | 33 | #### Parameters 34 | None 35 | 36 | #### Returns 37 | `nil` 38 | -------------------------------------------------------------------------------- /docs/modules/am2320.md: -------------------------------------------------------------------------------- 1 | # AM2320 Module 2 | | Since | Origin / Contributor | Maintainer | Source | 3 | | :----- | :-------------------- | :---------- | :------ | 4 | | 2016-02-14 | [Henk Vergonet](https://github.com/hvegh) | [Henk Vergonet](https://github.com/hvegh) | [am2320.c](../../app/modules/am2320.c)| 5 | 6 | 7 | This module provides access to the [AM2320](https://akizukidenshi.com/download/ds/aosong/AM2320.pdf) humidity and temperature sensor, using the i2c interface. 8 | 9 | ## am2320.read() 10 | Samples the sensor and returns the relative humidity in % and temperature in celsius, as an integer multiplied with 10. 11 | 12 | #### Syntax 13 | `am2320.read()` 14 | 15 | #### Returns 16 | - `relative humidity` percentage multiplied with 10 (integer) 17 | - `temperature` in celcius multiplied with 10 (integer) 18 | 19 | #### Example 20 | ```lua 21 | sda, scl = 1, 2 22 | i2c.setup(0, sda, scl, i2c.SLOW) -- call i2c.setup() only once 23 | am2320.setup() 24 | rh, t = am2320.read() 25 | print(string.format("RH: %s%%", rh / 10)) 26 | print(string.format("Temperature: %s degrees C", t / 10)) 27 | ``` 28 | 29 | ## am2320.setup() 30 | Initializes the module. Returns model, version, serial but is seams these where all zero on my model. 31 | 32 | #### Syntax 33 | `model, version, serial = am2320.setup()` 34 | 35 | #### Parameters 36 | None 37 | 38 | #### Returns 39 | - `model` 16 bits number of model 40 | - `version` 8 bits version number 41 | - `serial` 32 bits serial number 42 | 43 | Note: I have only observed values of 0 for all of these, maybe other sensors return more sensible readings. 44 | -------------------------------------------------------------------------------- /docs/modules/cjson.md: -------------------------------------------------------------------------------- 1 | # CJSON Module 2 | 3 | This module has been replaced by [sjson](sjson.md). It provides a superset of functionality. All references to `cjson` can be replaced by `sjson`. 4 | 5 | 6 | -------------------------------------------------------------------------------- /docs/modules/hdc1080.md: -------------------------------------------------------------------------------- 1 | # HDC1080 Module 2 | | Since | Origin / Contributor | Maintainer | Source | 3 | | :----- | :-------------------- | :---------- | :------ | 4 | | 2017-04-01 | [Metin KOC](https://github.com/saucompeng) | [Metin KOC](https://github.com/saucompeng) | [hdc1080.c](../../app/modules/hdc1080.c)| 5 | 6 | 7 | This module provides access to the [HDC1080](http://www.ti.com/product/HDC1080) low power, high accuracy digital humidity sensor with temperature sensor. 8 | 9 | ## hdc1080.read() 10 | Samples the sensor then returns temperature and humidity value. 11 | 12 | #### Syntax 13 | `hdc1080.read()` 14 | 15 | #### Returns 16 | Temperature data in centigrade and humidity data in percentage (0-100) (integer/float) 17 | 18 | #### Example 19 | ```lua 20 | local sda, scl = 1, 2 21 | i2c.setup(0, sda, scl, i2c.SLOW) -- call i2c.setup() only once 22 | hdc1080.setup() 23 | local temperature,humidity = hdc1080.read() 24 | print(temperature) 25 | print(humidity) 26 | ``` 27 | 28 | ## hdc1080.setup() 29 | Initializes the module. 30 | 31 | #### Syntax 32 | `hdc1080.setup()` 33 | 34 | #### Parameters 35 | - None 36 | 37 | #### Returns 38 | `nil` 39 | -------------------------------------------------------------------------------- /docs/modules/hmc5883l.md: -------------------------------------------------------------------------------- 1 | # HMC5883L Module 2 | | Since | Origin / Contributor | Maintainer | Source | 3 | | :----- | :-------------------- | :---------- | :------ | 4 | | 2016-04-09 | [Jason Schmidlapp](https://github.com/jschmidlapp) | [Jason Schmidlapp](https://github.com/jschmidlapp) | [hmc5883l.c](../../app/modules/hmc5883l.c)| 5 | 6 | 7 | This module provides access to the [HMC5883L](https://www.sparkfun.com/products/10530) three axis digital compass. 8 | 9 | ## hmc5883l.read() 10 | Samples the sensor and returns X,Y and Z data. 11 | 12 | #### Syntax 13 | `hmc5883l.read()` 14 | 15 | #### Returns 16 | x,y,z measurements (integers) 17 | temperature multiplied with 10 (integer) 18 | 19 | #### Example 20 | ```lua 21 | local sda, scl = 1, 2 22 | i2c.setup(0, sda, scl, i2c.SLOW) -- call i2c.setup() only once 23 | hmc5883l.setup() 24 | local x,y,z = hmc5883l.read() 25 | print(string.format("x = %d, y = %d, z = %d", x, y, z)) 26 | ``` 27 | 28 | ## hmc5883l.setup() 29 | Initializes the module. 30 | 31 | #### Syntax 32 | `hmc5883l.setup()` 33 | 34 | #### Parameters 35 | None 36 | 37 | #### Returns 38 | `nil` 39 | -------------------------------------------------------------------------------- /docs/modules/hx711.md: -------------------------------------------------------------------------------- 1 | # HX711 Module 2 | | Since | Origin / Contributor | Maintainer | Source | 3 | | :----- | :-------------------- | :---------- | :------ | 4 | | 2015-10-09 | [Chris Takahashi](https://github.com/christakahashi) | [Chris Takahashi](https://github.com/christakahashi) | [hx711.c](../../app/modules/hx711.c)| 5 | 6 | This module provides access to an [HX711 load cell amplifier/ADC](https://learn.sparkfun.com/tutorials/load-cell-amplifier-hx711-breakout-hookup-guide). The HX711 is an inexpensive 24bit ADC with programmable 128x, 64x, and 32x gain. Currently only channel A at 128x gain is supported. 7 | 8 | Note: To save ROM image space, this module is not compiled into the firmware by default. 9 | 10 | ## hx711.init() 11 | 12 | Initialize io pins for hx711 clock and data. 13 | 14 | #### Syntax 15 | `hx711.init(clk, data)` 16 | 17 | #### Parameters 18 | - `clk` pin the hx711 clock signal is connected to 19 | - `data` pin the hx711 data signal is connected to 20 | 21 | #### Returns 22 | `nil` 23 | 24 | #### Example 25 | ```lua 26 | -- Initialize the hx711 with clk on pin 5 and data on pin 6 27 | hx711.init(5,6) 28 | ``` 29 | 30 | ## hx711.read() 31 | 32 | Read digital loadcell ADC value. 33 | 34 | #### Syntax 35 | `hx711.read(mode)` 36 | 37 | #### Parameters 38 | `mode` ADC mode. This parameter is currently ignored and reserved to ensure backward compatibility if support for additional modes is added. Currently only channel A @ 128 gain is supported. 39 | 40 | |mode | channel | gain | 41 | |-----|---------|------| 42 | | 0 | A | 128 | 43 | 44 | #### Returns 45 | a number (24 bit signed ADC value extended to the machine int size) 46 | 47 | #### Example 48 | ```lua 49 | -- Read ch A with 128 gain. 50 | raw_data = hx711.read(0) 51 | ``` 52 | -------------------------------------------------------------------------------- /docs/modules/l3g4200d.md: -------------------------------------------------------------------------------- 1 | # L3G4200D Module 2 | | Since | Origin / Contributor | Maintainer | Source | 3 | | :----- | :-------------------- | :---------- | :------ | 4 | | 2015-04-09 | [Jason Schmidlapp](https://github.com/jschmidlapp) | [Jason Schmidlapp](https://github.com/jschmidlapp) | [l3g4200d.c](../../app/modules/l3g4200d.c)| 5 | 6 | 7 | This module provides access to the [L3G4200D](https://www.sparkfun.com/products/10612) three axis digital gyroscope. 8 | 9 | ## l3g4200d.read() 10 | Samples the sensor and returns the gyroscope output. 11 | 12 | #### Syntax 13 | `l3g4200d.read()` 14 | 15 | #### Returns 16 | X,Y,Z gyroscope output 17 | 18 | #### Example 19 | ```lua 20 | local sda, scl = 1, 2 21 | i2c.setup(0, sda, scl, i2c.SLOW) -- call i2c.setup() only once 22 | l3g4200d.setup() 23 | local x,y,z = l3g4200d.read() 24 | print(string.format("X = %d, Y = %d, Z = %d", x, y, z) 25 | ``` 26 | 27 | ## l3g4200d.setup() 28 | Initializes the module. 29 | 30 | #### Syntax 31 | `l3g4200d.setup()` 32 | 33 | #### Parameters 34 | None 35 | 36 | #### Returns 37 | `nil` 38 | -------------------------------------------------------------------------------- /docs/modules/sqlite3.md: -------------------------------------------------------------------------------- 1 | # sqlite3 Module 2 | | Since | Origin / Contributor | Maintainer | Source | 3 | | :----- | :-------------------- | :---------- | :------ | 4 | | 2017-06-20 | [Luiz Felipe Silva](https://github.com/luizfeliperj) | [Luiz Felipe Silva](https://github.com/luizfeliperj) | [sqlite3.c](../../app/modules/sqlite3.c)| 5 | 6 | This module is based on [LuaSQLite3](http://lua.sqlite.org/index.cgi/index) module developed by Tiago Dionizio and Doug Currie with contributions from Thomas Lauer, Michael Roth, and Wolfgang Oertl. 7 | 8 | This module depens on [SQLite3](http://www.sqlite.org/) library developed by Dwayne Richard Hipp. 9 | 10 | For instruction on how to use this module or further documentation, please, refer to [LuaSQLite3 Documentation](http://lua.sqlite.org/index.cgi/doc/tip/doc/lsqlite3.wiki). 11 | 12 | This module is a stripped down version of SQLite, with every possible OMIT_\* configuration enable. The enabled OMIT_\* directives are available in the module's [config file](../../app/sqlite3/config_ext.h). 13 | 14 | The SQLite3 module vfs layer integration with NodeMCU was developed by me. 15 | 16 | **Simple example** 17 | 18 | ```lua 19 | db = sqlite3.open_memory() 20 | 21 | db:exec[[ 22 | CREATE TABLE test (id INTEGER PRIMARY KEY, content); 23 | 24 | INSERT INTO test VALUES (NULL, 'Hello, World'); 25 | INSERT INTO test VALUES (NULL, 'Hello, Lua'); 26 | INSERT INTO test VALUES (NULL, 'Hello, Sqlite3') 27 | ]] 28 | 29 | for row in db:nrows("SELECT * FROM test") do 30 | print(row.id, row.content) 31 | end 32 | ``` 33 | -------------------------------------------------------------------------------- /docs/modules/tm1829.md: -------------------------------------------------------------------------------- 1 | # TM1829 Module 2 | | Since | Origin / Contributor | Maintainer | Source | 3 | | :----- | :-------------------- | :---------- | :------ | 4 | | 2016-05-15 | [Sebastian Haas](https://github.com/sebi2k1) | [Sebastian Haas](https://github.com/sebi2k1) | [tm1829.c](../../app/modules/tm1829.c)| 5 | 6 | tm1829 is a library to handle led strips using Titan Micro tm1829 7 | led controller. 8 | 9 | The library uses any GPIO to bitstream the led control commands. 10 | 11 | ## tm1829.write() 12 | Send data to a led strip using native chip format. 13 | 14 | #### Syntax 15 | `tm1829.write(string)` 16 | 17 | #### Parameters 18 | - `string` payload to be sent to one or more TM1829 leds. 19 | 20 | #### Returns 21 | `nil` 22 | 23 | #### Example 24 | ```lua 25 | tm1829.write(5, string.char(255,0,0,255,0,0)) -- turn the two first RGB leds to blue using GPIO 5 26 | ``` 27 | 28 | -------------------------------------------------------------------------------- /docs/modules/ws2801.md: -------------------------------------------------------------------------------- 1 | # WS2801 Module 2 | | Since | Origin / Contributor | Maintainer | Source | 3 | | :----- | :-------------------- | :---------- | :------ | 4 | | 2015-07-12 | [Espressif example](https://github.com/CHERTS/esp8266-devkit/blob/master/Espressif/examples/ESP8266/EspLightNode/user/ws2801.c), [Konrad Beckmann](https://github.com/kbeckmann) | [Konrad Beckmann](https://github.com/kbeckmann) | [ws2801.c](../../app/modules/ws2801.c)| 5 | 6 | 7 | ## ws2801.init() 8 | Initializes the module and sets the pin configuration. 9 | 10 | #### Syntax 11 | `ws2801.init(pin_clk, pin_data)` 12 | 13 | #### Parameters 14 | - `pin_clk` pin for the clock. Supported are GPIO 0, 2, 4, 5. 15 | - `pin_data` pin for the data. Supported are GPIO 0, 2, 4, 5. 16 | 17 | #### Returns 18 | `nil` 19 | 20 | ## ws2801.write() 21 | Sends a string of RGB Data in 24 bits to WS2801. Don't forget to call `ws2801.init()` before. 22 | 23 | #### Syntax 24 | `ws2801.write(string)` 25 | 26 | ####Parameters 27 | - `string` payload to be sent to one or more WS2801. 28 | It should be composed from an RGB triplet per element. 29 | - `R1` the first pixel's red channel value (0-255) 30 | - `G1` the first pixel's green channel value (0-255) 31 | - `B1` the first pixel's blue channel value (0-255)
32 | ... You can connect a lot of WS2801... 33 | - `R2`, `G2`, `B2` are the next WS2801's Red, Green, and Blue channel values 34 | 35 | #### Returns 36 | `nil` 37 | 38 | #### Example 39 | ```lua 40 | ws2801.write(string.char(255,0,0, 0,255,0, 0,0,255)) 41 | ``` 42 | -------------------------------------------------------------------------------- /docs/support.md: -------------------------------------------------------------------------------- 1 | The [issues list on GitHub](https://github.com/nodemcu/nodemcu-firmware/issues) is **not** the right place to ask for help. Use it to report bugs and to place feature requests. Questions like "how do I ..." or "I can't get this to work ..." should be directed to StackOverflow or esp8266.com. 2 | 3 | Which ever site you use you need to make sure the description of the problem is to the point. It should be accompanied by a stripped down version of your Lua source code i.e. create a Minimal, Complete, and Verifiable Example (MCVE). A good resource is [http://stackoverflow.com/help/how-to-ask](http://stackoverflow.com/help/how-to-ask) 4 | 5 | ## Stack Overflow 6 | Stack Overflow is the perfect place to ask coding questions. Use one or several of the following tags: [esp8266](http://stackoverflow.com/tags/esp8266), [nodemcu](http://stackoverflow.com/tags/nodemcu) or [Lua](http://stackoverflow.com/tags/lua). 7 | 8 | ## esp8266.com Forums 9 | esp8266.com has a few [NodeMCU specific forums](http://www.esp8266.com/viewforum.php?f=17) where a number of our active community members tend to hang out. 10 | -------------------------------------------------------------------------------- /ld/defsym.rom: -------------------------------------------------------------------------------- 1 | --defsym=strcmp=ets_strcmp 2 | --defsym=strcpy=ets_strcpy 3 | --defsym=strlen=ets_strlen 4 | --defsym=strncmp=ets_strncmp 5 | --defsym=strncpy=ets_strncpy 6 | --defsym=strstr=ets_strstr 7 | --defsym=memcmp=ets_memcmp 8 | --defsym=memcpy=ets_memcpy 9 | --defsym=memmove=ets_memmove 10 | --defsym=memset=ets_memset 11 | -------------------------------------------------------------------------------- /local/fs/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore everything 2 | * 3 | # But not this file itself. 4 | !.gitignore 5 | -------------------------------------------------------------------------------- /local/lua/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore everything 2 | * 3 | # But not this file itself. 4 | !.gitignore 5 | -------------------------------------------------------------------------------- /lua_examples/adc_rgb.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- Light sensor on ADC(0), RGB LED connected to gpio12(6) Green, gpio13(7) Blue & gpio15(8) Red. 3 | -- This works out of the box on the typical ESP8266 evaluation boards with Battery Holder 4 | -- 5 | -- It uses the input from the sensor to drive a "rainbow" effect on the RGB LED 6 | -- Includes a very "pseudoSin" function 7 | -- 8 | 9 | function led(r,Sg,b) 10 | pwm.setduty(8,r) 11 | pwm.setduty(6,g) 12 | pwm.setduty(7,b) 13 | end 14 | 15 | -- this is perhaps the lightest weight sin function in existance 16 | -- Given an integer from 0..128, 0..512 appximating 256 + 256 * sin(idx*Pi/256) 17 | -- This is first order square approximation of sin, it's accurate around 0 and any multiple of 128 (Pi/2), 18 | -- 92% accurate at 64 (Pi/4). 19 | function pseudoSin (idx) 20 | idx = idx % 128 21 | lookUp = 32 - idx % 64 22 | val = 256 - (lookUp * lookUp) / 4 23 | if (idx > 64) then 24 | val = - val; 25 | end 26 | return 256+val 27 | end 28 | 29 | pwm.setup(6,500,512) 30 | pwm.setup(7,500,512) 31 | pwm.setup(8,500,512) 32 | pwm.start(6) 33 | pwm.start(7) 34 | pwm.start(8) 35 | 36 | tmr.alarm(1,20,1,function() 37 | idx = 3 * adc.read(0) / 2 38 | r = pseudoSin(idx) 39 | g = pseudoSin(idx + 43) 40 | b = pseudoSin(idx + 85) 41 | led(r,g,b) 42 | idx = (idx + 1) % 128 43 | end) 44 | -------------------------------------------------------------------------------- /lua_examples/luaOTA/config.json: -------------------------------------------------------------------------------- 1 | {"leave":0,"port":8266,"ssid":"YourSID","spwd":"YourSSIDpwd","server":"your_server","secret":"yoursecret"} 2 | -------------------------------------------------------------------------------- /lua_examples/luaOTA/default.lua: -------------------------------------------------------------------------------- 1 | -- 2 | local function enum(t,log) for k,v in pairs(t)do log(k,v) end end 3 | return {entry = function(msg) 4 | package.loaded["luaOTA.default"]=nil 5 | local gc=collectgarbage; gc(); gc() 6 | if DEBUG then 7 | for k,v in pairs(_G) do print(k,v) end 8 | for k,v in pairs(debug.getregistry()) do print(k,v) end 9 | end 10 | gc(); gc() 11 | print(msg, node.heap()) 12 | end} 13 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /lua_examples/mqtt/mqtt2cloud.lua: -------------------------------------------------------------------------------- 1 | -- test with cloudmqtt.com 2 | m_dis={} 3 | function dispatch(m,t,pl) 4 | if pl~=nil and m_dis[t] then 5 | m_dis[t](m,pl) 6 | end 7 | end 8 | function topic1func(m,pl) 9 | print("get1: "..pl) 10 | end 11 | function topic2func(m,pl) 12 | print("get2: "..pl) 13 | end 14 | m_dis["/topic1"]=topic1func 15 | m_dis["/topic2"]=topic2func 16 | -- Lua: mqtt.Client(clientid, keepalive, user, pass) 17 | m=mqtt.Client("nodemcu1",60,"test","test123") 18 | m:on("connect",function(m) 19 | print("connection "..node.heap()) 20 | m:subscribe("/topic1",0,function(m) print("sub done") end) 21 | m:subscribe("/topic2",0,function(m) print("sub done") end) 22 | m:publish("/topic1","hello",0,0) m:publish("/topic2","world",0,0) 23 | end ) 24 | m:on("offline", function(conn) 25 | print("disconnect to broker...") 26 | print(node.heap()) 27 | end) 28 | m:on("message",dispatch ) 29 | -- Lua: mqtt:connect( host, port, secure, auto_reconnect, function(client) ) 30 | m:connect("m11.cloudmqtt.com",11214,0,1) 31 | tmr.alarm(0,10000,1,function() local pl = "time: "..tmr.time() 32 | m:publish("/topic1",pl,0,0) 33 | end) 34 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /lua_examples/pcm/jump_8k.u8: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devsaurus/nodemcu-firmware/27e9e6c085aaac8b7e78b7c1d9cd5afe39428ba0/lua_examples/pcm/jump_8k.u8 -------------------------------------------------------------------------------- /lua_examples/pcm/play_file.lua: -------------------------------------------------------------------------------- 1 | -- **************************************************************************** 2 | -- Play file with pcm module. 3 | -- 4 | -- Upload jump_8k.u8 to spiffs before running this script. 5 | -- 6 | -- **************************************************************************** 7 | 8 | 9 | function cb_drained(d) 10 | print("drained "..node.heap()) 11 | 12 | file.seek("set", 0) 13 | -- uncomment the following line for continuous playback 14 | --d:play(pcm.RATE_8K) 15 | end 16 | 17 | function cb_stopped(d) 18 | print("playback stopped") 19 | file.seek("set", 0) 20 | end 21 | 22 | function cb_paused(d) 23 | print("playback paused") 24 | end 25 | 26 | file.open("jump_8k.u8", "r") 27 | 28 | drv = pcm.new(pcm.SD, 1) 29 | 30 | -- fetch data in chunks of FILE_READ_CHUNK (1024) from file 31 | drv:on("data", function(drv) return file.read() end) 32 | 33 | -- get called back when all samples were read from the file 34 | drv:on("drained", cb_drained) 35 | 36 | drv:on("stopped", cb_stopped) 37 | drv:on("paused", cb_paused) 38 | 39 | -- start playback 40 | drv:play(pcm.RATE_8K) 41 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /lua_examples/telnet/simple_telnet.lua: -------------------------------------------------------------------------------- 1 | -- a simple telnet server 2 | 3 | telnet_srv = net.createServer(net.TCP, 180) 4 | telnet_srv:listen(2323, function(socket) 5 | local fifo = {} 6 | local fifo_drained = true 7 | 8 | local function sender(c) 9 | if #fifo > 0 then 10 | c:send(table.remove(fifo, 1)) 11 | else 12 | fifo_drained = true 13 | end 14 | end 15 | 16 | local function s_output(str) 17 | table.insert(fifo, str) 18 | if socket ~= nil and fifo_drained then 19 | fifo_drained = false 20 | sender(socket) 21 | end 22 | end 23 | 24 | node.output(s_output, 0) -- re-direct output to function s_ouput. 25 | 26 | socket:on("receive", function(c, l) 27 | node.input(l) -- works like pcall(loadstring(l)) but support multiple separate line 28 | end) 29 | socket:on("disconnection", function(c) 30 | node.output(nil) -- un-regist the redirect output function, output goes to serial 31 | end) 32 | socket:on("sent", sender) 33 | 34 | print("Welcome to NodeMCU world.") 35 | end) 36 | -------------------------------------------------------------------------------- /lua_examples/timezone/README.md: -------------------------------------------------------------------------------- 1 | # tz module 2 | 3 | This is a simple module that parses timezone files as found on unix systems. It is oriented around converting the current time. It can convert other times, but it is 4 | rather less efficient as it maintains only a single cached entry in memory. 5 | 6 | On my linux system, these files can be found in `/usr/share/zoneinfo`. 7 | 8 | 9 | ## tz.setzone() 10 | 11 | This sets the timezone to be used in subsequent conversions 12 | 13 | #### Syntax 14 | `tz.setzone(timezone)` 15 | 16 | #### Parameters 17 | - `timezone` this is the timezone string. It must correspond to a file in the file system which is named timezone.zone. 18 | 19 | #### Returns 20 | true if the zone exists in the file system. 21 | 22 | ## tz.getoffset() 23 | 24 | This gets the offset (in seconds) of the time passed as the argument. 25 | 26 | #### Syntax 27 | `tz.getoffset(time)` 28 | 29 | #### Parameters 30 | - `time` the number of seconds since the epoch. This is the same value as used by the `sntp` module. 31 | 32 | #### Returns 33 | 34 | - The number of seconds of offset. West of Greenwich is negative. 35 | - The start time (in epoch seconds) of this offset. 36 | - The end time (in epoch seconds) of this offset. 37 | 38 | #### Example 39 | ``` 40 | tz = require('tz') 41 | tz.setzone('eastern') 42 | sntp.sync(nil, function(now) 43 | local tm = rtctime.epoch2cal(now + tz.getoffset(now)) 44 | print(string.format("%04d/%02d/%02d %02d:%02d:%02d", tm["year"], tm["mon"], tm["day"], tm["hour"], tm["min"], tm["sec"])) 45 | end) 46 | ``` 47 | 48 | ## tz.getzones() 49 | 50 | This returns a list of the available timezones in the file system. 51 | 52 | #### Syntax 53 | `tz.getzones()` 54 | 55 | #### Returns 56 | A list of timezones. 57 | -------------------------------------------------------------------------------- /lua_examples/timezone/alaska.zone: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devsaurus/nodemcu-firmware/27e9e6c085aaac8b7e78b7c1d9cd5afe39428ba0/lua_examples/timezone/alaska.zone -------------------------------------------------------------------------------- /lua_examples/timezone/central.zone: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devsaurus/nodemcu-firmware/27e9e6c085aaac8b7e78b7c1d9cd5afe39428ba0/lua_examples/timezone/central.zone -------------------------------------------------------------------------------- /lua_examples/timezone/eastern.zone: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devsaurus/nodemcu-firmware/27e9e6c085aaac8b7e78b7c1d9cd5afe39428ba0/lua_examples/timezone/eastern.zone -------------------------------------------------------------------------------- /lua_examples/timezone/mountain.zone: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devsaurus/nodemcu-firmware/27e9e6c085aaac8b7e78b7c1d9cd5afe39428ba0/lua_examples/timezone/mountain.zone -------------------------------------------------------------------------------- /lua_examples/timezone/pacific.zone: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devsaurus/nodemcu-firmware/27e9e6c085aaac8b7e78b7c1d9cd5afe39428ba0/lua_examples/timezone/pacific.zone -------------------------------------------------------------------------------- /lua_examples/ucglib/GT_box.lua: -------------------------------------------------------------------------------- 1 | local M, module = {}, ... 2 | _G[module] = M 3 | 4 | function M.run() 5 | -- make this a volatile module: 6 | package.loaded[module] = nil 7 | 8 | print("Running component box...") 9 | 10 | local x, y, w, h 11 | local m 12 | 13 | disp:setColor(0, 0, 40, 80) 14 | disp:setColor(1, 60, 0, 40) 15 | disp:setColor(2, 128, 0, 140) 16 | disp:setColor(3, 0, 128, 140) 17 | disp:drawGradientBox(0, 0, disp:getWidth(), disp:getHeight()) 18 | 19 | disp:setColor(255, 255, 255) 20 | disp:setPrintPos(2,18) 21 | disp:setPrintDir(0) 22 | disp:print("Box") 23 | 24 | m = millis() + T 25 | 26 | while millis() < m do 27 | disp:setColor(bit.band(lcg_rnd(), 127)+127, bit.band(lcg_rnd(), 127)+64, bit.band(lcg_rnd(), 31)) 28 | w = bit.band(lcg_rnd(), 31) 29 | h = bit.band(lcg_rnd(), 31) 30 | w = w + 10 31 | h = h + 10 32 | x = bit.rshift(lcg_rnd() * (disp:getWidth()-w), 8) 33 | y = bit.rshift(lcg_rnd() * (disp:getHeight()-h-20), 8) 34 | 35 | disp:drawBox(x, y+20, w, h) 36 | end 37 | 38 | print("...done") 39 | end 40 | 41 | return M 42 | -------------------------------------------------------------------------------- /lua_examples/ucglib/GT_color_test.lua: -------------------------------------------------------------------------------- 1 | local M, module = {}, ... 2 | _G[module] = M 3 | 4 | function M.run() 5 | -- make this a volatile module: 6 | package.loaded[module] = nil 7 | 8 | print("Running component color_test...") 9 | 10 | local mx 11 | local c, x 12 | mx = disp:getWidth() / 2 13 | --my = disp:getHeight() / 2 14 | 15 | disp:setColor(0, 0, 0, 0) 16 | disp:drawBox(0, 0, disp:getWidth(), disp:getHeight()) 17 | 18 | disp:setColor(255, 255, 255) 19 | disp:setPrintPos(2,18) 20 | disp:setPrintDir(0) 21 | disp:print("Color Test") 22 | 23 | disp:setColor(0, 127, 127, 127) 24 | disp:drawBox(0, 20, 16*4+4, 5*8+4) 25 | 26 | c = 0 27 | x = 2 28 | while c < 255 do 29 | disp:setColor(0, c, c, c) 30 | disp:drawBox(x, 22, 4, 8) 31 | disp:setColor(0, c, 0, 0) 32 | disp:drawBox(x, 22+8, 4, 8) 33 | disp:setColor(0, 0, c, 0) 34 | disp:drawBox(x, 22+2*8, 4, 8) 35 | disp:setColor(0, 0, 0, c) 36 | disp:drawBox(x, 22+3*8, 4, 8) 37 | disp:setColor(0, c, 255-c, 0) 38 | disp:drawBox(x, 22+4*8, 4, 8) 39 | 40 | c = c + 17 41 | x = x + 4 42 | end 43 | 44 | print("...done") 45 | end 46 | 47 | return M 48 | -------------------------------------------------------------------------------- /lua_examples/ucglib/GT_cross.lua: -------------------------------------------------------------------------------- 1 | local M, module = {}, ... 2 | _G[module] = M 3 | 4 | function M.run() 5 | -- make this a volatile module: 6 | package.loaded[module] = nil 7 | 8 | print("Running component cross...") 9 | 10 | local mx, my 11 | disp:setColor(0, 250, 0, 0) 12 | disp:setColor(1, 255, 255, 30) 13 | disp:setColor(2, 220, 235, 10) 14 | disp:setColor(3, 205, 0, 30) 15 | disp:drawGradientBox(0, 0, disp:getWidth(), disp:getHeight()) 16 | mx = disp:getWidth() / 2 17 | my = disp:getHeight() / 2 18 | 19 | disp:setColor(0, 255, 255, 255) 20 | disp:setPrintPos(2,18) 21 | disp:print("Cross") 22 | 23 | disp:setColor(0, 0, 0x66, 0xcc) 24 | disp:setPrintPos(mx+15, my-5) 25 | disp:print("dir0") 26 | disp:setPrintPos(mx+5, my+26) 27 | disp:print("dir1") 28 | disp:setPrintPos(mx-40, my+20) 29 | disp:print("dir2") 30 | disp:setPrintPos(mx+5,my-25) 31 | disp:print("dir3") 32 | 33 | disp:setColor(0, 0, 0x66, 0xff) 34 | disp:setColor(1, 0, 0x66, 0xcc) 35 | disp:setColor(2, 0, 0, 0x99) 36 | 37 | disp:draw90Line(mx+2, my-1, 20, 0, 0) 38 | disp:draw90Line(mx+2, my, 20, 0, 1) 39 | disp:draw90Line(mx+2, my+1, 20, 0, 2) 40 | 41 | disp:draw90Line(mx+1, my+2, 20, 1, 0) 42 | disp:draw90Line(mx, my+2, 20, 1, 1) 43 | disp:draw90Line(mx-1, my+2, 20, 1, 2) 44 | 45 | disp:draw90Line(mx-2, my+1, 20, 2, 0) 46 | disp:draw90Line(mx-2, my, 20, 2, 1) 47 | disp:draw90Line(mx-2, my-1, 20, 2, 2) 48 | 49 | disp:draw90Line(mx-1, my-2, 20, 3, 0) 50 | disp:draw90Line(mx, my-2, 20, 3, 1) 51 | disp:draw90Line(mx+1, my-2, 20, 3, 2) 52 | 53 | print("...done") 54 | end 55 | 56 | return M 57 | -------------------------------------------------------------------------------- /lua_examples/ucglib/GT_fonts.lua: -------------------------------------------------------------------------------- 1 | local M, module = {}, ... 2 | _G[module] = M 3 | 4 | function M.run() 5 | -- make this a volatile module: 6 | package.loaded[module] = nil 7 | 8 | print("Running component fonts...") 9 | 10 | local d = 5 11 | 12 | disp:setColor(0, 0, 40, 80) 13 | disp:setColor(1, 150, 0, 200) 14 | disp:setColor(2, 60, 0, 40) 15 | disp:setColor(3, 0, 160, 160) 16 | 17 | disp:drawGradientBox(0, 0, disp:getWidth(), disp:getHeight()) 18 | 19 | disp:setColor(255, 255, 255) 20 | disp:setPrintDir(0) 21 | disp:setPrintPos(2,18) 22 | disp:print("Fonts") 23 | 24 | disp:setFontMode(ucg.FONT_MODE_TRANSPARENT) 25 | 26 | disp:setColor(255, 200, 170) 27 | disp:setFont(ucg.font_helvB08_hr) 28 | disp:setPrintPos(2,30+d) 29 | disp:print("ABC abc 123") 30 | disp:setFont(ucg.font_helvB10_hr) 31 | disp:setPrintPos(2,45+d) 32 | disp:print("ABC abc 123") 33 | disp:setFont(ucg.font_helvB12_hr) 34 | --disp:setPrintPos(2,62+d) 35 | --disp:print("ABC abc 123") 36 | disp:drawString(2,62+d, 0, "ABC abc 123") -- test drawString 37 | 38 | disp:setFontMode(ucg.FONT_MODE_SOLID) 39 | 40 | disp:setColor(255, 200, 170) 41 | disp:setColor(1, 0, 100, 120) -- background color in solid mode 42 | disp:setFont(ucg.font_helvB08_hr) 43 | disp:setPrintPos(2,75+30+d) 44 | disp:print("ABC abc 123") 45 | disp:setFont(ucg.font_helvB10_hr) 46 | disp:setPrintPos(2,75+45+d) 47 | disp:print("ABC abc 123") 48 | disp:setFont(ucg.font_helvB12_hr) 49 | disp:setPrintPos(2,75+62+d) 50 | disp:print("ABC abc 123") 51 | 52 | disp:setFontMode(ucg.FONT_MODE_TRANSPARENT) 53 | 54 | disp:setFont(ucg.font_ncenR14_hr) 55 | 56 | print("...done") 57 | end 58 | 59 | return M 60 | -------------------------------------------------------------------------------- /lua_examples/ucglib/GT_gradient.lua: -------------------------------------------------------------------------------- 1 | local M, module = {}, ... 2 | _G[module] = M 3 | 4 | function M.run() 5 | -- make this a volatile module: 6 | package.loaded[module] = nil 7 | 8 | print("Running component gradient...") 9 | 10 | disp:setColor(0, 0, 255, 0) 11 | disp:setColor(1, 255, 0, 0) 12 | disp:setColor(2, 255, 0, 255) 13 | disp:setColor(3, 0, 255, 255) 14 | 15 | disp:drawGradientBox(0, 0, disp:getWidth(), disp:getHeight()) 16 | 17 | disp:setColor(255, 255, 255) 18 | disp:setPrintPos(2,18) 19 | disp:setPrintDir(0) 20 | disp:print("GradientBox") 21 | 22 | disp:setColor(0, 0, 255, 0) 23 | disp:drawBox(2, 25, 8, 8) 24 | 25 | disp:setColor(0, 255, 0, 0) 26 | disp:drawBox(2+10, 25, 8, 8) 27 | 28 | disp:setColor(0, 255, 0, 255) 29 | disp:drawBox(2, 25+10, 8, 8) 30 | 31 | disp:setColor(0, 0, 255, 255) 32 | disp:drawBox(2+10, 25+10, 8, 8) 33 | 34 | print("...done") 35 | end 36 | 37 | return M 38 | -------------------------------------------------------------------------------- /lua_examples/ucglib/GT_graphics_test.lua: -------------------------------------------------------------------------------- 1 | local M, module = {}, ... 2 | _G[module] = M 3 | 4 | function M.run() 5 | -- make this a volatile module: 6 | package.loaded[module] = nil 7 | 8 | print("Running component graphics_test...") 9 | 10 | --ucg.setMaxClipRange() 11 | disp:setColor(0, 0, 40, 80) 12 | disp:setColor(1, 80, 0, 40) 13 | disp:setColor(2, 255, 0, 255) 14 | disp:setColor(3, 0, 255, 255) 15 | 16 | disp:drawGradientBox(0, 0, disp:getWidth(), disp:getHeight()) 17 | 18 | disp:setColor(255, 168, 0) 19 | disp:setPrintDir(0) 20 | disp:setPrintPos(2, 18) 21 | disp:print("Ucglib") 22 | disp:setPrintPos(2, 18+20) 23 | disp:print("GraphicsTest") 24 | 25 | print("...done") 26 | end 27 | 28 | return M 29 | -------------------------------------------------------------------------------- /lua_examples/ucglib/GT_pixel_and_lines.lua: -------------------------------------------------------------------------------- 1 | local M, module = {}, ... 2 | _G[module] = M 3 | 4 | function M.run() 5 | -- make this a volatile module: 6 | package.loaded[module] = nil 7 | 8 | print("Running component pixel_and_lines...") 9 | 10 | local mx 11 | local x, xx 12 | mx = disp:getWidth() / 2 13 | --my = disp:getHeight() / 2 14 | 15 | disp:setColor(0, 0, 0, 150) 16 | disp:setColor(1, 0, 60, 40) 17 | disp:setColor(2, 60, 0, 40) 18 | disp:setColor(3, 120, 120, 200) 19 | disp:drawGradientBox(0, 0, disp:getWidth(), disp:getHeight()) 20 | 21 | disp:setColor(255, 255, 255) 22 | disp:setPrintPos(2, 18) 23 | disp:setPrintDir(0) 24 | disp:print("Pix&Line") 25 | 26 | disp:drawPixel(0, 0) 27 | disp:drawPixel(1, 0) 28 | --disp:drawPixel(disp:getWidth()-1, 0) 29 | --disp:drawPixel(0, disp:getHeight()-1) 30 | 31 | disp:drawPixel(disp:getWidth()-1, disp:getHeight()-1) 32 | disp:drawPixel(disp:getWidth()-1-1, disp:getHeight()-1) 33 | 34 | 35 | x = 0 36 | while x < mx do 37 | xx = ((x)*255)/mx 38 | disp:setColor(255, 255-xx/2, 255-xx) 39 | disp:drawPixel(x, 24) 40 | disp:drawVLine(x+7, 26, 13) 41 | x = x + 1 42 | end 43 | 44 | print("...done") 45 | end 46 | 47 | return M 48 | -------------------------------------------------------------------------------- /lua_examples/ucglib/GT_text.lua: -------------------------------------------------------------------------------- 1 | local M, module = {}, ... 2 | _G[module] = M 3 | 4 | function M.run() 5 | -- make this a volatile module: 6 | package.loaded[module] = nil 7 | 8 | print("Running component text...") 9 | 10 | local x, y, w, h, i 11 | local m 12 | 13 | disp:setColor(0, 80, 40, 0) 14 | disp:setColor(1, 60, 0, 40) 15 | disp:setColor(2, 20, 0, 20) 16 | disp:setColor(3, 60, 0, 0) 17 | disp:drawGradientBox(0, 0, disp:getWidth(), disp:getHeight()) 18 | 19 | disp:setColor(255, 255, 255) 20 | disp:setPrintPos(2,18) 21 | disp:setPrintDir(0) 22 | disp:print("Text") 23 | 24 | m = millis() + T 25 | i = 0 26 | while millis() < m do 27 | disp:setColor(bit.band(lcg_rnd(), 31), bit.band(lcg_rnd(), 127) + 127, bit.band(lcg_rnd(), 127) + 64) 28 | w = 40 29 | h = 22 30 | x = bit.rshift(lcg_rnd() * (disp:getWidth() - w), 8) 31 | y = bit.rshift(lcg_rnd() * (disp:getHeight() - h), 8) 32 | 33 | disp:setPrintPos(x, y+h) 34 | disp:setPrintDir(bit.band(bit.rshift(i, 2), 3)) 35 | i = i + 1 36 | disp:print("Ucglib") 37 | end 38 | disp:setPrintDir(0) 39 | 40 | print("...done") 41 | end 42 | 43 | return M 44 | -------------------------------------------------------------------------------- /lua_examples/ucglib/GT_triangle.lua: -------------------------------------------------------------------------------- 1 | local M, module = {}, ... 2 | _G[module] = M 3 | 4 | function M.run() 5 | -- make this a volatile module: 6 | package.loaded[module] = nil 7 | 8 | print("Running component triangle...") 9 | 10 | local m 11 | 12 | disp:setColor(0, 0, 80, 20) 13 | disp:setColor(1, 60, 80, 20) 14 | disp:setColor(2, 60, 120, 0) 15 | disp:setColor(3, 0, 140, 30) 16 | disp:drawGradientBox(0, 0, disp:getWidth(), disp:getHeight()) 17 | 18 | disp:setColor(255, 255, 255) 19 | disp:setPrintPos(2, 18) 20 | disp:print("Triangle") 21 | 22 | m = millis() + T 23 | 24 | while millis() < m do 25 | disp:setColor(bit.band(lcg_rnd(), 127)+127, bit.band(lcg_rnd(), 31), bit.band(lcg_rnd(), 127)+64) 26 | 27 | disp:drawTriangle( 28 | bit.rshift(lcg_rnd() * (disp:getWidth()), 8), 29 | bit.rshift(lcg_rnd() * (disp:getHeight()-20), 8) + 20, 30 | bit.rshift(lcg_rnd() * (disp:getWidth()), 8), 31 | bit.rshift(lcg_rnd() * (disp:getHeight()-20), 8) + 20, 32 | bit.rshift(lcg_rnd() * (disp:getWidth()), 8), 33 | bit.rshift(lcg_rnd() * (disp:getHeight()-20), 8) + 20 34 | ) 35 | 36 | tmr.wdclr() 37 | end 38 | 39 | print("...done") 40 | end 41 | 42 | return M 43 | -------------------------------------------------------------------------------- /lua_examples/ucglib/HelloWorld.lua: -------------------------------------------------------------------------------- 1 | -- setup SPI and connect display 2 | function init_spi_display() 3 | -- Hardware SPI CLK = GPIO14 4 | -- Hardware SPI MOSI = GPIO13 5 | -- Hardware SPI MISO = GPIO12 (not used) 6 | -- Hardware SPI /CS = GPIO15 (not used) 7 | -- CS, D/C, and RES can be assigned freely to available GPIOs 8 | local cs = 8 -- GPIO15, pull-down 10k to GND 9 | local dc = 4 -- GPIO2 10 | local res = 0 -- GPIO16 11 | local bus = 1 12 | 13 | spi.setup(bus, spi.MASTER, spi.CPOL_LOW, spi.CPHA_LOW, 8, 8) 14 | -- we won't be using the HSPI /CS line, so disable it again 15 | gpio.mode(8, gpio.INPUT, gpio.PULLUP) 16 | 17 | -- initialize the matching driver for your display 18 | -- see app/include/ucg_config.h 19 | --disp = ucg.ili9341_18x240x320_hw_spi(bus, cs, dc, res) 20 | disp = ucg.st7735_18x128x160_hw_spi(bus, cs, dc, res) 21 | end 22 | 23 | 24 | 25 | init_spi_display() 26 | 27 | disp:begin(ucg.FONT_MODE_TRANSPARENT) 28 | disp:clearScreen() 29 | 30 | disp:setFont(ucg.font_ncenR12_tr); 31 | disp:setColor(255, 255, 255); 32 | disp:setColor(1, 255, 0,0); 33 | 34 | 35 | disp:setPrintPos(0, 25) 36 | disp:print("Hello World!") 37 | -------------------------------------------------------------------------------- /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, this is NodeMCU.

Turn PIN1
" 28 | client:send(buf) 29 | end) 30 | conn:on("sent", function(c) c:close() end) 31 | end) 32 | -------------------------------------------------------------------------------- /lua_modules/bh1750/README.md: -------------------------------------------------------------------------------- 1 | # BH1750 Module 2 | 3 | Documentation for this Lua module is available in the [bh1750.md](../../docs/lua-modules/bh1750.md) file and in the [Official NodeMCU Documentation](https://nodemcu.readthedocs.io/) in `Lua Modules` section. 4 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /lua_modules/bmp085/README.md: -------------------------------------------------------------------------------- 1 | Support for this Lua module has been discontinued. 2 | 3 | Equivalent functionality is available from the bmp085 module in the NodeMCU 4 | firmware code base. Refer to `docs/en/modules/bmp085.md` for API 5 | documentation. 6 | 7 | The original Lua code can be found in the [git repository](https://github.com/nodemcu/nodemcu-firmware/tree/2fbd5ed509964a16057b22e00aa8469d6a522d73/lua_modules/bmp085). 8 | -------------------------------------------------------------------------------- /lua_modules/dht_lib/README.md: -------------------------------------------------------------------------------- 1 | Support for this Lua module has been discontinued. 2 | 3 | Equivalent functionality is available from the dht module in the NodeMCU 4 | firmware code base. Refer to `docs/en/modules/dht.md` for API 5 | documentation. 6 | 7 | The original Lua code can be found in the [git repository](https://github.com/nodemcu/nodemcu-firmware/tree/2fbd5ed509964a16057b22e00aa8469d6a522d73/lua_modules/dht_lib). 8 | -------------------------------------------------------------------------------- /lua_modules/ds18b20/README.md: -------------------------------------------------------------------------------- 1 | # DS18B20 Module 2 | 3 | Documentation for this Lua module is available in the [ds18b20.md](../../docs/lua-modules/ds18b20.md) file and in the [Official NodeMCU Documentation](https://nodemcu.readthedocs.io/) in `Lua Modules` section. 4 | -------------------------------------------------------------------------------- /lua_modules/ds18b20/ds18b20-web.lua: -------------------------------------------------------------------------------- 1 | t = require('ds18b20') 2 | 3 | port = 80 4 | pin = 3 -- gpio0 = 3, gpio2 = 4 5 | gconn = {} -- global variable for connection 6 | 7 | function readout(temp) 8 | local resp = "HTTP/1.1 200 OK\nContent-Type: text/html\nRefresh: 5\n\n" .. 9 | "" .. 10 | "" .. 11 | "ESP8266
" 12 | 13 | for addr, temp in pairs(temp) do 14 | resp = resp .. string.format("Sensor %s: %s ℃
", ('%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X '):format(addr:byte(1,8)), temp) 15 | end 16 | 17 | resp = resp .. 18 | "Node ChipID: " .. node.chipid() .. "
" .. 19 | "Node MAC: " .. wifi.sta.getmac() .. "
" .. 20 | "Node Heap: " .. node.heap() .. "
" .. 21 | "Timer Ticks: " .. tmr.now() .. "
" .. 22 | "" 23 | 24 | gconn:send(resp) 25 | gconn:on("sent",function(conn) conn:close() end) 26 | end 27 | 28 | srv=net.createServer(net.TCP) 29 | srv:listen(port, 30 | function(conn) 31 | gconn = conn 32 | -- t:read_temp(readout) -- default pin value is 3 33 | t:read_temp(readout, pin) 34 | end 35 | ) 36 | -------------------------------------------------------------------------------- /lua_modules/ds3231/README.md: -------------------------------------------------------------------------------- 1 | # DS3231 Module 2 | 3 | Documentation for this Lua module is available in the [ds3231.md](../../docs/lua-modules/ds3231.md) file and in the [Official NodeMCU Documentation](https://nodemcu.readthedocs.io/) in `Lua Modules` section. 4 | -------------------------------------------------------------------------------- /lua_modules/ds3231/ds3231-example.lua: -------------------------------------------------------------------------------- 1 | 2 | -- ESP-01 GPIO Mapping 3 | gpio0, gpio2 = 3, 4 4 | i2c.setup(gpio0, gpio2, scl, i2c.SLOW) -- call i2c.setup() only once 5 | 6 | require("ds3231") 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 | -------------------------------------------------------------------------------- /lua_modules/ds3231/ds3231-web.lua: -------------------------------------------------------------------------------- 1 | 2 | -- ESP-01 GPIO Mapping 3 | gpio0, gpio2 = 3, 4 4 | i2c.setup(gpio0, gpio2, scl, i2c.SLOW) -- call i2c.setup() only once 5 | 6 | require('ds3231') 7 | 8 | port = 80 9 | 10 | days = { 11 | [1] = "Sunday", 12 | [2] = "Monday", 13 | [3] = "Tuesday", 14 | [4] = "Wednesday", 15 | [5] = "Thursday", 16 | [6] = "Friday", 17 | [7] = "Saturday" 18 | } 19 | 20 | months = { 21 | [1] = "January", 22 | [2] = "Febuary", 23 | [3] = "March", 24 | [4] = "April", 25 | [5] = "May", 26 | [6] = "June", 27 | [7] = "July", 28 | [8] = "August", 29 | [9] = "September", 30 | [10] = "October", 31 | [11] = "November", 32 | [12] = "December" 33 | } 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 | ) 55 | -------------------------------------------------------------------------------- /lua_modules/email/README.md: -------------------------------------------------------------------------------- 1 | # IMAP Module 2 | 3 | Documentation for this Lua module is available in the [imap.md](../../docs/lua-modules/imap.md) file and in the [Official NodeMCU Documentation](https://nodemcu.readthedocs.io/) in `Lua Modules` section. 4 | -------------------------------------------------------------------------------- /lua_modules/ftp/README.md: -------------------------------------------------------------------------------- 1 | # FTP Server Module 2 | 3 | Documentation for this Lua module is available in the [ftpserver.md](../../docs/lua-modules/ftpserver.md) file and in the [Official NodeMCU Documentation](https://nodemcu.readthedocs.io/) in `Lua Modules` section. 4 | -------------------------------------------------------------------------------- /lua_modules/hdc1000/HDC1000-example.lua: -------------------------------------------------------------------------------- 1 | HDC1000 = require("HDC1000") 2 | 3 | sda = 1 4 | scl = 2 5 | drdyn = false 6 | 7 | i2c.setup(0, sda, scl, i2c.SLOW) -- call i2c.setup() only once 8 | HDC1000.setup(drdyn) 9 | HDC1000.config() -- default values are used if called with no arguments. prototype is config(address, resolution, heater) 10 | 11 | print(string.format("Temperature: %.2f °C\nHumidity: %.2f %%", HDC1000.getTemp(), HDC1000.getHumi())) 12 | 13 | HDC1000 = nil 14 | package.loaded["HDC1000"]=nil 15 | -------------------------------------------------------------------------------- /lua_modules/hdc1000/README.md: -------------------------------------------------------------------------------- 1 | # HDC1000 Module 2 | 3 | Documentation for this Lua module is available in the [hdc1000.md](../../docs/lua-modules/hdc1000.md) file and in the [Official NodeMCU Documentation](https://nodemcu.readthedocs.io/) in `Lua Modules` section. 4 | -------------------------------------------------------------------------------- /lua_modules/http/README.md: -------------------------------------------------------------------------------- 1 | # HTTP Server Module 2 | 3 | Documentation for this Lua module is available in the [httpserver.md](../../docs/lua-modules/httpserver.md) file and in the [Official NodeMCU Documentation](https://nodemcu.readthedocs.io/) in `Lua Modules` section. 4 | -------------------------------------------------------------------------------- /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("httpserver").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 | -------------------------------------------------------------------------------- /lua_modules/lm92/README.md: -------------------------------------------------------------------------------- 1 | # HTTP Server Module 2 | 3 | Documentation for this Lua module is available in the [lm92.md](../../docs/lua-modules/lm92.md) file and in the [Official NodeMCU Documentation](https://nodemcu.readthedocs.io/) in `Lua Modules` section. 4 | -------------------------------------------------------------------------------- /lua_modules/mcp23008/README.md: -------------------------------------------------------------------------------- 1 | # MCP23008 Module 2 | 3 | Documentation for this Lua module is available in the [mcp23008.md](../../docs/lua-modules/mcp23008.md) file and in the [Official NodeMCU Documentation](https://nodemcu.readthedocs.io/) in `Lua Modules` section. 4 | -------------------------------------------------------------------------------- /lua_modules/redis/README.md: -------------------------------------------------------------------------------- 1 | # Redis Module 2 | 3 | Documentation for this Lua module is available in the [redis.md](../../docs/lua-modules/redis.md) file and in the [Official NodeMCU Documentation](https://nodemcu.readthedocs.io/) in `Lua Modules` section. 4 | -------------------------------------------------------------------------------- /lua_modules/si7021/README.md: -------------------------------------------------------------------------------- 1 | Support for this Lua module has been discontinued. 2 | 3 | Equivalent functionality is available from the si7021 module in the NodeMCU 4 | firmware code base. Refer to `docs/en/modules/si7021.md` for API documentation. 5 | 6 | The original Lua code can be found in the [git repository](https://github.com/nodemcu/nodemcu-firmware/tree/3e24b1c75b4b4fd469be784fd5d596f0eb3871ff/lua_modules/si7021). 7 | -------------------------------------------------------------------------------- /lua_modules/tsl2561/README.md: -------------------------------------------------------------------------------- 1 | Support for this Lua module has been discontinued. 2 | 3 | Equivalent functionality is available from the dht module in the NodeMCU 4 | firmware code base. Refer to `docs/en/modules/tsl2561.md` for API 5 | documentation. 6 | 7 | The original Lua code can be found in the [git repository](https://github.com/nodemcu/nodemcu-firmware/tree/2fbd5ed509964a16057b22e00aa8469d6a522d73/lua_modules/tsl2561). 8 | -------------------------------------------------------------------------------- /lua_modules/yeelink/Example_for_Yeelink_Lib.lua: -------------------------------------------------------------------------------- 1 | -- *************************************************************************** 2 | -- Example for Yeelink Lib 3 | -- 4 | -- Written by Martin 5 | -- 6 | -- 7 | -- MIT license, http://opensource.org/licenses/MIT 8 | -- *************************************************************************** 9 | 10 | wifi.setmode(wifi.STATION) --Step1: Connect to Wifi 11 | wifi.sta.config("SSID","Password") 12 | 13 | dht = require("dht_lib") --Step2: "Require" the libs 14 | yeelink = require("yeelink_lib") 15 | 16 | yeelink.init(23333,23333,"You api-key",function() --Step3: Register the callback function 17 | 18 | print("Yeelink Init OK...") 19 | tmr.alarm(1,60000,1,function() --Step4: Have fun~ (Update your data) 20 | 21 | dht.read(4) 22 | yeelink.update(dht.getTemperature()) 23 | 24 | end) 25 | end) 26 | -------------------------------------------------------------------------------- /lua_modules/yeelink/README.md: -------------------------------------------------------------------------------- 1 | # Yeelink Module 2 | 3 | Documentation for this Lua module is available in the [yeelink.md](../../docs/lua-modules/yeelink.md) file and in the [Official NodeMCU Documentation](https://nodemcu.readthedocs.io/) in `Lua Modules` section. 4 | -------------------------------------------------------------------------------- /rtd-requirements.txt: -------------------------------------------------------------------------------- 1 | ################################################################# 2 | # This file is configured in RTD -> Admin -> Advanced Settings! # 3 | ################################################################# 4 | # Enforce a specific MkDocs version by using the standard pip requirements.txt syntax 5 | # mkdocs >= 0.16.3, < 0.17 6 | -------------------------------------------------------------------------------- /sdk-overrides/include/c_types.h: -------------------------------------------------------------------------------- 1 | #ifndef _OVERRIDE_C_TYPES_H_ 2 | #define _OVERRIDE_C_TYPES_H_ 3 | 4 | #include_next "c_types.h" 5 | 6 | typedef long long int64_t; 7 | typedef int8_t sint8_t; 8 | typedef int16_t sint16_t; 9 | typedef int64_t sint64_t; 10 | 11 | #endif 12 | -------------------------------------------------------------------------------- /sdk-overrides/include/eagle_soc.h: -------------------------------------------------------------------------------- 1 | #ifndef _SDK_OVERRIDE_EAGLE_SOC_H_ 2 | #define _SDK_OVERRIDE_EAGLE_SOC_H_ 3 | 4 | 5 | #include_next "eagle_soc.h" 6 | 7 | #define GPIO_SIGMA_DELTA 0x00000068 //defined in gpio register.xls 8 | 9 | #define GPIO_SIGMA_DELTA_SETTING_MASK (0x00000001ff) 10 | 11 | #define GPIO_SIGMA_DELTA_ENABLE 1 12 | #define GPIO_SIGMA_DELTA_DISABLE (~GPIO_SIGMA_DELTA_ENABLE) 13 | #define GPIO_SIGMA_DELTA_MSB 16 14 | #define GPIO_SIGMA_DELTA_LSB 16 15 | #define GPIO_SIGMA_DELTA_MASK (0x00000001<> GPIO_SIGMA_DELTA_LSB) 17 | #define GPIO_SIGMA_DELTA_SET(x) (((x) << GPIO_SIGMA_DELTA_LSB) & GPIO_SIGMA_DELTA_MASK) 18 | 19 | #define GPIO_SIGMA_DELTA_TARGET_MSB 7 20 | #define GPIO_SIGMA_DELTA_TARGET_LSB 0 21 | #define GPIO_SIGMA_DELTA_TARGET_MASK (0x000000FF<> GPIO_SIGMA_DELTA_TARGET_LSB) 23 | #define GPIO_SIGMA_DELTA_TARGET_SET(x) (((x) << GPIO_SIGMA_DELTA_TARGET_LSB) & GPIO_SIGMA_DELTA_TARGET_MASK) 24 | 25 | #define GPIO_SIGMA_DELTA_PRESCALE_MSB 15 26 | #define GPIO_SIGMA_DELTA_PRESCALE_LSB 8 27 | #define GPIO_SIGMA_DELTA_PRESCALE_MASK (0x000000FF<> GPIO_SIGMA_DELTA_PRESCALE_LSB) 29 | #define GPIO_SIGMA_DELTA_PRESCALE_SET(x) (((x) << GPIO_SIGMA_DELTA_PRESCALE_LSB) & GPIO_SIGMA_DELTA_PRESCALE_MASK) 30 | 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /sdk-overrides/include/ets_sys.h: -------------------------------------------------------------------------------- 1 | #ifndef SDK_OVERRIDES_INCLUDE_ETS_SYS_H_ 2 | #define SDK_OVERRIDES_INCLUDE_ETS_SYS_H_ 3 | 4 | #include_next "ets_sys.h" 5 | 6 | #include "../libc/c_stdarg.h" 7 | 8 | int ets_sprintf(char *str, const char *format, ...) __attribute__ ((format (printf, 2, 3))); 9 | 10 | int ets_vsprintf (char *d, const char *s, va_list ap); 11 | 12 | extern ETSTimer *timer_list; 13 | 14 | #endif /* SDK_OVERRIDES_INCLUDE_ETS_SYS_H_ */ 15 | -------------------------------------------------------------------------------- /sdk-overrides/include/mem.h: -------------------------------------------------------------------------------- 1 | #ifndef _SDK_OVERRIDE_MEM_H_ 2 | #define _SDK_OVERRIDE_MEM_H_ 3 | 4 | void *pvPortMalloc (size_t sz, const char *, unsigned); 5 | void vPortFree (void *p, const char *, unsigned); 6 | void *pvPortZalloc (size_t sz, const char *, unsigned); 7 | void *pvPortRealloc (void *p, size_t n, const char *, unsigned); 8 | 9 | #include_next "mem.h" 10 | 11 | #endif 12 | -------------------------------------------------------------------------------- /sdk-overrides/include/osapi.h: -------------------------------------------------------------------------------- 1 | #ifndef _SDK_OVERRIDE_OSAPI_H_ 2 | #define _SDK_OVERRIDE_OSAPI_H_ 3 | 4 | #include "rom.h" 5 | 6 | int atoi(const char *nptr); 7 | int os_printf(const char *format, ...) __attribute__ ((format (printf, 1, 2))); 8 | int os_printf_plus(const char *format, ...) __attribute__ ((format (printf, 1, 2))); 9 | 10 | unsigned int uart_baudrate_detect(unsigned int uart_no, unsigned int async); 11 | 12 | void NmiTimSetFunc(void (*func)(void)); 13 | 14 | void call_user_start(void); 15 | 16 | #include_next "osapi.h" 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /sdk-overrides/include/user_interface.h: -------------------------------------------------------------------------------- 1 | #ifndef SDK_OVERRIDES_INCLUDE_USER_INTERFACE_H_ 2 | #define SDK_OVERRIDES_INCLUDE_USER_INTERFACE_H_ 3 | 4 | #include_next "user_interface.h" 5 | 6 | bool wifi_softap_deauth(uint8 mac[6]); 7 | uint8 get_fpm_auto_sleep_flag(void); 8 | 9 | //force sleep API 10 | #define FPM_SLEEP_MAX_TIME 268435455 //0xFFFFFFF 11 | void wifi_fpm_set_wakeup_cb(void (*fpm_wakeup_cb_func)(void)); 12 | bool fpm_is_open(void); 13 | bool fpm_rf_is_closed(void); 14 | uint8 get_fpm_auto_sleep_flag(void); 15 | 16 | 17 | 18 | #endif /* SDK_OVERRIDES_INCLUDE_USER_INTERFACE_H_ */ 19 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /tools/.gitignore: -------------------------------------------------------------------------------- 1 | TLS.* 2 | private_key.h 3 | cert.h 4 | -------------------------------------------------------------------------------- /tools/make_cert.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | 4 | class Cert(object): 5 | def __init__(self, name, buff): 6 | self.name = name 7 | self.len = len(buff) 8 | self.buff = buff 9 | pass 10 | 11 | def __str__(self): 12 | out_str = ['\0']*32 13 | for i in range(len(self.name)): 14 | out_str[i] = self.name[i] 15 | out_str = "".join(out_str) 16 | out_str += str(chr(self.len & 0xFF)) 17 | out_str += str(chr((self.len & 0xFF00) >> 8)) 18 | out_str += self.buff 19 | return out_str 20 | pass 21 | 22 | 23 | def main(): 24 | cert_list = [] 25 | file_list = os.listdir(os.getcwd()) 26 | cert_file_list = [] 27 | for _file in file_list: 28 | pos = _file.find(".cer") 29 | if pos != -1: 30 | cert_file_list.append(_file[:pos]) 31 | 32 | for cert_file in cert_file_list: 33 | with open(cert_file+".cer", 'rb') as f: 34 | buff = f.read() 35 | cert_list.append(Cert(cert_file, buff)) 36 | with open('esp_ca_cert.bin', 'wb+') as f: 37 | for _cert in cert_list: 38 | f.write("%s" % _cert) 39 | pass 40 | if __name__ == '__main__': 41 | main() 42 | 43 | -------------------------------------------------------------------------------- /tools/pr-build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | echo "Running PR build (all modules, SSL enabled, debug enabled)" 6 | ( 7 | cd "$TRAVIS_BUILD_DIR"/app/include || exit 8 | # uncomment disabled modules e.g. '//#define LUA_USE_MODULES_UCG' -> '#define LUA_USE_MODULES_UCG' 9 | sed -E -i.bak 's@(//.*)(#define *LUA_USE_MODULES_.*)@\2@g' user_modules.h 10 | cat user_modules.h 11 | 12 | # enable SSL 13 | sed -i.bak 's@//#define CLIENT_SSL_ENABLE@#define CLIENT_SSL_ENABLE@' user_config.h 14 | 15 | # enable debug 16 | sed -E -i.bak 's@// ?#define DEVELOP_VERSION@#define DEVELOP_VERSION@' user_config.h 17 | 18 | # enable FATFS 19 | sed -i 's@//#define BUILD_FATFS@#define BUILD_FATFS@' user_config.h 20 | cat user_config.h 21 | 22 | cd "$TRAVIS_BUILD_DIR"/ld || exit 23 | # increase irom0_0_seg size for all modules build 24 | sed -E -i.bak 's@(.*irom0_0_seg *:.*len *=) *[^,]*(.*)@\1 0x200000\2@' nodemcu.ld 25 | sed -E -i.bak 's@(.*iram1_0_seg *:.*len *=) *[^,]*(.*)@\1 0x100000\2@' nodemcu.ld 26 | cat nodemcu.ld 27 | 28 | # change to "root" directory no matter where the script was started from 29 | cd "$TRAVIS_BUILD_DIR" || exit 30 | make clean 31 | make 32 | 33 | LUA_FILES=`find lua_modules lua_examples -iname "*.lua"` 34 | echo checking $LUA_FILES 35 | ./luac.cross -p $LUA_FILES 36 | ) 37 | -------------------------------------------------------------------------------- /tools/spiffsimg/.gitignore: -------------------------------------------------------------------------------- 1 | spiffs.lst 2 | spiffsimg 3 | -------------------------------------------------------------------------------- /tools/spiffsimg/Makefile: -------------------------------------------------------------------------------- 1 | 2 | summary ?= @true 3 | 4 | CC =gcc 5 | 6 | SRCS=\ 7 | main.c \ 8 | ../../app/spiffs/spiffs_cache.c ../../app/spiffs/spiffs_check.c ../../app/spiffs/spiffs_gc.c ../../app/spiffs/spiffs_hydrogen.c ../../app/spiffs/spiffs_nucleus.c 9 | 10 | CFLAGS=-g -Wall -Wextra -Wno-unused-parameter -Wno-unused-function -I. -I../../app/spiffs -I../../app/include -DNODEMCU_SPIFFS_NO_INCLUDE --include spiffs_typedefs.h -Ddbg_printf=printf 11 | 12 | spiffsimg: $(SRCS) 13 | $(summary) HOSTCC $(CURDIR)/$< 14 | $(CC) $(CFLAGS) $^ $(LDFLAGS) -o $@ 15 | 16 | clean: 17 | rm -f spiffsimg 18 | -------------------------------------------------------------------------------- /tools/spiffsimg/README.md: -------------------------------------------------------------------------------- 1 | # spiffsimg - Manipulate SPI Flash File System disk images 2 | 3 | Ever wished you could prepare a SPIFFS image offline and flash the whole 4 | thing onto your microprocessor's storage instead of painstakingly upload 5 | file-by-file through your app on the micro? With spiffsimg you can! 6 | 7 | For the full gory details see [spiffs.md](../../docs/en/spiffs.md) 8 | -------------------------------------------------------------------------------- /tools/spiffsimg/spiffs_typedefs.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | typedef int32_t s32_t; 7 | typedef uint32_t u32_t; 8 | typedef int16_t s16_t; 9 | typedef uint16_t u16_t; 10 | typedef int8_t s8_t; 11 | typedef uint8_t u8_t; 12 | 13 | #ifndef __CYGWIN__ 14 | typedef long long ptrdiff_t; 15 | #define offsetof(type, member) __builtin_offsetof (type, member) 16 | #endif 17 | -------------------------------------------------------------------------------- /tools/update_spiffs.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # This script updates the SPIFFS code from the master repository 4 | 5 | if [ ! -e ../tools/update_spiffs.sh ]; then 6 | echo Must run from the tools directory 7 | exit 1 8 | fi 9 | 10 | git clone https://github.com/pellepl/spiffs 11 | 12 | cp spiffs/src/*.[ch] ../app/spiffs 13 | cp spiffs/LICENSE ../app/spiffs 14 | 15 | rm -fr spiffs 16 | -------------------------------------------------------------------------------- /tools/xxd.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devsaurus/nodemcu-firmware/27e9e6c085aaac8b7e78b7c1d9cd5afe39428ba0/tools/xxd.exe --------------------------------------------------------------------------------