Adding sockets bindings for esp32

This commit is contained in:
Brad Nelson
2021-02-21 00:35:48 -08:00
parent 4fdba81711
commit 7869aa3859
3 changed files with 33 additions and 6 deletions

View File

@ -1,4 +1,4 @@
VERSION=7.0 VERSION=7.0.1
REVISION=$(shell git rev-parse HEAD) REVISION=$(shell git rev-parse HEAD)
OUT = out OUT = out

View File

@ -13,6 +13,7 @@
#define ENABLE_WEBSERVER_SUPPORT #define ENABLE_WEBSERVER_SUPPORT
#define ENABLE_SDCARD_SUPPORT #define ENABLE_SDCARD_SUPPORT
#define ENABLE_I2C_SUPPORT #define ENABLE_I2C_SUPPORT
#define ENABLE_SOCKETS_SUPPORT
// For now assume only boards with PSRAM (ESP32-CAM) // For now assume only boards with PSRAM (ESP32-CAM)
// will want SerialBluetooth (very large) and camera support. // will want SerialBluetooth (very large) and camera support.
@ -115,6 +116,7 @@
OPTIONAL_I2C_SUPPORT \ OPTIONAL_I2C_SUPPORT \
OPTIONAL_SERIAL_BLUETOOTH_SUPPORT \ OPTIONAL_SERIAL_BLUETOOTH_SUPPORT \
OPTIONAL_CAMERA_SUPPORT \ OPTIONAL_CAMERA_SUPPORT \
OPTIONAL_SOCKETS_SUPPORT \
#ifndef ENABLE_SPIFFS_SUPPORT #ifndef ENABLE_SPIFFS_SUPPORT
// Provide a default failing SPIFFS.begin // Provide a default failing SPIFFS.begin
@ -123,7 +125,6 @@
#else #else
# include "SPIFFS.h" # include "SPIFFS.h"
# define OPTIONAL_SPIFFS_SUPPORT \ # define OPTIONAL_SPIFFS_SUPPORT \
/* SPIFFS */ \
X("SPIFFS.begin", SPIFFS_BEGIN, \ X("SPIFFS.begin", SPIFFS_BEGIN, \
tos = SPIFFS.begin(n2, c1, n0); NIPn(2)) \ tos = SPIFFS.begin(n2, c1, n0); NIPn(2)) \
X("SPIFFS.end", SPIFFS_END, SPIFFS.end()) \ X("SPIFFS.end", SPIFFS_END, SPIFFS.end()) \
@ -137,7 +138,6 @@
#else #else
# include "esp_camera.h" # include "esp_camera.h"
# define OPTIONAL_CAMERA_SUPPORT \ # define OPTIONAL_CAMERA_SUPPORT \
/* Camera */ \
Y(esp_camera_init, n0 = esp_camera_init((camera_config_t *) a0)) \ Y(esp_camera_init, n0 = esp_camera_init((camera_config_t *) a0)) \
Y(esp_camera_deinit, PUSH esp_camera_deinit()) \ Y(esp_camera_deinit, PUSH esp_camera_deinit()) \
Y(esp_camera_fb_get, PUSH esp_camera_fb_get()) \ Y(esp_camera_fb_get, PUSH esp_camera_fb_get()) \
@ -145,12 +145,32 @@
Y(esp_camera_sensor_get, PUSH esp_camera_sensor_get()) Y(esp_camera_sensor_get, PUSH esp_camera_sensor_get())
#endif #endif
#ifndef ENABLE_SOCKETS_SUPPORT
# define OPTIONAL_SOCKETS_SUPPORT
#else
# include <errno.h>
# include <sys/select.h>
# include <sys/socket.h>
# include <sys/time.h>
# include <sys/types.h>
# include <sys/un.h>
# include <sys/poll.h>
# define OPTIONAL_SOCKETS_SUPPORT \
Y(socket, n0 = socket(n2, n1, n0); NIPn(2)) \
Y(bind, n0 = bind(n2, (struct sockaddr *) a1, n0); NIPn(2)) \
Y(listen, n0 = listen(n1, n0); NIP) \
Y(connect, n0 = connect(n2, (struct sockaddr *) a1, n0); NIPn(2)) \
Y(accept, n0 = accept(n2, (struct sockaddr *) a1, (socklen_t *) a0); NIPn(2)) \
Y(select, n0 = select(n4, (fd_set *) a3, (fd_set *) a2, (fd_set *) a1, (struct timeval *) a0); NIPn(4)) \
Y(poll, n0 = poll((struct pollfd *) a2, (nfds_t) n1, n0); NIPn(2)) \
Y(errno, PUSH errno)
#endif
#ifndef ENABLE_SDCARD_SUPPORT #ifndef ENABLE_SDCARD_SUPPORT
# define OPTIONAL_SDCARD_SUPPORT # define OPTIONAL_SDCARD_SUPPORT
#else #else
# include "SD_MMC.h" # include "SD_MMC.h"
# define OPTIONAL_SDCARD_SUPPORT \ # define OPTIONAL_SDCARD_SUPPORT \
/* SD_MMC */ \
X("SD_MMC.begin", SD_MMC_BEGIN, tos = SD_MMC.begin(c1, n0); NIP) \ X("SD_MMC.begin", SD_MMC_BEGIN, tos = SD_MMC.begin(c1, n0); NIP) \
X("SD_MMC.end", SD_MMC_END, SD_MMC.end()) \ X("SD_MMC.end", SD_MMC_END, SD_MMC.end()) \
X("SD_MMC.cardType", SD_MMC_CARD_TYPE, PUSH SD_MMC.cardType()) \ X("SD_MMC.cardType", SD_MMC_CARD_TYPE, PUSH SD_MMC.cardType()) \
@ -163,7 +183,6 @@
#else #else
# include <Wire.h> # include <Wire.h>
# define OPTIONAL_I2C_SUPPORT \ # define OPTIONAL_I2C_SUPPORT \
/* Wire */ \
X("Wire.begin", WIRE_BEGIN, n0 = Wire.begin(n1, n0); NIP) \ X("Wire.begin", WIRE_BEGIN, n0 = Wire.begin(n1, n0); NIP) \
X("Wire.setClock", WIRE_SET_CLOCK, Wire.setClock(n0); DROP) \ X("Wire.setClock", WIRE_SET_CLOCK, Wire.setClock(n0); DROP) \
X("Wire.getClock", WIRE_GET_CLOCK, PUSH Wire.getClock()) \ X("Wire.getClock", WIRE_GET_CLOCK, PUSH Wire.getClock()) \
@ -193,7 +212,6 @@
# include "BluetoothSerial.h" # include "BluetoothSerial.h"
# define bt0 ((BluetoothSerial *) a0) # define bt0 ((BluetoothSerial *) a0)
# define OPTIONAL_SERIAL_BLUETOOTH_SUPPORT \ # define OPTIONAL_SERIAL_BLUETOOTH_SUPPORT \
/* SerialBT */ \
X("SerialBT.new", SERIALBT_NEW, PUSH new BluetoothSerial()) \ X("SerialBT.new", SERIALBT_NEW, PUSH new BluetoothSerial()) \
X("SerialBT.delete", SERIALBT_DELETE, delete bt0; DROP) \ X("SerialBT.delete", SERIALBT_DELETE, delete bt0; DROP) \
X("SerialBT.begin", SERIALBT_BEGIN, n0 = bt0->begin(c2, n1); NIPn(2)) \ X("SerialBT.begin", SERIALBT_BEGIN, n0 = bt0->begin(c2, n1); NIPn(2)) \

View File

@ -77,6 +77,15 @@ transfer{
}transfer }transfer
forth definitions forth definitions
vocabulary sockets sockets definitions
transfer{
socket bind listen connect accept select poll errno
}transfer
1 constant SOCK_STREAM
2 constant AF_INET
16 constant sizeof(sockaddr_in)
forth definitions
vocabulary bluetooth bluetooth definitions vocabulary bluetooth bluetooth definitions
?transfer SerialBT.new ?transfer SerialBT.new
?transfer SerialBT.delete ?transfer SerialBT.delete