diff --git a/examples/espidf-ble-adv/.gitignore b/examples/espidf-ble-adv/.gitignore new file mode 100644 index 0000000..5402c18 --- /dev/null +++ b/examples/espidf-ble-adv/.gitignore @@ -0,0 +1,3 @@ +.pioenvs +.clang_complete +.gcc-flags.json diff --git a/examples/espidf-ble-adv/.travis.yml b/examples/espidf-ble-adv/.travis.yml new file mode 100644 index 0000000..72c6e43 --- /dev/null +++ b/examples/espidf-ble-adv/.travis.yml @@ -0,0 +1,65 @@ +# Continuous Integration (CI) is the practice, in software +# engineering, of merging all developer working copies with a shared mainline +# several times a day < http://docs.platformio.org/en/stable/ci/index.html > +# +# Documentation: +# +# * Travis CI Embedded Builds with PlatformIO +# < https://docs.travis-ci.com/user/integration/platformio/ > +# +# * PlatformIO integration with Travis CI +# < http://docs.platformio.org/en/stable/ci/travis.html > +# +# * User Guide for `platformio ci` command +# < http://docs.platformio.org/en/stable/userguide/cmd_ci.html > +# +# +# Please choice one of the following templates (proposed below) and uncomment +# it (remove "# " before each line) or use own configuration according to the +# Travis CI documentation (see above). +# + + +# +# Template #1: General project. Test it using existing `platformio.ini`. +# + +# language: python +# python: +# - "2.7" +# +# sudo: false +# cache: +# directories: +# - "~/.platformio" +# +# install: +# - pip install -U platformio +# +# script: +# - platformio run + + +# +# Template #2: The project is intended to by used as a library with examples +# + +# language: python +# python: +# - "2.7" +# +# sudo: false +# cache: +# directories: +# - "~/.platformio" +# +# env: +# - PLATFORMIO_CI_SRC=path/to/test/file.c +# - PLATFORMIO_CI_SRC=examples/file.ino +# - PLATFORMIO_CI_SRC=path/to/test/directory +# +# install: +# - pip install -U platformio +# +# script: +# - platformio ci --lib="." --board=ID_1 --board=ID_2 --board=ID_N diff --git a/examples/espidf-ble-adv/README.rst b/examples/espidf-ble-adv/README.rst new file mode 100644 index 0000000..dc07957 --- /dev/null +++ b/examples/espidf-ble-adv/README.rst @@ -0,0 +1,38 @@ +.. Copyright 2014-present PlatformIO + 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. + +How to build PlatformIO based project +===================================== + +1. `Install PlatformIO `_ +2. Download `development platform with examples `_ +3. Extract ZIP archive +4. Run these commands: + +.. code-block:: bash + + # Change directory to example + > cd platform-espressif32/examples/espidf-ble-adv + + # Build project + > platformio run + + # Upload firmware + > platformio run --target upload + + # Build specific environment + > platformio run -e esp32dev + + # Upload firmware for the specific environment + > platformio run -e esp32dev --target upload + + # Clean build files + > platformio run --target clean diff --git a/examples/espidf-ble-adv/lib/readme.txt b/examples/espidf-ble-adv/lib/readme.txt new file mode 100644 index 0000000..a3271c7 --- /dev/null +++ b/examples/espidf-ble-adv/lib/readme.txt @@ -0,0 +1,38 @@ + +This directory is intended for the project specific (private) libraries. +PlatformIO will compile them to static libraries and link to executable file. + +The source code of each library should be placed in separate directory, like +"lib/private_lib/[here are source files]". + +For example, see how can be organised `Foo` and `Bar` libraries: + +|--lib +| |--Bar +| | |--docs +| | |--examples +| | |--src +| | |- Bar.c +| | |- Bar.h +| |--Foo +| | |- Foo.c +| | |- Foo.h +| |- readme.txt --> THIS FILE +|- platformio.ini +|--src + |- main.c + +Then in `src/main.c` you should use: + +#include +#include + +// rest H/C/CPP code + +PlatformIO will find your libraries automatically, configure preprocessor's +include paths and build them. + +See additional options for PlatformIO Library Dependency Finder `lib_*`: + +http://docs.platformio.org/en/stable/projectconf.html#lib-install + diff --git a/examples/espidf-ble-adv/platformio.ini b/examples/espidf-ble-adv/platformio.ini new file mode 100644 index 0000000..e743c61 --- /dev/null +++ b/examples/espidf-ble-adv/platformio.ini @@ -0,0 +1,26 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter, extra scripting +; Upload options: custom port, speed and extra flags +; Library options: dependencies, extra library storages +; +; Please visit documentation for the other options and examples +; http://docs.platformio.org/en/stable/projectconf.html + +[env:nano32] +platform = espressif32 +framework = espidf +board = nano32 +build_flags = -DCONFIG_WIFI_SSID=\"ESP_AP\" -DCONFIG_WIFI_PASSWORD=\"MYPASS\" + +[env:espea32] +platform = espressif32 +framework = espidf +board = espea32 +build_flags = -DCONFIG_WIFI_SSID=\"ESP_AP\" -DCONFIG_WIFI_PASSWORD=\"MYPASS\" + +[env:esp32dev] +platform = espressif32 +framework = espidf +board = esp32dev +build_flags = -DCONFIG_WIFI_SSID=\"ESP_AP\" -DCONFIG_WIFI_PASSWORD=\"MYPASS\" diff --git a/examples/espidf-ble-adv/src/main.c b/examples/espidf-ble-adv/src/main.c new file mode 100644 index 0000000..7d12388 --- /dev/null +++ b/examples/espidf-ble-adv/src/main.c @@ -0,0 +1,219 @@ +// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD +// +// 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. + +#include +#include "freertos/FreeRTOS.h" +#include "freertos/task.h" +#include "bt.h" +#include + +#define HCI_H4_CMD_PREAMBLE_SIZE (4) + +/* HCI Command opcode group field(OGF) */ +#define HCI_GRP_HOST_CONT_BASEBAND_CMDS (0x03 << 10) /* 0x0C00 */ +#define HCI_GRP_BLE_CMDS (0x08 << 10) + +#define HCI_RESET (0x0003 | HCI_GRP_HOST_CONT_BASEBAND_CMDS) +#define HCI_BLE_WRITE_ADV_ENABLE (0x000A | HCI_GRP_BLE_CMDS) +#define HCI_BLE_WRITE_ADV_PARAMS (0x0006 | HCI_GRP_BLE_CMDS) +#define HCI_BLE_WRITE_ADV_DATA (0x0008 | HCI_GRP_BLE_CMDS) + +#define HCIC_PARAM_SIZE_WRITE_ADV_ENABLE (1) +#define HCIC_PARAM_SIZE_BLE_WRITE_ADV_PARAMS (15) +#define HCIC_PARAM_SIZE_BLE_WRITE_ADV_DATA (31) + +#define BD_ADDR_LEN (6) /* Device address length */ +typedef uint8_t bd_addr_t[BD_ADDR_LEN]; /* Device address */ + +#define UINT16_TO_STREAM(p, u16) {*(p)++ = (uint8_t)(u16); *(p)++ = (uint8_t)((u16) >> 8);} +#define UINT8_TO_STREAM(p, u8) {*(p)++ = (uint8_t)(u8);} +#define BDADDR_TO_STREAM(p, a) {int ijk; for (ijk = 0; ijk < BD_ADDR_LEN; ijk++) *(p)++ = (uint8_t) a[BD_ADDR_LEN - 1 - ijk];} +#define ARRAY_TO_STREAM(p, a, len) {int ijk; for (ijk = 0; ijk < len; ijk++) *(p)++ = (uint8_t) a[ijk];} + +enum { + H4_TYPE_COMMAND = 1, + H4_TYPE_ACL = 2, + H4_TYPE_SCO = 3, + H4_TYPE_EVENT = 4 +}; + +static uint8_t hci_cmd_buf[128]; + +/* + * @brief: BT controller callback function, used to notify the upper layer that + * controller is ready to receive command + */ +static void controller_rcv_pkt_ready(void) +{ + printf("controller rcv pkt ready\n"); +} + +/* + * @brief: BT controller callback function, to transfer data packet to upper + * controller is ready to receive command + */ +static int host_rcv_pkt(uint8_t *data, uint16_t len) +{ + printf("host rcv pkt: "); + for (uint16_t i = 0; i < len; i++) { + printf("%02x", data[i]); + } + printf("\n"); + return 0; +} + +static esp_vhci_host_callback_t vhci_host_cb = { + controller_rcv_pkt_ready, + host_rcv_pkt +}; + +static uint16_t make_cmd_reset(uint8_t *buf) +{ + UINT8_TO_STREAM (buf, H4_TYPE_COMMAND); + UINT16_TO_STREAM (buf, HCI_RESET); + UINT8_TO_STREAM (buf, 0); + return HCI_H4_CMD_PREAMBLE_SIZE; +} + +static uint16_t make_cmd_ble_set_adv_enable (uint8_t *buf, uint8_t adv_enable) +{ + UINT8_TO_STREAM (buf, H4_TYPE_COMMAND); + UINT16_TO_STREAM (buf, HCI_BLE_WRITE_ADV_ENABLE); + UINT8_TO_STREAM (buf, HCIC_PARAM_SIZE_WRITE_ADV_ENABLE); + UINT8_TO_STREAM (buf, adv_enable); + return HCI_H4_CMD_PREAMBLE_SIZE + HCIC_PARAM_SIZE_WRITE_ADV_ENABLE; +} + +static uint16_t make_cmd_ble_set_adv_param (uint8_t *buf, uint16_t adv_int_min, uint16_t adv_int_max, + uint8_t adv_type, uint8_t addr_type_own, + uint8_t addr_type_dir, bd_addr_t direct_bda, + uint8_t channel_map, uint8_t adv_filter_policy) +{ + UINT8_TO_STREAM (buf, H4_TYPE_COMMAND); + UINT16_TO_STREAM (buf, HCI_BLE_WRITE_ADV_PARAMS); + UINT8_TO_STREAM (buf, HCIC_PARAM_SIZE_BLE_WRITE_ADV_PARAMS ); + + UINT16_TO_STREAM (buf, adv_int_min); + UINT16_TO_STREAM (buf, adv_int_max); + UINT8_TO_STREAM (buf, adv_type); + UINT8_TO_STREAM (buf, addr_type_own); + UINT8_TO_STREAM (buf, addr_type_dir); + BDADDR_TO_STREAM (buf, direct_bda); + UINT8_TO_STREAM (buf, channel_map); + UINT8_TO_STREAM (buf, adv_filter_policy); + return HCI_H4_CMD_PREAMBLE_SIZE + HCIC_PARAM_SIZE_BLE_WRITE_ADV_PARAMS; +} + + +static uint16_t make_cmd_ble_set_adv_data(uint8_t *buf, uint8_t data_len, uint8_t *p_data) +{ + UINT8_TO_STREAM (buf, H4_TYPE_COMMAND); + UINT16_TO_STREAM (buf, HCI_BLE_WRITE_ADV_DATA); + UINT8_TO_STREAM (buf, HCIC_PARAM_SIZE_BLE_WRITE_ADV_DATA + 1); + + memset(buf, 0, HCIC_PARAM_SIZE_BLE_WRITE_ADV_DATA); + + if (p_data != NULL && data_len > 0) { + if (data_len > HCIC_PARAM_SIZE_BLE_WRITE_ADV_DATA) { + data_len = HCIC_PARAM_SIZE_BLE_WRITE_ADV_DATA; + } + + UINT8_TO_STREAM (buf, data_len); + + ARRAY_TO_STREAM (buf, p_data, data_len); + } + return HCI_H4_CMD_PREAMBLE_SIZE + HCIC_PARAM_SIZE_BLE_WRITE_ADV_DATA + 1; +} + +static void hci_cmd_send_reset(void) +{ + uint16_t sz = make_cmd_reset (hci_cmd_buf); + esp_vhci_host_send_packet(hci_cmd_buf, sz); +} + +static void hci_cmd_send_ble_adv_start(void) +{ + uint16_t sz = make_cmd_ble_set_adv_enable (hci_cmd_buf, 1); + esp_vhci_host_send_packet(hci_cmd_buf, sz); +} + +static void hci_cmd_send_ble_set_adv_param(void) +{ + uint16_t adv_intv_min = 256; // 160ms + uint16_t adv_intv_max = 256; // 160ms + uint8_t adv_type = 0; // connectable undirected advertising (ADV_IND) + uint8_t own_addr_type = 0; // Public Device Address + uint8_t peer_addr_type = 0; // Public Device Address + uint8_t peer_addr[6] = {0x80, 0x81, 0x82, 0x83, 0x84, 0x85}; + uint8_t adv_chn_map = 0x07; // 37, 38, 39 + uint8_t adv_filter_policy = 0; // Process All Conn and Scan + + uint16_t sz = make_cmd_ble_set_adv_param(hci_cmd_buf, + adv_intv_min, + adv_intv_max, + adv_type, + own_addr_type, + peer_addr_type, + peer_addr, + adv_chn_map, + adv_filter_policy); + esp_vhci_host_send_packet(hci_cmd_buf, sz); +} + +static void hci_cmd_send_ble_set_adv_data(void) +{ + char *adv_name = "ESP-BLE-HELLO"; + uint8_t name_len = (uint8_t)strlen(adv_name); + uint8_t adv_data[31] = {0x02, 0x01, 0x06, 0x0, 0x09}; + uint8_t adv_data_len; + + adv_data[3] = name_len + 1; + for (int i = 0; i < name_len; i++) { + adv_data[5 + i] = (uint8_t)adv_name[i]; + } + adv_data_len = 5 + name_len; + + uint16_t sz = make_cmd_ble_set_adv_data(hci_cmd_buf, adv_data_len, (uint8_t *)adv_data); + esp_vhci_host_send_packet(hci_cmd_buf, sz); +} + +/* + * @brief: send HCI commands to perform BLE advertising; + */ +void bleAdvtTask(void *pvParameters) +{ + int cmd_cnt = 0; + bool send_avail = false; + esp_vhci_host_register_callback(&vhci_host_cb); + printf("BLE advt task start\n"); + while (1) { + vTaskDelay(1000 / portTICK_PERIOD_MS); + send_avail = esp_vhci_host_check_send_available(); + if (send_avail) { + switch (cmd_cnt) { + case 0: hci_cmd_send_reset(); ++cmd_cnt; break; + case 1: hci_cmd_send_ble_set_adv_param(); ++cmd_cnt; break; + case 2: hci_cmd_send_ble_set_adv_data(); ++cmd_cnt; break; + case 3: hci_cmd_send_ble_adv_start(); ++cmd_cnt; break; + } + } + printf("BLE Advertise, flag_send_avail: %d, cmd_sent: %d\n", send_avail, cmd_cnt); + } +} + +void app_main() +{ + esp_bt_controller_init(); + xTaskCreatePinnedToCore(&bleAdvtTask, "bleAdvtTask", 2048, NULL, 5, NULL, 0); +} diff --git a/examples/espidf-ble-adv/src/sdkconfig.h b/examples/espidf-ble-adv/src/sdkconfig.h new file mode 100644 index 0000000..9bde466 --- /dev/null +++ b/examples/espidf-ble-adv/src/sdkconfig.h @@ -0,0 +1,98 @@ +/* + * + * Automatically generated file; DO NOT EDIT. + * Espressif IoT Development Framework Configuration + * + */ +#define CONFIG_ESP32_PHY_MAX_TX_POWER 20 +#define CONFIG_PHY_ENABLED 1 +#define CONFIG_TRACEMEM_RESERVE_DRAM 0x0 +#define CONFIG_ESPTOOLPY_FLASHFREQ "40m" +#define CONFIG_NEWLIB_STDOUT_ADDCR 1 +#define CONFIG_TASK_WDT_CHECK_IDLE_TASK 1 +#define CONFIG_ESPTOOLPY_FLASHSIZE "2MB" +#define CONFIG_ETHERNET 1 +#define CONFIG_INT_WDT 1 +#define CONFIG_ESPTOOLPY_FLASHFREQ_40M 1 +#define CONFIG_LOG_BOOTLOADER_LEVEL_INFO 1 +#define CONFIG_ESPTOOLPY_FLASHSIZE_2MB 1 +#define CONFIG_FREERTOS_THREAD_LOCAL_STORAGE_POINTERS 1 +#define CONFIG_LOG_DEFAULT_LEVEL_INFO 1 +#define CONFIG_BT_RESERVE_DRAM 0x10000 +#define CONFIG_ESP32_PANIC_PRINT_REBOOT 1 +#define CONFIG_CONSOLE_UART_BAUDRATE 115200 +#define CONFIG_LWIP_MAX_SOCKETS 10 +#define CONFIG_EMAC_TASK_PRIORITY 20 +#define CONFIG_ULP_COPROC_RESERVE_MEM 0 +#define CONFIG_ESPTOOLPY_BAUD 115200 +#define CONFIG_INT_WDT_CHECK_CPU1 1 +#define CONFIG_ESPTOOLPY_AFTER_RESET 1 +#define CONFIG_TOOLPREFIX "xtensa-esp32-elf-" +#define CONFIG_CONSOLE_UART_NUM 0 +#define CONFIG_ESP32_RTC_CLOCK_SOURCE_INTERNAL_RC 1 +#define CONFIG_ESPTOOLPY_BAUD_115200B 1 +#define CONFIG_LWIP_THREAD_LOCAL_STORAGE_INDEX 0 +#define CONFIG_CONSOLE_UART_DEFAULT 1 +#define CONFIG_MBEDTLS_SSL_MAX_CONTENT_LEN 16384 +#define CONFIG_ESPTOOLPY_FLASHSIZE_DETECT 1 +#define CONFIG_MBEDTLS_MPI_USE_INTERRUPT 1 +#define CONFIG_ESP32_ENABLE_COREDUMP_TO_NONE 1 +#define CONFIG_TASK_WDT 1 +#define CONFIG_MAIN_TASK_STACK_SIZE 4096 +#define CONFIG_TASK_WDT_TIMEOUT_S 5 +#define CONFIG_INT_WDT_TIMEOUT_MS 300 +#define CONFIG_ESPTOOLPY_FLASHMODE "dio" +#define CONFIG_BTC_TASK_STACK_SIZE 3072 +#define CONFIG_ESPTOOLPY_BEFORE "default_reset" +#define CONFIG_LOG_DEFAULT_LEVEL 3 +#define CONFIG_FREERTOS_ASSERT_ON_UNTESTED_FUNCTION 1 +#define CONFIG_SPI_FLASH_ENABLE_COUNTERS 1 +#define CONFIG_ESP32_PHY_MAX_WIFI_TX_POWER 20 +#define CONFIG_DMA_RX_BUF_NUM 10 +#define CONFIG_ESPTOOLPY_FLASHMODE_DIO 1 +#define CONFIG_TCP_SYNMAXRTX 6 +#define CONFIG_PYTHON "python" +#define CONFIG_ESP32_TIME_SYSCALL_USE_RTC_FRC1 1 +#define CONFIG_ESPTOOLPY_COMPRESSED 1 +#define CONFIG_PARTITION_TABLE_FILENAME "partitions_singleapp.csv" +#define CONFIG_LWIP_DHCP_MAX_NTP_SERVERS 1 +#define CONFIG_PARTITION_TABLE_SINGLE_APP 1 +#define CONFIG_WIFI_ENABLED 1 +#define CONFIG_SYSTEM_EVENT_TASK_STACK_SIZE 4096 +#define CONFIG_ESP32_DEEP_SLEEP_WAKEUP_DELAY 0 +#define CONFIG_PHY_DATA_OFFSET 0xf000 +#define CONFIG_PARTITION_TABLE_CUSTOM_APP_BIN_OFFSET 0x10000 +#define CONFIG_TASK_WDT_CHECK_IDLE_TASK_CPU1 1 +#define CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ 240 +#define CONFIG_MBEDTLS_HARDWARE_AES 1 +#define CONFIG_FREERTOS_HZ 100 +#define CONFIG_LOG_COLORS 1 +#define CONFIG_FREERTOS_ASSERT_FAIL_ABORT 1 +#define CONFIG_MONITOR_BAUD_115200B 1 +#define CONFIG_LOG_BOOTLOADER_LEVEL 3 +#define CONFIG_ESPTOOLPY_BEFORE_RESET 1 +#define CONFIG_ESPTOOLPY_BAUD_OTHER_VAL 115200 +#define CONFIG_ESP32_DEFAULT_CPU_FREQ_240 1 +#define CONFIG_TCP_MAXRTX 12 +#define CONFIG_ESPTOOLPY_AFTER "hard_reset" +#define CONFIG_DMA_TX_BUF_NUM 10 +#define CONFIG_ESP32_DEBUG_OCDAWARE 1 +#define CONFIG_FREERTOS_BREAK_ON_SCHEDULER_START_JTAG 1 +#define CONFIG_BT_ENABLED 1 +#define CONFIG_MONITOR_BAUD 115200 +#define CONFIG_MBEDTLS_HARDWARE_SHA 1 +#define CONFIG_FREERTOS_CORETIMER_0 1 +#define CONFIG_PARTITION_TABLE_CUSTOM_FILENAME "partitions.csv" +#define CONFIG_MBEDTLS_HAVE_TIME 1 +#define CONFIG_FREERTOS_CHECK_STACKOVERFLOW_CANARY 1 +#define CONFIG_FREERTOS_ISR_STACKSIZE 1536 +#define CONFIG_OPENSSL_ASSERT_DO_NOTHING 1 +#define CONFIG_OPTIMIZATION_LEVEL_DEBUG 1 +#define CONFIG_ESP32_PHY_AUTO_INIT 1 +#define CONFIG_SYSTEM_EVENT_QUEUE_SIZE 32 +#define CONFIG_ESP32_WIFI_RX_BUFFER_NUM 25 +#define CONFIG_APP_OFFSET 0x10000 +#define CONFIG_MEMMAP_SMP 1 +#define CONFIG_MBEDTLS_HARDWARE_MPI 1 +#define CONFIG_MONITOR_BAUD_OTHER_VAL 115200 +#define CONFIG_ESPTOOLPY_PORT "/dev/ttyUSB0" \ No newline at end of file diff --git a/examples/espidf-coap-server/.gitignore b/examples/espidf-coap-server/.gitignore new file mode 100644 index 0000000..5402c18 --- /dev/null +++ b/examples/espidf-coap-server/.gitignore @@ -0,0 +1,3 @@ +.pioenvs +.clang_complete +.gcc-flags.json diff --git a/examples/espidf-coap-server/.travis.yml b/examples/espidf-coap-server/.travis.yml new file mode 100644 index 0000000..72c6e43 --- /dev/null +++ b/examples/espidf-coap-server/.travis.yml @@ -0,0 +1,65 @@ +# Continuous Integration (CI) is the practice, in software +# engineering, of merging all developer working copies with a shared mainline +# several times a day < http://docs.platformio.org/en/stable/ci/index.html > +# +# Documentation: +# +# * Travis CI Embedded Builds with PlatformIO +# < https://docs.travis-ci.com/user/integration/platformio/ > +# +# * PlatformIO integration with Travis CI +# < http://docs.platformio.org/en/stable/ci/travis.html > +# +# * User Guide for `platformio ci` command +# < http://docs.platformio.org/en/stable/userguide/cmd_ci.html > +# +# +# Please choice one of the following templates (proposed below) and uncomment +# it (remove "# " before each line) or use own configuration according to the +# Travis CI documentation (see above). +# + + +# +# Template #1: General project. Test it using existing `platformio.ini`. +# + +# language: python +# python: +# - "2.7" +# +# sudo: false +# cache: +# directories: +# - "~/.platformio" +# +# install: +# - pip install -U platformio +# +# script: +# - platformio run + + +# +# Template #2: The project is intended to by used as a library with examples +# + +# language: python +# python: +# - "2.7" +# +# sudo: false +# cache: +# directories: +# - "~/.platformio" +# +# env: +# - PLATFORMIO_CI_SRC=path/to/test/file.c +# - PLATFORMIO_CI_SRC=examples/file.ino +# - PLATFORMIO_CI_SRC=path/to/test/directory +# +# install: +# - pip install -U platformio +# +# script: +# - platformio ci --lib="." --board=ID_1 --board=ID_2 --board=ID_N diff --git a/examples/espidf-coap-server/README.rst b/examples/espidf-coap-server/README.rst new file mode 100644 index 0000000..294285d --- /dev/null +++ b/examples/espidf-coap-server/README.rst @@ -0,0 +1,38 @@ +.. Copyright 2014-present PlatformIO + 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. + +How to build PlatformIO based project +===================================== + +1. `Install PlatformIO `_ +2. Download `development platform with examples `_ +3. Extract ZIP archive +4. Run these commands: + +.. code-block:: bash + + # Change directory to example + > cd platform-espressif32/examples/espidf-coap-server + + # Build project + > platformio run + + # Upload firmware + > platformio run --target upload + + # Build specific environment + > platformio run -e esp32dev + + # Upload firmware for the specific environment + > platformio run -e esp32dev --target upload + + # Clean build files + > platformio run --target clean diff --git a/examples/espidf-coap-server/lib/readme.txt b/examples/espidf-coap-server/lib/readme.txt new file mode 100644 index 0000000..a3271c7 --- /dev/null +++ b/examples/espidf-coap-server/lib/readme.txt @@ -0,0 +1,38 @@ + +This directory is intended for the project specific (private) libraries. +PlatformIO will compile them to static libraries and link to executable file. + +The source code of each library should be placed in separate directory, like +"lib/private_lib/[here are source files]". + +For example, see how can be organised `Foo` and `Bar` libraries: + +|--lib +| |--Bar +| | |--docs +| | |--examples +| | |--src +| | |- Bar.c +| | |- Bar.h +| |--Foo +| | |- Foo.c +| | |- Foo.h +| |- readme.txt --> THIS FILE +|- platformio.ini +|--src + |- main.c + +Then in `src/main.c` you should use: + +#include +#include + +// rest H/C/CPP code + +PlatformIO will find your libraries automatically, configure preprocessor's +include paths and build them. + +See additional options for PlatformIO Library Dependency Finder `lib_*`: + +http://docs.platformio.org/en/stable/projectconf.html#lib-install + diff --git a/examples/espidf-coap-server/platformio.ini b/examples/espidf-coap-server/platformio.ini new file mode 100644 index 0000000..e743c61 --- /dev/null +++ b/examples/espidf-coap-server/platformio.ini @@ -0,0 +1,26 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter, extra scripting +; Upload options: custom port, speed and extra flags +; Library options: dependencies, extra library storages +; +; Please visit documentation for the other options and examples +; http://docs.platformio.org/en/stable/projectconf.html + +[env:nano32] +platform = espressif32 +framework = espidf +board = nano32 +build_flags = -DCONFIG_WIFI_SSID=\"ESP_AP\" -DCONFIG_WIFI_PASSWORD=\"MYPASS\" + +[env:espea32] +platform = espressif32 +framework = espidf +board = espea32 +build_flags = -DCONFIG_WIFI_SSID=\"ESP_AP\" -DCONFIG_WIFI_PASSWORD=\"MYPASS\" + +[env:esp32dev] +platform = espressif32 +framework = espidf +board = esp32dev +build_flags = -DCONFIG_WIFI_SSID=\"ESP_AP\" -DCONFIG_WIFI_PASSWORD=\"MYPASS\" diff --git a/examples/espidf-coap-server/src/main.c b/examples/espidf-coap-server/src/main.c new file mode 100644 index 0000000..998f06d --- /dev/null +++ b/examples/espidf-coap-server/src/main.c @@ -0,0 +1,192 @@ +/* CoAP server Example + + This example code is in the Public Domain (or CC0 licensed, at your option.) + + Unless required by applicable law or agreed to in writing, this + software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR + CONDITIONS OF ANY KIND, either express or implied. +*/ + +#include +#include + +#include "freertos/FreeRTOS.h" +#include "freertos/task.h" +#include "freertos/event_groups.h" + +#include "esp_log.h" +#include "esp_wifi.h" +#include "esp_event_loop.h" + +#include "nvs_flash.h" + +#include "coap.h" + +/* The examples use simple WiFi configuration that you can set via + 'make menuconfig'. + + If you'd rather not, just change the below entries to strings with + the config you want - ie #define EXAMPLE_WIFI_SSID "mywifissid" +*/ +#define EXAMPLE_WIFI_SSID CONFIG_WIFI_SSID +#define EXAMPLE_WIFI_PASS CONFIG_WIFI_PASSWORD + +#define COAP_DEFAULT_TIME_SEC 5 +#define COAP_DEFAULT_TIME_USEC 0 + +static EventGroupHandle_t wifi_event_group; + +/* The event group allows multiple bits for each event, + but we only care about one event - are we connected + to the AP with an IP? */ +const static int CONNECTED_BIT = BIT0; + +const static char *TAG = "CoAP_server"; + +static coap_async_state_t *async = NULL; + +static void +send_async_response(coap_context_t *ctx, const coap_endpoint_t *local_if) +{ + coap_pdu_t *response; + unsigned char buf[3]; + const char* response_data = "Hello World!"; + size_t size = sizeof(coap_hdr_t) + 20; + response = coap_pdu_init(async->flags & COAP_MESSAGE_CON, COAP_RESPONSE_CODE(205), 0, size); + response->hdr->id = coap_new_message_id(ctx); + if (async->tokenlen) + coap_add_token(response, async->tokenlen, async->token); + coap_add_option(response, COAP_OPTION_CONTENT_TYPE, coap_encode_var_bytes(buf, COAP_MEDIATYPE_TEXT_PLAIN), buf); + coap_add_data (response, strlen(response_data), (unsigned char *)response_data); + + if (coap_send(ctx, local_if, &async->peer, response) == COAP_INVALID_TID) { + + } + coap_delete_pdu(response); + coap_async_state_t *tmp; + coap_remove_async(ctx, async->id, &tmp); + coap_free_async(async); + async = NULL; +} + +/* + * The resource handler + */ +static void +async_handler(coap_context_t *ctx, struct coap_resource_t *resource, + const coap_endpoint_t *local_interface, coap_address_t *peer, + coap_pdu_t *request, str *token, coap_pdu_t *response) +{ + async = coap_register_async(ctx, peer, request, COAP_ASYNC_SEPARATE | COAP_ASYNC_CONFIRM, (void*)"no data"); +} + +static void coap_demo_thread(void *p) +{ + coap_context_t* ctx = NULL; + coap_address_t serv_addr; + coap_resource_t* resource = NULL; + fd_set readfds; + struct timeval tv; + int flags = 0; + + while (1) { + /* Wait for the callback to set the CONNECTED_BIT in the + event group. + */ + xEventGroupWaitBits(wifi_event_group, CONNECTED_BIT, + false, true, portMAX_DELAY); + ESP_LOGI(TAG, "Connected to AP"); + + /* Prepare the CoAP server socket */ + coap_address_init(&serv_addr); + serv_addr.addr.sin.sin_family = AF_INET; + serv_addr.addr.sin.sin_addr.s_addr = INADDR_ANY; + serv_addr.addr.sin.sin_port = htons(COAP_DEFAULT_PORT); + ctx = coap_new_context(&serv_addr); + if (ctx) { + flags = fcntl(ctx->sockfd, F_GETFL, 0); + fcntl(ctx->sockfd, F_SETFL, flags|O_NONBLOCK); + + tv.tv_usec = COAP_DEFAULT_TIME_USEC; + tv.tv_sec = COAP_DEFAULT_TIME_SEC; + /* Initialize the resource */ + resource = coap_resource_init((unsigned char *)"Espressif", 9, 0); + if (resource){ + coap_register_handler(resource, COAP_REQUEST_GET, async_handler); + coap_add_resource(ctx, resource); + /*For incoming connections*/ + for (;;) { + FD_ZERO(&readfds); + FD_CLR( ctx->sockfd, &readfds); + FD_SET( ctx->sockfd, &readfds); + + int result = select( FD_SETSIZE, &readfds, 0, 0, &tv ); + if (result > 0){ + if (FD_ISSET( ctx->sockfd, &readfds )) + coap_read(ctx); + } else if (result < 0){ + break; + } else { + ESP_LOGE(TAG, "select timeout"); + } + + if (async) { + send_async_response(ctx, ctx->endpoint); + } + } + } + + coap_free_context(ctx); + } + } + + vTaskDelete(NULL); +} + +static esp_err_t wifi_event_handler(void *ctx, system_event_t *event) +{ + switch(event->event_id) { + case SYSTEM_EVENT_STA_START: + esp_wifi_connect(); + break; + case SYSTEM_EVENT_STA_GOT_IP: + xEventGroupSetBits(wifi_event_group, CONNECTED_BIT); + break; + case SYSTEM_EVENT_STA_DISCONNECTED: + /* This is a workaround as ESP32 WiFi libs don't currently + auto-reassociate. */ + esp_wifi_connect(); + xEventGroupClearBits(wifi_event_group, CONNECTED_BIT); + break; + default: + break; + } + return ESP_OK; +} + +static void wifi_conn_init(void) +{ + tcpip_adapter_init(); + wifi_event_group = xEventGroupCreate(); + ESP_ERROR_CHECK( esp_event_loop_init(wifi_event_handler, NULL) ); + wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT(); + ESP_ERROR_CHECK( esp_wifi_init(&cfg) ); + ESP_ERROR_CHECK( esp_wifi_set_storage(WIFI_STORAGE_RAM) ); + wifi_config_t wifi_config = { + .sta = { + .ssid = EXAMPLE_WIFI_SSID, + .password = EXAMPLE_WIFI_PASS, + }, + }; + ESP_ERROR_CHECK( esp_wifi_set_mode(WIFI_MODE_STA) ); + ESP_ERROR_CHECK( esp_wifi_set_config(WIFI_IF_STA, &wifi_config) ); + ESP_ERROR_CHECK( esp_wifi_start() ); +} + +void app_main(void) +{ + nvs_flash_init(); + wifi_conn_init(); + + xTaskCreate(coap_demo_thread, "coap", 2048, NULL, 5, NULL); +} \ No newline at end of file diff --git a/examples/espidf-coap-server/src/sdkconfig.h b/examples/espidf-coap-server/src/sdkconfig.h new file mode 100644 index 0000000..9bde466 --- /dev/null +++ b/examples/espidf-coap-server/src/sdkconfig.h @@ -0,0 +1,98 @@ +/* + * + * Automatically generated file; DO NOT EDIT. + * Espressif IoT Development Framework Configuration + * + */ +#define CONFIG_ESP32_PHY_MAX_TX_POWER 20 +#define CONFIG_PHY_ENABLED 1 +#define CONFIG_TRACEMEM_RESERVE_DRAM 0x0 +#define CONFIG_ESPTOOLPY_FLASHFREQ "40m" +#define CONFIG_NEWLIB_STDOUT_ADDCR 1 +#define CONFIG_TASK_WDT_CHECK_IDLE_TASK 1 +#define CONFIG_ESPTOOLPY_FLASHSIZE "2MB" +#define CONFIG_ETHERNET 1 +#define CONFIG_INT_WDT 1 +#define CONFIG_ESPTOOLPY_FLASHFREQ_40M 1 +#define CONFIG_LOG_BOOTLOADER_LEVEL_INFO 1 +#define CONFIG_ESPTOOLPY_FLASHSIZE_2MB 1 +#define CONFIG_FREERTOS_THREAD_LOCAL_STORAGE_POINTERS 1 +#define CONFIG_LOG_DEFAULT_LEVEL_INFO 1 +#define CONFIG_BT_RESERVE_DRAM 0x10000 +#define CONFIG_ESP32_PANIC_PRINT_REBOOT 1 +#define CONFIG_CONSOLE_UART_BAUDRATE 115200 +#define CONFIG_LWIP_MAX_SOCKETS 10 +#define CONFIG_EMAC_TASK_PRIORITY 20 +#define CONFIG_ULP_COPROC_RESERVE_MEM 0 +#define CONFIG_ESPTOOLPY_BAUD 115200 +#define CONFIG_INT_WDT_CHECK_CPU1 1 +#define CONFIG_ESPTOOLPY_AFTER_RESET 1 +#define CONFIG_TOOLPREFIX "xtensa-esp32-elf-" +#define CONFIG_CONSOLE_UART_NUM 0 +#define CONFIG_ESP32_RTC_CLOCK_SOURCE_INTERNAL_RC 1 +#define CONFIG_ESPTOOLPY_BAUD_115200B 1 +#define CONFIG_LWIP_THREAD_LOCAL_STORAGE_INDEX 0 +#define CONFIG_CONSOLE_UART_DEFAULT 1 +#define CONFIG_MBEDTLS_SSL_MAX_CONTENT_LEN 16384 +#define CONFIG_ESPTOOLPY_FLASHSIZE_DETECT 1 +#define CONFIG_MBEDTLS_MPI_USE_INTERRUPT 1 +#define CONFIG_ESP32_ENABLE_COREDUMP_TO_NONE 1 +#define CONFIG_TASK_WDT 1 +#define CONFIG_MAIN_TASK_STACK_SIZE 4096 +#define CONFIG_TASK_WDT_TIMEOUT_S 5 +#define CONFIG_INT_WDT_TIMEOUT_MS 300 +#define CONFIG_ESPTOOLPY_FLASHMODE "dio" +#define CONFIG_BTC_TASK_STACK_SIZE 3072 +#define CONFIG_ESPTOOLPY_BEFORE "default_reset" +#define CONFIG_LOG_DEFAULT_LEVEL 3 +#define CONFIG_FREERTOS_ASSERT_ON_UNTESTED_FUNCTION 1 +#define CONFIG_SPI_FLASH_ENABLE_COUNTERS 1 +#define CONFIG_ESP32_PHY_MAX_WIFI_TX_POWER 20 +#define CONFIG_DMA_RX_BUF_NUM 10 +#define CONFIG_ESPTOOLPY_FLASHMODE_DIO 1 +#define CONFIG_TCP_SYNMAXRTX 6 +#define CONFIG_PYTHON "python" +#define CONFIG_ESP32_TIME_SYSCALL_USE_RTC_FRC1 1 +#define CONFIG_ESPTOOLPY_COMPRESSED 1 +#define CONFIG_PARTITION_TABLE_FILENAME "partitions_singleapp.csv" +#define CONFIG_LWIP_DHCP_MAX_NTP_SERVERS 1 +#define CONFIG_PARTITION_TABLE_SINGLE_APP 1 +#define CONFIG_WIFI_ENABLED 1 +#define CONFIG_SYSTEM_EVENT_TASK_STACK_SIZE 4096 +#define CONFIG_ESP32_DEEP_SLEEP_WAKEUP_DELAY 0 +#define CONFIG_PHY_DATA_OFFSET 0xf000 +#define CONFIG_PARTITION_TABLE_CUSTOM_APP_BIN_OFFSET 0x10000 +#define CONFIG_TASK_WDT_CHECK_IDLE_TASK_CPU1 1 +#define CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ 240 +#define CONFIG_MBEDTLS_HARDWARE_AES 1 +#define CONFIG_FREERTOS_HZ 100 +#define CONFIG_LOG_COLORS 1 +#define CONFIG_FREERTOS_ASSERT_FAIL_ABORT 1 +#define CONFIG_MONITOR_BAUD_115200B 1 +#define CONFIG_LOG_BOOTLOADER_LEVEL 3 +#define CONFIG_ESPTOOLPY_BEFORE_RESET 1 +#define CONFIG_ESPTOOLPY_BAUD_OTHER_VAL 115200 +#define CONFIG_ESP32_DEFAULT_CPU_FREQ_240 1 +#define CONFIG_TCP_MAXRTX 12 +#define CONFIG_ESPTOOLPY_AFTER "hard_reset" +#define CONFIG_DMA_TX_BUF_NUM 10 +#define CONFIG_ESP32_DEBUG_OCDAWARE 1 +#define CONFIG_FREERTOS_BREAK_ON_SCHEDULER_START_JTAG 1 +#define CONFIG_BT_ENABLED 1 +#define CONFIG_MONITOR_BAUD 115200 +#define CONFIG_MBEDTLS_HARDWARE_SHA 1 +#define CONFIG_FREERTOS_CORETIMER_0 1 +#define CONFIG_PARTITION_TABLE_CUSTOM_FILENAME "partitions.csv" +#define CONFIG_MBEDTLS_HAVE_TIME 1 +#define CONFIG_FREERTOS_CHECK_STACKOVERFLOW_CANARY 1 +#define CONFIG_FREERTOS_ISR_STACKSIZE 1536 +#define CONFIG_OPENSSL_ASSERT_DO_NOTHING 1 +#define CONFIG_OPTIMIZATION_LEVEL_DEBUG 1 +#define CONFIG_ESP32_PHY_AUTO_INIT 1 +#define CONFIG_SYSTEM_EVENT_QUEUE_SIZE 32 +#define CONFIG_ESP32_WIFI_RX_BUFFER_NUM 25 +#define CONFIG_APP_OFFSET 0x10000 +#define CONFIG_MEMMAP_SMP 1 +#define CONFIG_MBEDTLS_HARDWARE_MPI 1 +#define CONFIG_MONITOR_BAUD_OTHER_VAL 115200 +#define CONFIG_ESPTOOLPY_PORT "/dev/ttyUSB0" \ No newline at end of file diff --git a/examples/espidf-peripherals-uart/.gitignore b/examples/espidf-peripherals-uart/.gitignore new file mode 100644 index 0000000..5402c18 --- /dev/null +++ b/examples/espidf-peripherals-uart/.gitignore @@ -0,0 +1,3 @@ +.pioenvs +.clang_complete +.gcc-flags.json diff --git a/examples/espidf-peripherals-uart/.travis.yml b/examples/espidf-peripherals-uart/.travis.yml new file mode 100644 index 0000000..72c6e43 --- /dev/null +++ b/examples/espidf-peripherals-uart/.travis.yml @@ -0,0 +1,65 @@ +# Continuous Integration (CI) is the practice, in software +# engineering, of merging all developer working copies with a shared mainline +# several times a day < http://docs.platformio.org/en/stable/ci/index.html > +# +# Documentation: +# +# * Travis CI Embedded Builds with PlatformIO +# < https://docs.travis-ci.com/user/integration/platformio/ > +# +# * PlatformIO integration with Travis CI +# < http://docs.platformio.org/en/stable/ci/travis.html > +# +# * User Guide for `platformio ci` command +# < http://docs.platformio.org/en/stable/userguide/cmd_ci.html > +# +# +# Please choice one of the following templates (proposed below) and uncomment +# it (remove "# " before each line) or use own configuration according to the +# Travis CI documentation (see above). +# + + +# +# Template #1: General project. Test it using existing `platformio.ini`. +# + +# language: python +# python: +# - "2.7" +# +# sudo: false +# cache: +# directories: +# - "~/.platformio" +# +# install: +# - pip install -U platformio +# +# script: +# - platformio run + + +# +# Template #2: The project is intended to by used as a library with examples +# + +# language: python +# python: +# - "2.7" +# +# sudo: false +# cache: +# directories: +# - "~/.platformio" +# +# env: +# - PLATFORMIO_CI_SRC=path/to/test/file.c +# - PLATFORMIO_CI_SRC=examples/file.ino +# - PLATFORMIO_CI_SRC=path/to/test/directory +# +# install: +# - pip install -U platformio +# +# script: +# - platformio ci --lib="." --board=ID_1 --board=ID_2 --board=ID_N diff --git a/examples/espidf-peripherals-uart/README.rst b/examples/espidf-peripherals-uart/README.rst new file mode 100644 index 0000000..27183da --- /dev/null +++ b/examples/espidf-peripherals-uart/README.rst @@ -0,0 +1,38 @@ +.. Copyright 2014-present PlatformIO + 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. + +How to build PlatformIO based project +===================================== + +1. `Install PlatformIO `_ +2. Download `development platform with examples `_ +3. Extract ZIP archive +4. Run these commands: + +.. code-block:: bash + + # Change directory to example + > cd platform-espressif32/examples/espidf-peripherals-uart + + # Build project + > platformio run + + # Upload firmware + > platformio run --target upload + + # Build specific environment + > platformio run -e esp32dev + + # Upload firmware for the specific environment + > platformio run -e esp32dev --target upload + + # Clean build files + > platformio run --target clean diff --git a/examples/espidf-peripherals-uart/lib/readme.txt b/examples/espidf-peripherals-uart/lib/readme.txt new file mode 100644 index 0000000..a3271c7 --- /dev/null +++ b/examples/espidf-peripherals-uart/lib/readme.txt @@ -0,0 +1,38 @@ + +This directory is intended for the project specific (private) libraries. +PlatformIO will compile them to static libraries and link to executable file. + +The source code of each library should be placed in separate directory, like +"lib/private_lib/[here are source files]". + +For example, see how can be organised `Foo` and `Bar` libraries: + +|--lib +| |--Bar +| | |--docs +| | |--examples +| | |--src +| | |- Bar.c +| | |- Bar.h +| |--Foo +| | |- Foo.c +| | |- Foo.h +| |- readme.txt --> THIS FILE +|- platformio.ini +|--src + |- main.c + +Then in `src/main.c` you should use: + +#include +#include + +// rest H/C/CPP code + +PlatformIO will find your libraries automatically, configure preprocessor's +include paths and build them. + +See additional options for PlatformIO Library Dependency Finder `lib_*`: + +http://docs.platformio.org/en/stable/projectconf.html#lib-install + diff --git a/examples/espidf-peripherals-uart/platformio.ini b/examples/espidf-peripherals-uart/platformio.ini new file mode 100644 index 0000000..e743c61 --- /dev/null +++ b/examples/espidf-peripherals-uart/platformio.ini @@ -0,0 +1,26 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter, extra scripting +; Upload options: custom port, speed and extra flags +; Library options: dependencies, extra library storages +; +; Please visit documentation for the other options and examples +; http://docs.platformio.org/en/stable/projectconf.html + +[env:nano32] +platform = espressif32 +framework = espidf +board = nano32 +build_flags = -DCONFIG_WIFI_SSID=\"ESP_AP\" -DCONFIG_WIFI_PASSWORD=\"MYPASS\" + +[env:espea32] +platform = espressif32 +framework = espidf +board = espea32 +build_flags = -DCONFIG_WIFI_SSID=\"ESP_AP\" -DCONFIG_WIFI_PASSWORD=\"MYPASS\" + +[env:esp32dev] +platform = espressif32 +framework = espidf +board = esp32dev +build_flags = -DCONFIG_WIFI_SSID=\"ESP_AP\" -DCONFIG_WIFI_PASSWORD=\"MYPASS\" diff --git a/examples/espidf-peripherals-uart/src/main.c b/examples/espidf-peripherals-uart/src/main.c new file mode 100644 index 0000000..61faf2b --- /dev/null +++ b/examples/espidf-peripherals-uart/src/main.c @@ -0,0 +1,183 @@ +/* Uart Example + + This example code is in the Public Domain (or CC0 licensed, at your option.) + + Unless required by applicable law or agreed to in writing, this + software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR + CONDITIONS OF ANY KIND, either express or implied. +*/ +#include +#include +#include +#include "freertos/FreeRTOS.h" +#include "freertos/task.h" +#include "esp_system.h" +#include "nvs_flash.h" +#include "driver/uart.h" +#include "freertos/queue.h" +#include "esp_log.h" +#include "soc/uart_struct.h" +static const char *TAG = "uart_example"; + +/** + * Test code brief + * This example shows how to configure uart settings and install uart driver. + * + * uart_evt_test() is an example that read and write data on UART0, and handler some of the special events. + * - port: UART0 + * - rx buffer: on + * - tx buffer: on + * - flow control: off + * - event queue: on + * - pin assignment: txd(default), rxd(default) + * + * uart_echo_test() is an example that read and write data on UART1, with hardware flow control turning on. + * - port: UART1 + * - rx buffer: on + * - tx buffer: off + * - flow control: on + * - event queue: off + * - pin assignment: txd(io4), rxd(io5), rts(18), cts(19) + */ + +#define BUF_SIZE (1024) +#define ECHO_TEST_TXD (4) +#define ECHO_TEST_RXD (5) +#define ECHO_TEST_RTS (18) +#define ECHO_TEST_CTS (19) + +QueueHandle_t uart0_queue; +void uart_task(void *pvParameters) +{ + int uart_num = (int) pvParameters; + uart_event_t event; + size_t buffered_size; + uint8_t* dtmp = (uint8_t*) malloc(BUF_SIZE); + for(;;) { + //Waiting for UART event. + if(xQueueReceive(uart0_queue, (void * )&event, (portTickType)portMAX_DELAY)) { + ESP_LOGI(TAG, "uart[%d] event:", uart_num); + switch(event.type) { + //Event of UART receving data + /*We'd better handler data event fast, there would be much more data events than + other types of events. If we take too much time on data event, the queue might + be full. + in this example, we don't process data in event, but read data outside.*/ + case UART_DATA: + uart_get_buffered_data_len(uart_num, &buffered_size); + ESP_LOGI(TAG, "data, len: %d; buffered len: %d", event.size, buffered_size); + break; + //Event of HW FIFO overflow detected + case UART_FIFO_OVF: + ESP_LOGI(TAG, "hw fifo overflow\n"); + //If fifo overflow happened, you should consider adding flow control for your application. + //We can read data out out the buffer, or directly flush the rx buffer. + uart_flush(uart_num); + break; + //Event of UART ring buffer full + case UART_BUFFER_FULL: + ESP_LOGI(TAG, "ring buffer full\n"); + //If buffer full happened, you should consider encreasing your buffer size + //We can read data out out the buffer, or directly flush the rx buffer. + uart_flush(uart_num); + break; + //Event of UART RX break detected + case UART_BREAK: + ESP_LOGI(TAG, "uart rx break\n"); + break; + //Event of UART parity check error + case UART_PARITY_ERR: + ESP_LOGI(TAG, "uart parity error\n"); + break; + //Event of UART frame error + case UART_FRAME_ERR: + ESP_LOGI(TAG, "uart frame error\n"); + break; + //UART_PATTERN_DET + case UART_PATTERN_DET: + ESP_LOGI(TAG, "uart pattern detected\n"); + break; + //Others + default: + ESP_LOGI(TAG, "uart event type: %d\n", event.type); + break; + } + } + } + free(dtmp); + dtmp = NULL; + vTaskDelete(NULL); +} + +void uart_evt_test() +{ + int uart_num = UART_NUM_0; + uart_config_t uart_config = { + .baud_rate = 115200, + .data_bits = UART_DATA_8_BITS, + .parity = UART_PARITY_DISABLE, + .stop_bits = UART_STOP_BITS_1, + .flow_ctrl = UART_HW_FLOWCTRL_DISABLE, + .rx_flow_ctrl_thresh = 122, + }; + //Set UART parameters + uart_param_config(uart_num, &uart_config); + //Set UART log level + esp_log_level_set(TAG, ESP_LOG_INFO); + //Install UART driver, and get the queue. + uart_driver_install(uart_num, BUF_SIZE * 2, BUF_SIZE * 2, 10, &uart0_queue, 0); + //Set UART pins,(-1: default pin, no change.) + //For UART0, we can just use the default pins. + //uart_set_pin(uart_num, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE); + //Set uart pattern detect function. + uart_enable_pattern_det_intr(uart_num, '+', 3, 10000, 10, 10); + //Create a task to handler UART event from ISR + xTaskCreate(uart_task, "uart_task", 2048, (void*)uart_num, 12, NULL); + //process data + uint8_t* data = (uint8_t*) malloc(BUF_SIZE); + do { + int len = uart_read_bytes(uart_num, data, BUF_SIZE, 100 / portTICK_RATE_MS); + if(len > 0) { + ESP_LOGI(TAG, "uart read : %d", len); + uart_write_bytes(uart_num, (const char*)data, len); + } + } while(1); +} + +//an example of echo test with hardware flow control on UART1 +void uart_echo_test() +{ + int uart_num = UART_NUM_1; + uart_config_t uart_config = { + .baud_rate = 115200, + .data_bits = UART_DATA_8_BITS, + .parity = UART_PARITY_DISABLE, + .stop_bits = UART_STOP_BITS_1, + .flow_ctrl = UART_HW_FLOWCTRL_CTS_RTS, + .rx_flow_ctrl_thresh = 122, + }; + //Configure UART1 parameters + uart_param_config(uart_num, &uart_config); + //Set UART1 pins(TX: IO4, RX: I05, RTS: IO18, CTS: IO19) + uart_set_pin(uart_num, ECHO_TEST_TXD, ECHO_TEST_RXD, ECHO_TEST_RTS, ECHO_TEST_CTS); + //Install UART driver( We don't need an event queue here) + //In this example we don't even use a buffer for sending data. + uart_driver_install(uart_num, BUF_SIZE * 2, 0, 0, NULL, 0); + + uint8_t* data = (uint8_t*) malloc(BUF_SIZE); + while(1) { + //Read data from UART + int len = uart_read_bytes(uart_num, data, BUF_SIZE, 20 / portTICK_RATE_MS); + //Write data back to UART + uart_write_bytes(uart_num, (const char*) data, len); + } +} + +void app_main() +{ + //A uart read/write example without event queue; + xTaskCreate(uart_echo_test, "uart_echo_test", 1024, NULL, 10, NULL); + + //A uart example with event queue. + uart_evt_test(); +} \ No newline at end of file diff --git a/examples/espidf-peripherals-uart/src/sdkconfig.h b/examples/espidf-peripherals-uart/src/sdkconfig.h new file mode 100644 index 0000000..9bde466 --- /dev/null +++ b/examples/espidf-peripherals-uart/src/sdkconfig.h @@ -0,0 +1,98 @@ +/* + * + * Automatically generated file; DO NOT EDIT. + * Espressif IoT Development Framework Configuration + * + */ +#define CONFIG_ESP32_PHY_MAX_TX_POWER 20 +#define CONFIG_PHY_ENABLED 1 +#define CONFIG_TRACEMEM_RESERVE_DRAM 0x0 +#define CONFIG_ESPTOOLPY_FLASHFREQ "40m" +#define CONFIG_NEWLIB_STDOUT_ADDCR 1 +#define CONFIG_TASK_WDT_CHECK_IDLE_TASK 1 +#define CONFIG_ESPTOOLPY_FLASHSIZE "2MB" +#define CONFIG_ETHERNET 1 +#define CONFIG_INT_WDT 1 +#define CONFIG_ESPTOOLPY_FLASHFREQ_40M 1 +#define CONFIG_LOG_BOOTLOADER_LEVEL_INFO 1 +#define CONFIG_ESPTOOLPY_FLASHSIZE_2MB 1 +#define CONFIG_FREERTOS_THREAD_LOCAL_STORAGE_POINTERS 1 +#define CONFIG_LOG_DEFAULT_LEVEL_INFO 1 +#define CONFIG_BT_RESERVE_DRAM 0x10000 +#define CONFIG_ESP32_PANIC_PRINT_REBOOT 1 +#define CONFIG_CONSOLE_UART_BAUDRATE 115200 +#define CONFIG_LWIP_MAX_SOCKETS 10 +#define CONFIG_EMAC_TASK_PRIORITY 20 +#define CONFIG_ULP_COPROC_RESERVE_MEM 0 +#define CONFIG_ESPTOOLPY_BAUD 115200 +#define CONFIG_INT_WDT_CHECK_CPU1 1 +#define CONFIG_ESPTOOLPY_AFTER_RESET 1 +#define CONFIG_TOOLPREFIX "xtensa-esp32-elf-" +#define CONFIG_CONSOLE_UART_NUM 0 +#define CONFIG_ESP32_RTC_CLOCK_SOURCE_INTERNAL_RC 1 +#define CONFIG_ESPTOOLPY_BAUD_115200B 1 +#define CONFIG_LWIP_THREAD_LOCAL_STORAGE_INDEX 0 +#define CONFIG_CONSOLE_UART_DEFAULT 1 +#define CONFIG_MBEDTLS_SSL_MAX_CONTENT_LEN 16384 +#define CONFIG_ESPTOOLPY_FLASHSIZE_DETECT 1 +#define CONFIG_MBEDTLS_MPI_USE_INTERRUPT 1 +#define CONFIG_ESP32_ENABLE_COREDUMP_TO_NONE 1 +#define CONFIG_TASK_WDT 1 +#define CONFIG_MAIN_TASK_STACK_SIZE 4096 +#define CONFIG_TASK_WDT_TIMEOUT_S 5 +#define CONFIG_INT_WDT_TIMEOUT_MS 300 +#define CONFIG_ESPTOOLPY_FLASHMODE "dio" +#define CONFIG_BTC_TASK_STACK_SIZE 3072 +#define CONFIG_ESPTOOLPY_BEFORE "default_reset" +#define CONFIG_LOG_DEFAULT_LEVEL 3 +#define CONFIG_FREERTOS_ASSERT_ON_UNTESTED_FUNCTION 1 +#define CONFIG_SPI_FLASH_ENABLE_COUNTERS 1 +#define CONFIG_ESP32_PHY_MAX_WIFI_TX_POWER 20 +#define CONFIG_DMA_RX_BUF_NUM 10 +#define CONFIG_ESPTOOLPY_FLASHMODE_DIO 1 +#define CONFIG_TCP_SYNMAXRTX 6 +#define CONFIG_PYTHON "python" +#define CONFIG_ESP32_TIME_SYSCALL_USE_RTC_FRC1 1 +#define CONFIG_ESPTOOLPY_COMPRESSED 1 +#define CONFIG_PARTITION_TABLE_FILENAME "partitions_singleapp.csv" +#define CONFIG_LWIP_DHCP_MAX_NTP_SERVERS 1 +#define CONFIG_PARTITION_TABLE_SINGLE_APP 1 +#define CONFIG_WIFI_ENABLED 1 +#define CONFIG_SYSTEM_EVENT_TASK_STACK_SIZE 4096 +#define CONFIG_ESP32_DEEP_SLEEP_WAKEUP_DELAY 0 +#define CONFIG_PHY_DATA_OFFSET 0xf000 +#define CONFIG_PARTITION_TABLE_CUSTOM_APP_BIN_OFFSET 0x10000 +#define CONFIG_TASK_WDT_CHECK_IDLE_TASK_CPU1 1 +#define CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ 240 +#define CONFIG_MBEDTLS_HARDWARE_AES 1 +#define CONFIG_FREERTOS_HZ 100 +#define CONFIG_LOG_COLORS 1 +#define CONFIG_FREERTOS_ASSERT_FAIL_ABORT 1 +#define CONFIG_MONITOR_BAUD_115200B 1 +#define CONFIG_LOG_BOOTLOADER_LEVEL 3 +#define CONFIG_ESPTOOLPY_BEFORE_RESET 1 +#define CONFIG_ESPTOOLPY_BAUD_OTHER_VAL 115200 +#define CONFIG_ESP32_DEFAULT_CPU_FREQ_240 1 +#define CONFIG_TCP_MAXRTX 12 +#define CONFIG_ESPTOOLPY_AFTER "hard_reset" +#define CONFIG_DMA_TX_BUF_NUM 10 +#define CONFIG_ESP32_DEBUG_OCDAWARE 1 +#define CONFIG_FREERTOS_BREAK_ON_SCHEDULER_START_JTAG 1 +#define CONFIG_BT_ENABLED 1 +#define CONFIG_MONITOR_BAUD 115200 +#define CONFIG_MBEDTLS_HARDWARE_SHA 1 +#define CONFIG_FREERTOS_CORETIMER_0 1 +#define CONFIG_PARTITION_TABLE_CUSTOM_FILENAME "partitions.csv" +#define CONFIG_MBEDTLS_HAVE_TIME 1 +#define CONFIG_FREERTOS_CHECK_STACKOVERFLOW_CANARY 1 +#define CONFIG_FREERTOS_ISR_STACKSIZE 1536 +#define CONFIG_OPENSSL_ASSERT_DO_NOTHING 1 +#define CONFIG_OPTIMIZATION_LEVEL_DEBUG 1 +#define CONFIG_ESP32_PHY_AUTO_INIT 1 +#define CONFIG_SYSTEM_EVENT_QUEUE_SIZE 32 +#define CONFIG_ESP32_WIFI_RX_BUFFER_NUM 25 +#define CONFIG_APP_OFFSET 0x10000 +#define CONFIG_MEMMAP_SMP 1 +#define CONFIG_MBEDTLS_HARDWARE_MPI 1 +#define CONFIG_MONITOR_BAUD_OTHER_VAL 115200 +#define CONFIG_ESPTOOLPY_PORT "/dev/ttyUSB0" \ No newline at end of file diff --git a/examples/espidf-storage-sdcard/.gitignore b/examples/espidf-storage-sdcard/.gitignore new file mode 100644 index 0000000..5402c18 --- /dev/null +++ b/examples/espidf-storage-sdcard/.gitignore @@ -0,0 +1,3 @@ +.pioenvs +.clang_complete +.gcc-flags.json diff --git a/examples/espidf-storage-sdcard/.travis.yml b/examples/espidf-storage-sdcard/.travis.yml new file mode 100644 index 0000000..72c6e43 --- /dev/null +++ b/examples/espidf-storage-sdcard/.travis.yml @@ -0,0 +1,65 @@ +# Continuous Integration (CI) is the practice, in software +# engineering, of merging all developer working copies with a shared mainline +# several times a day < http://docs.platformio.org/en/stable/ci/index.html > +# +# Documentation: +# +# * Travis CI Embedded Builds with PlatformIO +# < https://docs.travis-ci.com/user/integration/platformio/ > +# +# * PlatformIO integration with Travis CI +# < http://docs.platformio.org/en/stable/ci/travis.html > +# +# * User Guide for `platformio ci` command +# < http://docs.platformio.org/en/stable/userguide/cmd_ci.html > +# +# +# Please choice one of the following templates (proposed below) and uncomment +# it (remove "# " before each line) or use own configuration according to the +# Travis CI documentation (see above). +# + + +# +# Template #1: General project. Test it using existing `platformio.ini`. +# + +# language: python +# python: +# - "2.7" +# +# sudo: false +# cache: +# directories: +# - "~/.platformio" +# +# install: +# - pip install -U platformio +# +# script: +# - platformio run + + +# +# Template #2: The project is intended to by used as a library with examples +# + +# language: python +# python: +# - "2.7" +# +# sudo: false +# cache: +# directories: +# - "~/.platformio" +# +# env: +# - PLATFORMIO_CI_SRC=path/to/test/file.c +# - PLATFORMIO_CI_SRC=examples/file.ino +# - PLATFORMIO_CI_SRC=path/to/test/directory +# +# install: +# - pip install -U platformio +# +# script: +# - platformio ci --lib="." --board=ID_1 --board=ID_2 --board=ID_N diff --git a/examples/espidf-storage-sdcard/README.rst b/examples/espidf-storage-sdcard/README.rst new file mode 100644 index 0000000..6be3563 --- /dev/null +++ b/examples/espidf-storage-sdcard/README.rst @@ -0,0 +1,38 @@ +.. Copyright 2014-present PlatformIO + 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. + +How to build PlatformIO based project +===================================== + +1. `Install PlatformIO `_ +2. Download `development platform with examples `_ +3. Extract ZIP archive +4. Run these commands: + +.. code-block:: bash + + # Change directory to example + > cd platform-espressif32/examples/espidf-storage-sdcard + + # Build project + > platformio run + + # Upload firmware + > platformio run --target upload + + # Build specific environment + > platformio run -e esp32dev + + # Upload firmware for the specific environment + > platformio run -e esp32dev --target upload + + # Clean build files + > platformio run --target clean diff --git a/examples/espidf-storage-sdcard/lib/readme.txt b/examples/espidf-storage-sdcard/lib/readme.txt new file mode 100644 index 0000000..a3271c7 --- /dev/null +++ b/examples/espidf-storage-sdcard/lib/readme.txt @@ -0,0 +1,38 @@ + +This directory is intended for the project specific (private) libraries. +PlatformIO will compile them to static libraries and link to executable file. + +The source code of each library should be placed in separate directory, like +"lib/private_lib/[here are source files]". + +For example, see how can be organised `Foo` and `Bar` libraries: + +|--lib +| |--Bar +| | |--docs +| | |--examples +| | |--src +| | |- Bar.c +| | |- Bar.h +| |--Foo +| | |- Foo.c +| | |- Foo.h +| |- readme.txt --> THIS FILE +|- platformio.ini +|--src + |- main.c + +Then in `src/main.c` you should use: + +#include +#include + +// rest H/C/CPP code + +PlatformIO will find your libraries automatically, configure preprocessor's +include paths and build them. + +See additional options for PlatformIO Library Dependency Finder `lib_*`: + +http://docs.platformio.org/en/stable/projectconf.html#lib-install + diff --git a/examples/espidf-storage-sdcard/platformio.ini b/examples/espidf-storage-sdcard/platformio.ini new file mode 100644 index 0000000..e743c61 --- /dev/null +++ b/examples/espidf-storage-sdcard/platformio.ini @@ -0,0 +1,26 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter, extra scripting +; Upload options: custom port, speed and extra flags +; Library options: dependencies, extra library storages +; +; Please visit documentation for the other options and examples +; http://docs.platformio.org/en/stable/projectconf.html + +[env:nano32] +platform = espressif32 +framework = espidf +board = nano32 +build_flags = -DCONFIG_WIFI_SSID=\"ESP_AP\" -DCONFIG_WIFI_PASSWORD=\"MYPASS\" + +[env:espea32] +platform = espressif32 +framework = espidf +board = espea32 +build_flags = -DCONFIG_WIFI_SSID=\"ESP_AP\" -DCONFIG_WIFI_PASSWORD=\"MYPASS\" + +[env:esp32dev] +platform = espressif32 +framework = espidf +board = esp32dev +build_flags = -DCONFIG_WIFI_SSID=\"ESP_AP\" -DCONFIG_WIFI_PASSWORD=\"MYPASS\" diff --git a/examples/espidf-storage-sdcard/src/main.c b/examples/espidf-storage-sdcard/src/main.c new file mode 100644 index 0000000..8010685 --- /dev/null +++ b/examples/espidf-storage-sdcard/src/main.c @@ -0,0 +1,107 @@ +/* SD card and FAT filesystem example. + This example code is in the Public Domain (or CC0 licensed, at your option.) + + Unless required by applicable law or agreed to in writing, this + software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR + CONDITIONS OF ANY KIND, either express or implied. +*/ + +#include +#include +#include +#include +#include "esp_err.h" +#include "esp_log.h" +#include "esp_vfs_fat.h" +#include "driver/sdmmc_host.h" +#include "driver/sdmmc_defs.h" +#include "sdmmc_cmd.h" + +static const char* TAG = "example"; + +void app_main(void) +{ + ESP_LOGI(TAG, "Initializing SD card"); + + sdmmc_host_t host = SDMMC_HOST_DEFAULT(); + + // To use 1-line SD mode, uncomment the following line: + // host.flags = SDMMC_HOST_FLAG_1BIT; + + // This initializes the slot without card detect (CD) and write protect (WP) signals. + // Modify slot_config.gpio_cd and slot_config.gpio_wp if your board has these signals. + sdmmc_slot_config_t slot_config = SDMMC_SLOT_CONFIG_DEFAULT(); + + // Options for mounting the filesystem. + // If format_if_mount_failed is set to true, SD card will be partitioned and formatted + // in case when mounting fails. + esp_vfs_fat_sdmmc_mount_config_t mount_config = { + .format_if_mount_failed = false, + .max_files = 5 + }; + + // Use settings defined above to initialize SD card and mount FAT filesystem. + // Note: esp_vfs_fat_sdmmc_mount is an all-in-one convenience function. + // Please check its source code and implement error recovery when developing + // production applications. + sdmmc_card_t* card; + esp_err_t ret = esp_vfs_fat_sdmmc_mount("/sdcard", &host, &slot_config, &mount_config, &card); + if (ret != ESP_OK) { + if (ret == ESP_FAIL) { + ESP_LOGE(TAG, "Failed to mount filesystem. If you want the card to be formatted, set format_if_mount_failed = true."); + } else { + ESP_LOGE(TAG, "Failed to initialize the card (%d). Make sure SD card lines have pull-up resistors in place.", ret); + } + return; + } + + // Card has been initialized, print its properties + sdmmc_card_print_info(stdout, card); + + // Use POSIX and C standard library functions to work with files. + // First create a file. + ESP_LOGI(TAG, "Opening file"); + FILE* f = fopen("/sdcard/hello.txt", "w"); + if (f == NULL) { + ESP_LOGE(TAG, "Failed to open file for writing"); + return; + } + fprintf(f, "Hello %s!\n", card->cid.name); + fclose(f); + ESP_LOGI(TAG, "File written"); + + // Check if destination file exists before renaming + struct stat st; + if (stat("/sdcard/foo.txt", &st) == 0) { + // Delete it if it exists + unlink("/sdcard/foo.txt"); + } + + // Rename original file + ESP_LOGI(TAG, "Renaming file"); + if (rename("/sdcard/hello.txt", "/sdcard/foo.txt") != 0) { + ESP_LOGE(TAG, "Rename failed"); + return; + } + + // Open renamed file for reading + ESP_LOGI(TAG, "Reading file"); + f = fopen("/sdcard/foo.txt", "r"); + if (f == NULL) { + ESP_LOGE(TAG, "Failed to open file for reading"); + return; + } + char line[64]; + fgets(line, sizeof(line), f); + fclose(f); + // strip newline + char* pos = strchr(line, '\n'); + if (pos) { + *pos = '\0'; + } + ESP_LOGI(TAG, "Read from file: '%s'", line); + + // All done, unmount partition and disable SDMMC host peripheral + esp_vfs_fat_sdmmc_unmount(); + ESP_LOGI(TAG, "Card unmounted"); +} \ No newline at end of file diff --git a/examples/espidf-storage-sdcard/src/sdkconfig.h b/examples/espidf-storage-sdcard/src/sdkconfig.h new file mode 100644 index 0000000..9bde466 --- /dev/null +++ b/examples/espidf-storage-sdcard/src/sdkconfig.h @@ -0,0 +1,98 @@ +/* + * + * Automatically generated file; DO NOT EDIT. + * Espressif IoT Development Framework Configuration + * + */ +#define CONFIG_ESP32_PHY_MAX_TX_POWER 20 +#define CONFIG_PHY_ENABLED 1 +#define CONFIG_TRACEMEM_RESERVE_DRAM 0x0 +#define CONFIG_ESPTOOLPY_FLASHFREQ "40m" +#define CONFIG_NEWLIB_STDOUT_ADDCR 1 +#define CONFIG_TASK_WDT_CHECK_IDLE_TASK 1 +#define CONFIG_ESPTOOLPY_FLASHSIZE "2MB" +#define CONFIG_ETHERNET 1 +#define CONFIG_INT_WDT 1 +#define CONFIG_ESPTOOLPY_FLASHFREQ_40M 1 +#define CONFIG_LOG_BOOTLOADER_LEVEL_INFO 1 +#define CONFIG_ESPTOOLPY_FLASHSIZE_2MB 1 +#define CONFIG_FREERTOS_THREAD_LOCAL_STORAGE_POINTERS 1 +#define CONFIG_LOG_DEFAULT_LEVEL_INFO 1 +#define CONFIG_BT_RESERVE_DRAM 0x10000 +#define CONFIG_ESP32_PANIC_PRINT_REBOOT 1 +#define CONFIG_CONSOLE_UART_BAUDRATE 115200 +#define CONFIG_LWIP_MAX_SOCKETS 10 +#define CONFIG_EMAC_TASK_PRIORITY 20 +#define CONFIG_ULP_COPROC_RESERVE_MEM 0 +#define CONFIG_ESPTOOLPY_BAUD 115200 +#define CONFIG_INT_WDT_CHECK_CPU1 1 +#define CONFIG_ESPTOOLPY_AFTER_RESET 1 +#define CONFIG_TOOLPREFIX "xtensa-esp32-elf-" +#define CONFIG_CONSOLE_UART_NUM 0 +#define CONFIG_ESP32_RTC_CLOCK_SOURCE_INTERNAL_RC 1 +#define CONFIG_ESPTOOLPY_BAUD_115200B 1 +#define CONFIG_LWIP_THREAD_LOCAL_STORAGE_INDEX 0 +#define CONFIG_CONSOLE_UART_DEFAULT 1 +#define CONFIG_MBEDTLS_SSL_MAX_CONTENT_LEN 16384 +#define CONFIG_ESPTOOLPY_FLASHSIZE_DETECT 1 +#define CONFIG_MBEDTLS_MPI_USE_INTERRUPT 1 +#define CONFIG_ESP32_ENABLE_COREDUMP_TO_NONE 1 +#define CONFIG_TASK_WDT 1 +#define CONFIG_MAIN_TASK_STACK_SIZE 4096 +#define CONFIG_TASK_WDT_TIMEOUT_S 5 +#define CONFIG_INT_WDT_TIMEOUT_MS 300 +#define CONFIG_ESPTOOLPY_FLASHMODE "dio" +#define CONFIG_BTC_TASK_STACK_SIZE 3072 +#define CONFIG_ESPTOOLPY_BEFORE "default_reset" +#define CONFIG_LOG_DEFAULT_LEVEL 3 +#define CONFIG_FREERTOS_ASSERT_ON_UNTESTED_FUNCTION 1 +#define CONFIG_SPI_FLASH_ENABLE_COUNTERS 1 +#define CONFIG_ESP32_PHY_MAX_WIFI_TX_POWER 20 +#define CONFIG_DMA_RX_BUF_NUM 10 +#define CONFIG_ESPTOOLPY_FLASHMODE_DIO 1 +#define CONFIG_TCP_SYNMAXRTX 6 +#define CONFIG_PYTHON "python" +#define CONFIG_ESP32_TIME_SYSCALL_USE_RTC_FRC1 1 +#define CONFIG_ESPTOOLPY_COMPRESSED 1 +#define CONFIG_PARTITION_TABLE_FILENAME "partitions_singleapp.csv" +#define CONFIG_LWIP_DHCP_MAX_NTP_SERVERS 1 +#define CONFIG_PARTITION_TABLE_SINGLE_APP 1 +#define CONFIG_WIFI_ENABLED 1 +#define CONFIG_SYSTEM_EVENT_TASK_STACK_SIZE 4096 +#define CONFIG_ESP32_DEEP_SLEEP_WAKEUP_DELAY 0 +#define CONFIG_PHY_DATA_OFFSET 0xf000 +#define CONFIG_PARTITION_TABLE_CUSTOM_APP_BIN_OFFSET 0x10000 +#define CONFIG_TASK_WDT_CHECK_IDLE_TASK_CPU1 1 +#define CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ 240 +#define CONFIG_MBEDTLS_HARDWARE_AES 1 +#define CONFIG_FREERTOS_HZ 100 +#define CONFIG_LOG_COLORS 1 +#define CONFIG_FREERTOS_ASSERT_FAIL_ABORT 1 +#define CONFIG_MONITOR_BAUD_115200B 1 +#define CONFIG_LOG_BOOTLOADER_LEVEL 3 +#define CONFIG_ESPTOOLPY_BEFORE_RESET 1 +#define CONFIG_ESPTOOLPY_BAUD_OTHER_VAL 115200 +#define CONFIG_ESP32_DEFAULT_CPU_FREQ_240 1 +#define CONFIG_TCP_MAXRTX 12 +#define CONFIG_ESPTOOLPY_AFTER "hard_reset" +#define CONFIG_DMA_TX_BUF_NUM 10 +#define CONFIG_ESP32_DEBUG_OCDAWARE 1 +#define CONFIG_FREERTOS_BREAK_ON_SCHEDULER_START_JTAG 1 +#define CONFIG_BT_ENABLED 1 +#define CONFIG_MONITOR_BAUD 115200 +#define CONFIG_MBEDTLS_HARDWARE_SHA 1 +#define CONFIG_FREERTOS_CORETIMER_0 1 +#define CONFIG_PARTITION_TABLE_CUSTOM_FILENAME "partitions.csv" +#define CONFIG_MBEDTLS_HAVE_TIME 1 +#define CONFIG_FREERTOS_CHECK_STACKOVERFLOW_CANARY 1 +#define CONFIG_FREERTOS_ISR_STACKSIZE 1536 +#define CONFIG_OPENSSL_ASSERT_DO_NOTHING 1 +#define CONFIG_OPTIMIZATION_LEVEL_DEBUG 1 +#define CONFIG_ESP32_PHY_AUTO_INIT 1 +#define CONFIG_SYSTEM_EVENT_QUEUE_SIZE 32 +#define CONFIG_ESP32_WIFI_RX_BUFFER_NUM 25 +#define CONFIG_APP_OFFSET 0x10000 +#define CONFIG_MEMMAP_SMP 1 +#define CONFIG_MBEDTLS_HARDWARE_MPI 1 +#define CONFIG_MONITOR_BAUD_OTHER_VAL 115200 +#define CONFIG_ESPTOOLPY_PORT "/dev/ttyUSB0" \ No newline at end of file