├── .gdbinit ├── .gdbinitlua ├── .github ├── ISSUE_TEMPLATE │ ├── bug_report.md │ ├── feature_request.md │ └── question.md ├── PULL_REQUEST_TEMPLATE.md ├── stale.yml └── workflows │ ├── AutoCreateRelease.yml │ └── build.yml ├── .gitignore ├── .gitmodules ├── .readthedocs.yaml ├── 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 │ ├── NmraDcc.c │ ├── gpio16.c │ ├── i2c_master.c │ ├── input.c │ ├── key.c │ ├── onewire.c │ ├── pwm.c │ ├── pwm2.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 │ │ ├── NmraDcc.h │ │ ├── gpio16.h │ │ ├── i2c_master.h │ │ ├── input.h │ │ ├── key.h │ │ ├── onewire.h │ │ ├── pwm.h │ │ ├── pwm2.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 │ │ ├── aria.h │ │ ├── asn1.h │ │ ├── asn1write.h │ │ ├── base64.h │ │ ├── bignum.h │ │ ├── blowfish.h │ │ ├── bn_mul.h │ │ ├── camellia.h │ │ ├── ccm.h │ │ ├── certs.h │ │ ├── chacha20.h │ │ ├── chachapoly.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 │ │ ├── hkdf.h │ │ ├── hmac_drbg.h │ │ ├── md.h │ │ ├── md2.h │ │ ├── md4.h │ │ ├── md5.h │ │ ├── md_internal.h │ │ ├── memory_buffer_alloc.h │ │ ├── net.h │ │ ├── net_sockets.h │ │ ├── nist_kw.h │ │ ├── oid.h │ │ ├── padlock.h │ │ ├── pem.h │ │ ├── pk.h │ │ ├── pk_internal.h │ │ ├── pkcs11.h │ │ ├── pkcs12.h │ │ ├── pkcs5.h │ │ ├── platform.h │ │ ├── platform_time.h │ │ ├── platform_util.h │ │ ├── poly1305.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 │ ├── nodemcu_mdns.h │ ├── pm │ │ ├── pmSleep.h │ │ └── swtimer.h │ ├── rom.h │ ├── rtc │ │ ├── rtcaccess.h │ │ ├── rtcfifo.h │ │ ├── rtctime.h │ │ └── rtctime_internal.h │ ├── sections.h │ ├── sys │ │ ├── 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 │ ├── math.c │ ├── snprintf.c │ └── stdlib.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 │ ├── 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 │ ├── lnodemcu.c │ ├── lnodemcu.h │ ├── loadlib.c │ ├── lobject.c │ ├── lobject.h │ ├── lopcodes.c │ ├── lopcodes.h │ ├── lparser.c │ ├── lparser.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 │ │ ├── Makefile │ │ ├── lflashimg.c │ │ ├── liolib.c │ │ ├── loslib.c │ │ ├── luac.c │ │ ├── mingw32-Makefile.mak │ │ └── print.c │ ├── luaconf.h │ ├── lualib.h │ ├── lundump.c │ ├── lundump.h │ ├── lvm.c │ ├── lvm.h │ ├── lzio.c │ └── lzio.h ├── lua53 │ ├── Makefile │ ├── host │ │ ├── Makefile │ │ ├── liolib.c │ │ ├── loslib.c │ │ ├── ltests.c │ │ ├── ltests.h │ │ ├── luac.c │ │ └── tests │ │ │ ├── all.lua │ │ │ ├── api.lua │ │ │ ├── attrib.lua │ │ │ ├── big.lua │ │ │ ├── bitwise.lua │ │ │ ├── calls.lua │ │ │ ├── closure.lua │ │ │ ├── code.lua │ │ │ ├── constructs.lua │ │ │ ├── coroutine.lua │ │ │ ├── db.lua │ │ │ ├── errors.lua │ │ │ ├── events.lua │ │ │ ├── files.lua │ │ │ ├── gc.lua │ │ │ ├── goto.lua │ │ │ ├── literals.lua │ │ │ ├── locals.lua │ │ │ ├── main.lua │ │ │ ├── math.lua │ │ │ ├── nextvar.lua │ │ │ ├── pm.lua │ │ │ ├── sort.lua │ │ │ ├── stackbreak.lua │ │ │ ├── strings.lua │ │ │ ├── tpack.lua │ │ │ ├── utf8.lua │ │ │ ├── vararg.lua │ │ │ └── verybig.lua │ ├── lapi.c │ ├── lapi.h │ ├── lauxlib.c │ ├── lauxlib.h │ ├── lbaselib.c │ ├── lbitlib.c │ ├── lcode.c │ ├── lcode.h │ ├── lcorolib.c │ ├── lctype.c │ ├── lctype.h │ ├── ldblib.c │ ├── ldebug.c │ ├── ldebug.h │ ├── ldo.c │ ├── ldo.h │ ├── ldump.c │ ├── lfunc.c │ ├── lfunc.h │ ├── lgc.c │ ├── lgc.h │ ├── linit.c │ ├── llex.c │ ├── llex.h │ ├── llimits.h │ ├── lmathlib.c │ ├── lmem.c │ ├── lmem.h │ ├── lnodemcu.c │ ├── lnodemcu.h │ ├── loadlib.c │ ├── lobject.c │ ├── lobject.h │ ├── lopcodes.c │ ├── lopcodes.h │ ├── lparser.c │ ├── lparser.h │ ├── lprefix.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 │ ├── luaconf.h │ ├── lualib.h │ ├── lundump.c │ ├── lundump.h │ ├── lutf8lib.c │ ├── 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_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 │ │ ├── Makefile │ │ ├── espconn_mbedtls.c │ │ ├── espconn_secure.c │ │ ├── lwIPBuffer.c │ │ ├── lwIPFile.c │ │ └── lwIPSocket.c │ ├── library │ │ ├── Makefile │ │ ├── aes.c │ │ ├── aesni.c │ │ ├── arc4.c │ │ ├── aria.c │ │ ├── asn1parse.c │ │ ├── asn1write.c │ │ ├── base64.c │ │ ├── bignum.c │ │ ├── blowfish.c │ │ ├── camellia.c │ │ ├── ccm.c │ │ ├── certs.c │ │ ├── chacha20.c │ │ ├── chachapoly.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 │ │ ├── hkdf.c │ │ ├── hmac_drbg.c │ │ ├── md.c │ │ ├── md2.c │ │ ├── md4.c │ │ ├── md5.c │ │ ├── md_wrap.c │ │ ├── memory_buffer_alloc.c │ │ ├── nist_kw.c │ │ ├── oid.c │ │ ├── padlock.c │ │ ├── pem.c │ │ ├── pk.c │ │ ├── pk_wrap.c │ │ ├── pkcs11.c │ │ ├── pkcs12.c │ │ ├── pkcs5.c │ │ ├── pkparse.c │ │ ├── pkwrite.c │ │ ├── platform.c │ │ ├── platform_util.c │ │ ├── poly1305.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 │ │ └── memcompat.c ├── modules │ ├── .gitignore │ ├── Makefile │ ├── adc.c │ ├── ads1115.c │ ├── adxl345.c │ ├── am2320.c │ ├── apa102.c │ ├── bit.c │ ├── bloom.c │ ├── bme280.c │ ├── bme280_math.c │ ├── bme680.c │ ├── bme680_defs.h │ ├── bmp085.c │ ├── coap.c │ ├── color_utils.c │ ├── color_utils.h │ ├── cron.c │ ├── crypto.c │ ├── dcc.c │ ├── dht.c │ ├── encoder.c │ ├── enduser_setup.c │ ├── enduser_setup │ │ ├── .gitattributes │ │ ├── .gitignore │ │ ├── enduser_setup.html │ │ ├── enduser_setup.html.gz.def.h │ │ └── 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 │ ├── net_ping.c │ ├── net_ping.h │ ├── node.c │ ├── ow.c │ ├── pcm.c │ ├── perf.c │ ├── pipe.c │ ├── pixbuf.c │ ├── pixbuf.h │ ├── pwm.c │ ├── pwm2.c │ ├── rfswitch.c │ ├── rotary.c │ ├── rtcfifo.c │ ├── rtcmem.c │ ├── rtctime.c │ ├── si7021.c │ ├── sigma_delta.c │ ├── sjson.c │ ├── sntp.c │ ├── softuart.c │ ├── somfy.c │ ├── spi.c │ ├── struct.c │ ├── switec.c │ ├── tcs34725.c │ ├── tls.c │ ├── tm1829.c │ ├── tmr.c │ ├── tsl2561.c │ ├── u8g2.c │ ├── uart.c │ ├── ucg.c │ ├── websocket.c │ ├── wiegand.c │ ├── wifi.c │ ├── wifi_common.c │ ├── wifi_common.h │ ├── wifi_eventmon.c │ ├── wifi_monitor.c │ ├── wps.c │ ├── ws2801.c │ ├── ws2812.c │ ├── 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 │ ├── cpu_esp8266_irq.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 │ ├── 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 ├── tsl2561 │ ├── Makefile │ ├── tsl2561.c │ └── tsl2561.h ├── u8g2lib │ ├── Makefile │ └── u8x8_d_fbrle.c ├── ucglib │ └── Makefile ├── user │ ├── Makefile │ ├── dbg_printf.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 │ ├── WiFi-softap-mode.png │ ├── WiFi-station-mode.png │ ├── WiFi-stationap-mode.png │ ├── enduser-setup-captive-portal.png │ ├── 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 │ ├── README.md │ ├── bh1750.md │ ├── bme280.md │ ├── cohelper.md │ ├── ds18b20.md │ ├── ds3231.md │ ├── fifo.md │ ├── fifosock.md │ ├── file_lfs.md │ ├── ftpserver.md │ ├── gossip.md │ ├── hdc1000.md │ ├── httpserver.md │ ├── imap.md │ ├── liquidcrystal.md │ ├── lm92.md │ ├── mcp23008.md │ ├── mcp23017.md │ ├── redis.md │ ├── telnet.md │ └── yeelink.md ├── lua53.md ├── modules │ ├── adc.md │ ├── ads1115.md │ ├── adxl345.md │ ├── am2320.md │ ├── apa102.md │ ├── bit.md │ ├── bloom.md │ ├── bme280.md │ ├── bme280_math.md │ ├── bme680.md │ ├── bmp085.md │ ├── cjson.md │ ├── coap.md │ ├── color-utils.md │ ├── cron.md │ ├── crypto.md │ ├── dcc.md │ ├── dht.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 │ ├── pipe.md │ ├── pixbuf.md │ ├── pwm.md │ ├── pwm2.md │ ├── rfswitch.md │ ├── rotary.md │ ├── rtcfifo.md │ ├── rtcmem.md │ ├── rtctime.md │ ├── si7021.md │ ├── sigma-delta.md │ ├── sjson.md │ ├── sntp.md │ ├── softuart.md │ ├── somfy.md │ ├── spi.md │ ├── struct.md │ ├── switec.md │ ├── tcs34725.md │ ├── tls.md │ ├── tm1829.md │ ├── tmr.md │ ├── tsl2561.md │ ├── u8g2.md │ ├── uart.md │ ├── ucg.md │ ├── websocket.md │ ├── wiegand.md │ ├── wifi.md │ ├── wifi_monitor.md │ ├── wps.md │ ├── ws2801.md │ ├── ws2812-effects.md │ ├── ws2812.md │ └── xpt2046.md ├── nodemcu-lrm.md ├── nodemcu-pil.md ├── requirements.txt ├── sdcard.md ├── spiffs.md ├── support.md └── upload.md ├── ld ├── defsym.rom └── nodemcu.ld ├── local ├── fs │ └── .gitignore └── lua │ └── .gitignore ├── lua_examples ├── adc_rgb.lua ├── dcc │ └── dcc.lua ├── email │ ├── read_email_imap.lua │ └── send_email_smtp.lua ├── gossip_example.lua ├── irsend.lua ├── lfs │ ├── HTTP_OTA.lua │ ├── _init.lua │ ├── dummy_strings.lua │ └── lfs_fragments.lua ├── luaOTA │ ├── ESP-11223344.json │ ├── 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 ├── mcp23017 │ └── mcp23017_example.lua ├── mqtt │ ├── mqtt2cloud.lua │ └── mqtt_file.lua ├── myfile.lua ├── pcm │ ├── jump_8k.u8 │ ├── play_file.lua │ └── play_network.lua ├── pipeutils.lua ├── send_text_message.lua ├── sjson-streaming.lua ├── somfy.lua ├── tcp2uart.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 ├── bme280 │ └── bme280.lua ├── bmp085 │ └── README.md ├── cohelper │ ├── README.md │ └── cohelper.lua ├── dht_lib │ └── README.md ├── ds18b20 │ ├── README.md │ ├── ds18b20-example.lua │ ├── ds18b20-integer.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 ├── fifo │ ├── README.md │ ├── fifo.lua │ ├── fifosock.lua │ └── fifosocktest.lua ├── file_lfs │ ├── file_lfs.lua │ └── make_resource.lua ├── ftp │ ├── README.md │ └── ftpserver.lua ├── gossip │ ├── README.md │ ├── gossip.lua │ └── gossip_tests.lua ├── hdc1000 │ ├── HDC1000-example.lua │ ├── HDC1000.lua │ └── README.md ├── http │ ├── README.md │ ├── http-example.lua │ └── httpserver.lua ├── liquidcrystal │ ├── lc-gpio4bit.lua │ ├── lc-gpio8bit.lua │ ├── lc-i2c4bit.lua │ └── liquidcrystal.lua ├── lm92 │ ├── README.md │ └── lm92.lua ├── mcp23008 │ ├── README.md │ └── mcp23008.lua ├── mcp23017 │ ├── README.md │ └── mcp23017.lua ├── redis │ ├── README.md │ └── redis.lua ├── si7021 │ └── README.md ├── telnet │ ├── README.md │ └── telnet.lua ├── tsl2561 │ └── README.md └── yeelink │ ├── Example_for_Yeelink_Lib.lua │ ├── README.md │ └── yeelink_lib.lua ├── mkdocs.yml ├── msvc ├── .gitignore ├── README.md ├── hosttools.sln ├── luac-cross │ ├── luac-cross.vcxproj │ └── luac-cross.vcxproj.filters └── spiffsimg │ ├── getopt.h │ ├── spiffsimg.vcxproj │ └── spiffsimg.vcxproj.filters ├── rtd-requirements.txt ├── sdk-overrides └── include │ ├── c_types.h │ ├── eagle_soc.h │ ├── espconn.h │ ├── ets_sys.h │ ├── mem.h │ ├── osapi.h │ ├── stdbool.h │ ├── stdint.h │ ├── stdio.h │ ├── stdlib.h │ └── user_interface.h ├── tests ├── .gitattributes ├── HardwareTestHarness.md ├── NTest │ ├── NTest.lua │ ├── NTest.md │ └── NTest_NTest.lua ├── NTest_adc_env.lua ├── NTest_file.lua ├── NTest_file_lfs.lua ├── NTest_gpio_env.lua ├── NTest_lcd_i2c4bit.lua ├── NTest_lua.lua ├── NTest_pixbuf.lua ├── NTest_tmr.lua ├── NTest_ws2812.lua ├── NTest_ws2812_effects.lua ├── README.md ├── Test-Harness-Render-V1.png ├── Test-harness-schematic-v1.pdf ├── expectnmcu │ ├── core.tcl │ ├── pkgIndex.tcl │ └── xfer.tcl ├── tap-driver.expect └── utils │ └── NTestTapOut.lua └── tools ├── .gitattributes ├── .gitignore ├── Makefile ├── check_docs_module_linkage.sh ├── luacheck_NTest_config.lua ├── luacheck_config.lua ├── luacheck_config_helper.lua ├── make_cert.py ├── make_server_cert.py ├── makefile.sh ├── nodemcu-partition.py ├── spiffsimg ├── .gitignore ├── Makefile ├── README.md ├── main.c └── spiffs_typedefs.h ├── travis ├── ci-build-linux.sh ├── ci-build-windows-ms.sh ├── localua.sh ├── pr-build.sh ├── run-luacheck-linux.sh └── run-luacheck-windows.sh ├── update_buildinfo.sh ├── 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/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | ### Expected behavior 11 | 12 | ### Actual behavior 13 | 14 | ### Test code 15 | Provide a [Minimal, Complete, and Verifiable example](http://stackoverflow.com/help/mcve) which will reproduce the problem. 16 | ```Lua 17 | -- add code here 18 | ``` 19 | ### NodeMCU startup banner 20 | You MUST include the firmware startup banner to describe the version you are using. We reserve the right to immediately close any bug that doesn't. 21 | 22 | ### Hardware 23 | Describe which ESP8266/ESP32 device you use and document any special hardware setup 24 | required to reproduce the problem. 25 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | ### Missing feature 11 | See issue #1010 and note that we reserve the right to close feature requests if the originating poster is not proposing to resource the development him or herself. 12 | 13 | ### Justification 14 | Tell us why you would like to see this feature added. 15 | 16 | ### Workarounds 17 | Are there any workarounds you currently have in place because the feature is missing? 18 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/question.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Question 3 | about: Use Stack Overflow instead 4 | title: "\U0001F649" 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | 🛑 𝙎𝙏𝙊𝙋 11 | 12 | This issue tracker is not the place for questions! 13 | 14 | If you want to ask how to do something, or to understand why something isn't working the way you expect it to, see https://nodemcu.readthedocs.io/en/latest/support/ 15 | 16 | We close all questions without reading them. -------------------------------------------------------------------------------- /.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 the `release` branch. 6 | - [ ] This PR is compliant with the [other contributing guidelines](/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 | _To be completed below: Description of and rationale behind this PR._ 11 | -------------------------------------------------------------------------------- /.github/stale.yml: -------------------------------------------------------------------------------- 1 | # Number of days of inactivity before an issue becomes stale 2 | daysUntilStale: 360 3 | # Number of days of inactivity before a stale issue is closed 4 | daysUntilClose: 14 5 | # Issues with these labels will never be considered stale 6 | exemptLabels: 7 | - pinned 8 | - security 9 | - governance 10 | # Label to use when marking an issue as stale 11 | staleLabel: stale 12 | # Comment to post when marking an issue as stale. Set to `false` to disable 13 | markComment: > 14 | This issue has been automatically marked as stale because it has not had 15 | recent activity. It will be closed if no further activity occurs. Thank you 16 | for your contributions. 17 | # Comment to post when closing a stale issue. Set to `false` to disable 18 | closeComment: false 19 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | sdk/ 2 | cache/ 3 | user_config.h 4 | server-ca.crt 5 | sdkconfig 6 | sdkconfig.old* 7 | build/ 8 | components/*/.output/ 9 | tools/toolchains 10 | extmods.ini 11 | .ccache 12 | bin 13 | 14 | .gdb_history 15 | app/lua/.std 16 | app/lua53/.std 17 | sdk/ 18 | local/ 19 | luac.cross 20 | luac.cross.int 21 | uz_unzip 22 | uz_zip 23 | 24 | #ignore Eclipse project files 25 | .cproject 26 | .project 27 | .settings/ 28 | 29 | # ignore VS Code files 30 | .vscode/** 31 | # ignore VS files 32 | .vs/** 33 | 34 | # ignore IDEA files 35 | .idea 36 | *.iml 37 | 38 | #ignore temp file for build infos 39 | buildinfo.h 40 | -------------------------------------------------------------------------------- /.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 | [submodule "app/libc/c99-snprintf"] 8 | path = app/libc/c99-snprintf 9 | url = https://github.com/weiss/c99-snprintf.git 10 | -------------------------------------------------------------------------------- /.readthedocs.yaml: -------------------------------------------------------------------------------- 1 | # Read the Docs configuration file for MkDocs projects 2 | # See https://docs.readthedocs.io/en/stable/config-file/v2.html for details 3 | 4 | # Required 5 | version: 2 6 | 7 | # Set the version of Python and other tools you might need 8 | build: 9 | os: ubuntu-20.04 10 | tools: 11 | python: "3.7" 12 | 13 | mkdocs: 14 | configuration: mkdocs.yml 15 | 16 | # Optionally declare the Python requirements required to build your docs 17 | python: 18 | install: 19 | - requirements: docs/requirements.txt 20 | -------------------------------------------------------------------------------- /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 | PDIR := ../$(PDIR) 40 | sinclude $(PDIR)Makefile 41 | 42 | -------------------------------------------------------------------------------- /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 "lwip/ip_addr.h" 9 | #include "espconn.h" 10 | #include "pdu.h" 11 | #include "hash.h" 12 | 13 | coap_tid_t coap_send(struct espconn *pesp_conn, coap_pdu_t *pdu); 14 | 15 | coap_tid_t coap_send_confirmed(struct espconn *pesp_conn, coap_pdu_t *pdu); 16 | 17 | #ifdef __cplusplus 18 | } 19 | #endif 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /app/coap/coap_server.c: -------------------------------------------------------------------------------- 1 | #include "user_config.h" 2 | #include 3 | #include 4 | #include 5 | 6 | #include "coap.h" 7 | 8 | size_t coap_server_respond(char *req, unsigned short reqlen, char *rsp, unsigned short rsplen) 9 | { 10 | NODE_DBG("coap_server_respond is called.\n"); 11 | size_t rlen = rsplen; 12 | coap_packet_t pkt; 13 | pkt.content.p = NULL; 14 | pkt.content.len = 0; 15 | uint8_t scratch_raw[4]; 16 | coap_rw_buffer_t scratch_buf = {scratch_raw, sizeof(scratch_raw)}; 17 | int rc; 18 | 19 | #ifdef COAP_DEBUG 20 | NODE_DBG("Received: "); 21 | coap_dump(req, reqlen, true); 22 | NODE_DBG("\n"); 23 | #endif 24 | 25 | if (0 != (rc = coap_parse(&pkt, req, reqlen))){ 26 | NODE_DBG("Bad packet rc=%d\n", rc); 27 | return 0; 28 | } 29 | else 30 | { 31 | coap_packet_t rsppkt; 32 | rsppkt.content.p = NULL; 33 | rsppkt.content.len = 0; 34 | #ifdef COAP_DEBUG 35 | coap_dumpPacket(&pkt); 36 | #endif 37 | coap_handle_req(&scratch_buf, &pkt, &rsppkt); 38 | if (0 != (rc = coap_build(rsp, &rlen, &rsppkt))){ 39 | NODE_DBG("coap_build failed rc=%d\n", rc); 40 | // return 0; 41 | rlen = 0; 42 | } 43 | else 44 | { 45 | #ifdef COAP_DEBUG 46 | NODE_DBG("Responding: "); 47 | coap_dump(rsp, rlen, true); 48 | NODE_DBG("\n"); 49 | #endif 50 | #ifdef COAP_DEBUG 51 | coap_dumpPacket(&rsppkt); 52 | #endif 53 | } 54 | if(rsppkt.content.p){ 55 | free(rsppkt.content.p); 56 | rsppkt.content.p = NULL; 57 | rsppkt.content.len = 0; 58 | } 59 | return rlen; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /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 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 | 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 2 | #include "pdu.h" 3 | 4 | coap_pdu_t * coap_new_pdu(void) { 5 | coap_pdu_t *pdu = NULL; 6 | pdu = (coap_pdu_t *)calloc(1,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 *)calloc(1,MAX_REQ_SCRATCH_SIZE); 13 | if(!pdu->scratch.p){ 14 | NODE_DBG("coap_new_pdu malloc error.\n"); 15 | free(pdu); 16 | return NULL; 17 | } 18 | pdu->scratch.len = MAX_REQ_SCRATCH_SIZE; 19 | 20 | pdu->pkt = (coap_packet_t *)calloc(1,sizeof(coap_packet_t)); 21 | if(!pdu->pkt){ 22 | NODE_DBG("coap_new_pdu malloc error.\n"); 23 | free(pdu->scratch.p); 24 | 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 *)calloc(1,MAX_REQUEST_SIZE+1); // +1 for string '\0' 31 | if(!pdu->msg.p){ 32 | NODE_DBG("coap_new_pdu malloc error.\n"); 33 | free(pdu->pkt); 34 | free(pdu->scratch.p); 35 | 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 | free(pdu->scratch.p); 48 | pdu->scratch.p = NULL; 49 | pdu->scratch.len = 0; 50 | } 51 | 52 | if(pdu->pkt){ 53 | free(pdu->pkt); 54 | pdu->pkt = NULL; 55 | } 56 | 57 | if(pdu->msg.p){ 58 | free(pdu->msg.p); 59 | pdu->msg.p = NULL; 60 | pdu->msg.len = 0; 61 | } 62 | 63 | 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 10 | #include 11 | 12 | #include "str.h" 13 | 14 | str * coap_new_string(size_t size) { 15 | str *s = (str *)malloc(sizeof(str) + size + 1); 16 | if ( !s ) { 17 | return NULL; 18 | } 19 | 20 | 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 | 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 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 | PDIR := ../$(PDIR) 42 | sinclude $(PDIR)Makefile 43 | 44 | -------------------------------------------------------------------------------- /app/crypto/mech.h: -------------------------------------------------------------------------------- 1 | #ifndef _MECH_H_ 2 | #define _MECH_H_ 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | typedef struct 9 | { 10 | const char *key; 11 | size_t keylen; 12 | const char *iv; 13 | size_t ivlen; 14 | const char *data; 15 | size_t datalen; 16 | char *out; 17 | size_t outlen; 18 | enum { OP_ENCRYPT, OP_DECRYPT } op; 19 | } crypto_op_t; 20 | 21 | 22 | typedef struct 23 | { 24 | const char *name; 25 | bool (*run) (crypto_op_t *op); 26 | uint16_t block_size; 27 | } crypto_mech_t; 28 | 29 | 30 | const crypto_mech_t *crypto_encryption_mech (const char *name); 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /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 | #include 6 | 7 | /************************************************************************** 8 | * SHA256/384/512 declarations 9 | **************************************************************************/ 10 | 11 | #define SHA256_BLOCK_LENGTH 64 12 | #define SHA256_DIGEST_LENGTH 32 13 | 14 | typedef struct 15 | { 16 | uint32_t state[8]; 17 | uint64_t bitcount; 18 | uint8_t buffer[SHA256_BLOCK_LENGTH]; 19 | } SHA256_CTX; 20 | 21 | 22 | void SHA256_Init(SHA256_CTX *); 23 | void SHA256_Update(SHA256_CTX *, const uint8_t *msg, size_t len); 24 | void SHA256_Final(uint8_t[SHA256_DIGEST_LENGTH], SHA256_CTX*); 25 | 26 | #define SHA384_BLOCK_LENGTH 128 27 | #define SHA384_DIGEST_LENGTH 48 28 | 29 | typedef struct 30 | { 31 | uint64_t state[8]; 32 | uint64_t bitcount[2]; 33 | uint8_t buffer[SHA384_BLOCK_LENGTH]; 34 | } SHA384_CTX; 35 | 36 | void SHA384_Init(SHA384_CTX*); 37 | void SHA384_Update(SHA384_CTX*, const uint8_t *msg, size_t len); 38 | void SHA384_Final(uint8_t[SHA384_DIGEST_LENGTH], SHA384_CTX*); 39 | 40 | #define SHA512_BLOCK_LENGTH 128 41 | #define SHA512_DIGEST_LENGTH 64 42 | typedef SHA384_CTX SHA512_CTX; 43 | 44 | void SHA512_Init(SHA512_CTX*); 45 | void SHA512_Update(SHA512_CTX*, const uint8_t *msg, size_t len); 46 | void SHA512_Final(uint8_t[SHA512_DIGEST_LENGTH], SHA512_CTX*); 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /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 | PDIR := ../$(PDIR) 41 | sinclude $(PDIR)Makefile 42 | 43 | -------------------------------------------------------------------------------- /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 -Wall 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 | PDIR := ../$(PDIR) 42 | sinclude $(PDIR)Makefile 43 | 44 | -------------------------------------------------------------------------------- /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/nodemcu/nodemcu-firmware/36cbf9f017d356319a6369e299765eedff191154/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 ../../include/ets 41 | PDIR := ../$(PDIR) 42 | sinclude $(PDIR)Makefile 43 | 44 | -------------------------------------------------------------------------------- /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/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 = libfatfs.a 16 | endif 17 | 18 | ifndef FATFS_INC_DIR 19 | FATFS_INC_DIR = ./ 20 | endif 21 | 22 | STD_CFLAGS=-std=gnu11 -Wimplicit -imacros $(FATFS_INC_DIR)fatfs_prefix_lib.h 23 | 24 | ############################################################# 25 | # Configuration i.e. compile options etc. 26 | # Target specific stuff (defines etc.) goes in here! 27 | # Generally values applying to a tree are captured in the 28 | # makefile at its root level - these are then overridden 29 | # for a subtree within the makefile rooted therein 30 | # 31 | #DEFINES += 32 | 33 | ############################################################# 34 | # Recursion Magic - Don't touch this!! 35 | # 36 | # Each subtree potentially has an include directory 37 | # corresponding to the common APIs applicable to modules 38 | # rooted at that subtree. Accordingly, the INCLUDE PATH 39 | # of a module can only contain the include directories up 40 | # its parent path, and not its siblings 41 | # 42 | # Required for each makefile to inherit from the parent 43 | # 44 | 45 | PDIR := ../$(PDIR) 46 | sinclude $(PDIR)Makefile 47 | 48 | -------------------------------------------------------------------------------- /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 | PDIR := ../$(PDIR) 42 | sinclude $(PDIR)Makefile 43 | 44 | -------------------------------------------------------------------------------- /app/include/arch/sys_arch.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nodemcu/nodemcu-firmware/36cbf9f017d356319a6369e299765eedff191154/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/i2c_master.h: -------------------------------------------------------------------------------- 1 | #ifndef __I2C_MASTER_H__ 2 | #define __I2C_MASTER_H__ 3 | 4 | uint32 i2c_master_setup(uint16 id, uint8 sda, uint8 scl, uint32 speed); 5 | void i2c_master_init(uint16 id); 6 | bool i2c_master_configured(uint16 id); 7 | void i2c_master_stop(uint16 id); 8 | void i2c_master_start(uint16 id); 9 | uint8 i2c_master_readByte(uint16 id, sint16 ack); 10 | uint8 i2c_master_writeByte(uint16 id, uint8 wrdata); 11 | 12 | #endif //__I2C_MASTER_H__ 13 | -------------------------------------------------------------------------------- /app/include/driver/input.h: -------------------------------------------------------------------------------- 1 | #ifndef READLINE_APP_H 2 | #define READLINE_APP_H 3 | typedef void (*uart_cb_t)(const char *buf, size_t len); 4 | 5 | extern void input_setup(int bufsize, const char *prompt); 6 | extern void input_setup_receive(uart_cb_t uart_on_data_cb, int data_len, char end_char, bool run_input); 7 | extern void input_setecho (bool flag); 8 | extern void input_setprompt (const char *prompt); 9 | 10 | #endif /* READLINE_APP_H */ 11 | -------------------------------------------------------------------------------- /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/rotary.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Definitions to access the Rotary driver 3 | */ 4 | #ifndef __ROTARY_H__ 5 | #define __ROTARY_H__ 6 | 7 | #include 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 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 18 | #include 19 | 20 | #include "ets_sys.h" 21 | #include "os_type.h" 22 | 23 | typedef struct ringbuf_t { 24 | uint8_t *buf; 25 | uint8_t *head, *tail; 26 | size_t size; 27 | } ringbuf, *ringbuf_t; 28 | 29 | ringbuf_t ringbuf_new(size_t capacity); 30 | 31 | size_t ringbuf_buffer_size(const struct ringbuf_t *rb); 32 | 33 | void ringbuf_reset(ringbuf_t rb); 34 | 35 | void ringbuf_free(ringbuf_t *rb); 36 | 37 | size_t ringbuf_capacity(const struct ringbuf_t *rb); 38 | 39 | size_t ringbuf_bytes_free(const struct ringbuf_t *rb); 40 | 41 | size_t ringbuf_bytes_used(const struct ringbuf_t *rb); 42 | 43 | int ringbuf_is_full(const struct ringbuf_t *rb); 44 | 45 | int ringbuf_is_empty(const struct ringbuf_t *rb); 46 | 47 | const void* ringbuf_tail(const struct ringbuf_t *rb); 48 | 49 | const void* ringbuf_head(const struct ringbuf_t *rb); 50 | 51 | static uint8_t *ringbuf_nextp(ringbuf_t rb, const uint8_t *p); 52 | 53 | size_t ringbuf_findchr(const struct ringbuf_t *rb, int c, size_t offset); 54 | 55 | size_t ringbuf_memset(ringbuf_t dst, int c, size_t len); 56 | 57 | void *ringbuf_memcpy_into(ringbuf_t dst, const void *src, size_t count); 58 | 59 | void *ringbuf_memcpy_from(void *dst, ringbuf_t src, size_t count); 60 | 61 | #endif /* RINGBUF_H_ */ 62 | -------------------------------------------------------------------------------- /app/include/lwip/icmp.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nodemcu/nodemcu-firmware/36cbf9f017d356319a6369e299765eedff191154/app/include/lwip/icmp.h -------------------------------------------------------------------------------- /app/include/lwip/netif.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nodemcu/nodemcu-firmware/36cbf9f017d356319a6369e299765eedff191154/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 | #if !defined(MBEDTLS_CONFIG_FILE) 27 | #include "config.h" 28 | #else 29 | #include MBEDTLS_CONFIG_FILE 30 | #endif 31 | 32 | #if !defined(MBEDTLS_DEPRECATED_REMOVED) 33 | #include "net_sockets.h" 34 | #if defined(MBEDTLS_DEPRECATED_WARNING) 35 | #warning "Deprecated header file: Superseded by mbedtls/net_sockets.h" 36 | #endif /* MBEDTLS_DEPRECATED_WARNING */ 37 | #endif /* !MBEDTLS_DEPRECATED_REMOVED */ 38 | -------------------------------------------------------------------------------- /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/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/network_80211.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nodemcu/nodemcu-firmware/36cbf9f017d356319a6369e299765eedff191154/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 | ** The task interface is now part of the core platform interface. 5 | ** This header is preserved for backwards compatability only. 6 | */ 7 | #include "platform.h" 8 | 9 | #define TASK_PRIORITY_LOW PLATFORM_TASK_PRIORITY_LOW 10 | #define TASK_PRIORITY_MEDIUM PLATFORM_TASK_PRIORITY_MEDIUM 11 | #define TASK_PRIORITY_HIGH PLATFORM_TASK_PRIORITY_HIGH 12 | 13 | #define task_post(priority,handle,param) platform_post(priority,handle,param) 14 | #define task_post_low(handle,param) platform_post_low(handle,param) 15 | #define task_post_medium(handle,param) platform_post_medium(handle,param) 16 | #define task_post_high(handle,param) platform_post_high(handle,param) 17 | 18 | #define task_handle_t platform_task_handle_t 19 | #define task_param_t platform_task_param_t 20 | #define task_callback_t platform_task_callback_t 21 | #define task_get_id platform_task_get_id 22 | 23 | #endif 24 | 25 | -------------------------------------------------------------------------------- /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 | #include 6 | 7 | #define NODE_VERSION_MAJOR ESP_SDK_VERSION_MAJOR 8 | #define NODE_VERSION_MINOR ESP_SDK_VERSION_MINOR 9 | #define NODE_VERSION_REVISION ESP_SDK_VERSION_PATCH 10 | #define NODE_VERSION_INTERNAL 0 11 | 12 | #define NODE_VERSION_STR(x) #x 13 | #define NODE_VERSION_XSTR(x) NODE_VERSION_STR(x) 14 | 15 | # define NODE_VERSION "NodeMCU " ESP_SDK_VERSION_STRING "." NODE_VERSION_XSTR(NODE_VERSION_INTERNAL) " " NODE_VERSION_LONG 16 | // Leave the space after # in the line above. It busts replacement of NODE_VERSION in the docker build which is not needed anymore with this PR. 17 | // Can be removed when the script is adapted 18 | 19 | #ifndef BUILD_DATE 20 | #define BUILD_DATE BUILDINFO_BUILD_DATE 21 | #endif 22 | 23 | extern char SDK_VERSION[]; 24 | 25 | #endif /* __USER_VERSION_H__ */ 26 | -------------------------------------------------------------------------------- /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 | PDIR := ../$(PDIR) 40 | sinclude $(PDIR)Makefile 41 | 42 | -------------------------------------------------------------------------------- /app/libc/snprintf.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Wrapper around https://github.com/weiss/c99-snprintf 3 | */ 4 | 5 | #define HAVE_CONFIG_H 0 6 | #define TEST_SNPRINTF 0 7 | #define HAVE_SNPRINTF 0 8 | #define HAVE_VSNPRINTF 0 9 | #define HAVE_ASPRINTF 0 10 | #define HAVE_VASPRINTF 0 11 | 12 | #define HAVE_STDARG_H 1 13 | #define HAVE_STDLIB_H 1 14 | 15 | #define HAVE_VA_COPY 0 16 | #define HAVE___VA_COPY 0 17 | #define HAVE_FLOAT_H 1 18 | #define HAVE_INTTYPES_H 1 19 | #define HAVE_LOCALE_H 0 20 | #define HAVE_STDDEF_H 1 21 | #define HAVE_STDINT_H 1 22 | #define HAVE_UNSIGNED_LONG_LONG_INT 1 23 | #define HAVE_UINTMAX_T 1 24 | #define HAVE_LONG_DOUBLE 0 25 | #define HAVE_LONG_LONG_INT 1 26 | #define HAVE_INTMAX_T 1 27 | #define HAVE_UINTPTR_T 1 28 | #define HAVE_PTRDIFF_T 1 29 | 30 | #define HAVE_LOCALECONV 0 31 | #define HAVE_LCONV_DECIMAL_POINT 0 32 | #define HAVE_LCONV_THOUSANDS_SEP 0 33 | #define LDOUBLE_MIN_10_EXP DBL_MIN_10_EXP 34 | #define LDOUBLE_MAX_10_EXP DBL_MAX_10_EXP 35 | 36 | #define rpl_snprintf snprintf 37 | #define rpl_vsnprintf vsnprintf 38 | #define rpl_vasprintf vasprintf 39 | #define rpl_asprintf asprintf 40 | 41 | #include "c99-snprintf/snprintf.c" 42 | 43 | int sprintf(char *s, const char *fmt, ...) 44 | { 45 | int n; 46 | va_list arg; 47 | va_start(arg, fmt); 48 | n = vsnprintf(s, 1024, fmt, arg); 49 | va_end(arg); 50 | return n; 51 | } 52 | 53 | int vsprintf (char *d, const char *s, va_list ap) 54 | { 55 | return vsnprintf(d, 1024, s, ap); 56 | } 57 | 58 | 59 | -------------------------------------------------------------------------------- /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/ldebug.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: ldebug.h,v 2.3.1.1 2007/12/27 13:02:25 roberto Exp $ 3 | ** Auxiliary functions from Debug Interface module 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef ldebug_h 8 | #define ldebug_h 9 | 10 | 11 | #include "lstate.h" 12 | 13 | 14 | #define pcRel(pc, p) (cast(int, (pc) - (p)->code) - 1) 15 | 16 | # include "lvm.h" 17 | # define getline(f,pc) (((f)->packedlineinfo) ? luaG_getline((f), pc) : 0) 18 | # define INFO_FILL_BYTE 0x7F 19 | # define INFO_DELTA_MASK 0x80 20 | # define INFO_SIGN_MASK 0x40 21 | # define INFO_DELTA_6BITS 0x3F 22 | # define INFO_DELTA_7BITS 0x7F 23 | # define INFO_MAX_LINECNT 126 24 | # define lineInfoTop(fs) ((fs)->f->packedlineinfo + (fs)->lastlineOffset) 25 | 26 | #define resethookcount(L) (L->hookcount = L->basehookcount) 27 | 28 | 29 | LUAI_FUNC void luaG_typeerror (lua_State *L, const TValue *o, 30 | const char *opname); 31 | LUAI_FUNC void luaG_concaterror (lua_State *L, StkId p1, StkId p2); 32 | LUAI_FUNC void luaG_aritherror (lua_State *L, const TValue *p1, 33 | const TValue *p2); 34 | LUAI_FUNC int luaG_ordererror (lua_State *L, const TValue *p1, 35 | const TValue *p2); 36 | LUAI_FUNC void luaG_runerror (lua_State *L, const char *fmt, ...); 37 | LUAI_FUNC void luaG_errormsg (lua_State *L); 38 | LUAI_FUNC int luaG_checkcode (const Proto *pt); 39 | LUAI_FUNC int luaG_checkopenop (Instruction i); 40 | LUAI_FUNC int luaG_getline (const Proto *f, int pc); 41 | LUAI_FUNC int luaG_stripdebug (lua_State *L, Proto *f, int level, int recv); 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /app/lua/lflash.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** lflashe.h 3 | ** See Copyright Notice in lua.h 4 | */ 5 | 6 | #ifndef 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 | #endif 47 | 48 | -------------------------------------------------------------------------------- /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 | #include "llimits.h" 12 | #include "lua.h" 13 | 14 | #define MEMERRMSG "not enough memory" 15 | 16 | 17 | #define luaM_reallocv(L,b,on,n,e) \ 18 | ((cast(size_t, (n)+1) <= MAX_SIZET/(e)) ? /* +1 to avoid warnings */ \ 19 | luaM_realloc_(L, (b), (on)*(e), (n)*(e)) : \ 20 | luaM_toobig(L)) 21 | 22 | #define luaM_freemem(L, b, s) luaM_realloc_(L, (b), (s), 0) 23 | #define luaM_free(L, b) luaM_realloc_(L, (b), sizeof(*(b)), 0) 24 | #define luaM_freearray(L, b, n, t) luaM_reallocv(L, (b), n, 0, sizeof(t)) 25 | 26 | #define luaM_malloc(L,t) luaM_realloc_(L, NULL, 0, (t)) 27 | #define luaM_new(L,t) cast(t *, luaM_malloc(L, sizeof(t))) 28 | #define luaM_newvector(L,n,t) \ 29 | cast(t *, luaM_reallocv(L, NULL, 0, n, sizeof(t))) 30 | 31 | #define luaM_growvector(L,v,nelems,size,t,limit,e) \ 32 | if ((nelems)+1 > (size)) \ 33 | ((v)=cast(t *, luaM_growaux_(L,v,&(size),sizeof(t),limit,e))) 34 | 35 | #define luaM_reallocvector(L, v,oldn,n,t) \ 36 | ((v)=cast(t *, luaM_reallocv(L, v, oldn, n, sizeof(t)))) 37 | 38 | 39 | LUAI_FUNC void *luaM_realloc_ (lua_State *L, void *block, size_t oldsize, 40 | size_t size); 41 | LUAI_FUNC void *luaM_toobig (lua_State *L); 42 | LUAI_FUNC void *luaM_growaux_ (lua_State *L, void *block, int *size, 43 | size_t size_elem, int limit, 44 | const char *errormsg); 45 | 46 | #endif 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)+((s)->len+1)*sizeof(char)) 17 | #define sizeudata(u) (sizeof(union Udata)+(u)->len) 18 | 19 | #define luaS_new(L, s) (luaS_newlstr(L, s, strlen(s))) 20 | #define luaS_newliteral(L, s) (luaS_newlstr(L, "" s, \ 21 | (sizeof(s)/sizeof(char))-1)) 22 | 23 | LUAI_FUNC void luaS_resize (lua_State *L, int newsize); 24 | LUAI_FUNC Udata *luaS_newudata (lua_State *L, size_t s, Table *e); 25 | LUAI_FUNC TString *luaS_newlstr (lua_State *L, const char *str, size_t l); 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /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 | #define isrotable(t) (gettt(t)==LUA_TROTABLE) 20 | #define isrwtable(t) (gettt(t)==LUA_TTABLE) 21 | 22 | LUAI_FUNC const TValue *luaH_getnum (Table *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 TValue *luaH_setstr (lua_State *L, Table *t, TString *key); 26 | LUAI_FUNC const TValue *luaH_get (Table *t, const TValue *key); 27 | LUAI_FUNC TValue *luaH_set (lua_State *L, Table *t, const TValue *key); 28 | LUAI_FUNC Table *luaH_new (lua_State *L, int narray, int lnhash); 29 | LUAI_FUNC void luaH_resizearray (lua_State *L, Table *t, int nasize); 30 | LUAI_FUNC void luaH_free (lua_State *L, Table *t); 31 | LUAI_FUNC int luaH_next (lua_State *L, Table *t, StkId key); 32 | LUAI_FUNC int luaH_getn (Table *t); 33 | LUAI_FUNC int luaH_isdummy (Node *n); 34 | 35 | #define LUA_MAX_ROTABLE_NAME 32 36 | 37 | #if defined(LUA_DEBUG) 38 | LUAI_FUNC Node *luaH_mainposition (const Table *t, const TValue *key); 39 | #endif 40 | #endif 41 | -------------------------------------------------------------------------------- /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 | * WARNING: if you change the order of this enumeration, 12 | * grep "ORDER TM" 13 | */ 14 | typedef enum { 15 | TM_INDEX, 16 | TM_NEWINDEX, 17 | TM_GC, 18 | TM_MODE, 19 | TM_EQ, /* last tag method with `fast' access */ 20 | TM_ADD, 21 | TM_SUB, 22 | TM_MUL, 23 | TM_DIV, 24 | TM_MOD, 25 | TM_POW, 26 | TM_UNM, 27 | TM_LEN, 28 | TM_LT, 29 | TM_LE, 30 | TM_CONCAT, 31 | TM_CALL, 32 | TM_METATABLE, 33 | TM_N /* number of elements in the enum */ 34 | } TMS; 35 | 36 | //#include "lobject.h" 37 | 38 | #define gfasttm(g,et,e) ((et) == NULL ? NULL : \ 39 | (getflags(et) & (1u<<(e))) ? NULL : luaT_gettm(et, e, (g)->tmname[e])) 40 | 41 | #define fasttm(l,et,e) gfasttm(G(l), et, e) 42 | 43 | LUAI_DATA const char *const luaT_typenames[]; 44 | 45 | 46 | LUAI_FUNC const TValue *luaT_gettm (Table *events, TMS event, TString *ename); 47 | LUAI_FUNC const TValue *luaT_gettmbyobj (lua_State *L, const TValue *o, 48 | TMS event); 49 | LUAI_FUNC void luaT_init (lua_State *L); 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /app/lua/lua.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** NodeMCU Lua 5.1 main initiator and comand interpreter 3 | ** See Copyright Notice in lua.h 4 | */ 5 | #include "lua.h" 6 | #include "lauxlib.h" 7 | #include "lualib.h" 8 | #include "llimits.h" 9 | #define LUA_VERSION_51 10 | #include "os_type.h" 11 | #include "../lua53/lua.c" 12 | 13 | -------------------------------------------------------------------------------- /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/lundump.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lundump.h,v 1.37.1.1 2007/12/27 13:02:25 roberto Exp $ 3 | ** load precompiled Lua chunks 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lundump_h 8 | #define lundump_h 9 | 10 | #include 11 | 12 | #include "lobject.h" 13 | #include "lzio.h" 14 | 15 | typedef uint32_t strsize_t; 16 | 17 | /* info about target machine for cross-compilation */ 18 | typedef struct { 19 | int little_endian; 20 | int sizeof_int; 21 | int sizeof_strsize_t; 22 | int sizeof_lua_Number; 23 | int lua_Number_integral; 24 | int is_arm_fpa; 25 | } DumpTargetInfo; 26 | 27 | /* load one chunk; from lundump.c */ 28 | LUAI_FUNC Proto* luaU_undump (lua_State* L, ZIO* Z, Mbuffer* buff, const char* name); 29 | 30 | /* make header; from lundump.c */ 31 | LUAI_FUNC void luaU_header (char* h); 32 | 33 | /* dump one chunk to a different target; from ldump.c */ 34 | int luaU_dump_crosscompile (lua_State* L, const Proto* f, lua_Writer w, void* data, int strip, DumpTargetInfo target); 35 | 36 | /* dump one chunk; from ldump.c */ 37 | LUAI_FUNC int luaU_dump (lua_State* L, const Proto* f, lua_Writer w, void* data, int strip); 38 | 39 | #ifdef luac_c 40 | /* print one chunk; from print.c */ 41 | LUAI_FUNC void luaU_print (const Proto* f, int full); 42 | #endif 43 | 44 | /* for header of binary files -- this is Lua 5.1 */ 45 | #define LUAC_VERSION 0x51 46 | 47 | /* for header of binary files -- this is the official format */ 48 | #define LUAC_FORMAT 0 49 | 50 | /* size of header of binary files */ 51 | #define LUAC_HEADERSIZE 12 52 | 53 | #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_lessequal (lua_State *L, const TValue *l, const TValue *r); 27 | LUAI_FUNC int luaV_equalval (lua_State *L, const TValue *t1, const TValue *t2); 28 | LUAI_FUNC const TValue *luaV_tonumber (const TValue *obj, TValue *n); 29 | LUAI_FUNC int luaV_tostring (lua_State *L, StkId obj); 30 | LUAI_FUNC void luaV_gettable (lua_State *L, const TValue *t, TValue *key, 31 | StkId val); 32 | LUAI_FUNC void luaV_settable (lua_State *L, const TValue *t, TValue *key, 33 | StkId val); 34 | LUAI_FUNC void luaV_execute (lua_State *L, int nexeccalls); 35 | LUAI_FUNC void luaV_concat (lua_State *L, int total, int last); 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /app/lua53/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 | SUBDIRS = host 16 | GEN_LIBS = liblua.a 17 | endif 18 | 19 | STD_CFLAGS=-std=gnu11 -Wimplicit -Wall 20 | 21 | 22 | # Validate LUA setting 23 | ifeq ("$(LUA)","53") 24 | # ok 25 | else ifeq ("$(LUA)","51") 26 | $(error Your variable LUA="$(LUA)" looks like you probably want \ 27 | app/lua/Makefile instead) 28 | else 29 | $(error Expected environment variable "LUA" to be "53", not "$(LUA)") 30 | endif 31 | 32 | 33 | ############################################################# 34 | # Configuration i.e. compile options etc. 35 | # Target specific stuff (defines etc.) goes in here! 36 | # 37 | #DEFINES += -DDEVELOPMENT_TOOLS -DDEVELOPMENT_USE_GDB -DDEVELOPMENT_BREAK_ON_STARTUP_PIN=1 38 | #EXTRA_CCFLAGS += -ggdb -O0 39 | 40 | ############################################################# 41 | # Recursion Magic - Don't touch this!! 42 | # 43 | 44 | INCLUDES := $(INCLUDES) -I $(PDIR)include 45 | INCLUDES += -I ./ 46 | INCLUDES += -I ../spiffs 47 | INCLUDES += -I ../libc 48 | INCLUDES += -I ../modules 49 | INCLUDES += -I ../platform 50 | INCLUDES += -I ../uzlib 51 | PDIR := ../$(PDIR) 52 | sinclude $(PDIR)Makefile 53 | -------------------------------------------------------------------------------- /app/lua53/host/tests/db.lua: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nodemcu/nodemcu-firmware/36cbf9f017d356319a6369e299765eedff191154/app/lua53/host/tests/db.lua -------------------------------------------------------------------------------- /app/lua53/host/tests/files.lua: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nodemcu/nodemcu-firmware/36cbf9f017d356319a6369e299765eedff191154/app/lua53/host/tests/files.lua -------------------------------------------------------------------------------- /app/lua53/host/tests/pm.lua: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nodemcu/nodemcu-firmware/36cbf9f017d356319a6369e299765eedff191154/app/lua53/host/tests/pm.lua -------------------------------------------------------------------------------- /app/lua53/host/tests/sort.lua: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nodemcu/nodemcu-firmware/36cbf9f017d356319a6369e299765eedff191154/app/lua53/host/tests/sort.lua -------------------------------------------------------------------------------- /app/lua53/host/tests/strings.lua: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nodemcu/nodemcu-firmware/36cbf9f017d356319a6369e299765eedff191154/app/lua53/host/tests/strings.lua -------------------------------------------------------------------------------- /app/lua53/lapi.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lapi.h,v 2.9.1.1 2017/04/19 17:20:42 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 "llimits.h" 12 | #include "lstate.h" 13 | 14 | #define api_incr_top(L) {L->top++; api_check(L, L->top <= L->ci->top, \ 15 | "stack overflow");} 16 | 17 | #define adjustresults(L,nres) \ 18 | { if ((nres) == LUA_MULTRET && L->ci->top < L->top) L->ci->top = L->top; } 19 | 20 | #define api_checknelems(L,n) api_check(L, (n) < (L->top - L->ci->func), \ 21 | "not enough elements in the stack") 22 | 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /app/lua53/ldebug.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: ldebug.h,v 2.14.1.1 2017/04/19 17:20:42 roberto Exp $ 3 | ** Auxiliary functions from Debug Interface module 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef ldebug_h 8 | #define ldebug_h 9 | 10 | 11 | #include "lstate.h" 12 | 13 | 14 | #define pcRel(pc, p) (cast(int, (pc) - (p)->code) - 1) 15 | 16 | #define getfuncline(f,pc) (luaG_getfuncline(NULL,f,pc)) 17 | 18 | #define resethookcount(L) (L->hookcount = L->basehookcount) 19 | 20 | 21 | LUAI_FUNC l_noret luaG_typeerror (lua_State *L, const TValue *o, 22 | const char *opname); 23 | LUAI_FUNC l_noret luaG_concaterror (lua_State *L, const TValue *p1, 24 | const TValue *p2); 25 | LUAI_FUNC l_noret luaG_opinterror (lua_State *L, const TValue *p1, 26 | const TValue *p2, 27 | const char *msg); 28 | LUAI_FUNC l_noret luaG_tointerror (lua_State *L, const TValue *p1, 29 | const TValue *p2); 30 | LUAI_FUNC l_noret luaG_ordererror (lua_State *L, const TValue *p1, 31 | const TValue *p2); 32 | LUAI_FUNC l_noret luaG_runerror (lua_State *L, const char *fmt, ...); 33 | LUAI_FUNC const char *luaG_addinfo (lua_State *L, const char *msg, 34 | TString *src, int line); 35 | LUAI_FUNC l_noret luaG_errormsg (lua_State *L); 36 | LUAI_FUNC void luaG_traceexec (lua_State *L); 37 | LUAI_FUNC int luaG_getfuncline (lua_State *L, const Proto *f, int ins_pc); 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /app/lua53/lprefix.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lprefix.h,v 1.2.1.1 2017/04/19 17:20:42 roberto Exp $ 3 | ** Definitions for Lua code that must come before any other header file 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lprefix_h 8 | #define lprefix_h 9 | 10 | 11 | /* 12 | ** Allows POSIX/XSI stuff 13 | */ 14 | #if !defined(LUA_USE_C89) /* { */ 15 | 16 | #if !defined(_XOPEN_SOURCE) 17 | #define _XOPEN_SOURCE 600 18 | #elif _XOPEN_SOURCE == 0 19 | #undef _XOPEN_SOURCE /* use -D_XOPEN_SOURCE=0 to undefine it */ 20 | #endif 21 | 22 | /* 23 | ** Allows manipulation of large files in gcc and some other compilers 24 | */ 25 | #if !defined(LUA_32BITS) && !defined(_FILE_OFFSET_BITS) 26 | #define _LARGEFILE_SOURCE 1 27 | #define _FILE_OFFSET_BITS 64 28 | #endif 29 | 30 | #endif /* } */ 31 | 32 | 33 | /* 34 | ** Windows stuff 35 | */ 36 | #if defined(_WIN32) /* { */ 37 | 38 | #if !defined(_CRT_SECURE_NO_WARNINGS) 39 | #define _CRT_SECURE_NO_WARNINGS /* avoid warnings about ISO C functions */ 40 | #endif 41 | 42 | #endif /* } */ 43 | 44 | #endif 45 | 46 | -------------------------------------------------------------------------------- /app/lua53/lualib.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lualib.h,v 1.45.1.1 2017/04/19 17:20:42 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 | /* version suffix for environment variable names */ 15 | #define LUA_VERSUFFIX "_" LUA_VERSION_MAJOR "_" LUA_VERSION_MINOR 16 | 17 | 18 | LUAMOD_API int (luaopen_base) (lua_State *L); 19 | 20 | #define LUA_COLIBNAME "coroutine" 21 | LUAMOD_API int (luaopen_coroutine) (lua_State *L); 22 | 23 | #define LUA_TABLIBNAME "table" 24 | LUAMOD_API int (luaopen_table) (lua_State *L); 25 | 26 | #define LUA_IOLIBNAME "io" 27 | LUAMOD_API int (luaopen_io) (lua_State *L); 28 | 29 | #define LUA_OSLIBNAME "os" 30 | LUAMOD_API int (luaopen_os) (lua_State *L); 31 | 32 | #define LUA_STRLIBNAME "string" 33 | LUAMOD_API int (luaopen_string) (lua_State *L); 34 | 35 | #define LUA_UTF8LIBNAME "utf8" 36 | LUAMOD_API int (luaopen_utf8) (lua_State *L); 37 | 38 | #define LUA_BITLIBNAME "bit32" 39 | LUAMOD_API int (luaopen_bit32) (lua_State *L); 40 | 41 | #define LUA_MATHLIBNAME "math" 42 | LUAMOD_API int (luaopen_math) (lua_State *L); 43 | 44 | #define LUA_DBLIBNAME "debug" 45 | LUAMOD_API int (luaopen_debug) (lua_State *L); 46 | 47 | #define LUA_LOADLIBNAME "package" 48 | LUAMOD_API int (luaopen_package) (lua_State *L); 49 | 50 | 51 | /* open all previous libraries */ 52 | LUALIB_API void (luaL_openlibs) (lua_State *L); 53 | 54 | 55 | 56 | #if !defined(lua_assert) 57 | #define lua_assert(x) ((void)0) 58 | #endif 59 | 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /app/lua53/lzio.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lzio.c,v 1.37.1.1 2017/04/19 17:20:42 roberto Exp $ 3 | ** Buffered streams 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #define lzio_c 8 | #define LUA_CORE 9 | 10 | #include "lprefix.h" 11 | 12 | 13 | #include 14 | 15 | #include "lua.h" 16 | 17 | #include "llimits.h" 18 | #include "lmem.h" 19 | #include "lstate.h" 20 | #include "lzio.h" 21 | 22 | 23 | int luaZ_fill (ZIO *z) { 24 | size_t size; 25 | lua_State *L = z->L; 26 | const char *buff; 27 | lua_unlock(L); 28 | buff = z->reader(L, z->data, &size); 29 | lua_lock(L); 30 | if (buff == NULL || size == 0) 31 | return EOZ; 32 | z->n = size - 1; /* discount char being returned */ 33 | z->p = buff; 34 | return cast_uchar(*(z->p++)); 35 | } 36 | 37 | 38 | void luaZ_init (lua_State *L, ZIO *z, lua_Reader reader, void *data) { 39 | z->L = L; 40 | z->reader = reader; 41 | z->data = data; 42 | z->n = 0; 43 | z->p = NULL; 44 | } 45 | 46 | 47 | /* --------------------------------------------------------------- read --- */ 48 | size_t luaZ_read (ZIO *z, void *b, size_t n) { 49 | while (n) { 50 | size_t m; 51 | if (z->n == 0) { /* no bytes in buffer? */ 52 | if (luaZ_fill(z) == EOZ) /* try to read more */ 53 | return n; /* no more input; return number of missing bytes */ 54 | else { 55 | z->n++; /* luaZ_fill consumed first byte; put it back */ 56 | z->p--; 57 | } 58 | } 59 | m = (n <= z->n) ? n : z->n; /* min. between n and z->n */ 60 | memcpy(b, z->p, m); 61 | z->n -= m; 62 | z->p += m; 63 | b = (char *)b + m; 64 | n -= m; 65 | } 66 | return 0; 67 | } 68 | 69 | -------------------------------------------------------------------------------- /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 | PDIR := ../$(PDIR) 43 | sinclude $(PDIR)Makefile 44 | 45 | -------------------------------------------------------------------------------- /app/lwip/api/netbuf.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nodemcu/nodemcu-firmware/36cbf9f017d356319a6369e299765eedff191154/app/lwip/api/netbuf.c -------------------------------------------------------------------------------- /app/lwip/api/tcpip.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nodemcu/nodemcu-firmware/36cbf9f017d356319a6369e299765eedff191154/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 | PDIR := ../$(PDIR) 43 | sinclude $(PDIR)Makefile 44 | 45 | -------------------------------------------------------------------------------- /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 | PDIR := ../$(PDIR) 43 | sinclude $(PDIR)Makefile 44 | 45 | -------------------------------------------------------------------------------- /app/lwip/core/ipv4/Makefile: -------------------------------------------------------------------------------- 1 | 2 | ############################################################# 3 | # Required variables for each makefile 4 | # Discard this section from all parent makefiles 5 | # Expected variables (with automatic defaults): 6 | # CSRCS (all "C" files in the dir) 7 | # SUBDIRS (all subdirs with a Makefile) 8 | # GEN_LIBS - list of libs to be generated () 9 | # GEN_IMAGES - list of images to be generated () 10 | # COMPONENTS_xxx - a list of libs/objs in the form 11 | # subdir/lib to be extracted and rolled up into 12 | # a generated lib/image xxx.a () 13 | # 14 | ifndef PDIR 15 | 16 | GEN_LIBS = liblwipipv4.a 17 | 18 | endif 19 | 20 | 21 | ############################################################# 22 | # Configuration i.e. compile options etc. 23 | # Target specific stuff (defines etc.) goes in here! 24 | # Generally values applying to a tree are captured in the 25 | # makefile at its root level - these are then overridden 26 | # for a subtree within the makefile rooted therein 27 | # 28 | #DEFINES += 29 | 30 | ############################################################# 31 | # Recursion Magic - Don't touch this!! 32 | # 33 | # Each subtree potentially has an include directory 34 | # corresponding to the common APIs applicable to modules 35 | # rooted at that subtree. Accordingly, the INCLUDE PATH 36 | # of a module can only contain the include directories up 37 | # its parent path, and not its siblings 38 | # 39 | # Required for each makefile to inherit from the parent 40 | # 41 | 42 | PDIR := ../$(PDIR) 43 | sinclude $(PDIR)Makefile 44 | 45 | -------------------------------------------------------------------------------- /app/lwip/core/ipv4/icmp.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nodemcu/nodemcu-firmware/36cbf9f017d356319a6369e299765eedff191154/app/lwip/core/ipv4/icmp.c -------------------------------------------------------------------------------- /app/lwip/core/sys_arch.c: -------------------------------------------------------------------------------- 1 | /* 2 | * copyright (c) 2010 - 2011 espressif system 3 | */ 4 | 5 | #include 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 | PDIR := ../$(PDIR) 43 | sinclude $(PDIR)Makefile 44 | 45 | -------------------------------------------------------------------------------- /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 | STD_CFLAGS=-std=gnu11 21 | 22 | ############################################################# 23 | # Configuration i.e. compile options etc. 24 | # Target specific stuff (defines etc.) goes in here! 25 | # Generally values applying to a tree are captured in the 26 | # makefile at its root level - these are then overridden 27 | # for a subtree within the makefile rooted therein 28 | # 29 | #DEFINES += 30 | 31 | ############################################################# 32 | # Recursion Magic - Don't touch this!! 33 | # 34 | # Each subtree potentially has an include directory 35 | # corresponding to the common APIs applicable to modules 36 | # rooted at that subtree. Accordingly, the INCLUDE PATH 37 | # of a module can only contain the include directories up 38 | # its parent path, and not its siblings 39 | # 40 | # Required for each makefile to inherit from the parent 41 | # 42 | 43 | PDIR := ../$(PDIR) 44 | sinclude $(PDIR)Makefile 45 | 46 | -------------------------------------------------------------------------------- /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 | PDIR := ../$(PDIR) 43 | sinclude $(PDIR)Makefile 44 | 45 | -------------------------------------------------------------------------------- /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( void ) 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 | PDIR := ../$(PDIR) 43 | sinclude $(PDIR)Makefile 44 | 45 | -------------------------------------------------------------------------------- /app/mbedtls/platform/memcompat.c: -------------------------------------------------------------------------------- 1 | #include 2 | void *mbedtls_calloc_wrap(size_t n, size_t sz) { return calloc(n, sz); } 3 | void mbedtls_free_wrap(void *p) { free(p); } 4 | -------------------------------------------------------------------------------- /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 "lnodemcu.h" 5 | 6 | /** 7 | * Convert hsv to grb 8 | * hue is 0-360, sat and val are 0-255 9 | */ 10 | uint32_t hsv2grb(uint16_t hue, uint8_t sat, uint8_t val); 11 | /** 12 | * Convert hsv to grbw 13 | * hue is 0-360, sat and val are 0-255 14 | */ 15 | uint32_t hsv2grbw(uint16_t hue, uint8_t sat, uint8_t val); 16 | /** 17 | * Convert grb to hsv 18 | * g, r, b are 0-255 19 | */ 20 | uint32_t grb2hsv(uint8_t g, uint8_t r, uint8_t b); 21 | 22 | 23 | /** 24 | * The color wheel function provides colors from r -> g -> b -> r. 25 | * They are fully saturated and with full brightness. 26 | * degree is from 0-360 27 | */ 28 | uint32_t color_wheel(uint16_t degree); 29 | 30 | 31 | #endif /* APP_MODULES_COLOR_UTILS_H_ */ 32 | -------------------------------------------------------------------------------- /app/modules/enduser_setup/.gitattributes: -------------------------------------------------------------------------------- 1 | *.sh text eol=lf 2 | -------------------------------------------------------------------------------- /app/modules/enduser_setup/.gitignore: -------------------------------------------------------------------------------- 1 | enduser_setup.html.gz 2 | -------------------------------------------------------------------------------- /app/modules/enduser_setup/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/enduser_setup_html_default/' > enduser_setup.html.gz.def.h 7 | 8 | -------------------------------------------------------------------------------- /app/modules/net_ping.h: -------------------------------------------------------------------------------- 1 | #ifdef NET_PING_ENABLE 2 | int net_ping(lua_State *L); 3 | #endif 4 | -------------------------------------------------------------------------------- /app/modules/pixbuf.h: -------------------------------------------------------------------------------- 1 | #ifndef APP_MODULES_PIXBUF_H_ 2 | #define APP_MODULES_PIXBUF_H_ 3 | 4 | typedef struct pixbuf { 5 | const size_t npix; 6 | const size_t nchan; 7 | 8 | /* Flexible Array Member; true size is npix * pixbuf_channels_for(type) */ 9 | uint8_t values[]; 10 | } pixbuf; 11 | 12 | enum pixbuf_fade { 13 | PIXBUF_FADE_IN, 14 | PIXBUF_FADE_OUT 15 | }; 16 | 17 | enum pixbuf_shift { 18 | PIXBUF_SHIFT_LOGICAL, 19 | PIXBUF_SHIFT_CIRCULAR 20 | }; 21 | 22 | pixbuf *pixbuf_from_lua_arg(lua_State *, int); 23 | const size_t pixbuf_size(pixbuf *); 24 | 25 | // Exported for backwards compat with ws2812 module 26 | int pixbuf_new_lua(lua_State *); 27 | 28 | /* 29 | * WS2812_EFFECTS does pixbuf manipulation directly in C, which isn't the 30 | * intended use case, but for backwards compat, we export just what it needs. 31 | * Move this struct to pixbuf.c and mark these exports static instead once 32 | * WS2812_EFFECTS is no more. 33 | */ 34 | struct pixbuf_shift_params { 35 | enum pixbuf_shift type; 36 | // 0 <= offset <= buffer length 37 | size_t offset; 38 | // 0 <= window + offset <= buffer length 39 | size_t window; 40 | // 0 <= shift <= window_size 41 | size_t shift; 42 | bool shiftLeft; 43 | }; 44 | void pixbuf_shift(pixbuf *, struct pixbuf_shift_params *); 45 | void pixbuf_prepare_shift(pixbuf *, struct pixbuf_shift_params *, 46 | int val, enum pixbuf_shift, int start, int end); 47 | const size_t pixbuf_channels(pixbuf *); 48 | /* end WS2812_EFFECTS exports */ 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /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_checkinteger (L, 1); 10 | int n = (lua_gettop(L) < 2) ? 1 : lua_tointeger (L, 2); 11 | if (n == 0 || !lua_checkstack (L, n)) { 12 | return 0; 13 | } 14 | 15 | int ret = 0; 16 | while (n > 0 && idx >= 0 && idx < RTC_USER_MEM_NUM_DWORDS) 17 | { 18 | lua_pushinteger (L, rtc_mem_read (idx++)); 19 | --n; 20 | ++ret; 21 | } 22 | return ret; 23 | } 24 | 25 | 26 | static int rtcmem_write32 (lua_State *L) 27 | { 28 | int idx = luaL_checkinteger (L, 1); 29 | int n = lua_gettop (L) - 1; 30 | luaL_argcheck ( 31 | L, idx + n <= RTC_USER_MEM_NUM_DWORDS, 1, "RTC mem would overrun"); 32 | int src = 2; 33 | while (n-- > 0) 34 | { 35 | rtc_mem_write (idx++, (uint32_t) lua_tointeger (L, src++)); 36 | } 37 | return 0; 38 | } 39 | 40 | 41 | // Module function map 42 | LROT_BEGIN(rtcmem, NULL, 0) 43 | LROT_FUNCENTRY( read32, rtcmem_read32 ) 44 | LROT_FUNCENTRY( write32, rtcmem_write32 ) 45 | LROT_END(rtcmem, NULL, 0) 46 | 47 | 48 | NODEMCU_MODULE(RTCMEM, "rtcmem", rtcmem, NULL); 49 | -------------------------------------------------------------------------------- /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 | vsprintf( buffer, string, arglist ); 14 | va_end( arglist ); 15 | lua_pushstring(L, buffer); 16 | lua_setfield(L, -2, name); 17 | } 18 | -------------------------------------------------------------------------------- /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 | PDIR := ../$(PDIR) 42 | sinclude $(PDIR)Makefile 43 | 44 | -------------------------------------------------------------------------------- /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 | 17 | bool sent; 18 | } msg_queue_t; 19 | 20 | msg_queue_t * msg_enqueue(msg_queue_t **head, mqtt_message_t *msg, uint16_t msg_id, int msg_type, int publish_qos); 21 | void msg_destroy(msg_queue_t *node); 22 | msg_queue_t * msg_dequeue(msg_queue_t **head); 23 | msg_queue_t * msg_peek(msg_queue_t **head); 24 | int msg_size(msg_queue_t **head); 25 | 26 | #ifdef __cplusplus 27 | } 28 | #endif 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /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 | PDIR := ../$(PDIR) 40 | sinclude $(PDIR)Makefile 41 | 42 | -------------------------------------------------------------------------------- /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 | PDIR := ../$(PDIR) 42 | sinclude $(PDIR)Makefile 43 | -------------------------------------------------------------------------------- /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/Makefile: -------------------------------------------------------------------------------- 1 | 2 | ############################################################# 3 | # Required variables for each makefile 4 | # Discard this section from all parent makefiles 5 | # Expected variables (with automatic defaults): 6 | # CSRCS (all "C" files in the dir) 7 | # SUBDIRS (all subdirs with a Makefile) 8 | # GEN_LIBS - list of libs to be generated () 9 | # GEN_IMAGES - list of images to be generated () 10 | # COMPONENTS_xxx - a list of libs/objs in the form 11 | # subdir/lib to be extracted and rolled up into 12 | # a generated lib/image xxx.a () 13 | # 14 | ifndef PDIR 15 | GEN_LIBS = libplatform.a 16 | endif 17 | 18 | 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 += -I ../spiffs -I ../u8g2lib/u8g2/src/clib -I ../ucglib/ucg/src/clib 42 | PDIR := ../$(PDIR) 43 | sinclude $(PDIR)Makefile 44 | 45 | -------------------------------------------------------------------------------- /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/cpu_esp8266_irq.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | static inline uint32_t 4 | esp8266_defer_irqs(void) 5 | { 6 | uint32_t state; 7 | __asm__ __volatile__ ("rsil %0, 15" : "=a"(state) : : "memory"); 8 | return state; 9 | } 10 | 11 | static inline void 12 | esp8266_restore_irqs(uint32_t state) 13 | { 14 | __asm__ __volatile__ ("wsr %0, ps" : : "a"(state) : "memory"); 15 | } 16 | -------------------------------------------------------------------------------- /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 | bool platform_hw_timer_init_exclusive(FRC1_TIMER_SOURCE_TYPE source_type, bool autoload, void (* frc1_timer_cb)(os_param_t), os_param_t arg, void (*nmi_timer_cb)(void) ); 34 | 35 | bool ICACHE_RAM_ATTR platform_hw_timer_close_exclusive(); 36 | 37 | bool ICACHE_RAM_ATTR platform_hw_timer_arm_ticks_exclusive(uint32_t ticks); 38 | 39 | bool ICACHE_RAM_ATTR platform_hw_timer_arm_us_exclusive(uint32_t microseconds); 40 | 41 | #endif 42 | 43 | -------------------------------------------------------------------------------- /app/platform/pin_map.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef __PIN_MAP_H__ 3 | #define __PIN_MAP_H__ 4 | 5 | #include 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 5 | #include 6 | 7 | int platform_sdcard_init( uint8_t spi_no, uint8_t ss_pin ); 8 | int platform_sdcard_status( void ); 9 | int platform_sdcard_error( void ); 10 | int platform_sdcard_type( void ); 11 | int platform_sdcard_read_block( uint8_t ss_pin, uint32_t block, uint8_t *dst ); 12 | int platform_sdcard_read_blocks( uint8_t ss_pin, uint32_t block, size_t num, uint8_t *dst ); 13 | int platform_sdcard_read_csd( uint8_t ss_pin, uint8_t *csd ); 14 | int platform_sdcard_read_cid( uint8_t ss_pin, uint8_t *cid ); 15 | int platform_sdcard_write_block( uint8_t ss_pin, uint32_t block, const uint8_t *src ); 16 | int platform_sdcard_write_blocks( uint8_t ss_pin, uint32_t block, size_t num, const uint8_t *src ); 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /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 | 12 | // elements for the overlay display driver 13 | struct { 14 | u8x8_msg_cb hardware_display_cb, template_display_cb; 15 | int rfb_cb_ref; 16 | uint8_t fb_update_ongoing; 17 | } overlay; 18 | } u8g2_nodemcu_t; 19 | 20 | 21 | uint8_t u8x8_gpio_and_delay_nodemcu(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr); 22 | uint8_t u8x8_byte_nodemcu_i2c(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr); 23 | uint8_t u8x8_byte_nodemcu_spi(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr); 24 | 25 | #endif /* _U8X8_NODEMCU_HAL_H */ 26 | -------------------------------------------------------------------------------- /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/pm/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 = libpm.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 | PDIR := ../$(PDIR) 42 | sinclude $(PDIR)Makefile 43 | 44 | -------------------------------------------------------------------------------- /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 | PDIR := ../$(PDIR) 41 | sinclude $(PDIR)Makefile 42 | 43 | -------------------------------------------------------------------------------- /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 5 | #include "mem.h" 6 | 7 | #endif 8 | -------------------------------------------------------------------------------- /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 | PDIR := ../$(PDIR) 40 | sinclude $(PDIR)Makefile 41 | 42 | -------------------------------------------------------------------------------- /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 += -DDEVELOPMENT_TOOLS -DNODE_DEBUG -DSPIFFS_API_DBG=NODE_DBG 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 | PDIR := ../$(PDIR) 40 | sinclude $(PDIR)Makefile 41 | -------------------------------------------------------------------------------- /app/spiffs/docs/IMPLEMENTING: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nodemcu/nodemcu-firmware/36cbf9f017d356319a6369e299765eedff191154/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/nodemcu_spiffs.h: -------------------------------------------------------------------------------- 1 | #ifndef _NODEMCU_SPIFFS_H 2 | #define _NODEMCU_SPIFFS_H 3 | 4 | #ifndef NODEMCU_SPIFFS_NO_INCLUDE 5 | #include 6 | #include 7 | #include 8 | #include "user_interface.h" 9 | #endif 10 | 11 | // Turn off stats 12 | #define SPIFFS_CACHE_STATS 0 13 | #define SPIFFS_GC_STATS 0 14 | 15 | // Needs to align stuff 16 | #define SPIFFS_ALIGNED_OBJECT_INDEX_TABLES 1 17 | 18 | // Enable magic so we can find the file system (but not yet) 19 | #define SPIFFS_USE_MAGIC 1 20 | #define SPIFFS_USE_MAGIC_LENGTH 1 21 | 22 | // Reduce the chance of returning disk full 23 | #define SPIFFS_GC_MAX_RUNS 256 24 | 25 | #define SPIFFS_SECURE_ERASE 0 26 | 27 | extern void myspiffs_set_automount(); 28 | #endif 29 | -------------------------------------------------------------------------------- /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 | PDIR := ../$(PDIR) 42 | sinclude $(PDIR)Makefile 43 | 44 | -------------------------------------------------------------------------------- /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 += -I ucg/src/clib 44 | PDIR := ../$(PDIR) 45 | sinclude $(PDIR)Makefile 46 | 47 | -------------------------------------------------------------------------------- /app/user/Makefile: -------------------------------------------------------------------------------- 1 | 2 | ############################################################# 3 | # Required variables for each makefile 4 | # Discard this section from all parent makefiles 5 | # Expected variables (with automatic defaults): 6 | # CSRCS (all "C" files in the dir) 7 | # SUBDIRS (all subdirs with a Makefile) 8 | # GEN_LIBS - list of libs to be generated () 9 | # GEN_IMAGES - list of images to be generated () 10 | # COMPONENTS_xxx - a list of libs/objs in the form 11 | # subdir/lib to be extracted and rolled up into 12 | # a generated lib/image xxx.a () 13 | # 14 | ifndef PDIR 15 | GEN_LIBS = libuser.a 16 | endif 17 | 18 | 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 += -DESP_INIT_DATA_DEFAULT="\"$(SDK_DIR)/bin/esp_init_data_default_v05.bin\"" 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 += -I ../spiffs 42 | PDIR := ../$(PDIR) 43 | sinclude $(PDIR)Makefile 44 | 45 | -------------------------------------------------------------------------------- /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 | PDIR := ../$(PDIR) 41 | sinclude $(PDIR)Makefile 42 | 43 | -------------------------------------------------------------------------------- /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 | PDIR := ../$(PDIR) 42 | sinclude $(PDIR)Makefile 43 | 44 | -------------------------------------------------------------------------------- /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/nodemcu/nodemcu-firmware/36cbf9f017d356319a6369e299765eedff191154/docs/img/ESPlorer.jpg -------------------------------------------------------------------------------- /docs/img/WiFi-softap-mode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nodemcu/nodemcu-firmware/36cbf9f017d356319a6369e299765eedff191154/docs/img/WiFi-softap-mode.png -------------------------------------------------------------------------------- /docs/img/WiFi-station-mode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nodemcu/nodemcu-firmware/36cbf9f017d356319a6369e299765eedff191154/docs/img/WiFi-station-mode.png -------------------------------------------------------------------------------- /docs/img/WiFi-stationap-mode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nodemcu/nodemcu-firmware/36cbf9f017d356319a6369e299765eedff191154/docs/img/WiFi-stationap-mode.png -------------------------------------------------------------------------------- /docs/img/enduser-setup-captive-portal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nodemcu/nodemcu-firmware/36cbf9f017d356319a6369e299765eedff191154/docs/img/enduser-setup-captive-portal.png -------------------------------------------------------------------------------- /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/nodemcu/nodemcu-firmware/36cbf9f017d356319a6369e299765eedff191154/docs/img/favicon.ico -------------------------------------------------------------------------------- /docs/img/favicon_package_v0.16.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nodemcu/nodemcu-firmware/36cbf9f017d356319a6369e299765eedff191154/docs/img/favicon_package_v0.16.zip -------------------------------------------------------------------------------- /docs/img/logo-small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nodemcu/nodemcu-firmware/36cbf9f017d356319a6369e299765eedff191154/docs/img/logo-small.png -------------------------------------------------------------------------------- /docs/img/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nodemcu/nodemcu-firmware/36cbf9f017d356319a6369e299765eedff191154/docs/img/logo.png -------------------------------------------------------------------------------- /docs/img/micro_sd-small.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nodemcu/nodemcu-firmware/36cbf9f017d356319a6369e299765eedff191154/docs/img/micro_sd-small.jpg -------------------------------------------------------------------------------- /docs/img/micro_sd.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nodemcu/nodemcu-firmware/36cbf9f017d356319a6369e299765eedff191154/docs/img/micro_sd.jpg -------------------------------------------------------------------------------- /docs/img/micro_sd_shield-small.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nodemcu/nodemcu-firmware/36cbf9f017d356319a6369e299765eedff191154/docs/img/micro_sd_shield-small.jpg -------------------------------------------------------------------------------- /docs/img/micro_sd_shield.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nodemcu/nodemcu-firmware/36cbf9f017d356319a6369e299765eedff191154/docs/img/micro_sd_shield.jpg -------------------------------------------------------------------------------- /docs/img/sigma_delta_audiofilter.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nodemcu/nodemcu-firmware/36cbf9f017d356319a6369e299765eedff191154/docs/img/sigma_delta_audiofilter.png -------------------------------------------------------------------------------- /docs/lua-modules/README.md: -------------------------------------------------------------------------------- 1 | # NodeMCU Lua modules directory 2 | 3 | Reviewing, hosting and thus potentially maintaining an ever growing list of NodeMCU Lua modules (the ones here) does not scale well for the project team. Instead, we give the community a chance - and the responsibility - to maintain a directory of Lua modules found in the wild through the [GitHub wiki](https://github.com/nodemcu/nodemcu-firmware/wiki/Lua-modules-directory). 4 | 5 | In the (hopefully not too distant) future, we will request that Lua modules to be hosted _in this repository_ come with a test program in whatever framework [we end up adopting](https://github.com/nodemcu/nodemcu-firmware/issues/2145). 6 | 7 | **A module being listed on the wiki does NOT mean the NodeMCU project team endorses it in any way.** 8 | 9 | → [https://github.com/nodemcu/nodemcu-firmware/wiki/Lua-modules-directory](https://github.com/nodemcu/nodemcu-firmware/wiki/Lua-modules-directory) -------------------------------------------------------------------------------- /docs/lua-modules/telnet.md: -------------------------------------------------------------------------------- 1 | # Telnet Module 2 | 3 | | Since | Origin / Contributor | Maintainer | Source | 4 | | :----- | :-------------------- | :---------- | :------ | 5 | | 2018-05-24 | [Terry Ellison](https://github.com/TerryE) | [Terry Ellison](https://github.com/TerryE) | [telnet.lua](../../lua_modules/telnet/telnet.lua) | 6 | 7 | The current version of this module exploits the stdin / stdout pipe functionality and 8 | task integration that is now build into the NodeNMCU Lua core. 9 | 10 | There are two nice advantages of this core implementation: 11 | 12 | - Errors are now written to stdout in a separate task execution. 13 | - The pipes pretty much eliminate UART and telnet overrun. 14 | 15 | Both have the same interface if required into the variable `telnet` 16 | 17 | ## telnet:open() 18 | 19 | Open a telnet server based on the provided parameters. 20 | 21 | #### Syntax 22 | 23 | `telnet:open(ssid, pwd, port)` 24 | 25 | #### Parameters 26 | 27 | `ssid` and `password`. Strings. SSID and Password for the Wifi network. If these are 28 | `nil` then the wifi is assumed to be configured or auto-configured. 29 | 30 | `port`. Integer TCP listening port for the Telnet service. The default is 2323 31 | 32 | #### Returns 33 | 34 | Nothing returned (this is evaluated as `nil` in a scalar context). 35 | 36 | ## telnet:close() 37 | 38 | Close a telnet server and release all resources. Also set the variable `telnet` to nil to fully reference and GC the resources. 39 | 40 | #### Syntax 41 | 42 | `telnet:close()` 43 | 44 | #### Parameters 45 | 46 | None 47 | 48 | #### Returns 49 | 50 | Nothing returned (this is evaluated as `nil` in a scalar context). 51 | -------------------------------------------------------------------------------- /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/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/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/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 | !!! caution 12 | 13 | This module has an _optional_ dependency to the [pixbuf module](pixbuf.md) i.e. it can work without. However, if you compile the firmware without pixbuf the respective features will be missing from this module. 14 | 15 | ## tm1829.write() 16 | Send data to a led strip using native chip format. 17 | 18 | #### Syntax 19 | `tm1829.write(data)` 20 | 21 | #### Parameters 22 | - `data` payload to be sent to one or more TM1829 leds. It is either 23 | a 3-channel [pixbuf](pixbuf) (e.g., `pixbuf.TYPE_RGB`) or a string of 24 | raw byte values to be sent. 25 | 26 | #### Returns 27 | `nil` 28 | 29 | #### Example 30 | ```lua 31 | tm1829.write(5, string.char(255,0,0,255,0,0)) -- turn the two first RGB leds to blue using GPIO 5 32 | ``` 33 | 34 | -------------------------------------------------------------------------------- /docs/requirements.txt: -------------------------------------------------------------------------------- 1 | mkdocs>=1.5.3 2 | jinja2>=3.1.0 3 | -------------------------------------------------------------------------------- /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=strdup=ets_strdup 8 | --defsym=memcmp=ets_memcmp 9 | --defsym=memcpy=ets_memcpy 10 | --defsym=memmove=ets_memmove 11 | --defsym=memset=ets_memset 12 | -------------------------------------------------------------------------------- /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 adc0(A0), RGB LED connected to gpio12(D6) Green, gpio13(D7) Blue & gpio15(D8) 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 | -- Required C Modules: adc, tmr, pwm 9 | 10 | local redLed, greenLed, blueLed = 8, 6, 7 11 | 12 | local function setRGB(r,g,b) 13 | pwm.setduty(redLed, r) 14 | pwm.setduty(greenLed, g) 15 | pwm.setduty(blueLed, b) 16 | end 17 | 18 | -- this is perhaps the lightest weight sin function in existence 19 | -- Given an integer from 0..128, 0..512 approximating 256 + 256 * sin(idx*Pi/256) 20 | -- This is first order square approximation of sin, it's accurate around 0 and any multiple of 128 (Pi/2), 21 | -- 92% accurate at 64 (Pi/4). 22 | local function pseudoSin(idx) 23 | idx = idx % 128 24 | local lookUp = 32 - idx % 64 25 | local val = 256 - (lookUp * lookUp) / 4 26 | if (idx > 64) then 27 | val = - val; 28 | end 29 | return 256+val 30 | end 31 | 32 | do 33 | pwm.setup(redLed, 500, 512) 34 | pwm.setup(greenLed,500, 512) 35 | pwm.setup(blueLed, 500, 512) 36 | pwm.start(redLed) 37 | pwm.start(greenLed) 38 | pwm.start(blueLed) 39 | 40 | tmr.create():alarm(20, tmr.ALARM_AUTO, function() 41 | local idx = 3 * adc.read(0) / 2 42 | local r = pseudoSin(idx) 43 | local g = pseudoSin(idx + 43) -- ~1/3rd of 128 44 | local b = pseudoSin(idx + 85) -- ~2/3rd of 128 45 | setRGB(r,g,b) 46 | end) 47 | end 48 | -------------------------------------------------------------------------------- /lua_examples/luaOTA/ESP-11223344.json: -------------------------------------------------------------------------------- 1 | { 2 | "files": [ "main.lc", "supporfile.lc", "othercontent.txt" ], 3 | "secret": "supersekrit" 4 | } 5 | -------------------------------------------------------------------------------- /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 | -- luacheck: globals DEBUG 2 | return {entry = function(msg) 3 | package.loaded["luaOTA.default"]=nil 4 | local gc=collectgarbage; gc(); gc() 5 | if DEBUG then 6 | for k,v in pairs(_G) do print(k,v) end 7 | for k,v in pairs(debug.getregistry()) do print(k,v) end 8 | end 9 | gc(); gc() 10 | print(msg, node.heap()) 11 | end} 12 | -------------------------------------------------------------------------------- /lua_examples/mqtt/mqtt2cloud.lua: -------------------------------------------------------------------------------- 1 | -- test with cloudmqtt.com 2 | local m_dis = {} 3 | 4 | local function dispatch(m,t,pl) 5 | if pl~=nil and m_dis[t] then 6 | m_dis[t](m,pl) 7 | end 8 | end 9 | 10 | local function topic1func(_,pl) 11 | print("get1: "..pl) 12 | end 13 | 14 | local function topic2func(_,pl) 15 | print("get2: "..pl) 16 | end 17 | 18 | do 19 | m_dis["/topic1"] = topic1func 20 | m_dis["/topic2"] = topic2func 21 | -- Lua: mqtt.Client(clientid, keepalive, user, pass) 22 | local m = mqtt.Client("nodemcu1", 60, "test", "test123") 23 | m:on("connect",function(client) 24 | print("connection "..node.heap()) 25 | client:subscribe("/topic1",0,function() print("sub done") end) 26 | client:subscribe("/topic2",0,function() print("sub done") end) 27 | client:publish("/topic1","hello",0,0) 28 | client:publish("/topic2","world",0,0) 29 | end) 30 | m:on("offline", function() 31 | print("disconnect to broker...") 32 | print(node.heap()) 33 | end) 34 | m:on("message",dispatch ) 35 | -- Lua: mqtt:connect( host, port, secure, function(client) ) 36 | m:connect("m11.cloudmqtt.com",11214,0) 37 | tmr.create():alarm(10000, tmr.ALARM_AUTO, function() 38 | local pl = "time: "..tmr.time() 39 | m:publish("/topic1",pl,0,0) 40 | end) 41 | end -------------------------------------------------------------------------------- /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/nodemcu/nodemcu-firmware/36cbf9f017d356319a6369e299765eedff191154/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 | local function cb_drained() 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 | local function cb_stopped() 18 | print("playback stopped") 19 | file.seek("set", 0) 20 | end 21 | 22 | local function cb_paused() 23 | print("playback paused") 24 | end 25 | 26 | do 27 | file.open("jump_8k.u8", "r") 28 | 29 | local drv = pcm.new(pcm.SD, 1) 30 | 31 | -- fetch data in chunks of FILE_READ_CHUNK (1024) from file 32 | drv:on("data", function(driver) return file.read() end) -- luacheck: no unused 33 | 34 | -- get called back when all samples were read from the file 35 | drv:on("drained", cb_drained) 36 | 37 | drv:on("stopped", cb_stopped) 38 | drv:on("paused", cb_paused) 39 | 40 | -- start playback 41 | drv:play(pcm.RATE_8K) 42 | end 43 | -------------------------------------------------------------------------------- /lua_examples/tcp2uart.lua: -------------------------------------------------------------------------------- 1 | do 2 | uart.setup(0, 9600, 8, 0, 1, 0) 3 | local sv = net.createServer(net.TCP, 60) 4 | local global_c = nil 5 | sv:listen(9999, function(c) 6 | if global_c~=nil then 7 | global_c:close() 8 | end 9 | global_c = c 10 | c:on("receive",function(_, pl) uart.write(0, pl) end) 11 | end) 12 | 13 | uart.on("data", 4, function(data) 14 | if global_c ~= nil then 15 | global_c:send(data) 16 | end 17 | end, 0) 18 | end 19 | -------------------------------------------------------------------------------- /lua_examples/timezone/alaska.zone: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nodemcu/nodemcu-firmware/36cbf9f017d356319a6369e299765eedff191154/lua_examples/timezone/alaska.zone -------------------------------------------------------------------------------- /lua_examples/timezone/central.zone: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nodemcu/nodemcu-firmware/36cbf9f017d356319a6369e299765eedff191154/lua_examples/timezone/central.zone -------------------------------------------------------------------------------- /lua_examples/timezone/eastern.zone: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nodemcu/nodemcu-firmware/36cbf9f017d356319a6369e299765eedff191154/lua_examples/timezone/eastern.zone -------------------------------------------------------------------------------- /lua_examples/timezone/mountain.zone: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nodemcu/nodemcu-firmware/36cbf9f017d356319a6369e299765eedff191154/lua_examples/timezone/mountain.zone -------------------------------------------------------------------------------- /lua_examples/timezone/pacific.zone: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nodemcu/nodemcu-firmware/36cbf9f017d356319a6369e299765eedff191154/lua_examples/timezone/pacific.zone -------------------------------------------------------------------------------- /lua_examples/ucglib/GT_box.lua: -------------------------------------------------------------------------------- 1 | -- luacheck: globals T r disp millis lcg_rnd 2 | local M, module = {}, ... 3 | _G[module] = M 4 | 5 | function M.run() 6 | -- make this a volatile module: 7 | package.loaded[module] = nil 8 | 9 | print("Running component box...") 10 | 11 | local x, y, w, h 12 | local m 13 | 14 | disp:setColor(0, 0, 40, 80) 15 | disp:setColor(1, 60, 0, 40) 16 | disp:setColor(2, 128, 0, 140) 17 | disp:setColor(3, 0, 128, 140) 18 | disp:drawGradientBox(0, 0, disp:getWidth(), disp:getHeight()) 19 | 20 | disp:setColor(255, 255, 255) 21 | disp:setPrintPos(2,18) 22 | disp:setPrintDir(0) 23 | disp:print("Box") 24 | 25 | m = millis() + T 26 | 27 | while millis() < m do 28 | disp:setColor(bit.band(lcg_rnd(), 127)+127, bit.band(lcg_rnd(), 127)+64, bit.band(lcg_rnd(), 31)) 29 | w = bit.band(lcg_rnd(), 31) 30 | h = bit.band(lcg_rnd(), 31) 31 | w = w + 10 32 | h = h + 10 33 | x = bit.rshift(lcg_rnd() * (disp:getWidth()-w), 8) 34 | y = bit.rshift(lcg_rnd() * (disp:getHeight()-h-20), 8) 35 | 36 | disp:drawBox(x, y+20, w, h) 37 | end 38 | 39 | print("...done") 40 | end 41 | 42 | return M 43 | -------------------------------------------------------------------------------- /lua_examples/ucglib/GT_color_test.lua: -------------------------------------------------------------------------------- 1 | -- luacheck: globals T r disp millis lcg_rnd 2 | local M, module = {}, ... 3 | _G[module] = M 4 | 5 | function M.run() 6 | -- make this a volatile module: 7 | package.loaded[module] = nil 8 | 9 | print("Running component color_test...") 10 | 11 | local c, x 12 | 13 | disp:setColor(0, 0, 0, 0) 14 | disp:drawBox(0, 0, disp:getWidth(), disp:getHeight()) 15 | 16 | disp:setColor(255, 255, 255) 17 | disp:setPrintPos(2,18) 18 | disp:setPrintDir(0) 19 | disp:print("Color Test") 20 | 21 | disp:setColor(0, 127, 127, 127) 22 | disp:drawBox(0, 20, 16*4+4, 5*8+4) 23 | 24 | c = 0 25 | x = 2 26 | while c < 255 do 27 | disp:setColor(0, c, c, c) 28 | disp:drawBox(x, 22, 4, 8) 29 | disp:setColor(0, c, 0, 0) 30 | disp:drawBox(x, 22+8, 4, 8) 31 | disp:setColor(0, 0, c, 0) 32 | disp:drawBox(x, 22+2*8, 4, 8) 33 | disp:setColor(0, 0, 0, c) 34 | disp:drawBox(x, 22+3*8, 4, 8) 35 | disp:setColor(0, c, 255-c, 0) 36 | disp:drawBox(x, 22+4*8, 4, 8) 37 | 38 | c = c + 17 39 | x = x + 4 40 | end 41 | 42 | print("...done") 43 | end 44 | 45 | return M 46 | -------------------------------------------------------------------------------- /lua_examples/ucglib/GT_gradient.lua: -------------------------------------------------------------------------------- 1 | -- luacheck: globals T r disp millis lcg_rnd 2 | local M, module = {}, ... 3 | _G[module] = M 4 | 5 | function M.run() 6 | -- make this a volatile module: 7 | package.loaded[module] = nil 8 | 9 | print("Running component gradient...") 10 | 11 | disp:setColor(0, 0, 255, 0) 12 | disp:setColor(1, 255, 0, 0) 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, 255, 255) 19 | disp:setPrintPos(2,18) 20 | disp:setPrintDir(0) 21 | disp:print("GradientBox") 22 | 23 | disp:setColor(0, 0, 255, 0) 24 | disp:drawBox(2, 25, 8, 8) 25 | 26 | disp:setColor(0, 255, 0, 0) 27 | disp:drawBox(2+10, 25, 8, 8) 28 | 29 | disp:setColor(0, 255, 0, 255) 30 | disp:drawBox(2, 25+10, 8, 8) 31 | 32 | disp:setColor(0, 0, 255, 255) 33 | disp:drawBox(2+10, 25+10, 8, 8) 34 | 35 | print("...done") 36 | end 37 | 38 | return M 39 | -------------------------------------------------------------------------------- /lua_examples/ucglib/GT_graphics_test.lua: -------------------------------------------------------------------------------- 1 | -- luacheck: globals T r disp millis lcg_rnd 2 | local M, module = {}, ... 3 | _G[module] = M 4 | 5 | function M.run() 6 | -- make this a volatile module: 7 | package.loaded[module] = nil 8 | 9 | print("Running component graphics_test...") 10 | 11 | --ucg.setMaxClipRange() 12 | disp:setColor(0, 0, 40, 80) 13 | disp:setColor(1, 80, 0, 40) 14 | disp:setColor(2, 255, 0, 255) 15 | disp:setColor(3, 0, 255, 255) 16 | 17 | disp:drawGradientBox(0, 0, disp:getWidth(), disp:getHeight()) 18 | 19 | disp:setColor(255, 168, 0) 20 | disp:setPrintDir(0) 21 | disp:setPrintPos(2, 18) 22 | disp:print("Ucglib") 23 | disp:setPrintPos(2, 18+20) 24 | disp:print("GraphicsTest") 25 | 26 | print("...done") 27 | end 28 | 29 | return M 30 | -------------------------------------------------------------------------------- /lua_examples/ucglib/GT_pixel_and_lines.lua: -------------------------------------------------------------------------------- 1 | -- luacheck: globals T r disp millis lcg_rnd 2 | local M, module = {}, ... 3 | _G[module] = M 4 | 5 | function M.run() 6 | -- make this a volatile module: 7 | package.loaded[module] = nil 8 | 9 | print("Running component pixel_and_lines...") 10 | 11 | local mx 12 | local x, xx 13 | mx = disp:getWidth() / 2 14 | --my = disp:getHeight() / 2 15 | 16 | disp:setColor(0, 0, 0, 150) 17 | disp:setColor(1, 0, 60, 40) 18 | disp:setColor(2, 60, 0, 40) 19 | disp:setColor(3, 120, 120, 200) 20 | disp:drawGradientBox(0, 0, disp:getWidth(), disp:getHeight()) 21 | 22 | disp:setColor(255, 255, 255) 23 | disp:setPrintPos(2, 18) 24 | disp:setPrintDir(0) 25 | disp:print("Pix&Line") 26 | 27 | disp:drawPixel(0, 0) 28 | disp:drawPixel(1, 0) 29 | --disp:drawPixel(disp:getWidth()-1, 0) 30 | --disp:drawPixel(0, disp:getHeight()-1) 31 | 32 | disp:drawPixel(disp:getWidth()-1, disp:getHeight()-1) 33 | disp:drawPixel(disp:getWidth()-1-1, disp:getHeight()-1) 34 | 35 | 36 | x = 0 37 | while x < mx do 38 | xx = ((x)*255)/mx 39 | disp:setColor(255, 255-xx/2, 255-xx) 40 | disp:drawPixel(x, 24) 41 | disp:drawVLine(x+7, 26, 13) 42 | x = x + 1 43 | end 44 | 45 | print("...done") 46 | end 47 | 48 | return M 49 | -------------------------------------------------------------------------------- /lua_examples/ucglib/GT_text.lua: -------------------------------------------------------------------------------- 1 | -- luacheck: globals T r disp millis lcg_rnd 2 | local M, module = {}, ... 3 | _G[module] = M 4 | 5 | function M.run() 6 | -- make this a volatile module: 7 | package.loaded[module] = nil 8 | 9 | print("Running component text...") 10 | 11 | local x, y, w, h, i 12 | local m 13 | 14 | disp:setColor(0, 80, 40, 0) 15 | disp:setColor(1, 60, 0, 40) 16 | disp:setColor(2, 20, 0, 20) 17 | disp:setColor(3, 60, 0, 0) 18 | disp:drawGradientBox(0, 0, disp:getWidth(), disp:getHeight()) 19 | 20 | disp:setColor(255, 255, 255) 21 | disp:setPrintPos(2,18) 22 | disp:setPrintDir(0) 23 | disp:print("Text") 24 | 25 | m = millis() + T 26 | i = 0 27 | while millis() < m do 28 | disp:setColor(bit.band(lcg_rnd(), 31), bit.band(lcg_rnd(), 127) + 127, bit.band(lcg_rnd(), 127) + 64) 29 | w = 40 30 | h = 22 31 | x = bit.rshift(lcg_rnd() * (disp:getWidth() - w), 8) 32 | y = bit.rshift(lcg_rnd() * (disp:getHeight() - h), 8) 33 | 34 | disp:setPrintPos(x, y+h) 35 | disp:setPrintDir(bit.band(bit.rshift(i, 2), 3)) 36 | i = i + 1 37 | disp:print("Ucglib") 38 | end 39 | disp:setPrintDir(0) 40 | 41 | print("...done") 42 | end 43 | 44 | return M 45 | -------------------------------------------------------------------------------- /lua_examples/ucglib/GT_triangle.lua: -------------------------------------------------------------------------------- 1 | -- luacheck: globals T r disp millis lcg_rnd 2 | local M, module = {}, ... 3 | _G[module] = M 4 | 5 | function M.run() 6 | -- make this a volatile module: 7 | package.loaded[module] = nil 8 | 9 | print("Running component triangle...") 10 | 11 | local m 12 | 13 | disp:setColor(0, 0, 80, 20) 14 | disp:setColor(1, 60, 80, 20) 15 | disp:setColor(2, 60, 120, 0) 16 | disp:setColor(3, 0, 140, 30) 17 | disp:drawGradientBox(0, 0, disp:getWidth(), disp:getHeight()) 18 | 19 | disp:setColor(255, 255, 255) 20 | disp:setPrintPos(2, 18) 21 | disp:print("Triangle") 22 | 23 | m = millis() + T 24 | 25 | while millis() < m do 26 | disp:setColor(bit.band(lcg_rnd(), 127)+127, bit.band(lcg_rnd(), 31), bit.band(lcg_rnd(), 127)+64) 27 | 28 | disp:drawTriangle( 29 | bit.rshift(lcg_rnd() * (disp:getWidth()), 8), 30 | bit.rshift(lcg_rnd() * (disp:getHeight()-20), 8) + 20, 31 | bit.rshift(lcg_rnd() * (disp:getWidth()), 8), 32 | bit.rshift(lcg_rnd() * (disp:getHeight()-20), 8) + 20, 33 | bit.rshift(lcg_rnd() * (disp:getWidth()), 8), 34 | bit.rshift(lcg_rnd() * (disp:getHeight()-20), 8) + 20 35 | ) 36 | 37 | tmr.wdclr() 38 | end 39 | 40 | print("...done") 41 | end 42 | 43 | return M 44 | -------------------------------------------------------------------------------- /lua_examples/ucglib/HelloWorld.lua: -------------------------------------------------------------------------------- 1 | local disp 2 | 3 | -- setup SPI and connect display 4 | local function init_spi_display() 5 | -- Hardware SPI CLK = GPIO14 6 | -- Hardware SPI MOSI = GPIO13 7 | -- Hardware SPI MISO = GPIO12 (not used) 8 | -- Hardware SPI /CS = GPIO15 (not used) 9 | -- CS, D/C, and RES can be assigned freely to available GPIOs 10 | local cs = 8 -- GPIO15, pull-down 10k to GND 11 | local dc = 4 -- GPIO2 12 | local res = 0 -- GPIO16 13 | local bus = 1 14 | 15 | spi.setup(bus, spi.MASTER, spi.CPOL_LOW, spi.CPHA_LOW, 8, 8) 16 | -- we won't be using the HSPI /CS line, so disable it again 17 | gpio.mode(8, gpio.INPUT, gpio.PULLUP) 18 | 19 | -- initialize the matching driver for your display 20 | -- see app/include/ucg_config.h 21 | --disp = ucg.ili9341_18x240x320_hw_spi(bus, cs, dc, res) 22 | disp = ucg.st7735_18x128x160_hw_spi(bus, cs, dc, res) 23 | end 24 | 25 | do 26 | init_spi_display() 27 | 28 | disp:begin(ucg.FONT_MODE_TRANSPARENT) 29 | disp:clearScreen() 30 | 31 | disp:setFont(ucg.font_ncenR12_tr); 32 | disp:setColor(255, 255, 255); 33 | disp:setColor(1, 255, 0,0); 34 | 35 | 36 | disp:setPrintPos(0, 25) 37 | disp:print("Hello World!") 38 | end 39 | -------------------------------------------------------------------------------- /lua_examples/webap_toggle_pin.lua: -------------------------------------------------------------------------------- 1 | do 2 | wifi.setmode(wifi.SOFTAP) 3 | wifi.ap.config({ ssid = "test", pwd = "12345678" }) 4 | gpio.mode(1, gpio.OUTPUT) 5 | local srv = net.createServer(net.TCP) 6 | srv:listen(80, function(conn) 7 | conn:on("receive", function(client, request) 8 | local buf = "" 9 | local _, _, method, path, vars = string.find(request, "([A-Z]+) (.+)?(.+) HTTP") -- luacheck: no unused 10 | if (method == nil) then 11 | _, _, method, path = string.find(request, "([A-Z]+) (.+) HTTP") -- luacheck: no unused 12 | end 13 | 14 | local _GET = {} 15 | if (vars ~= nil) then 16 | for k, v in string.gmatch(vars, "(%w+)=(%w+)&*") do 17 | _GET[k] = v 18 | end 19 | end 20 | buf = buf .. "

Hello, this is NodeMCU.

" 21 | .. "
Turn PIN1
" 31 | client:send(buf) 32 | end) 33 | conn:on("sent", function(c) c:close() end) 34 | end) 35 | end -------------------------------------------------------------------------------- /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 | local c = i2c.read(id, length) 37 | i2c.stop(id) 38 | return c 39 | end 40 | local function read_lux() 41 | local dataT = read_data(GY_30_address, CMD, 2) 42 | --Make it more faster 43 | local 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 | local bh1750 = require("bh1750") 10 | 11 | local sda = 6 -- sda pin, GPIO12 12 | local scl = 5 -- scl pin, GPIO14 13 | 14 | do 15 | bh1750.init(sda, scl) 16 | 17 | tmr.create():alarm(10000, tmr.ALARM_AUTO, function() 18 | bh1750.read() 19 | local l = bh1750.getlux() 20 | print("lux: "..(l / 100).."."..(l % 100).." lx") 21 | end) 22 | end 23 | -------------------------------------------------------------------------------- /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/cohelper/README.md: -------------------------------------------------------------------------------- 1 | # Coroutine Helper Module 2 | 3 | Documentation for this Lua module is available in the [Lua Modules->cohelper](../../docs/lua-modules/cohelper.md) MD file and in the [Official NodeMCU Documentation](https://nodemcu.readthedocs.io/) in `Lua Modules` section. 4 | -------------------------------------------------------------------------------- /lua_modules/cohelper/cohelper.lua: -------------------------------------------------------------------------------- 1 | --[[ A coroutine Helper T. Ellison, June 2019 2 | 3 | This version of couroutine helper demonstrates the use of corouting within 4 | NodeMCU execution to split structured Lua code into smaller tasks 5 | 6 | ]] 7 | --luacheck: read globals node 8 | 9 | local modname = ... 10 | 11 | local function taskYieldFactory(co) 12 | local post = node.task.post 13 | return function(nCBs) -- upval: co,post 14 | post(function () -- upval: co, nCBs 15 | coroutine.resume(co, nCBs or 0) 16 | end) 17 | return coroutine.yield() + 1 18 | end 19 | end 20 | 21 | return { exec = function(func, ...) -- upval: modname 22 | package.loaded[modname] = nil 23 | local co = coroutine.create(func) 24 | return coroutine.resume(co, taskYieldFactory(co), ... ) 25 | end } 26 | 27 | 28 | -------------------------------------------------------------------------------- /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 | local t = require('ds18b20') 2 | 3 | local port = 80 4 | local pin = 3 -- gpio0 = 3, gpio2 = 4 5 | local gconn = {} -- local variable for connection 6 | 7 | local function readout(temps) 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(temps) do 14 | resp = resp .. string.format("Sensor %s: %s ℃
", 15 | ('%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X '):format(addr:byte(1,8)), temp) 16 | end 17 | 18 | resp = resp .. 19 | "Node ChipID: " .. node.chipid() .. "
" .. 20 | "Node MAC: " .. wifi.sta.getmac() .. "
" .. 21 | "Node Heap: " .. node.heap() .. "
" .. 22 | "Timer Ticks: " .. tmr.now() .. "
" .. 23 | "" 24 | 25 | gconn:send(resp) 26 | gconn:on("sent",function(conn) conn:close() end) 27 | end 28 | 29 | do 30 | local srv = net.createServer(net.TCP) 31 | srv:listen(port, 32 | function(conn) 33 | gconn = conn 34 | -- t:read_temp(readout) -- default pin value is 3 35 | t:read_temp(readout, pin) 36 | end) 37 | end 38 | -------------------------------------------------------------------------------- /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 | local ds3231 = require("ds3231") 2 | 3 | -- ESP-01 GPIO Mapping 4 | local gpio0, gpio2 = 3, 4 5 | 6 | do 7 | i2c.setup(0, gpio0, gpio2, i2c.SLOW) -- call i2c.setup() only once 8 | 9 | local second, minute, hour, day, date, month, year = ds3231.getTime(); -- luacheck: no unused 10 | 11 | -- Get current time 12 | print(string.format("Time & Date: %s:%s:%s %s/%s/%s", hour, minute, second, date, month, year)) 13 | 14 | -- Don't forget to release it after use 15 | ds3231 = nil -- luacheck: no unused 16 | package.loaded["ds3231"] = nil 17 | end -------------------------------------------------------------------------------- /lua_modules/ds3231/ds3231-web.lua: -------------------------------------------------------------------------------- 1 | local ds3231 = require('ds3231') 2 | 3 | -- ESP-01 GPIO Mapping 4 | local gpio0, gpio2 = 3, 4 5 | local port = 80 6 | local days = { 7 | [1] = "Sunday", 8 | [2] = "Monday", 9 | [3] = "Tuesday", 10 | [4] = "Wednesday", 11 | [5] = "Thursday", 12 | [6] = "Friday", 13 | [7] = "Saturday" 14 | } 15 | 16 | local months = { 17 | [1] = "January", 18 | [2] = "Febuary", 19 | [3] = "March", 20 | [4] = "April", 21 | [5] = "May", 22 | [6] = "June", 23 | [7] = "July", 24 | [8] = "August", 25 | [9] = "September", 26 | [10] = "October", 27 | [11] = "November", 28 | [12] = "December" 29 | } 30 | 31 | do 32 | i2c.setup(0, gpio0, gpio2, i2c.SLOW) -- call i2c.setup() only once 33 | 34 | local srv = net.createServer(net.TCP) 35 | srv:listen(port, function(conn) 36 | local second, minute, hour, day, date, month, year = ds3231.getTime() 37 | local prettyTime = string.format("%s, %s %s %s %s:%s:%s", 38 | days[day], date, months[month], year, hour, minute, second) 39 | 40 | conn:send("HTTP/1.1 200 OK\nContent-Type: text/html\nRefresh: 5\n\n" .. 41 | "" .. 42 | "" .. 43 | "ESP8266
" .. 44 | "Time and Date: " .. prettyTime .. "
" .. 45 | "Node ChipID : " .. node.chipid() .. "
" .. 46 | "Node MAC : " .. wifi.sta.getmac() .. "
" .. 47 | "Node Heap : " .. node.heap() .. "
" .. 48 | "Timer Ticks : " .. tmr.now() .. "
" .. 49 | "") 50 | 51 | conn:on("sent",function(sck) sck:close() end) 52 | end) 53 | end 54 | -------------------------------------------------------------------------------- /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/fifo/README.md: -------------------------------------------------------------------------------- 1 | # FIFO Module 2 | 3 | Documentation for this Lua module is available in the [fifo.md](../../docs/lua-modules/fifo.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/gossip/README.md: -------------------------------------------------------------------------------- 1 | # Gossip module 2 | 3 | Documentation for this Lua module is available in the [gossip.md](../../docs/lua-modules/gossip.md) file and in the [Official NodeMCU Documentation](https://nodemcu.readthedocs.io/) in `Lua Modules` section. 4 | -------------------------------------------------------------------------------- /lua_modules/hdc1000/HDC1000-example.lua: -------------------------------------------------------------------------------- 1 | local HDC1000 = require("HDC1000") 2 | 3 | local sda, scl = 1, 2 4 | local drdyn = false 5 | 6 | do 7 | i2c.setup(0, sda, scl, i2c.SLOW) -- call i2c.setup() only once 8 | HDC1000.setup(drdyn) 9 | -- prototype is config(address, resolution, heater) 10 | HDC1000.config() -- default values are used if called with no arguments. 11 | 12 | print(string.format("Temperature: %.2f °C\nHumidity: %.2f %%", HDC1000.getTemp(), HDC1000.getHumi())) 13 | 14 | -- Don't forget to release it after use 15 | HDC1000 = nil -- luacheck: no unused 16 | package.loaded["HDC1000"] = nil 17 | end -------------------------------------------------------------------------------- /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) -- luacheck: ignore 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) -- luacheck: ignore 25 | print("+B", chunk and #chunk, node.heap()) 26 | if not chunk then 27 | -- reply 28 | res:send(nil, 200) 29 | res:send_header("Connection", "close") 30 | res:send("Hello, world!\n") 31 | res:finish() 32 | end 33 | end 34 | -- or just do something not waiting till body (if any) comes 35 | --res:finish("Hello, world!") 36 | --res:finish("Salut, monde!") 37 | end) 38 | -------------------------------------------------------------------------------- /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/mcp23017/README.md: -------------------------------------------------------------------------------- 1 | # MCP23017 Module 2 | 3 | Documentation for this Lua module is available in the [mcp23017.md](../../docs/lua-modules/mcp23017.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/telnet/README.md: -------------------------------------------------------------------------------- 1 | # Telnet Module 2 | 3 | Documentation for this Lua module is available in the [telnet.md](../../docs/lua-modules/telnet.md) file and in the [Official NodeMCU Documentation](https://nodemcu.readthedocs.io/) in `Lua Modules` section. 4 | -------------------------------------------------------------------------------- /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 | local dht = require("dht_lib") --Step2: "Require" the libs 14 | local 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.create():alarm(60000, tmr.ALARM_AUTO, 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 | -------------------------------------------------------------------------------- /msvc/.gitignore: -------------------------------------------------------------------------------- 1 | .vs/ 2 | */Win32/ 3 | */x64/ 4 | 5 | *.vcxproj.user 6 | 7 | *.lua 8 | *.img 9 | -------------------------------------------------------------------------------- /msvc/README.md: -------------------------------------------------------------------------------- 1 | These are MSVC (Visual Studio 2017) project files for the host-side tools, 2 | namely 'luac.cross' and 'spiffsimg'. Some may find these convenient if they 3 | already have MSVC instead of, say, setting up a Cygwin or MingW build 4 | system. 5 | 6 | To build 'luac.cross', you must first edit app/include/user_config.h to make 7 | some choices about the kind of cross-compiler you are generating. 8 | 9 | In particular, the definition of 10 | LUA_FLASH_STORE 11 | should be enabled if you are creating a cross-compiler for generating images 12 | for the Lua File Storage (LFS). The specific value of this define is not 13 | critical for luac.cross, but it's existence is if you want to be able to 14 | generate appropriate code for LFS. 15 | 16 | Be aware that the codebase, as checked in, has LUA_FLASH_STORE undefined. 17 | Since it is expected that most folks wanting a host-side luac.cross is 18 | for LFS use, you will want to first make sure that is changed to be 19 | defined. 20 | 21 | Secondly, if you are wanting to generate code that is appropriate for an 22 | integer-only build, you should ensure that 23 | LUA_NUMBER_INTEGRAL 24 | is defined. 25 | 26 | After altering those settings, you can build using the hosttools.sln file in 27 | the Visual Studio UI, or directly on the command line. x86 and x64 targets 28 | are provisioned, though there isn't anything to be gained with the 64-bit 29 | build. 30 | 31 | -------------------------------------------------------------------------------- /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 | 2 | #ifndef _SDKOVERRIDES_C_TYPES_H_ 3 | #define _SDKOVERRIDES_C_TYPES_H_ 4 | 5 | #error "Please do not use c_types.h, use instead" 6 | 7 | #endif 8 | -------------------------------------------------------------------------------- /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/espconn.h: -------------------------------------------------------------------------------- 1 | // poor mans link which also works on docker under windows 2 | #include "../../app/include/lwip/app/espconn.h" 3 | -------------------------------------------------------------------------------- /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 5 | #include 6 | #include 7 | 8 | #include_next "ets_sys.h" 9 | 10 | #include 11 | 12 | int ets_sprintf(char *str, const char *format, ...) __attribute__ ((format (printf, 2, 3))); 13 | 14 | int ets_vsprintf (char *d, const char *s, va_list ap); 15 | 16 | extern ETSTimer *timer_list; 17 | 18 | #endif /* SDK_OVERRIDES_INCLUDE_ETS_SYS_H_ */ 19 | -------------------------------------------------------------------------------- /sdk-overrides/include/mem.h: -------------------------------------------------------------------------------- 1 | #include 2 | #define MEM_DEFAULT_USE_DRAM 3 | #include_next "mem.h" 4 | -------------------------------------------------------------------------------- /sdk-overrides/include/osapi.h: -------------------------------------------------------------------------------- 1 | #ifndef _SDK_OVERRIDE_OSAPI_H_ 2 | #define _SDK_OVERRIDE_OSAPI_H_ 3 | 4 | #include 5 | #include 6 | #include 7 | #define USE_OPTIMIZE_PRINTF 8 | 9 | #include_next "osapi.h" 10 | 11 | #include "rom.h" 12 | 13 | unsigned int uart_baudrate_detect(unsigned int uart_no, unsigned int async); 14 | 15 | void NmiTimSetFunc(void (*func)(void)); 16 | 17 | void call_user_start(void); 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /sdk-overrides/include/stdbool.h: -------------------------------------------------------------------------------- 1 | #ifndef __stdbool_h__ 2 | #define __stdbool_h__ 3 | 4 | // For compatibility with SDK. Boo. 5 | typedef unsigned char bool; 6 | #define BOOL bool 7 | #define true (1) 8 | #define false (0) 9 | #define TRUE true 10 | #define FALSE false 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /sdk-overrides/include/stdio.h: -------------------------------------------------------------------------------- 1 | #ifndef _OVERRIDE_STDIO_H_ 2 | #define _OVERRIDE_STDIO_H_ 3 | 4 | #include_next "stdio.h" 5 | 6 | #ifdef __BUFSIZ__ 7 | # define BUFSIZ __BUFSIZ__ 8 | #else 9 | # define BUFSIZ 1024 10 | #endif 11 | 12 | extern void output_redirect(const char *str, size_t l); 13 | #define puts(s) output_redirect((s), strlen(s)) 14 | 15 | #define printf(...) do { \ 16 | char __printf_buf[BUFSIZ]; \ 17 | snprintf(__printf_buf, BUFSIZ, __VA_ARGS__); \ 18 | puts(__printf_buf); \ 19 | } while(0) 20 | 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /sdk-overrides/include/stdlib.h: -------------------------------------------------------------------------------- 1 | #ifndef _OVERRIDE_STDLIB_H_ 2 | #define _OVERRIDE_STDLIB_H_ 3 | 4 | #include_next "stdlib.h" 5 | #include 6 | #include "mem.h" 7 | 8 | #define free os_free 9 | #define malloc os_malloc 10 | #define calloc(n,sz) os_zalloc(n*sz) 11 | #define realloc os_realloc 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /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 5 | #include 6 | #include 7 | 8 | #include_next "user_interface.h" 9 | 10 | bool wifi_softap_deauth(uint8 mac[6]); 11 | uint8 get_fpm_auto_sleep_flag(void); 12 | 13 | //force sleep API 14 | #define FPM_SLEEP_MAX_TIME 268435455 //0xFFFFFFF 15 | void wifi_fpm_set_wakeup_cb(void (*fpm_wakeup_cb_func)(void)); 16 | bool fpm_is_open(void); 17 | bool fpm_rf_is_closed(void); 18 | uint8 get_fpm_auto_sleep_flag(void); 19 | 20 | 21 | 22 | #endif /* SDK_OVERRIDES_INCLUDE_USER_INTERFACE_H_ */ 23 | -------------------------------------------------------------------------------- /tests/.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 | *.tcl text eol=lf 13 | *.expect text eol=lf 14 | -------------------------------------------------------------------------------- /tests/NTest_lua.lua: -------------------------------------------------------------------------------- 1 | local N = require "NTest" ("Lua detail tests") 2 | 3 | N.test('typeerror', function() 4 | fail(function() math.abs("") end, "number expected, got string", "string") 5 | fail(function() math.abs() end, "number expected, got no value", "no value") 6 | end) 7 | -------------------------------------------------------------------------------- /tests/NTest_ws2812_effects.lua: -------------------------------------------------------------------------------- 1 | local N = ... 2 | N = (N or require "NTest")("ws2812_effects") 3 | 4 | local buffer 5 | 6 | 7 | N.test('set_speed', function() 8 | buffer = ws2812.newBuffer(9, 3) 9 | ws2812_effects.init(buffer) 10 | 11 | ws2812_effects.set_speed(0) 12 | ws2812_effects.set_speed(255) 13 | 14 | fail(function() ws2812_effects.set_speed(-1) end, "should be") 15 | fail(function() ws2812_effects.set_speed(256) end, "should be") 16 | end) 17 | 18 | N.test('set_brightness', function() 19 | buffer = ws2812.newBuffer(9, 3) 20 | ws2812_effects.init(buffer) 21 | 22 | ws2812_effects.set_brightness(0) 23 | ws2812_effects.set_brightness(255) 24 | 25 | fail(function() ws2812_effects.set_brightness(-1) end, "should be") 26 | fail(function() ws2812_effects.set_brightness(256) end, "should be") 27 | end) 28 | -------------------------------------------------------------------------------- /tests/Test-Harness-Render-V1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nodemcu/nodemcu-firmware/36cbf9f017d356319a6369e299765eedff191154/tests/Test-Harness-Render-V1.png -------------------------------------------------------------------------------- /tests/Test-harness-schematic-v1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nodemcu/nodemcu-firmware/36cbf9f017d356319a6369e299765eedff191154/tests/Test-harness-schematic-v1.pdf -------------------------------------------------------------------------------- /tests/expectnmcu/pkgIndex.tcl: -------------------------------------------------------------------------------- 1 | # Tcl package index file, version 1.1 2 | # This file is generated by the "pkg_mkIndex" command 3 | # and sourced either when an application starts up or 4 | # by a "package unknown" script. It invokes the 5 | # "package ifneeded" command to set up package-related 6 | # information so that packages will be loaded automatically 7 | # in response to "package require" commands. When this 8 | # script is sourced, the variable $dir must contain the 9 | # full path name of this file's directory. 10 | 11 | package ifneeded expectnmcu::core 1.0 [list source [file join $dir core.tcl]] 12 | package ifneeded expectnmcu::xfer 1.0 [list source [file join $dir xfer.tcl]] 13 | -------------------------------------------------------------------------------- /tests/utils/NTestTapOut.lua: -------------------------------------------------------------------------------- 1 | -- This is a NTest output handler that formats its output in a way that 2 | -- resembles the Test Anything Protocol (though prefixed with "TAP: " so we can 3 | -- more readily find it in comingled output streams). 4 | 5 | local nrun 6 | return function(e, test, msg, err) 7 | msg = msg or "" 8 | err = err or "" 9 | if e == "pass" then 10 | print(("\nTAP: ok %d %s # %s"):format(nrun, test, msg)) 11 | nrun = nrun + 1 12 | elseif e == "fail" then 13 | print(("\nTAP: not ok %d %s # %s: %s"):format(nrun, test, msg, err)) 14 | nrun = nrun + 1 15 | elseif e == "except" then 16 | print(("\nTAP: not ok %d %s # exn; %s: %s"):format(nrun, test, msg, err)) 17 | nrun = nrun + 1 18 | elseif e == "abort" then 19 | print(("\nTAP: Bail out! %d %s # exn; %s: %s"):format(nrun, test, msg, err)) 20 | elseif e == "start" then 21 | -- We don't know how many tests we plan to run, so emit a comment instead 22 | print(("\nTAP: # STARTUP %s"):format(test)) 23 | nrun = 1 24 | elseif e == "finish" then 25 | -- Ah, now, here we go; we know how many tests we ran, so signal completion 26 | print(("\nTAP: POST 1..%d"):format(nrun)) 27 | elseif #msg ~= 0 or #err ~= 0 then 28 | print(("\nTAP: # %s: %s: %s"):format(test, msg, err)) 29 | end 30 | end 31 | -------------------------------------------------------------------------------- /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/check_docs_module_linkage.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # get all linked module docs for mkdocs.yml 4 | grep "modules/" mkdocs.yml | sed "s/ *- .*: *'//" | sed "s/'//" | sort > /tmp/doc 5 | 6 | # get all module and lua_module *.md files 7 | find docs/modules/ docs/lua-modules/ -name "*.md" | sed "sxdocs/xx" | sort > /tmp/files 8 | 9 | diff /tmp/doc /tmp/files && echo "all *.md files are reflected in mkdocs.yml" 10 | 11 | -------------------------------------------------------------------------------- /tools/luacheck_NTest_config.lua: -------------------------------------------------------------------------------- 1 | stds.nodemcu_libs = {} 2 | loadfile ("tools/luacheck_config.lua")(stds) 3 | local empty = { } 4 | 5 | stds.nodemcu_libs.read_globals.ok = empty 6 | stds.nodemcu_libs.read_globals.nok = empty 7 | stds.nodemcu_libs.read_globals.eq = empty 8 | stds.nodemcu_libs.read_globals.fail = empty 9 | stds.nodemcu_libs.read_globals.spy = empty 10 | 11 | std = "lua51+lua53+nodemcu_libs" 12 | -------------------------------------------------------------------------------- /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/spiffsimg/.gitignore: -------------------------------------------------------------------------------- 1 | spiffs.lst 2 | spiffsimg 3 | -------------------------------------------------------------------------------- /tools/spiffsimg/Makefile: -------------------------------------------------------------------------------- 1 | APP_DIR = ../../app 2 | summary ?= @true 3 | 4 | CC =gcc 5 | 6 | SRCS=\ 7 | main.c \ 8 | $(APP_DIR)/spiffs/spiffs_cache.c $(APP_DIR)/spiffs/spiffs_check.c $(APP_DIR)/spiffs/spiffs_gc.c $(APP_DIR)/spiffs/spiffs_hydrogen.c $(APP_DIR)/spiffs/spiffs_nucleus.c 9 | 10 | CFLAGS=-g -Wall -Wextra -Wno-unused-parameter -Wno-unused-function -I. -I$(APP_DIR)/spiffs -I$(APP_DIR)/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/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 | #if !defined(__CYGWIN__) && !defined(_MSC_VER) 14 | typedef long long ptrdiff_t; 15 | #define offsetof(type, member) __builtin_offsetof (type, member) 16 | #endif 17 | -------------------------------------------------------------------------------- /tools/travis/ci-build-linux.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | echo "Running ci build for linux" 6 | ( 7 | cd "$TRAVIS_BUILD_DIR" || exit 8 | export BUILD_DATE=$(date +%Y%m%d) 9 | 10 | # build integer firmware 11 | make EXTRA_CCFLAGS="-DLUA_NUMBER_INTEGRAL -DBUILD_DATE='\"'$BUILD_DATE'\"'" 12 | cd bin/ || exit 13 | file_name_integer="nodemcu_integer_${TRAVIS_TAG}.bin" 14 | srec_cat -output ${file_name_integer} -binary 0x00000.bin -binary -fill 0xff 0x00000 0x10000 0x10000.bin -binary -offset 0x10000 15 | cd ../ || exit 16 | 17 | # build float firmware 18 | make clean 19 | make EXTRA_CCFLAGS="-DBUILD_DATE='\"'$BUILD_DATE'\"'" all 20 | cd bin/ || exit 21 | file_name_float="nodemcu_float_${TRAVIS_TAG}.bin" 22 | srec_cat -output ${file_name_float} -binary 0x00000.bin -binary -fill 0xff 0x00000 0x10000 0x10000.bin -binary -offset 0x10000 23 | ) 24 | -------------------------------------------------------------------------------- /tools/travis/ci-build-windows-ms.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | echo "Running ci build for windows msbuild (supports only hosttools)" 6 | ( 7 | cd "$TRAVIS_BUILD_DIR"/msvc || exit 8 | export PATH=$MSBUILD_PATH:$PATH 9 | msbuild.exe hosttools.sln 10 | ) 11 | 12 | -------------------------------------------------------------------------------- /tools/travis/pr-build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | echo "Running PR build: all modules plus SSL, debug, FATFS, new I2C driver, pmSleep and SmartConfig all 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 -i -r 's@(//.*)(#define *LUA_USE_MODULES_.*)@\2@g' user_modules.h 10 | cat user_modules.h 11 | 12 | # enable SSL 13 | sed -i 's@//#define CLIENT_SSL_ENABLE@#define CLIENT_SSL_ENABLE@' user_config.h 14 | 15 | # enable debug 16 | sed -i '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 | 21 | # enable new I2C driver 22 | sed -i 's@#define I2C_MASTER_OLD_VERSION@//#define I2C_MASTER_OLD_VERSION@' user_config.h 23 | 24 | # enable pmSleep 25 | sed -i 's@//#define TIMER_SUSPEND_ENABLE@#define TIMER_SUSPEND_ENABLE@' user_config.h 26 | sed -i 's@//#define PMSLEEP_ENABLE@#define PMSLEEP_ENABLE@' user_config.h 27 | 28 | # enable WiFi SmartConfig 29 | sed -i 's@//#define WIFI_SMART_ENABLE@#define WIFI_SMART_ENABLE@' user_config.h 30 | 31 | cat user_config.h 32 | 33 | cd "$TRAVIS_BUILD_DIR"/ld || exit 34 | # increase irom0_0_seg size for all modules build 35 | sed -E -i.bak 's@(.*irom0_0_seg *:.*len *=) *[^,]*(.*)@\1 0x200000\2@' nodemcu.ld 36 | sed -E -i.bak 's@(.*iram1_0_seg *:.*len *=) *[^,]*(.*)@\1 0x100000\2@' nodemcu.ld 37 | cat nodemcu.ld 38 | 39 | # change to "root" directory no matter where the script was started from 40 | cd "$TRAVIS_BUILD_DIR" || exit 41 | make clean 42 | make 43 | ) 44 | -------------------------------------------------------------------------------- /tools/travis/run-luacheck-windows.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | #Download luacheck binary if nessesary 6 | if ! [ -x "cache/luacheck.exe" ]; then 7 | wget --tries=5 --timeout=10 --waitretry=10 --read-timeout=10 --retry-connrefused -O cache/luacheck.exe https://github.com/mpeterv/luacheck/releases/download/0.23.0/luacheck.exe 8 | fi 9 | 10 | echo "Static analysys of" 11 | find lua_modules lua_examples -iname "*.lua" -print0 | xargs -0 echo 12 | (find lua_modules lua_examples -iname "*.lua" -print0 | xargs -0 cache/luacheck.exe --config tools/luacheck_config.lua) || exit 13 | 14 | echo "Static analysys of" 15 | find tests -iname "*.lua" -print0 | xargs -0 echo 16 | (find tests -iname "*.lua" -print0 | xargs -0 cache/luacheck.exe --config tools/luacheck_NTest_config.lua) || exit 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/nodemcu/nodemcu-firmware/36cbf9f017d356319a6369e299765eedff191154/tools/xxd.exe --------------------------------------------------------------------------------