Adding HTTPClient, fix esp32 build board, deprecate old spi flash.
This commit is contained in:
30
esp32/BUILD
30
esp32/BUILD
@ -34,11 +34,12 @@ ESP32_OPTIONAL.append(
|
||||
'$dst/esp32/ESP32forth/ESP32forth.ino'))
|
||||
|
||||
|
||||
def Esp32Optional(main_name, main_source, parts):
|
||||
def Esp32Optional(main_name, main_source, parts, very_optional=False):
|
||||
global ESP32_OPTIONAL
|
||||
ESP32_OPTIONAL.append(
|
||||
Copy('$dst/esp32/with_optional/ESP32forth/' + main_name + '.h',
|
||||
'$dst/esp32/ESP32forth/optional/' + main_name + '.h'))
|
||||
if not very_optional:
|
||||
ESP32_OPTIONAL.append(
|
||||
Copy('$dst/esp32/with_optional/ESP32forth/' + main_name + '.h',
|
||||
'$dst/esp32/ESP32forth/optional/' + main_name + '.h'))
|
||||
implicit = []
|
||||
for name, source in parts:
|
||||
implicit.append(Importation('$dst/gen/esp32_' + name + '.h',
|
||||
@ -65,10 +66,12 @@ ESP32_ZIP_FILES += [
|
||||
[('interrupts', '$src/esp32/optional/interrupts/timers.fs')]),
|
||||
Esp32Optional('oled', '$src/esp32/optional/oled/oled.h',
|
||||
[('oled', '$src/esp32/optional/oled/oled.fs')]),
|
||||
Esp32Optional('spi-flash', '$src/esp32/optional/spi-flash/spi-flash.h',
|
||||
[('spi-flash', '$src/esp32/optional/spi-flash/spi-flash.fs')]),
|
||||
Esp32Optional('serial-bluetooth', '$src/esp32/optional/serial-bluetooth/serial-bluetooth.h',
|
||||
[('serial-bluetooth', '$src/esp32/optional/serial-bluetooth/serial-bluetooth.fs')]),
|
||||
[('serial-bluetooth', '$src/esp32/optional/serial-bluetooth/serial-bluetooth.fs')],
|
||||
very_optional=True),
|
||||
Esp32Optional('http-client', '$src/esp32/optional/http-client/http-client.h', []),
|
||||
Esp32Optional('spi-flash', '$src/esp32/optional/spi-flash/spi-flash.h',
|
||||
[('spi-flash', '$src/esp32/optional/spi-flash/spi-flash.fs')], very_optional=True),
|
||||
]
|
||||
|
||||
# Zip it.
|
||||
@ -110,14 +113,17 @@ BOARDS = {
|
||||
'tdongles3': '--fqbn=esp32:esp32:esp32s3:CDCOnBoot=cdc,FlashSize=16M,PartitionScheme=huge_app',
|
||||
}
|
||||
for board_base in BOARDS:
|
||||
options = BOARDS[board_base]
|
||||
for opt, optdir, deps in (('', '', ESP32_FILES),
|
||||
('opt', 'with_optional/', ESP32_OPTIONAL)):
|
||||
board = board_base + opt
|
||||
for optional, optional_dir, deps in (('', '', ESP32_FILES),
|
||||
('opt', 'with_optional/', ESP32_OPTIONAL)):
|
||||
options = BOARDS[board_base]
|
||||
if optional:
|
||||
options = options.replace('PartitionScheme=default', 'PartitionScheme=huge_app')
|
||||
options = options.replace('PartitionScheme=no_ota', 'PartitionScheme=huge_app')
|
||||
board = board_base + optional
|
||||
clobber = f'rm -rf {WINTMP}/ueforth_esp32/{board}_dir/ && '
|
||||
setup = (f'mkdir -p {WINTMP}/ueforth_esp32/{board}_dir/build && '
|
||||
f'mkdir -p {WINTMP}/ueforth_esp32/{board}_dir/cache && '
|
||||
f'cp -r $dst/esp32/ESP32forth {WINTMP}/ueforth_esp32/{board}_dir/ && '
|
||||
f'cp -r $dst/esp32/' + optional_dir + f'ESP32forth/ {WINTMP}/ueforth_esp32/{board}_dir/ && '
|
||||
f'cd {WINTMP} && ')
|
||||
cmd = f' {ARDUINO_CLI} compile '
|
||||
upload = '--port $${PORT:-com3} --upload '
|
||||
|
||||
@ -84,6 +84,14 @@
|
||||
# define OPTIONAL_SPI_FLASH_SUPPORT
|
||||
# endif
|
||||
|
||||
// Hook to pull in optional HTTPClient support.
|
||||
# if __has_include("http-client.h")
|
||||
# include "http-client.h"
|
||||
# else
|
||||
# define OPTIONAL_HTTP_CLIENT_VOCABULARY
|
||||
# define OPTIONAL_HTTP_CLIENT_SUPPORT
|
||||
# endif
|
||||
|
||||
static cell_t ResizeFile(cell_t fd, cell_t size);
|
||||
|
||||
#endif
|
||||
@ -120,7 +128,8 @@ static cell_t ResizeFile(cell_t fd, cell_t size);
|
||||
OPTIONAL_OLED_SUPPORT \
|
||||
OPTIONAL_RMT_SUPPORT \
|
||||
OPTIONAL_SERIAL_BLUETOOTH_SUPPORT \
|
||||
OPTIONAL_SPI_FLASH_SUPPORT
|
||||
OPTIONAL_SPI_FLASH_SUPPORT \
|
||||
OPTIONAL_HTTP_CLIENT_SUPPORT
|
||||
|
||||
#define REQUIRED_MEMORY_SUPPORT \
|
||||
YV(internals, MALLOC, SET malloc(n0)) \
|
||||
|
||||
@ -16,6 +16,7 @@ These are the current optional modules:
|
||||
* serial-bluetooth.h - Support for Bluetooth serial and
|
||||
bterm a Bluetooth serial redirector for the terminal
|
||||
* spi-flash.h - Support for low level SPI Flash partition access
|
||||
* http-client.h - Support for HTTP/HTTPS
|
||||
|
||||
Initially ESP32forth focused on a minimal C kernel, with most functionality
|
||||
built in Forth code loaded at boot. Eventually, as support for more capabilities
|
||||
|
||||
52
esp32/optional/http-client/http-client.h
Normal file
52
esp32/optional/http-client/http-client.h
Normal file
@ -0,0 +1,52 @@
|
||||
// Copyright 2024 Bradley D. Nelson
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
/*
|
||||
* ESP32forth RMT v{{VERSION}}
|
||||
* Revision: {{REVISION}}
|
||||
*/
|
||||
|
||||
#include "HTTPClient.h"
|
||||
|
||||
#define OPTIONAL_HTTP_CLIENT_VOCABULARY V(HTTPClient)
|
||||
#define OPTIONAL_HTTP_CLIENT_SUPPORT \
|
||||
XV(HTTPClient, "NetworkClientSecure.new", NetworkClientSecure_new, PUSH new NetworkClientSecure()) \
|
||||
XV(HTTPClient, "NetworkClientSecure.delete", NetworkClientSecure_delete, delete ((NetworkClientSecure *) a0); DROP) \
|
||||
XV(HTTPClient, "NetworkClientSecure.setCACert", NetworkClientSecure_setCACert, \
|
||||
((NetworkClientSecure *) a0)->setCACert(c1); DROPn(2)) \
|
||||
XV(HTTPClient, "HTTPClient.new", HTTPClient_new, PUSH new HTTPClient()) \
|
||||
XV(HTTPClient, "HTTPClient.delete", HTTPClient_delete, delete (HTTPClient *) a0; DROP) \
|
||||
XV(HTTPClient, "HTTPClient.begin", HTTPClient_begin, n0 = ((HTTPClient *) a0)->begin(c1); NIP) \
|
||||
XV(HTTPClient, "HTTPClient.beginNC", HTTPClient_beginNC, \
|
||||
n0 = ((HTTPClient *) a0)->begin(*(NetworkClient *)a1, c2); NIPn(2)) \
|
||||
XV(HTTPClient, "HTTPClient.end", HTTPClient_end, ((HTTPClient *) a0)->end(); DROP) \
|
||||
XV(HTTPClient, "HTTPClient.connected", HTTPClient_connected, n0 = ((HTTPClient *) a0)->connected()) \
|
||||
XV(HTTPClient, "HTTPClient.setReuse", HTTPClient_setReuse, ((HTTPClient *) a0)->setReuse(n1); DROPn(2)) \
|
||||
XV(HTTPClient, "HTTPClient.setUserAgent", HTTPClient_setUserAgent, ((HTTPClient *) a0)->setUserAgent(c1); DROPn(2)) \
|
||||
XV(HTTPClient, "HTTPClient.setAuthorization", HTTPClient_setAuthorization, \
|
||||
((HTTPClient *) a0)->setAuthorization(c2, cc1); DROPn(3)) \
|
||||
XV(HTTPClient, "HTTPClient.setFollowRedirects", HTTPClient_setFollowRedirects, \
|
||||
((HTTPClient *) a0)->setFollowRedirects((followRedirects_t) n1); DROPn(2)) \
|
||||
XV(HTTPClient, "HTTPClient.setRedirectLimit", HTTPClient_setRedirectLimit, \
|
||||
((HTTPClient *) a0)->setRedirectLimit(n1); DROPn(2)) \
|
||||
XV(HTTPClient, "HTTPClient.GET", HTTPClient_GET, n0 = ((HTTPClient *) a0)->GET()) \
|
||||
XV(HTTPClient, "HTTPClient.POST", HTTPClient_POST, n0 = ((HTTPClient *) a0)->POST(b2, n1); NIPn(2)) \
|
||||
XV(HTTPClient, "HTTPClient.addHeader", HTTPClient_addHeader, ((HTTPClient *) a0)->addHeader(c2, c1); DROPn(3)) \
|
||||
XV(HTTPClient, "HTTPClient.sendRequest", HTTPClient_sendRequest, n0 = ((HTTPClient *) a0)->sendRequest(c3, b2, n1); NIPn(3)) \
|
||||
XV(HTTPClient, "HTTPClient.getSize", HTTPClient_getSize, n0 = ((HTTPClient *) a0)->getSize()) \
|
||||
XV(HTTPClient, "HTTPClient.getString", HTTPClient_getString, ((HTTPClient *) a0)->getString().getBytes(b2, n1); DROPn(3)) \
|
||||
XV(HTTPClient, "HTTPClient.getStreamPtr", HTTPClient_getStreamPtr, \
|
||||
NetworkClient *s = ((HTTPClient *) a0)->getStreamPtr(); n0 = (cell_t) s) \
|
||||
XV(HTTPClient, "NetworkClient.available", NetworkClient_available, n0 = ((NetworkClient *) a0)->available()) \
|
||||
XV(HTTPClient, "NetworkClient.readBytes", NetworkClient_readBytes, n0 = ((NetworkClient *) a0)->readBytes(b2, n1); NIPn(2))
|
||||
@ -21,6 +21,11 @@
|
||||
#include "BluetoothSerial.h"
|
||||
|
||||
#define bt0 ((BluetoothSerial *) a0)
|
||||
#if defined(CONFIG_IDF_TARGET_ESP32S3)
|
||||
# define BT0_ENABLE_SSP
|
||||
#else
|
||||
# define BT0_ENABLE_SSP bt0->enableSSP()
|
||||
#endif
|
||||
|
||||
#define OPTIONAL_BLUETOOTH_VOCABULARY V(bluetooth)
|
||||
#define OPTIONAL_SERIAL_BLUETOOTH_SUPPORT \
|
||||
@ -35,7 +40,7 @@
|
||||
XV(bluetooth, "SerialBT.write", SERIALBT_WRITE, n0 = bt0->write(b2, n1); NIPn(2)) \
|
||||
XV(bluetooth, "SerialBT.flush", SERIALBT_FLUSH, bt0->flush(); DROP) \
|
||||
XV(bluetooth, "SerialBT.hasClient", SERIALBT_HAS_CLIENT, n0 = bt0->hasClient()) \
|
||||
XV(bluetooth, "SerialBT.enableSSP", SERIALBT_ENABLE_SSP, bt0->enableSSP(); DROP) \
|
||||
XV(bluetooth, "SerialBT.enableSSP", SERIALBT_ENABLE_SSP, BT0_ENABLE_SSP; DROP) \
|
||||
XV(bluetooth, "SerialBT.setPin", SERIALBT_SET_PIN, n0 = bt0->setPin(c1); NIP) \
|
||||
XV(bluetooth, "SerialBT.unpairDevice", SERIALBT_UNPAIR_DEVICE, \
|
||||
n0 = bt0->unpairDevice(b1); NIP) \
|
||||
|
||||
@ -47,3 +47,9 @@ internals DEFINED? serial-bluetooth-source [IF]
|
||||
internals DEFINED? spi-flash-source [IF]
|
||||
spi-flash-source evaluate
|
||||
[THEN] forth
|
||||
|
||||
internals DEFINED? HTTPClient [IF]
|
||||
vocabulary HTTPClient HTTPClient definitions
|
||||
transfer HTTPClient-buildtins
|
||||
forth definitions
|
||||
[THEN] forth
|
||||
|
||||
@ -101,4 +101,5 @@
|
||||
OPTIONAL_OLED_VOCABULARY \
|
||||
OPTIONAL_RMT_VOCABULARY \
|
||||
OPTIONAL_SPI_FLASH_VOCABULARY \
|
||||
OPTIONAL_HTTP_CLIENT_VOCABULARY \
|
||||
USER_VOCABULARIES
|
||||
|
||||
@ -31,6 +31,7 @@
|
||||
#define OPTIONAL_RMT_SUPPORT
|
||||
#define OPTIONAL_SERIAL_BLUETOOTH_SUPPORT
|
||||
#define OPTIONAL_SPI_FLASH_SUPPORT
|
||||
#define OPTIONAL_HTTP_CLIENT_SUPPORT
|
||||
|
||||
#define OPTIONAL_BLUETOOTH_VOCABULARY
|
||||
#define OPTIONAL_CAMERA_VOCABULARY
|
||||
@ -38,6 +39,7 @@
|
||||
#define OPTIONAL_OLED_VOCABULARY
|
||||
#define OPTIONAL_RMT_VOCABULARY
|
||||
#define OPTIONAL_SPI_FLASH_VOCABULARY
|
||||
#define OPTIONAL_HTTP_CLIENT_VOCABULARY
|
||||
|
||||
#include "builtins.h"
|
||||
|
||||
|
||||
@ -28,6 +28,7 @@
|
||||
#define OPTIONAL_OLED_VOCABULARY
|
||||
#define OPTIONAL_RMT_VOCABULARY
|
||||
#define OPTIONAL_SPI_FLASH_VOCABULARY
|
||||
#define OPTIONAL_HTTP_CLIENT_VOCABULARY
|
||||
|
||||
static cell_t *simulated(cell_t *sp, const char *op);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user