Compare commits

..

137 Commits

Author SHA1 Message Date
cf60cf4c3b Adding LITTLEFS after esp_littlefs (IDF) is built-in (#4483)
Tools idea: https://github.com/lorol/arduino-esp32fs-plugin
2020-11-03 23:06:40 +02:00
b5b45cd518 Update install-arduino-ide.sh 2020-11-03 21:25:02 +02:00
9a9fb2c3aa port 882b12c44e over
ports: 882b12c44e
2020-11-03 19:58:23 +02:00
41e392f661 Add esp-rainmaker support for ESP32 2020-11-03 11:12:53 +02:00
6be6abf35b Update IDF master to 357a27760 2020-11-02 23:19:24 +02:00
baaff8480e Update IDF and Camera 2020-10-15 00:19:54 +03:00
54140dc5ca Fix Arduino PIN counts 2020-10-14 21:09:15 +03:00
9f8b433196 Make esp32-hal-tinyusb.h conditional on tinyusb (#4155) 2020-10-14 15:26:51 +03:00
b7c3607b5b Update IDF and Tools 2020-10-13 16:52:16 +03:00
2b0dbdc12a Update .gitignore 2020-10-13 14:25:19 +03:00
b06735a33a Update platform.txt 2020-10-13 01:51:59 +03:00
537b1a6d3a Add camera support
first automated cmake build
2020-10-12 23:56:00 +03:00
440437c905 Try with speed optimization as opposed to debug. Coremark 240 -> 430 2020-10-11 19:51:11 +03:00
9bb8224159 Added ESP32-Wrover-Kit with distinct build.board (#4118)
* Added ESP32-Wrover-Kit with distinct build.board

* Fixed broken values

* Update boards.txt

Co-authored-by: Me No Dev <me-no-dev@users.noreply.github.com>
2020-10-03 02:18:02 +03:00
0db0af5932 Add board microS2 (#4314) 2020-10-03 02:00:48 +03:00
8d9d7bbca9 Makes ethernet get an IP when connected (#4234) 2020-10-01 14:40:15 +03:00
291c519642 Update WiFiMulti.cpp (#4099)
Fix for https://github.com/espressif/arduino-esp32/issues/3914 by syncing with https://github.com/espressif/arduino-esp32/blob/esp32s2/libraries/WiFi/src/WiFiSTA.cpp#L161
2020-09-30 15:33:05 +03:00
bbcc624c97 Update USB.cpp 2020-09-23 13:48:28 +03:00
2656452d04 Update boards.txt 2020-09-04 14:37:48 +03:00
273a8d79b4 Update platform.txt 2020-09-01 12:06:13 +03:00
42b4a9927d Update install-platformio-esp32.sh 2020-08-31 18:10:03 +03:00
383b999ddd Update platform.txt
Provided by @ESP32DE
2020-08-31 17:39:55 +03:00
52c284af75 Update IDF, tools and toolchains 2020-08-24 19:10:52 +03:00
5f057c7cac Some fixes 2020-08-22 23:37:42 +03:00
880fc0bdfb Add option to select the core used for Arduino and it's events 2020-08-16 17:52:09 +03:00
9eaa5873bf Update CMakeLists.txt 2020-07-23 16:13:37 +03:00
7678be447d Merge branch 'master' into esp32s2 2020-07-23 16:10:45 +03:00
c6f6522032 Update HardwareSerial.h 2020-07-23 15:49:54 +03:00
d2519843ad Added UM FeatherS2 and UM ProS2 boards to boards.txt (#4188)
* Added UM FeatherS2 and UM ProS2 boards to boards.txt
Updated the name of TinyPICO to UM TinyPICO in boards.txt

* Added VID/PID/Product names for TinyPICO, ProS2 & FeatherS2
Setup variant folders for each board

* Removed unneeded stuff from FeatherS2 & ProS2 menu options

* Added Serial CDC output default for FeatherS2 and ProS2

* Removed unneeded stuff from FeatherS2 & ProS2 menu options

* Rebase from upstream and fixed Serial Output settings for FeatherS2 and ProS2

Co-authored-by: Seon Rozenblum <seonr@3sprockets.com>
2020-07-23 10:32:44 +03:00
2cebf72876 Update CMakeLists.txt 2020-07-23 00:27:33 +03:00
4fa3cbab64 Improve CDC Logging support 2020-07-22 23:59:22 +03:00
280bf4d014 Create USB_NOT.h 2020-07-22 19:42:36 +03:00
dc0208ed1e Add option USB CDC to be used for Serial (starting USB early) 2020-07-22 19:16:22 +03:00
f58cba0b4f Add support for custom VID/PID and Board name to show in ArduinoIDE ports list 2020-07-22 13:46:59 +03:00
38057d66ad Update tinyusb 2020-07-20 00:57:06 +03:00
33f4745635 Update USB.cpp 2020-07-18 17:52:06 +03:00
9f1ccb9c85 Some CDC and BTSerial compatibility fixes 2020-07-14 18:21:21 +03:00
ea04207c8f Add debug output to CDC 2020-07-02 14:14:07 +03:00
e06f9b7fa6 Handle persistent reboot better in CDC 2020-07-02 13:07:34 +03:00
2e19d27e3e Change driver attach api and remove DFU from CDC 2020-07-02 02:16:07 +03:00
b8fcea9a8d Update TinyUSB 2020-07-01 23:45:42 +03:00
46bde99c06 Update USBCDC.cpp 2020-06-30 18:10:52 +03:00
7f61d2044a Update libtinyusb.a 2020-06-30 01:29:59 +03:00
f13f84ddeb Fix compilation issues 2020-06-29 23:28:15 +03:00
096af056d1 Fix DTR/RTS state for ESP32S2 native USB 2020-06-29 22:43:54 +03:00
acadabb146 Update CMakeLists.txt 2020-06-29 18:39:25 +03:00
7d50114881 Add files to cmakelists and disconnect CDC if unplugged 2020-06-29 18:30:50 +03:00
be074eec80 Add TinyUSB HAL and CDC 2020-06-29 17:23:12 +03:00
bd96f7f159 Update IDF Libs 2020-06-28 15:38:58 +03:00
ca7ed86bbd Update TinyUSB Lib 2020-06-28 15:02:03 +03:00
a1bd429747 Fix GPIO Interrupts 2020-06-22 14:03:18 +03:00
11cad8747e Fixing static IP configuration so it doesn't get overwritten by DHCP as part of WiFi.begin(). (#4103)
Fixing DHCP client stop if WiFi.config() is called before WiFi.begin() (as done in WiFiClientStaticIP.ino)
2020-06-22 13:59:51 +03:00
2d7ec30a1b Update libtinyusb.a 2020-06-01 19:42:38 +03:00
ef961442d7 Add missing DFU driver 2020-06-01 19:13:18 +03:00
d5bd8e325c Try custom device descriptors 2020-06-01 18:09:38 +03:00
0a4b6599d2 again 2020-06-01 13:31:21 +03:00
8cb2a4ba3e change endpoints 2020-06-01 13:16:03 +03:00
d12af93ee2 TinyUSB adjust 2020-06-01 12:54:09 +03:00
7e9d75a974 Merge branch 'master' into esp32s2 2020-06-01 01:55:35 +03:00
61c98b8370 Update pins_arduino.h 2020-06-01 01:54:11 +03:00
04267e12da Fix swapped USB pins issue 2020-05-30 17:36:26 +03:00
86494d5cb9 Update CMakeLists.txt 2020-05-30 17:28:25 +03:00
12a8779fd6 what happened to no-stub? 2020-05-30 16:50:24 +03:00
6ecd249a4a how about now? 2020-05-30 16:40:55 +03:00
b15f5bac79 what if functions are in the core? 2020-05-30 15:22:52 +03:00
3d7f9d9282 try to fix linking errors 2020-05-30 15:09:01 +03:00
dc3394d6ac hopefully all is here now 2020-05-30 14:50:26 +03:00
351a651295 Once again 2020-05-30 14:19:46 +03:00
d009787a6f Update TinyUSB 2020-05-30 14:06:28 +03:00
57b7e4c678 Add support for no-stub usb s2 flashing 2020-05-30 12:38:52 +03:00
345055050b Pull latest IDF and enable TinyUSB 2020-05-30 03:58:15 +03:00
cda6facdc7 Disable modem sleep by default on S2 for now. 2020-05-19 02:44:08 +03:00
eccbfdb48a add psram to malloc only if interrupts are not in IRAM 2020-05-19 02:03:24 +03:00
27e61dcaf5 fix psram always init 2020-05-19 01:56:52 +03:00
7553683bd2 fix issue with rtc wdt 2020-05-19 01:49:29 +03:00
40c325bd0a update idf libs, disable WDT on S2, use malloc for PSRAM 2020-05-19 01:18:55 +03:00
4f7e8065c0 Disable IRAM ISRs and functions by default 2020-05-19 00:08:10 +03:00
05db08e20a Update esp32-hal-gpio.c 2020-05-17 20:19:00 +03:00
ad067eab2d Update main.cpp 2020-05-17 15:36:41 +03:00
31d5120e04 some i2c fixes 2020-05-17 14:54:41 +03:00
d1110013af Update WPS.ino 2020-05-17 13:50:19 +03:00
caca107719 Update WiFiProv.ino 2020-05-17 13:41:45 +03:00
279f7e33be Update WiFiBlueToothSwitch.ino 2020-05-17 13:37:04 +03:00
f3835ea89f Update WiFiClientEvents.ino 2020-05-17 13:32:47 +03:00
0d61996917 more example fixes 2020-05-17 13:30:19 +03:00
88f1b235e6 fix wrong bootloader path in pio scripts 2020-05-17 13:23:29 +03:00
400aca52ce fix some examples 2020-05-17 13:12:58 +03:00
3fb164224d fix WiFi 2020-05-17 11:48:31 +03:00
cebaf93dd8 Fix PSRAM support 2020-05-14 19:02:35 +03:00
176e5b0e79 Update esp32-hal-uart.c 2020-05-14 04:03:26 +03:00
9a16cd4600 Update esp32-hal-uart.c 2020-05-14 03:04:10 +03:00
b769dd0de3 Fix Serial 2020-05-14 02:57:52 +03:00
7f1b7ade7b Update HardwareSerial.cpp 2020-05-13 19:26:34 +03:00
806e388d23 Add I2C IDF Wrapper 2020-05-13 19:04:26 +03:00
07f1bceef4 fix compile errors for esp32 2020-05-13 17:49:27 +03:00
aa61b75aa4 fix peripherals 2020-05-13 17:41:08 +03:00
48dfc89ccb Update on-push.sh 2020-05-12 20:07:29 +03:00
c6bae38ce9 Update install-platformio-esp32.sh 2020-05-12 16:46:10 +03:00
87d5f9d121 fix py script 2020-05-12 14:35:42 +03:00
ed2115e361 new try at pio 2020-05-12 14:32:24 +03:00
644f7a8a2f does not work 2020-05-12 13:09:59 +03:00
81cdcc9e27 how about now? 2020-05-12 12:48:36 +03:00
04988bdb21 try outputing the map 2020-05-12 12:36:15 +03:00
2103a789b6 Update on-push.sh 2020-05-12 12:19:26 +03:00
669cbec58e Update platformio-build-esp32.py 2020-05-12 11:38:56 +03:00
4f4bf07726 Update platformio-build-esp32.py 2020-05-12 11:36:45 +03:00
1840ba5c53 try pio again 2020-05-12 11:27:04 +03:00
20028a2027 Update on-push.sh 2020-05-12 03:10:19 +03:00
2977df4648 Update on-push.sh 2020-05-12 02:33:26 +03:00
5320123e04 Update WiFiTelnetToSerial.ino 2020-05-12 02:22:48 +03:00
0a0ee87ba5 skip more examples 2020-05-12 02:16:29 +03:00
1bb1160dea Update esp32-hal-i2c.c 2020-05-12 02:09:29 +03:00
a744383cbd Update SD_Update.ino 2020-05-12 02:01:04 +03:00
7ea54ab6aa Create .skip.esp32s2 2020-05-12 01:54:40 +03:00
fd70e0d071 skip some examples 2020-05-12 01:48:34 +03:00
0e3994c966 Update SPI_Multiple_Buses.ino 2020-05-12 01:26:40 +03:00
5d7032d4f2 Update TouchRead.ino 2020-05-12 01:21:00 +03:00
46abedcc1a disable BT Serial examples for S2 2020-05-12 01:16:30 +03:00
a6a68a9546 Update ResetReason.ino 2020-05-12 01:10:54 +03:00
062d4b123f Update on-push.sh 2020-05-12 01:04:27 +03:00
ad68da6e41 try s2 ci 2020-05-12 01:02:03 +03:00
f69b40dfff fix provision compilation 2020-05-12 00:43:43 +03:00
3a554c55f4 fix cmake check 2020-05-12 00:22:37 +03:00
03d3d6112b Update app_httpd.cpp 2020-05-12 00:07:11 +03:00
05df11e0d9 some compile fixes 2020-05-12 00:01:48 +03:00
c2be29eb97 Merge branch 'master' into esp32s2 2020-05-11 23:35:43 +03:00
49c47884a7 Update CameraWebServer.ino 2020-05-11 23:28:27 +03:00
0ea23fe38a Update esp32-hal-gpio.c 2020-05-11 21:36:23 +03:00
7f560284ff Add S2 variant 2020-05-11 20:24:34 +03:00
8569b2c893 Initial Commit 2020-05-11 20:00:33 +03:00
93d77859d9 Add fixes 2020-04-07 01:34:13 +03:00
856e596c79 Pass ethernet events to the main handler 2020-01-27 18:03:03 +02:00
354e485c4b get smart config to work as well 2020-01-27 17:34:30 +02:00
1c4966566c make ETH work 2020-01-27 16:22:07 +02:00
4bb60f68da Update package_esp32_index.template.json 2020-01-27 13:50:33 +02:00
251d5ef92b Update CMakeLists.txt 2020-01-25 22:41:03 +02:00
8c723be135 Initial IDF-4.0 port
SmartConfig and ETH need some work to adapt to the new API
2020-01-25 16:24:19 +02:00
762 changed files with 1136 additions and 7793 deletions

View File

@ -13,7 +13,7 @@ echo "Installing Platform ESP32 ..."
python -m platformio platform install $PLATFORMIO_ESP32_URL > /dev/null 2>&1
echo "Replacing the framework version ..."
python -c "import json; import os; fp=open(os.path.expanduser('~/.platformio/platforms/espressif32/platform.json'), 'r+'); data=json.load(fp); data['packages']['framework-arduinoespressif32']['version'] = '*'; fp.seek(0); fp.truncate(); json.dump(data, fp); fp.close()"
python -c "import json; import os; fp=open(os.path.expanduser('~/.platformio/platforms/espressif32/platform.json'), 'r+'); data=json.load(fp); data['packages']['framework-arduinoespressif32']['version'] = '*'; del data['packages']['framework-arduinoespressif32']['owner']; fp.seek(0); fp.truncate(); json.dump(data, fp); fp.close()"
if [ "$GITHUB_REPOSITORY" == "espressif/arduino-esp32" ]; then
echo "Linking Core..."

View File

@ -330,7 +330,7 @@ fi
if [ ! -z "$COMMITS_SINCE_RELEASE" ] && [ "$COMMITS_SINCE_RELEASE" != "null" ]; then
echo "Getting commits since $COMMITS_SINCE_RELEASE ..."
commitFile=$OUTPUT_DIR/commits.txt
git -C "$GITHUB_WORKSPACE" log --oneline "$COMMITS_SINCE_RELEASE..HEAD" > "$OUTPUT_DIR/commits.txt"
git -C "$GITHUB_WORKSPACE" log --oneline $COMMITS_SINCE_RELEASE.. > "$OUTPUT_DIR/commits.txt"
releaseNotes+=$'\r\n##### Commits\r\n'
IFS=$'\n'
for next in `cat $commitFile`

1
.gitignore vendored
View File

@ -16,4 +16,3 @@ __vm/
.vscode/
platform.sloeber.txt
boards.sloeber.txt
tools/mklittlefs

View File

@ -64,7 +64,6 @@ set(LIBRARY_SRCS
libraries/SPI/src/SPI.cpp
libraries/Ticker/src/Ticker.cpp
libraries/Update/src/Updater.cpp
libraries/Update/src/HttpsOTAUpdate.cpp
libraries/WebServer/src/WebServer.cpp
libraries/WebServer/src/Parsing.cpp
libraries/WebServer/src/detail/mimetable.cpp
@ -76,11 +75,11 @@ set(LIBRARY_SRCS
libraries/WiFi/src/WiFi.cpp
libraries/WiFi/src/WiFiGeneric.cpp
libraries/WiFi/src/WiFiMulti.cpp
libraries/WiFi/src/WiFiProv.cpp
libraries/WiFi/src/WiFiScan.cpp
libraries/WiFi/src/WiFiServer.cpp
libraries/WiFi/src/WiFiSTA.cpp
libraries/WiFi/src/WiFiUdp.cpp
libraries/WiFiProv/src/WiFiProv.cpp
libraries/Wire/src/Wire.cpp
)
@ -145,7 +144,6 @@ set(includedirs
libraries/WebServer/src
libraries/WiFiClientSecure/src
libraries/WiFi/src
libraries/WiFiProv/src
libraries/Wire/src
)

View File

@ -76,12 +76,6 @@ choice ARDUINO_UDP_RUNNING_CORE
endchoice
config ARDUINO_UDP_TASK_PRIORITY
int "Priority of the UDP task"
default 3
help
Select at what priority you want the UDP task to run.
config ARDUINO_UDP_RUNNING_CORE
int
default 0 if ARDUINO_UDP_RUN_CORE0

View File

@ -11,11 +11,9 @@
- [ESP32Dev Board PINMAP](#esp32dev-board-pinmap)
### Development Status
[Latest stable release ![Release Version](https://img.shields.io/github/release/espressif/arduino-esp32.svg?style=plastic) ![Release Date](https://img.shields.io/github/release-date/espressif/arduino-esp32.svg?style=plastic)](https://github.com/espressif/arduino-esp32/releases/latest/) ![Downloads](https://img.shields.io/github/downloads/espressif/arduino-esp32/latest/total.svg?style=plastic)
Latest Stable Release [![Release Version](https://img.shields.io/github/release/espressif/arduino-esp32.svg?style=plastic)](https://github.com/espressif/arduino-esp32/releases/latest/) [![Release Date](https://img.shields.io/github/release-date/espressif/arduino-esp32.svg?style=plastic)](https://github.com/espressif/arduino-esp32/releases/latest/) [![Downloads](https://img.shields.io/github/downloads/espressif/arduino-esp32/latest/total.svg?style=plastic)](https://github.com/espressif/arduino-esp32/releases/latest/)
Latest Development Release [![Release Version](https://img.shields.io/github/release/espressif/arduino-esp32/all.svg?style=plastic)](https://github.com/espressif/arduino-esp32/releases/latest/) [![Release Date](https://img.shields.io/github/release-date-pre/espressif/arduino-esp32.svg?style=plastic)](https://github.com/espressif/arduino-esp32/releases/latest/) [![Downloads](https://img.shields.io/github/downloads-pre/espressif/arduino-esp32/latest/total.svg?style=plastic)](https://github.com/espressif/arduino-esp32/releases/latest/)
[Latest development release ![Development Version](https://img.shields.io/github/release/espressif/arduino-esp32/all.svg?style=plastic) ![Development Date](https://img.shields.io/github/release-date-pre/espressif/arduino-esp32.svg?style=plastic)](https://github.com/espressif/arduino-esp32/releases/latest/) ![Downloads](https://img.shields.io/github/downloads-pre/espressif/arduino-esp32/latest/total.svg?style=plastic)
### Installation Instructions
- Using Arduino IDE Boards Manager (preferred)

1243
boards.txt

File diff suppressed because it is too large Load Diff

View File

@ -29,7 +29,6 @@
#include <string.h>
#include <inttypes.h>
#include "esp_arduino_version.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/semphr.h"
@ -79,7 +78,7 @@
#define interrupts() sei()
#define noInterrupts() cli()
#define clockCyclesPerMicrosecond() ( (long int)getCpuFrequencyMhz() )
#define clockCyclesPerMicrosecond() ( F_CPU / 1000000L )
#define clockCyclesToMicroseconds(a) ( (a) / clockCyclesPerMicrosecond() )
#define microsecondsToClockCycles(a) ( (a) * clockCyclesPerMicrosecond() )
@ -89,7 +88,7 @@
#define bitRead(value, bit) (((value) >> (bit)) & 0x01)
#define bitSet(value, bit) ((value) |= (1UL << (bit)))
#define bitClear(value, bit) ((value) &= ~(1UL << (bit)))
#define bitWrite(value, bit, bitvalue) ((bitvalue) ? bitSet(value, bit) : bitClear(value, bit))
#define bitWrite(value, bit, bitvalue) (bitvalue ? bitSet(value, bit) : bitClear(value, bit))
// avr-libc defines _NOP() since 1.6.2
#ifndef _NOP

View File

@ -23,6 +23,7 @@
#include "esp_spi_flash.h"
#include <memory>
#include <soc/soc.h>
#include <soc/efuse_reg.h>
#include <esp_partition.h>
extern "C" {
#include "esp_ota_ops.h"
@ -34,7 +35,6 @@ extern "C" {
#ifdef ESP_IDF_VERSION_MAJOR // IDF 4+
#if CONFIG_IDF_TARGET_ESP32 // ESP32/PICO-D4
#include "esp32/rom/spi_flash.h"
#include "soc/efuse_reg.h"
#elif CONFIG_IDF_TARGET_ESP32S2
#include "esp32s2/rom/spi_flash.h"
#else
@ -242,39 +242,6 @@ uint8_t EspClass::getChipRevision(void)
return chip_info.revision;
}
const char * EspClass::getChipModel(void)
{
#if CONFIG_IDF_TARGET_ESP32
uint32_t chip_ver = REG_GET_FIELD(EFUSE_BLK0_RDATA3_REG, EFUSE_RD_CHIP_VER_PKG);
uint32_t pkg_ver = chip_ver & 0x7;
switch (pkg_ver) {
case EFUSE_RD_CHIP_VER_PKG_ESP32D0WDQ6 :
return "ESP32-D0WDQ6";
case EFUSE_RD_CHIP_VER_PKG_ESP32D0WDQ5 :
return "ESP32-D0WDQ5";
case EFUSE_RD_CHIP_VER_PKG_ESP32D2WDQ5 :
return "ESP32-D2WDQ5";
case EFUSE_RD_CHIP_VER_PKG_ESP32PICOD2 :
return "ESP32-PICO-D2";
case EFUSE_RD_CHIP_VER_PKG_ESP32PICOD4 :
return "ESP32-PICO-D4";
case EFUSE_RD_CHIP_VER_PKG_ESP32PICOV302 :
return "ESP32-PICO-V3-02";
default:
return "Unknown";
}
#elif CONFIG_IDF_TARGET_ESP32S2
return "ESP32-S2";
#endif
}
uint8_t EspClass::getChipCores(void)
{
esp_chip_info_t chip_info;
esp_chip_info(&chip_info);
return chip_info.cores;
}
const char * EspClass::getSdkVersion(void)
{
return esp_get_idf_version();
@ -366,20 +333,6 @@ bool EspClass::flashRead(uint32_t offset, uint32_t *data, size_t size)
return spi_flash_read(offset, (uint32_t*) data, size) == ESP_OK;
}
bool EspClass::partitionEraseRange(const esp_partition_t *partition, uint32_t offset, size_t size)
{
return esp_partition_erase_range(partition, offset, size) == ESP_OK;
}
bool EspClass::partitionWrite(const esp_partition_t *partition, uint32_t offset, uint32_t *data, size_t size)
{
return esp_partition_write(partition, offset, data, size) == ESP_OK;
}
bool EspClass::partitionRead(const esp_partition_t *partition, uint32_t offset, uint32_t *data, size_t size)
{
return esp_partition_read(partition, offset, data, size) == ESP_OK;
}
uint64_t EspClass::getEfuseMac(void)
{

View File

@ -21,7 +21,6 @@
#define ESP_H
#include <Arduino.h>
#include <esp_partition.h>
/**
* AVR macros for WDT managment
@ -76,8 +75,6 @@ public:
uint32_t getMaxAllocPsram();
uint8_t getChipRevision();
const char * getChipModel();
uint8_t getChipCores();
uint32_t getCpuFreqMHz(){ return getCpuFrequencyMhz(); }
inline uint32_t getCycleCount() __attribute__((always_inline));
const char * getSdkVersion();
@ -100,10 +97,6 @@ public:
bool flashWrite(uint32_t offset, uint32_t *data, size_t size);
bool flashRead(uint32_t offset, uint32_t *data, size_t size);
bool partitionEraseRange(const esp_partition_t *partition, uint32_t offset, size_t size);
bool partitionWrite(const esp_partition_t *partition, uint32_t offset, uint32_t *data, size_t size);
bool partitionRead(const esp_partition_t *partition, uint32_t offset, uint32_t *data, size_t size);
uint64_t getEfuseMac();
};

View File

@ -79,8 +79,6 @@ void HardwareSerial::begin(unsigned long baud, uint32_t config, int8_t rxPin, in
}
#endif
_uart = uartBegin(_uart_nr, baud ? baud : 9600, config, rxPin, txPin, 256, invert);
_tx_pin = txPin;
_rx_pin = rxPin;
if(!baud) {
uartStartDetectBaudrate(_uart);
@ -98,8 +96,6 @@ void HardwareSerial::begin(unsigned long baud, uint32_t config, int8_t rxPin, in
} else {
log_e("Could not detect baudrate. Serial data at the port must be present within the timeout for detection to be possible");
_uart = NULL;
_tx_pin = 255;
_rx_pin = 255;
}
}
}
@ -114,8 +110,7 @@ void HardwareSerial::end()
if(uartGetDebug() == _uart_nr) {
uartSetDebug(0);
}
log_v("pins %d %d",_tx_pin, _rx_pin);
uartEnd(_uart, _tx_pin, _rx_pin);
uartEnd(_uart);
_uart = 0;
}
@ -210,8 +205,3 @@ HardwareSerial::operator bool() const
{
return true;
}
void HardwareSerial::setRxInvert(bool invert)
{
uartSetRxInvert(_uart, invert);
}

View File

@ -101,13 +101,9 @@ public:
size_t setRxBufferSize(size_t);
void setDebugOutput(bool);
void setRxInvert(bool);
protected:
int _uart_nr;
uart_t* _uart;
uint8_t _tx_pin;
uint8_t _rx_pin;
};
extern void serialEventRun(void) __attribute__((weak));

View File

@ -110,35 +110,22 @@ size_t Print::print(unsigned int n, int base)
}
size_t Print::print(long n, int base)
{
int t = 0;
if (base == 10 && n < 0) {
t = print('-');
n = -n;
}
return printNumber(static_cast<unsigned long>(n), base) + t;
}
size_t Print::print(unsigned long n, int base)
{
if(base == 0) {
return write(n);
} else if(base == 10) {
if(n < 0) {
int t = print('-');
n = -n;
return printNumber(n, 10) + t;
}
return printNumber(n, 10);
} else {
return printNumber(n, base);
}
}
size_t Print::print(long long n, int base)
{
int t = 0;
if (base == 10 && n < 0) {
t = print('-');
n = -n;
}
return printNumber(static_cast<unsigned long long>(n), base) + t;
}
size_t Print::print(unsigned long long n, int base)
size_t Print::print(unsigned long n, int base)
{
if(base == 0) {
return write(n);
@ -239,20 +226,6 @@ size_t Print::println(unsigned long num, int base)
return n;
}
size_t Print::println(long long num, int base)
{
size_t n = print(num, base);
n += println();
return n;
}
size_t Print::println(unsigned long long num, int base)
{
size_t n = print(num, base);
n += println();
return n;
}
size_t Print::println(double num, int digits)
{
size_t n = print(num, digits);
@ -278,7 +251,7 @@ size_t Print::println(struct tm * timeinfo, const char * format)
size_t Print::printNumber(unsigned long n, uint8_t base)
{
char buf[8 * sizeof(n) + 1]; // Assumes 8-bit chars plus zero byte.
char buf[8 * sizeof(long) + 1]; // Assumes 8-bit chars plus zero byte.
char *str = &buf[sizeof(buf) - 1];
*str = '\0';
@ -289,32 +262,9 @@ size_t Print::printNumber(unsigned long n, uint8_t base)
}
do {
char c = n % base;
n /= base;
*--str = c < 10 ? c + '0' : c + 'A' - 10;
} while (n);
return write(str);
}
size_t Print::printNumber(unsigned long long n, uint8_t base)
{
char buf[8 * sizeof(n) + 1]; // Assumes 8-bit chars plus zero byte.
char* str = &buf[sizeof(buf) - 1];
*str = '\0';
// prevent crash if called with base == 1
if (base < 2) {
base = 10;
}
do {
auto m = n;
unsigned long m = n;
n /= base;
char c = m - base * n;
*--str = c < 10 ? c + '0' : c + 'A' - 10;
} while(n);

View File

@ -36,7 +36,6 @@ class Print
private:
int write_error;
size_t printNumber(unsigned long, uint8_t);
size_t printNumber(unsigned long long, uint8_t);
size_t printFloat(double, uint8_t);
protected:
void setWriteError(int err = 1)
@ -82,8 +81,6 @@ public:
size_t print(unsigned int, int = DEC);
size_t print(long, int = DEC);
size_t print(unsigned long, int = DEC);
size_t print(long long, int = DEC);
size_t print(unsigned long long, int = DEC);
size_t print(double, int = 2);
size_t print(const Printable&);
size_t print(struct tm * timeinfo, const char * format = NULL);
@ -97,8 +94,6 @@ public:
size_t println(unsigned int, int = DEC);
size_t println(long, int = DEC);
size_t println(unsigned long, int = DEC);
size_t println(long long, int = DEC);
size_t println(unsigned long long, int = DEC);
size_t println(double, int = 2);
size_t println(const Printable&);
size_t println(struct tm * timeinfo, const char * format = NULL);

View File

@ -89,7 +89,7 @@ unsigned long Stream::getTimeout(void) {
// find returns true if the target string is found
bool Stream::find(const char *target)
{
return findUntil(target, strlen(target), NULL, 0);
return findUntil(target, (char*) "");
}
// reads data from the stream until the target string of given length is found
@ -110,78 +110,35 @@ bool Stream::findUntil(const char *target, const char *terminator)
// returns true if target string is found, false if terminated or timed out
bool Stream::findUntil(const char *target, size_t targetLen, const char *terminator, size_t termLen)
{
if (terminator == NULL) {
MultiTarget t[1] = {{target, targetLen, 0}};
return findMulti(t, 1) == 0 ? true : false;
size_t index = 0; // maximum target string length is 64k bytes!
size_t termIndex = 0;
int c;
if(*target == 0) {
return true; // return true if target is a null string
}
while((c = timedRead()) > 0) {
if(c != target[index]) {
index = 0; // reset index if any char does not match
}
if(c == target[index]) {
//////Serial.print("found "); Serial.write(c); Serial.print("index now"); Serial.println(index+1);
if(++index >= targetLen) { // return true if all chars in the target match
return true;
}
}
if(termLen > 0 && c == terminator[termIndex]) {
if(++termIndex >= termLen) {
return false; // return false if terminate string found before target string
}
} else {
MultiTarget t[2] = {{target, targetLen, 0}, {terminator, termLen, 0}};
return findMulti(t, 2) == 0 ? true : false;
termIndex = 0;
}
}
int Stream::findMulti( struct Stream::MultiTarget *targets, int tCount) {
// any zero length target string automatically matches and would make
// a mess of the rest of the algorithm.
for (struct MultiTarget *t = targets; t < targets+tCount; ++t) {
if (t->len <= 0)
return t - targets;
}
while (1) {
int c = timedRead();
if (c < 0)
return -1;
for (struct MultiTarget *t = targets; t < targets+tCount; ++t) {
// the simple case is if we match, deal with that first.
if (c == t->str[t->index]) {
if (++t->index == t->len)
return t - targets;
else
continue;
}
// if not we need to walk back and see if we could have matched further
// down the stream (ie '1112' doesn't match the first position in '11112'
// but it will match the second position so we can't just reset the current
// index to 0 when we find a mismatch.
if (t->index == 0)
continue;
int origIndex = t->index;
do {
--t->index;
// first check if current char works against the new current index
if (c != t->str[t->index])
continue;
// if it's the only char then we're good, nothing more to check
if (t->index == 0) {
t->index++;
break;
}
// otherwise we need to check the rest of the found string
int diff = origIndex - t->index;
size_t i;
for (i = 0; i < t->index; ++i) {
if (t->str[i] != t->str[i + diff])
break;
}
// if we successfully got through the previous loop then our current
// index is good.
if (i == t->index) {
t->index++;
break;
}
// otherwise we just try the next index
} while (t->index);
}
}
// unreachable
return -1;
return false;
}
// returns the first valid (long) integer value from the current position.

View File

@ -60,7 +60,6 @@ public:
void setTimeout(unsigned long timeout); // sets maximum milliseconds to wait for stream data, default is 1 second
unsigned long getTimeout(void);
bool find(const char *target); // reads data from the stream until the target string is found
bool find(uint8_t *target)
{
@ -124,17 +123,6 @@ protected:
// this allows format characters (typically commas) in values to be ignored
float parseFloat(char skipChar); // as above but the given skipChar is ignored
struct MultiTarget {
const char *str; // string you're searching for
size_t len; // length of string you're searching for
size_t index; // index used by the search routine.
};
// This allows you to search for an arbitrary number of strings.
// Returns index of the target that is found first or -1 if timeout occurs.
int findMulti(struct MultiTarget *targets, int tCount);
};
#endif

View File

@ -43,7 +43,6 @@ class UDP: public Stream
public:
virtual uint8_t begin(uint16_t) =0; // initialize, start listening on specified port. Returns 1 if successful, 0 if there are no sockets available to use
virtual uint8_t beginMulticast(IPAddress, uint16_t) { return 0; } // initialize, start listening on specified multicast IP address and port. Returns 1 if successful, 0 on failure
virtual void stop() =0; // Finish with the UDP socket
// Sending UDP packets

View File

@ -66,11 +66,11 @@ long random(long howsmall, long howbig)
}
long map(long x, long in_min, long in_max, long out_min, long out_max) {
const long dividend = out_max - out_min;
const long divisor = in_max - in_min;
const long delta = x - in_min;
return (delta * dividend + (divisor / 2)) / divisor + out_min;
long divisor = (in_max - in_min);
if(divisor == 0){
return -1; //AVR returns -1, SAM returns 0
}
return (x - in_min) * (out_max - out_min) / divisor + out_min;
}
unsigned int makeWord(unsigned int w)

View File

@ -183,7 +183,7 @@ uint32_t __analogReadMilliVolts(uint8_t pin){
__analogVRef = DEFAULT_VREF;
if(__analogVRefPin){
esp_adc_cal_characteristics_t chars;
if(adc_vref_to_gpio(ADC_UNIT_2, __analogVRefPin) == ESP_OK){
if(adc2_vref_to_gpio(__analogVRefPin) == ESP_OK){
__analogVRef = __analogRead(__analogVRefPin);
esp_adc_cal_characterize(1, __analogAttenuation, __analogWidth, DEFAULT_VREF, &chars);
__analogVRef = esp_adc_cal_raw_to_voltage(__analogVRef, &chars);

View File

@ -960,14 +960,6 @@ static void ARDUINO_ISR_ATTR i2c_isr_handler_default(void* arg)
activeInt &=~I2C_RXFIFO_FULL_INT_ST;
}
if(activeInt & I2C_RXFIFO_OVF_INT_ST) {
emptyRxFifo(p_i2c);
p_i2c->dev->int_clr.rx_fifo_full=1;
p_i2c->dev->int_ena.rx_fifo_full=1; //why?
activeInt &=~I2C_RXFIFO_OVF_INT_ST;
}
if (activeInt & I2C_ACK_ERR_INT_ST_M) {//fatal error, abort i2c service
if (p_i2c->mode == I2C_MASTER) {
i2c_update_error_byte_cnt(p_i2c); // calc which byte caused ack Error, check if address or data
@ -1798,10 +1790,6 @@ i2c_t * i2cInit(uint8_t i2c_num, int8_t sda, int8_t scl, uint32_t clk_speed){
if(i2c_num >= 2){
return NULL;
}
if(!clk_speed){
//originally does not change the speed, but getFrequency and setFrequency need to be implemented first.
clk_speed = 100000;
}
i2c_t * out = NULL;
if(i2c_ports[i2c_num] == NULL){
out = (i2c_t*)malloc(sizeof(i2c_t));

View File

@ -51,6 +51,7 @@ bool psramInit(){
log_w("PSRAM not supported!");
return false;
}
esp_spiram_init_cache();
#elif CONFIG_IDF_TARGET_ESP32S2
extern void esp_config_data_cache_mode(void);
esp_config_data_cache_mode();

View File

@ -96,7 +96,6 @@ struct rmt_obj_s
transaction_state_t tx_state;
rmt_rx_data_cb_t cb;
bool data_alloc;
void * arg;
};
/**
@ -110,15 +109,15 @@ static xSemaphoreHandle g_rmt_objlocks[MAX_CHANNELS] = {
};
static rmt_obj_t g_rmt_objects[MAX_CHANNELS] = {
{ false, NULL, 0, 0, 0, 0, 0, NULL, E_NO_INTR, E_INACTIVE, NULL, false, NULL},
{ false, NULL, 0, 0, 0, 0, 0, NULL, E_NO_INTR, E_INACTIVE, NULL, false, NULL},
{ false, NULL, 0, 0, 0, 0, 0, NULL, E_NO_INTR, E_INACTIVE, NULL, false, NULL},
{ false, NULL, 0, 0, 0, 0, 0, NULL, E_NO_INTR, E_INACTIVE, NULL, false, NULL},
{ false, NULL, 0, 0, 0, 0, 0, NULL, E_NO_INTR, E_INACTIVE, NULL, false},
{ false, NULL, 0, 0, 0, 0, 0, NULL, E_NO_INTR, E_INACTIVE, NULL, false},
{ false, NULL, 0, 0, 0, 0, 0, NULL, E_NO_INTR, E_INACTIVE, NULL, false},
{ false, NULL, 0, 0, 0, 0, 0, NULL, E_NO_INTR, E_INACTIVE, NULL, false},
#if CONFIG_IDF_TARGET_ESP32
{ false, NULL, 0, 0, 0, 0, 0, NULL, E_NO_INTR, E_INACTIVE, NULL, false, NULL},
{ false, NULL, 0, 0, 0, 0, 0, NULL, E_NO_INTR, E_INACTIVE, NULL, false, NULL},
{ false, NULL, 0, 0, 0, 0, 0, NULL, E_NO_INTR, E_INACTIVE, NULL, false, NULL},
{ false, NULL, 0, 0, 0, 0, 0, NULL, E_NO_INTR, E_INACTIVE, NULL, false, NULL},
{ false, NULL, 0, 0, 0, 0, 0, NULL, E_NO_INTR, E_INACTIVE, NULL, false},
{ false, NULL, 0, 0, 0, 0, 0, NULL, E_NO_INTR, E_INACTIVE, NULL, false},
{ false, NULL, 0, 0, 0, 0, 0, NULL, E_NO_INTR, E_INACTIVE, NULL, false},
{ false, NULL, 0, 0, 0, 0, 0, NULL, E_NO_INTR, E_INACTIVE, NULL, false},
#endif
};
@ -331,7 +330,6 @@ bool rmtReadData(rmt_obj_t* rmt, uint32_t* data, size_t size)
return true;
}
bool rmtBeginReceive(rmt_obj_t* rmt)
{
if (!rmt) {
@ -365,7 +363,7 @@ bool rmtReceiveCompleted(rmt_obj_t* rmt)
}
}
bool rmtRead(rmt_obj_t* rmt, rmt_rx_data_cb_t cb, void * arg)
bool rmtRead(rmt_obj_t* rmt, rmt_rx_data_cb_t cb)
{
if (!rmt && !cb) {
return false;
@ -373,7 +371,6 @@ bool rmtRead(rmt_obj_t* rmt, rmt_rx_data_cb_t cb, void * arg)
int channel = rmt->channel;
RMT_MUTEX_LOCK(channel);
rmt->arg = arg;
rmt->intr_mode = E_RX_INTR;
rmt->tx_state = E_FIRST_HALF;
rmt->cb = cb;
@ -400,19 +397,6 @@ bool rmtRead(rmt_obj_t* rmt, rmt_rx_data_cb_t cb, void * arg)
return true;
}
bool rmtEnd(rmt_obj_t* rmt) {
if (!rmt) {
return false;
}
int channel = rmt->channel;
RMT_MUTEX_LOCK(channel);
RMT.conf_ch[channel].conf1.rx_en = 1;
RMT_MUTEX_UNLOCK(channel);
return true;
}
bool rmtReadAsync(rmt_obj_t* rmt, rmt_data_t* data, size_t size, void* eventFlag, bool waitForData, uint32_t timeout)
{
if (!rmt) {
@ -545,8 +529,6 @@ rmt_obj_t* rmtInit(int pin, bool tx_not_rx, rmt_reserve_memsize_t memsize)
rmt->tx_not_rx = tx_not_rx;
rmt->buffers =buffers;
rmt->channel = channel;
rmt->arg = NULL;
_initPin(pin, channel, tx_not_rx);
// Initialize the registers in default mode:
@ -573,7 +555,6 @@ rmt_obj_t* rmtInit(int pin, bool tx_not_rx, rmt_reserve_memsize_t memsize)
RMT.conf_ch[channel].conf1.idle_out_lv = 0; // signal level for idle
RMT.conf_ch[channel].conf1.idle_out_en = 1; // enable idle
RMT.conf_ch[channel].conf1.ref_always_on = 0; // base clock
RMT.apb_conf.fifo_mask = 1;
if (tx_not_rx) {
@ -689,7 +670,7 @@ static void ARDUINO_ISR_ATTR _rmt_isr(void* arg)
}
if (g_rmt_objects[ch].cb) {
// actually received data ptr
(g_rmt_objects[ch].cb)(data_received, _rmt_get_mem_len(ch), g_rmt_objects[ch].arg);
(g_rmt_objects[ch].cb)(data_received, _rmt_get_mem_len(ch));
// restart the reception
RMT.conf_ch[ch].conf1.mem_owner = 1;

View File

@ -40,7 +40,7 @@ typedef enum {
typedef struct rmt_obj_s rmt_obj_t;
typedef void (*rmt_rx_data_cb_t)(uint32_t *data, size_t len, void *arg);
typedef void (*rmt_rx_data_cb_t)(uint32_t *data, size_t len);
typedef struct {
union {
@ -90,13 +90,8 @@ bool rmtReadAsync(rmt_obj_t* rmt, rmt_data_t* data, size_t size, void* eventFlag
* and callback with data from ISR
*
*/
bool rmtRead(rmt_obj_t* rmt, rmt_rx_data_cb_t cb, void * arg);
bool rmtRead(rmt_obj_t* rmt, rmt_rx_data_cb_t cb);
/***
* Ends async receive started with rmtRead(); but does not
* rmtDeInit().
*/
bool rmtEnd(rmt_obj_t* rmt);
/* Additional interface */

View File

@ -57,7 +57,7 @@ extern "C" {
struct spi_struct_t;
typedef struct spi_struct_t spi_t;
spi_t * spiStartBus(uint8_t spi_num, uint32_t clockDiv, uint8_t dataMode, uint8_t bitOrder);
spi_t * spiStartBus(uint8_t spi_num, uint32_t freq, uint8_t dataMode, uint8_t bitOrder);
void spiStopBus(spi_t * spi);
//Attach/Detach Signal Pins

View File

@ -30,8 +30,6 @@
#include "esp32-hal-tinyusb.h"
#include "esp32s2/rom/usb/usb_persist.h"
#include "esp32s2/rom/usb/usb_dc.h"
#include "esp32s2/rom/usb/chip_usb_dw_wrapper.h"
typedef char tusb_str_t[127];
@ -459,22 +457,27 @@ static void IRAM_ATTR usb_persist_shutdown_handler(void)
{
if(usb_persist_mode != RESTART_NO_PERSIST){
if (usb_persist_enabled) {
usb_dc_prepare_persist();
REG_SET_BIT(RTC_CNTL_USB_CONF_REG, RTC_CNTL_IO_MUX_RESET_DISABLE);
REG_SET_BIT(RTC_CNTL_USB_CONF_REG, RTC_CNTL_USB_RESET_DISABLE);
}
if (usb_persist_mode == RESTART_BOOTLOADER) {
//USB CDC Download
if (usb_persist_enabled) {
chip_usb_set_persist_flags(USBDC_PERSIST_ENA);
USB_WRAP.date.val = USBDC_PERSIST_ENA;
}
REG_WRITE(RTC_CNTL_OPTION1_REG, RTC_CNTL_FORCE_DOWNLOAD_BOOT);
periph_module_disable(PERIPH_TIMG1_MODULE);
} else if (usb_persist_mode == RESTART_BOOTLOADER_DFU) {
//DFU Download
chip_usb_set_persist_flags(USBDC_BOOT_DFU);
USB_WRAP.date.val = USBDC_BOOT_DFU;
REG_WRITE(RTC_CNTL_OPTION1_REG, RTC_CNTL_FORCE_DOWNLOAD_BOOT);
periph_module_disable(PERIPH_TIMG0_MODULE);
periph_module_disable(PERIPH_TIMG1_MODULE);
} else if (usb_persist_enabled) {
//USB Persist reboot
chip_usb_set_persist_flags(USBDC_PERSIST_ENA);
USB_WRAP.date.val = USBDC_PERSIST_ENA;
}
SET_PERI_REG_MASK(RTC_CNTL_OPTIONS0_REG, RTC_CNTL_SW_PROCPU_RST);
}
}
@ -528,7 +531,7 @@ esp_err_t tinyusb_init(tinyusb_device_config_t *config) {
periph_module_enable(PERIPH_USB_MODULE);
}
if (esp_register_shutdown_handler(usb_persist_shutdown_handler) != ESP_OK) {
if (usb_persist_enabled && esp_register_shutdown_handler(usb_persist_shutdown_handler) != ESP_OK) {
initialized = false;
return ESP_FAIL;
}
@ -547,9 +550,11 @@ esp_err_t tinyusb_init(tinyusb_device_config_t *config) {
void usb_persist_restart(restart_type_t mode)
{
if (mode < RESTART_TYPE_MAX) {
if (usb_persist_enabled && mode < RESTART_TYPE_MAX) {
usb_persist_mode = mode;
esp_restart();
} else {
log_e("Persistence is not enabled");
}
}

View File

@ -162,21 +162,21 @@ void uartDisableInterrupt(uart_t* uart)
UART_MUTEX_UNLOCK();
}
void uartDetachRx(uart_t* uart, uint8_t rxPin)
void uartDetachRx(uart_t* uart)
{
if(uart == NULL) {
return;
}
pinMatrixInDetach(rxPin, false, false);
pinMatrixInDetach(UART_RXD_IDX(uart->num), false, false);
uartDisableInterrupt(uart);
}
void uartDetachTx(uart_t* uart, uint8_t txPin)
void uartDetachTx(uart_t* uart)
{
if(uart == NULL) {
return;
}
pinMatrixOutDetach(txPin, false, false);
pinMatrixOutDetach(UART_TXD_IDX(uart->num), false, false);
}
void uartAttachRx(uart_t* uart, uint8_t rxPin, bool inverted)
@ -185,8 +185,8 @@ void uartAttachRx(uart_t* uart, uint8_t rxPin, bool inverted)
return;
}
pinMode(rxPin, INPUT);
uartEnableInterrupt(uart);
pinMatrixInAttach(rxPin, UART_RXD_IDX(uart->num), inverted);
uartEnableInterrupt(uart);
}
void uartAttachTx(uart_t* uart, uint8_t txPin, bool inverted)
@ -266,7 +266,7 @@ uart_t* uartBegin(uint8_t uart_nr, uint32_t baudrate, uint32_t config, int8_t rx
return uart;
}
void uartEnd(uart_t* uart, uint8_t txPin, uint8_t rxPin)
void uartEnd(uart_t* uart)
{
if(uart == NULL) {
return;
@ -283,8 +283,8 @@ void uartEnd(uart_t* uart, uint8_t txPin, uint8_t rxPin)
UART_MUTEX_UNLOCK();
uartDetachRx(uart, rxPin);
uartDetachTx(uart, txPin);
uartDetachRx(uart);
uartDetachTx(uart);
}
size_t uartResizeRxBuffer(uart_t * uart, size_t new_size) {
@ -297,7 +297,6 @@ size_t uartResizeRxBuffer(uart_t * uart, size_t new_size) {
vQueueDelete(uart->queue);
uart->queue = xQueueCreate(new_size, sizeof(uint8_t));
if(uart->queue == NULL) {
UART_MUTEX_UNLOCK();
return 0;
}
}
@ -306,17 +305,6 @@ size_t uartResizeRxBuffer(uart_t * uart, size_t new_size) {
return new_size;
}
void uartSetRxInvert(uart_t* uart, bool invert)
{
if (uart == NULL)
return;
if (invert)
uart->dev->conf0.rxd_inv = 1;
else
uart->dev->conf0.rxd_inv = 0;
}
uint32_t uartAvailable(uart_t* uart)
{
if(uart == NULL || uart->queue == NULL) {
@ -428,7 +416,7 @@ void uartWriteBuf(uart_t* uart, const uint8_t * data, size_t len)
void uartFlush(uart_t* uart)
{
uartFlushTxOnly(uart,true);
uartFlushTxOnly(uart,false);
}
void uartFlushTxOnly(uart_t* uart, bool txOnly)

View File

@ -52,7 +52,7 @@ struct uart_struct_t;
typedef struct uart_struct_t uart_t;
uart_t* uartBegin(uint8_t uart_nr, uint32_t baudrate, uint32_t config, int8_t rxPin, int8_t txPin, uint16_t queueLen, bool inverted);
void uartEnd(uart_t* uart, uint8_t rxPin, uint8_t txPin);
void uartEnd(uart_t* uart);
uint32_t uartAvailable(uart_t* uart);
uint32_t uartAvailableForWrite(uart_t* uart);
@ -70,8 +70,6 @@ uint32_t uartGetBaudRate(uart_t* uart);
size_t uartResizeRxBuffer(uart_t* uart, size_t new_size);
void uartSetRxInvert(uart_t* uart, bool invert);
void uartSetDebug(uart_t* uart);
int uartGetDebug();

View File

@ -1,46 +0,0 @@
// Copyright 2019 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.
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
/** Major version number (X.x.x) */
#define ESP_ARDUINO_VERSION_MAJOR 2
/** Minor version number (x.X.x) */
#define ESP_ARDUINO_VERSION_MINOR 0
/** Patch version number (x.x.X) */
#define ESP_ARDUINO_VERSION_PATCH 0
/**
* Macro to convert ARDUINO version number into an integer
*
* To be used in comparisons, such as ESP_ARDUINO_VERSION >= ESP_ARDUINO_VERSION_VAL(2, 0, 0)
*/
#define ESP_ARDUINO_VERSION_VAL(major, minor, patch) ((major << 16) | (minor << 8) | (patch))
/**
* Current ARDUINO version, as an integer
*
* To be used in comparisons, such as ESP_ARDUINO_VERSION >= ESP_ARDUINO_VERSION_VAL(2, 0, 0)
*/
#define ESP_ARDUINO_VERSION ESP_ARDUINO_VERSION_VAL(ESP_ARDUINO_VERSION_MAJOR, \
ESP_ARDUINO_VERSION_MINOR, \
ESP_ARDUINO_VERSION_PATCH)
#ifdef __cplusplus
}
#endif

View File

@ -53,8 +53,6 @@ typedef unsigned long prog_uint32_t;
*(void * const *)(_addr); \
})
#define pgm_get_far_address(x) ((uint32_t)(&(x)))
#define pgm_read_byte_near(addr) pgm_read_byte(addr)
#define pgm_read_word_near(addr) pgm_read_word(addr)
#define pgm_read_dword_near(addr) pgm_read_dword(addr)

View File

@ -1,6 +1,6 @@
Make your question, not a Statement, inclusive. Include all pertinent information:
What you are trying to do
What you are trying to do.
Describe your system( Hardware, computer, O/S, core version, environment)
Describe what is failing
Show the shortest possible code that will duplicate the error
@ -8,21 +8,19 @@ Show the EXACT error message (it doesn't work is not enough)
Then if someone is interested and knowledgeable you might get a answer. All of this work on your part shows us that you have worked to solve YOUR problem. The more complete your issue posting is, the more likely someone will volunteer their time to help you.
If you have a Guru Meditation Error or Backtrace, ***please decode it***:
[ExceptionDecoder](https://github.com/me-no-dev/EspExceptionDecoder)
https://github.com/me-no-dev/EspExceptionDecoder
----------------------------- Remove above -----------------------------
### Hardware:
|||||||
|:---|---|---|---|---|---|
|<B>Board</B>|ESP32 Dev Module|node32|ttgo_lora|ESP32-S2-Saola|Custom w/ ESP32-S2-WROVER 16MB|
|<B>Version/Date</B>|1.0.4|2.0.0|0badbeef|11/jul/2017|today's master|
|<B>IDE name</B>|Arduino IDE|Atom + Platform.io|IDF component|VSCode|
|<B>Flash Frequency</B>|40Mhz|80Mhz|
|<B>PSRAM enabled</B>|yes|no|
|<B>Upload Speed</B>|115200|
|<B>Computer OS</B>|Windows 10|Mac OSX|Ubuntu|
Board: ?ESP32 Dev Module? ?node32? ?ttgo_lora?
Core Installation/update date: ?11/jul/2017?
IDE name: ?Arduino IDE? ?Platform.io? ?IDF component?
Flash Frequency: ?40Mhz?
PSRAM enabled: ?no?
Upload Speed: ?115200?
Computer OS: ?Windows 10? ?Mac OSX? ?Ubuntu?
### Description:
Describe your problem here

View File

@ -4,7 +4,7 @@
- Stable release link: `https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json`
- Development release link: `https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_dev_index.json`
Starting with 1.6.4, Arduino allows installation of third-party platform packages using Boards Manager. We have packages available for Windows, Mac OS, and Linux (x86, amd64, armhf and arm64).
Starting with 1.6.4, Arduino allows installation of third-party platform packages using Boards Manager. We have packages available for Windows, Mac OS, and Linux (32, 64 bit and ARM).
- Install the current upstream Arduino IDE at the 1.8 level or later. The current version is at the [Arduino website](http://www.arduino.cc/en/main/software).
- Start Arduino and open Preferences window.

View File

@ -7,9 +7,9 @@ Installation instructions for Mac OS
```bash
mkdir -p ~/Documents/Arduino/hardware/espressif && \
cd ~/Documents/Arduino/hardware/espressif && \
git clone https://github.com/espressif/arduino-esp32.git esp32 --depth 1 && \
git clone https://github.com/espressif/arduino-esp32.git esp32 && \
cd esp32 && \
git submodule update --init --recursive --depth 1 && \
git submodule update --init --recursive && \
cd tools && \
python get.py
```

View File

@ -72,11 +72,6 @@ If you are writing code that does not require Arduino to compile and you want yo
#endif
```
## FreeRTOS Tick Rate (Hz)
You might notice that Arduino-esp32's `delay()` function will only work in multiples of 10ms. That is because, by default, esp-idf handles task events 100 times per second.
To fix that behavior you need to set FreeRTOS tick rate to 1000Hz in `make menuconfig` -> `Component config` -> `FreeRTOS` -> `Tick rate`.
## Compilation Errors
As commits are made to esp-idf and submodules, the codebases can develop incompatibilities which cause compilation errors. If you have problems compiling, follow the instructions in [Issue #1142](https://github.com/espressif/arduino-esp32/issues/1142) to roll esp-idf back to a known good version.

View File

@ -25,7 +25,6 @@ const char* loginIndex =
"<br>"
"<br>"
"</tr>"
"<tr>"
"<td>Username:</td>"
"<td><input type='text' size=25 name='userid'><br></td>"
"</tr>"

View File

@ -88,17 +88,6 @@ ArduinoOTAClass& ArduinoOTAClass::setPasswordHash(const char * password) {
return *this;
}
ArduinoOTAClass& ArduinoOTAClass::setPartitionLabel(const char * partition_label) {
if (!_initialized && !_partition_label.length() && partition_label) {
_partition_label = partition_label;
}
return *this;
}
String ArduinoOTAClass::getPartitionLabel() {
return _partition_label;
}
ArduinoOTAClass& ArduinoOTAClass::setRebootOnSuccess(bool reboot){
_rebootOnSuccess = reboot;
return *this;
@ -246,8 +235,7 @@ void ArduinoOTAClass::_onRx(){
}
void ArduinoOTAClass::_runUpdate() {
const char *partition_label = _partition_label.length() ? _partition_label.c_str() : NULL;
if (!Update.begin(_size, _cmd, -1, LOW, partition_label)) {
if (!Update.begin(_size, _cmd)) {
log_e("Begin ERROR: %s", Update.errorString());

View File

@ -44,10 +44,6 @@ class ArduinoOTAClass
//Sets the password as above but in the form MD5(password). Default NULL
ArduinoOTAClass& setPasswordHash(const char *password);
//Sets the partition label to write to when updating SPIFFS. Default NULL
ArduinoOTAClass &setPartitionLabel(const char *partition_label);
String getPartitionLabel();
//Sets if the device should be rebooted after successful update. Default true
ArduinoOTAClass& setRebootOnSuccess(bool reboot);
@ -84,7 +80,6 @@ class ArduinoOTAClass
int _port;
String _password;
String _hostname;
String _partition_label;
String _nonce;
WiFiUDP _udp_ota;
bool _initialized;

View File

@ -150,7 +150,7 @@ static bool _udp_task_start(){
}
}
if(!_udp_task_handle){
xTaskCreateUniversal(_udp_task, "async_udp", 4096, NULL, CONFIG_ARDUINO_UDP_TASK_PRIORITY, (TaskHandle_t*)&_udp_task_handle, CONFIG_ARDUINO_UDP_RUNNING_CORE);
xTaskCreateUniversal(_udp_task, "async_udp", 4096, NULL, 3, (TaskHandle_t*)&_udp_task_handle, CONFIG_ARDUINO_UDP_RUNNING_CORE);
if(!_udp_task_handle){
return false;
}

View File

@ -1,153 +0,0 @@
/*
Based on Neil Kolban example for IDF: https://github.com/nkolban/esp32-snippets/blob/master/cpp_utils/tests/BLE%20Tests/SampleScan.cpp
Ported to Arduino ESP32 by Evandro Copercini
Changed to a beacon scanner to report iBeacon, EddystoneURL and EddystoneTLM beacons by beegee-tokyo
*/
#include <Arduino.h>
#include <BLEDevice.h>
#include <BLEUtils.h>
#include <BLEScan.h>
#include <BLEAdvertisedDevice.h>
#include <BLEEddystoneURL.h>
#include <BLEEddystoneTLM.h>
#include <BLEBeacon.h>
#define ENDIAN_CHANGE_U16(x) ((((x)&0xFF00) >> 8) + (((x)&0xFF) << 8))
int scanTime = 5; //In seconds
BLEScan *pBLEScan;
class MyAdvertisedDeviceCallbacks : public BLEAdvertisedDeviceCallbacks
{
void onResult(BLEAdvertisedDevice advertisedDevice)
{
if (advertisedDevice.haveName())
{
Serial.print("Device name: ");
Serial.println(advertisedDevice.getName().c_str());
Serial.println("");
}
if (advertisedDevice.haveServiceUUID())
{
BLEUUID devUUID = advertisedDevice.getServiceUUID();
Serial.print("Found ServiceUUID: ");
Serial.println(devUUID.toString().c_str());
Serial.println("");
}
else
{
if (advertisedDevice.haveManufacturerData() == true)
{
std::string strManufacturerData = advertisedDevice.getManufacturerData();
uint8_t cManufacturerData[100];
strManufacturerData.copy((char *)cManufacturerData, strManufacturerData.length(), 0);
if (strManufacturerData.length() == 25 && cManufacturerData[0] == 0x4C && cManufacturerData[1] == 0x00)
{
Serial.println("Found an iBeacon!");
BLEBeacon oBeacon = BLEBeacon();
oBeacon.setData(strManufacturerData);
Serial.printf("iBeacon Frame\n");
Serial.printf("ID: %04X Major: %d Minor: %d UUID: %s Power: %d\n", oBeacon.getManufacturerId(), ENDIAN_CHANGE_U16(oBeacon.getMajor()), ENDIAN_CHANGE_U16(oBeacon.getMinor()), oBeacon.getProximityUUID().toString().c_str(), oBeacon.getSignalPower());
}
else
{
Serial.println("Found another manufacturers beacon!");
Serial.printf("strManufacturerData: %d ", strManufacturerData.length());
for (int i = 0; i < strManufacturerData.length(); i++)
{
Serial.printf("[%X]", cManufacturerData[i]);
}
Serial.printf("\n");
}
}
return;
}
uint8_t *payLoad = advertisedDevice.getPayload();
BLEUUID checkUrlUUID = (uint16_t)0xfeaa;
if (advertisedDevice.getServiceUUID().equals(checkUrlUUID))
{
if (payLoad[11] == 0x10)
{
Serial.println("Found an EddystoneURL beacon!");
BLEEddystoneURL foundEddyURL = BLEEddystoneURL();
std::string eddyContent((char *)&payLoad[11]); // incomplete EddystoneURL struct!
foundEddyURL.setData(eddyContent);
std::string bareURL = foundEddyURL.getURL();
if (bareURL[0] == 0x00)
{
size_t payLoadLen = advertisedDevice.getPayloadLength();
Serial.println("DATA-->");
for (int idx = 0; idx < payLoadLen; idx++)
{
Serial.printf("0x%08X ", payLoad[idx]);
}
Serial.println("\nInvalid Data");
return;
}
Serial.printf("Found URL: %s\n", foundEddyURL.getURL().c_str());
Serial.printf("Decoded URL: %s\n", foundEddyURL.getDecodedURL().c_str());
Serial.printf("TX power %d\n", foundEddyURL.getPower());
Serial.println("\n");
}
else if (payLoad[11] == 0x20)
{
Serial.println("Found an EddystoneTLM beacon!");
BLEEddystoneTLM foundEddyURL = BLEEddystoneTLM();
std::string eddyContent((char *)&payLoad[11]); // incomplete EddystoneURL struct!
eddyContent = "01234567890123";
for (int idx = 0; idx < 14; idx++)
{
eddyContent[idx] = payLoad[idx + 11];
}
foundEddyURL.setData(eddyContent);
Serial.printf("Reported battery voltage: %dmV\n", foundEddyURL.getVolt());
Serial.printf("Reported temperature from TLM class: %.2fC\n", (double)foundEddyURL.getTemp());
int temp = (int)payLoad[16] + (int)(payLoad[15] << 8);
float calcTemp = temp / 256.0f;
Serial.printf("Reported temperature from data: %.2fC\n", calcTemp);
Serial.printf("Reported advertise count: %d\n", foundEddyURL.getCount());
Serial.printf("Reported time since last reboot: %ds\n", foundEddyURL.getTime());
Serial.println("\n");
Serial.print(foundEddyURL.toString().c_str());
Serial.println("\n");
}
}
}
};
void setup()
{
Serial.begin(115200);
Serial.println("Scanning...");
BLEDevice::init("");
pBLEScan = BLEDevice::getScan(); //create new scan
pBLEScan->setAdvertisedDeviceCallbacks(new MyAdvertisedDeviceCallbacks());
pBLEScan->setActiveScan(true); //active scan uses more power, but get results faster
pBLEScan->setInterval(100);
pBLEScan->setWindow(99); // less or equal setInterval value
}
void loop()
{
// put your main code here, to run repeatedly:
BLEScanResults foundDevices = pBLEScan->start(scanTime, false);
Serial.print("Devices found: ");
Serial.println(foundDevices.getCount());
Serial.println("Scan done!");
pBLEScan->clearResults(); // delete results fromBLEScan buffer to release memory
delay(2000);
}

View File

@ -1,9 +0,0 @@
## BLE Beacon Scanner
Initiates a BLE device scan.
Checks if the discovered devices are
- an iBeacon
- an Eddystone TLM beacon
- an Eddystone URL beacon
and sends the decoded beacon information over Serial log

View File

@ -1,116 +0,0 @@
/*
EddystoneTLM beacon by BeeGee based on https://github.com/pcbreflux/espressif/blob/master/esp32/arduino/sketchbook/ESP32_Eddystone_TLM_deepsleep/ESP32_Eddystone_TLM_deepsleep.ino
EddystoneTLM frame specification https://github.com/google/eddystone/blob/master/eddystone-tlm/tlm-plain.md
*/
/*
Create a BLE server that will send periodic Eddystone URL frames.
The design of creating the BLE server is:
1. Create a BLE Server
2. Create advertising data
3. Start advertising.
4. wait
5. Stop advertising.
6. deep sleep
*/
#include "sys/time.h"
#include <Arduino.h>
#include "BLEDevice.h"
#include "BLEUtils.h"
#include "BLEBeacon.h"
#include "BLEAdvertising.h"
#include "BLEEddystoneURL.h"
#include "esp_sleep.h"
#define GPIO_DEEP_SLEEP_DURATION 10 // sleep x seconds and then wake up
RTC_DATA_ATTR static time_t last; // remember last boot in RTC Memory
RTC_DATA_ATTR static uint32_t bootcount; // remember number of boots in RTC Memory
// See the following for generating UUIDs:
// https://www.uuidgenerator.net/
BLEAdvertising *pAdvertising;
struct timeval nowTimeStruct;
time_t lastTenth;
#define BEACON_UUID "8ec76ea3-6668-48da-9866-75be8bc86f4d" // UUID 1 128-Bit (may use linux tool uuidgen or random numbers via https://www.uuidgenerator.net/)
// Check
// https://github.com/google/eddystone/blob/master/eddystone-tlm/tlm-plain.md
// and http://www.hugi.scene.org/online/coding/hugi%2015%20-%20cmtadfix.htm
// for the temperature value. It is a 8.8 fixed-point notation
void setBeacon()
{
char beacon_data[25];
uint16_t beconUUID = 0xFEAA;
uint16_t volt = random(2800, 3700); // 3300mV = 3.3V
float tempFloat = random(2000, 3100) / 100.0f;
Serial.printf("Random temperature is %.2fC\n", tempFloat);
int temp = (int)(tempFloat * 256); //(uint16_t)((float)23.00);
Serial.printf("Converted to 8.8 format %0X%0X\n", (temp >> 8), (temp & 0xFF));
BLEAdvertisementData oAdvertisementData = BLEAdvertisementData();
BLEAdvertisementData oScanResponseData = BLEAdvertisementData();
oScanResponseData.setFlags(0x06); // GENERAL_DISC_MODE 0x02 | BR_EDR_NOT_SUPPORTED 0x04
oScanResponseData.setCompleteServices(BLEUUID(beconUUID));
beacon_data[0] = 0x20; // Eddystone Frame Type (Unencrypted Eddystone-TLM)
beacon_data[1] = 0x00; // TLM version
beacon_data[2] = (volt >> 8); // Battery voltage, 1 mV/bit i.e. 0xCE4 = 3300mV = 3.3V
beacon_data[3] = (volt & 0xFF); //
beacon_data[4] = (temp >> 8); // Beacon temperature
beacon_data[5] = (temp & 0xFF); //
beacon_data[6] = ((bootcount & 0xFF000000) >> 24); // Advertising PDU count
beacon_data[7] = ((bootcount & 0xFF0000) >> 16); //
beacon_data[8] = ((bootcount & 0xFF00) >> 8); //
beacon_data[9] = (bootcount & 0xFF); //
beacon_data[10] = ((lastTenth & 0xFF000000) >> 24); // Time since power-on or reboot as 0.1 second resolution counter
beacon_data[11] = ((lastTenth & 0xFF0000) >> 16); //
beacon_data[12] = ((lastTenth & 0xFF00) >> 8); //
beacon_data[13] = (lastTenth & 0xFF); //
oScanResponseData.setServiceData(BLEUUID(beconUUID), std::string(beacon_data, 14));
oAdvertisementData.setName("TLMBeacon");
pAdvertising->setAdvertisementData(oAdvertisementData);
pAdvertising->setScanResponseData(oScanResponseData);
}
void setup()
{
Serial.begin(115200);
gettimeofday(&nowTimeStruct, NULL);
Serial.printf("start ESP32 %d\n", bootcount++);
Serial.printf("deep sleep (%lds since last reset, %lds since last boot)\n", nowTimeStruct.tv_sec, nowTimeStruct.tv_sec - last);
last = nowTimeStruct.tv_sec;
lastTenth = nowTimeStruct.tv_sec * 10; // Time since last reset as 0.1 second resolution counter
// Create the BLE Device
BLEDevice::init("TLMBeacon");
BLEDevice::setPower(ESP_PWR_LVL_N12);
pAdvertising = BLEDevice::getAdvertising();
setBeacon();
// Start advertising
pAdvertising->start();
Serial.println("Advertizing started for 10s ...");
delay(10000);
pAdvertising->stop();
Serial.printf("enter deep sleep for 10s\n");
esp_deep_sleep(1000000LL * GPIO_DEEP_SLEEP_DURATION);
Serial.printf("in deep sleep\n");
}
void loop()
{
}

View File

@ -1,14 +0,0 @@
## Eddystone TLM beacon
EddystoneTLM beacon by BeeGee based on
[pcbreflux ESP32 Eddystone TLM deepsleep](https://github.com/pcbreflux/espressif/blob/master/esp32/arduino/sketchbook/ESP32_Eddystone_TLM_deepsleep/ESP32_Eddystone_TLM_deepsleep.ino)
[EddystoneTLM frame specification](https://github.com/google/eddystone/blob/master/eddystone-tlm/tlm-plain.md)
Create a BLE server that will send periodic Eddystone TLM frames.
The design of creating the BLE server is:
1. Create a BLE Server
2. Create advertising data
3. Start advertising.
4. wait
5. Stop advertising.
6. deep sleep

View File

@ -1,192 +0,0 @@
/*
EddystoneURL beacon by BeeGee
EddystoneURL frame specification https://github.com/google/eddystone/blob/master/eddystone-url/README.md
*/
/*
Create a BLE server that will send periodic Eddystone URL frames.
The design of creating the BLE server is:
1. Create a BLE Server
2. Create advertising data
3. Start advertising.
4. wait
5. Stop advertising.
6. deep sleep
*/
#include "sys/time.h"
#include <Arduino.h>
#include "BLEDevice.h"
#include "BLEUtils.h"
#include "BLEBeacon.h"
#include "BLEAdvertising.h"
#include "BLEEddystoneURL.h"
#include "esp_sleep.h"
#define GPIO_DEEP_SLEEP_DURATION 10 // sleep x seconds and then wake up
RTC_DATA_ATTR static time_t last; // remember last boot in RTC Memory
RTC_DATA_ATTR static uint32_t bootcount; // remember number of boots in RTC Memory
// See the following for generating UUIDs:
// https://www.uuidgenerator.net/
BLEAdvertising *pAdvertising;
struct timeval now;
#define BEACON_UUID "8ec76ea3-6668-48da-9866-75be8bc86f4d" // UUID 1 128-Bit (may use linux tool uuidgen or random numbers via https://www.uuidgenerator.net/)
static const char *eddystone_url_prefix_subs[] = {
"http://www.",
"https://www.",
"http://",
"https://",
"urn:uuid:",
NULL
};
static const char *eddystone_url_suffix_subs[] = {
".com/",
".org/",
".edu/",
".net/",
".info/",
".biz/",
".gov/",
".com",
".org",
".edu",
".net",
".info",
".biz",
".gov",
NULL
};
static int string_begin_with(const char *str, const char *prefix)
{
int prefix_len = strlen(prefix);
if (strncmp(prefix, str, prefix_len) == 0)
{
return prefix_len;
}
return 0;
}
void setBeacon()
{
BLEAdvertisementData oAdvertisementData = BLEAdvertisementData();
BLEAdvertisementData oScanResponseData = BLEAdvertisementData();
const char url[] = "https://d.giesecke.tk";
int scheme_len, ext_len = 1, i, idx, url_idx;
char *ret_data;
int url_len = strlen(url);
ret_data = (char *)calloc(1, url_len + 13);
ret_data[0] = 2; // Len
ret_data[1] = 0x01; // Type Flags
ret_data[2] = 0x06; // GENERAL_DISC_MODE 0x02 | BR_EDR_NOT_SUPPORTED 0x04
ret_data[3] = 3; // Len
ret_data[4] = 0x03; // Type 16-Bit UUID
ret_data[5] = 0xAA; // Eddystone UUID 2 -> 0xFEAA LSB
ret_data[6] = 0xFE; // Eddystone UUID 1 MSB
ret_data[7] = 19; // Length of Beacon Data
ret_data[8] = 0x16; // Type Service Data
ret_data[9] = 0xAA; // Eddystone UUID 2 -> 0xFEAA LSB
ret_data[10] = 0xFE; // Eddystone UUID 1 MSB
ret_data[11] = 0x10; // Eddystone Frame Type
ret_data[12] = 0xF4; // Beacons TX power at 0m
i = 0, idx = 13, url_idx = 0;
//replace prefix
scheme_len = 0;
while (eddystone_url_prefix_subs[i] != NULL)
{
if ((scheme_len = string_begin_with(url, eddystone_url_prefix_subs[i])) > 0)
{
ret_data[idx] = i;
idx++;
url_idx += scheme_len;
break;
}
i++;
}
while (url_idx < url_len)
{
i = 0;
ret_data[idx] = url[url_idx];
ext_len = 1;
while (eddystone_url_suffix_subs[i] != NULL)
{
if ((ext_len = string_begin_with(&url[url_idx], eddystone_url_suffix_subs[i])) > 0)
{
ret_data[idx] = i;
break;
}
else
{
ext_len = 1; //inc 1
}
i++;
}
url_idx += ext_len;
idx++;
}
ret_data[7] = idx - 8;
Serial.printf("struct size %d url size %d reported len %d\n",
url_len + 13,
url_len, ret_data[7]);
Serial.printf("URL in data %s\n", &ret_data[13]);
std::string eddyStoneData(ret_data);
oAdvertisementData.addData(eddyStoneData);
oScanResponseData.setName("URLBeacon");
pAdvertising->setAdvertisementData(oAdvertisementData);
pAdvertising->setScanResponseData(oScanResponseData);
}
void setup()
{
Serial.begin(115200);
gettimeofday(&now, NULL);
Serial.printf("start ESP32 %d\n", bootcount++);
Serial.printf("deep sleep (%lds since last reset, %lds since last boot)\n", now.tv_sec, now.tv_sec - last);
last = now.tv_sec;
// Create the BLE Device
BLEDevice::init("URLBeacon");
BLEDevice::setPower(ESP_PWR_LVL_N12);
// Create the BLE Server
// BLEServer *pServer = BLEDevice::createServer(); // <-- no longer required to instantiate BLEServer, less flash and ram usage
pAdvertising = BLEDevice::getAdvertising();
setBeacon();
// Start advertising
pAdvertising->start();
Serial.println("Advertizing started...");
delay(10000);
pAdvertising->stop();
Serial.printf("enter deep sleep\n");
esp_deep_sleep(1000000LL * GPIO_DEEP_SLEEP_DURATION);
Serial.printf("in deep sleep\n");
}
void loop()
{
}

View File

@ -1,14 +0,0 @@
## Eddystone URL beacon
EddystoneURL beacon by BeeGee based on
[pcbreflux ESP32 Eddystone URL deepsleep](https://github.com/pcbreflux/espressif/tree/master/esp32/arduino/sketchbook/ESP32_Eddystone_URL_deepsleep)
[EddystoneURL frame specification](https://github.com/google/eddystone/blob/master/eddystone-url/README.md)
Create a BLE server that will send periodic Eddystone URL frames.
The design of creating the BLE server is:
1. Create a BLE Server
2. Create advertising data
3. Start advertising.
4. wait
5. Stop advertising.
6. deep sleep

View File

@ -10,7 +10,7 @@
* https://www.bluetooth.com/specifications/gatt/viewer?attributeXmlFile=org.bluetooth.descriptor.gatt.client_characteristic_configuration.xml
*/
#include "sdkconfig.h"
#if defined(CONFIG_BLUEDROID_ENABLED)
#if defined(CONFIG_BT_ENABLED)
#include "BLE2902.h"

View File

@ -8,7 +8,7 @@
#ifndef COMPONENTS_CPP_UTILS_BLE2902_H_
#define COMPONENTS_CPP_UTILS_BLE2902_H_
#include "sdkconfig.h"
#if defined(CONFIG_BLUEDROID_ENABLED)
#if defined(CONFIG_BT_ENABLED)
#include "BLEDescriptor.h"
@ -30,5 +30,5 @@ public:
}; // BLE2902
#endif /* CONFIG_BLUEDROID_ENABLED */
#endif /* CONFIG_BT_ENABLED */
#endif /* COMPONENTS_CPP_UTILS_BLE2902_H_ */

View File

@ -10,7 +10,7 @@
* https://www.bluetooth.com/specifications/gatt/viewer?attributeXmlFile=org.bluetooth.descriptor.gatt.characteristic_presentation_format.xml
*/
#include "sdkconfig.h"
#if defined(CONFIG_BLUEDROID_ENABLED)
#if defined(CONFIG_BT_ENABLED)
#include "BLE2904.h"

View File

@ -8,7 +8,7 @@
#ifndef COMPONENTS_CPP_UTILS_BLE2904_H_
#define COMPONENTS_CPP_UTILS_BLE2904_H_
#include "sdkconfig.h"
#if defined(CONFIG_BLUEDROID_ENABLED)
#if defined(CONFIG_BT_ENABLED)
#include "BLEDescriptor.h"
@ -70,5 +70,5 @@ private:
BLE2904_Data m_data;
}; // BLE2904
#endif /* CONFIG_BLUEDROID_ENABLED */
#endif /* CONFIG_BT_ENABLED */
#endif /* COMPONENTS_CPP_UTILS_BLE2904_H_ */

View File

@ -5,7 +5,7 @@
* Author: kolban
*/
#include "sdkconfig.h"
#if defined(CONFIG_BLUEDROID_ENABLED)
#if defined(CONFIG_BT_ENABLED)
#include "BLEAddress.h"
#include <string>

View File

@ -8,7 +8,7 @@
#ifndef COMPONENTS_CPP_UTILS_BLEADDRESS_H_
#define COMPONENTS_CPP_UTILS_BLEADDRESS_H_
#include "sdkconfig.h"
#if defined(CONFIG_BLUEDROID_ENABLED)
#if defined(CONFIG_BT_ENABLED)
#include <esp_gap_ble_api.h> // ESP32 BLE
#include <string>
@ -30,5 +30,5 @@ private:
esp_bd_addr_t m_address;
};
#endif /* CONFIG_BLUEDROID_ENABLED */
#endif /* CONFIG_BT_ENABLED */
#endif /* COMPONENTS_CPP_UTILS_BLEADDRESS_H_ */

View File

@ -12,7 +12,7 @@
* Author: kolban
*/
#include "sdkconfig.h"
#if defined(CONFIG_BLUEDROID_ENABLED)
#if defined(CONFIG_BT_ENABLED)
#include <sstream>
#include "BLEAdvertisedDevice.h"
#include "BLEUtils.h"
@ -388,15 +388,6 @@ void BLEAdvertisedDevice::parseAdvertisement(uint8_t* payload, size_t total_len)
} // !finished
} // parseAdvertisement
/**
* @brief Parse the advertising payload.
* @param [in] payload The payload of the advertised device.
* @param [in] total_len The length of payload
*/
void BLEAdvertisedDevice::setPayload(uint8_t* payload, size_t total_len) {
m_payload = payload;
m_payloadLength = total_len;
} // setPayload
/**
* @brief Set the address of the advertised device.
@ -571,5 +562,5 @@ size_t BLEAdvertisedDevice::getPayloadLength() {
return m_payloadLength;
}
#endif /* CONFIG_BLUEDROID_ENABLED */
#endif /* CONFIG_BT_ENABLED */

View File

@ -8,7 +8,7 @@
#ifndef COMPONENTS_CPP_UTILS_BLEADVERTISEDDEVICE_H_
#define COMPONENTS_CPP_UTILS_BLEADVERTISEDDEVICE_H_
#include "sdkconfig.h"
#if defined(CONFIG_BLUEDROID_ENABLED)
#if defined(CONFIG_BT_ENABLED)
#include <esp_gattc_api.h>
#include <map>
@ -64,7 +64,6 @@ private:
friend class BLEScan;
void parseAdvertisement(uint8_t* payload, size_t total_len=62);
void setPayload(uint8_t* payload, size_t total_len=62);
void setAddress(BLEAddress address);
void setAdFlag(uint8_t adFlag);
void setAdvertizementResult(uint8_t* payload);
@ -124,5 +123,5 @@ public:
virtual void onResult(BLEAdvertisedDevice advertisedDevice) = 0;
};
#endif /* CONFIG_BLUEDROID_ENABLED */
#endif /* CONFIG_BT_ENABLED */
#endif /* COMPONENTS_CPP_UTILS_BLEADVERTISEDDEVICE_H_ */

View File

@ -17,7 +17,7 @@
*
*/
#include "sdkconfig.h"
#if defined(CONFIG_BLUEDROID_ENABLED)
#if defined(CONFIG_BT_ENABLED)
#include "BLEAdvertising.h"
#include <esp_err.h>
#include "BLEUtils.h"
@ -28,9 +28,7 @@
* @brief Construct a default advertising object.
*
*/
BLEAdvertising::BLEAdvertising()
: m_scanRespData{}
{
BLEAdvertising::BLEAdvertising() {
m_advData.set_scan_rsp = false;
m_advData.include_name = true;
m_advData.include_txpower = true;
@ -217,15 +215,10 @@ void BLEAdvertising::start() {
}
if (!m_customScanResponseData && m_scanResp) {
// Set the configuration for scan response.
memcpy(&m_scanRespData, &m_advData, sizeof(esp_ble_adv_data_t)); // Copy the content of m_advData.
m_scanRespData.set_scan_rsp = true; // Define this struct as scan response data
m_scanRespData.include_name = true; // Caution: This may lead to a crash if the device name has more than 29 characters
m_scanRespData.include_txpower = true;
m_scanRespData.appearance = 0; // If defined the 'Appearance' attribute is already included in the advertising data
m_scanRespData.flag = 0; // 'Flags' attribute should no be included in the scan response
errRc = ::esp_ble_gap_config_adv_data(&m_scanRespData);
m_advData.set_scan_rsp = true;
m_advData.include_name = m_scanResp;
m_advData.include_txpower = m_scanResp;
errRc = ::esp_ble_gap_config_adv_data(&m_advData);
if (errRc != ESP_OK) {
log_e("<< esp_ble_gap_config_adv_data (Scan response): rc=%d %s", errRc, GeneralUtils::errorToString(errRc));
return;
@ -525,4 +518,4 @@ void BLEAdvertising::handleGAPEvent(
}
#endif /* CONFIG_BLUEDROID_ENABLED */
#endif /* CONFIG_BT_ENABLED */

View File

@ -8,7 +8,7 @@
#ifndef COMPONENTS_CPP_UTILS_BLEADVERTISING_H_
#define COMPONENTS_CPP_UTILS_BLEADVERTISING_H_
#include "sdkconfig.h"
#if defined(CONFIG_BLUEDROID_ENABLED)
#if defined(CONFIG_BT_ENABLED)
#include <esp_gap_ble_api.h>
#include "BLEUUID.h"
#include <vector>
@ -68,7 +68,6 @@ public:
private:
esp_ble_adv_data_t m_advData;
esp_ble_adv_data_t m_scanRespData; // Used for configuration of scan response data when m_scanResp is true
esp_ble_adv_params_t m_advParams;
std::vector<BLEUUID> m_serviceUUIDs;
bool m_customAdvData = false; // Are we using custom advertising data?
@ -77,5 +76,5 @@ private:
bool m_scanResp = true;
};
#endif /* CONFIG_BLUEDROID_ENABLED */
#endif /* CONFIG_BT_ENABLED */
#endif /* COMPONENTS_CPP_UTILS_BLEADVERTISING_H_ */

View File

@ -5,7 +5,7 @@
* Author: kolban
*/
#include "sdkconfig.h"
#if defined(CONFIG_BLUEDROID_ENABLED)
#if defined(CONFIG_BT_ENABLED)
#include <string.h>
#include "BLEBeacon.h"
#include "esp32-hal-log.h"

View File

@ -5,7 +5,7 @@
* Author: kolban
*/
#include "sdkconfig.h"
#if defined(CONFIG_BLUEDROID_ENABLED)
#if defined(CONFIG_BT_ENABLED)
#include <sstream>
#include <string.h>
#include <iomanip>
@ -219,8 +219,6 @@ void BLECharacteristic::handleGATTServerEvent(
// - uint8_t exec_write_flag - Either ESP_GATT_PREP_WRITE_EXEC or ESP_GATT_PREP_WRITE_CANCEL
//
case ESP_GATTS_EXEC_WRITE_EVT: {
if(m_writeEvt){
m_writeEvt = false;
if (param->exec_write.exec_write_flag == ESP_GATT_PREP_WRITE_EXEC) {
m_value.commit();
m_pCallbacks->onWrite(this); // Invoke the onWrite callback handler.
@ -235,7 +233,6 @@ void BLECharacteristic::handleGATTServerEvent(
if (errRc != ESP_OK) {
log_e("esp_ble_gatts_send_response: rc=%d %s", errRc, GeneralUtils::errorToString(errRc));
}
}
break;
} // ESP_GATTS_EXEC_WRITE_EVT
@ -280,7 +277,6 @@ void BLECharacteristic::handleGATTServerEvent(
if (param->write.handle == m_handle) {
if (param->write.is_prep) {
m_value.addPart(param->write.value, param->write.len);
m_writeEvt = true;
} else {
setValue(param->write.value, param->write.len);
}
@ -800,4 +796,4 @@ void BLECharacteristicCallbacks::onStatus(BLECharacteristic* pCharacteristic, St
} // onStatus
#endif /* CONFIG_BLUEDROID_ENABLED */
#endif /* CONFIG_BT_ENABLED */

View File

@ -8,7 +8,7 @@
#ifndef COMPONENTS_CPP_UTILS_BLECHARACTERISTIC_H_
#define COMPONENTS_CPP_UTILS_BLECHARACTERISTIC_H_
#include "sdkconfig.h"
#if defined(CONFIG_BLUEDROID_ENABLED)
#if defined(CONFIG_BT_ENABLED)
#include <string>
#include <map>
#include "BLEUUID.h"
@ -107,7 +107,6 @@ private:
BLEService* m_pService;
BLEValue m_value;
esp_gatt_perm_t m_permissions = ESP_GATT_PERM_READ | ESP_GATT_PERM_WRITE;
bool m_writeEvt = false; // If we have started a long write, this tells the commit code that we were the target
void handleGATTServerEvent(
esp_gatts_cb_event_t event,
@ -150,5 +149,5 @@ public:
virtual void onNotify(BLECharacteristic* pCharacteristic);
virtual void onStatus(BLECharacteristic* pCharacteristic, Status s, uint32_t code);
};
#endif /* CONFIG_BLUEDROID_ENABLED */
#endif /* CONFIG_BT_ENABLED */
#endif /* COMPONENTS_CPP_UTILS_BLECHARACTERISTIC_H_ */

View File

@ -5,7 +5,7 @@
* Author: kolban
*/
#include "sdkconfig.h"
#if defined(CONFIG_BLUEDROID_ENABLED)
#if defined(CONFIG_BT_ENABLED)
#include <sstream>
#include <iomanip>
#include "BLEService.h"
@ -131,4 +131,4 @@ std::string BLECharacteristicMap::toString() {
} // toString
#endif /* CONFIG_BLUEDROID_ENABLED */
#endif /* CONFIG_BT_ENABLED */

View File

@ -5,7 +5,7 @@
* Author: kolban
*/
#include "sdkconfig.h"
#if defined(CONFIG_BLUEDROID_ENABLED)
#if defined(CONFIG_BT_ENABLED)
#include <esp_bt.h>
#include <esp_bt_main.h>
#include <esp_gap_ble_api.h>
@ -105,7 +105,6 @@ bool BLEClient::connect(BLEAddress address, esp_ble_addr_type_t type) {
esp_err_t errRc = ::esp_ble_gattc_app_register(m_appId);
if (errRc != ESP_OK) {
log_e("esp_ble_gattc_app_register: rc=%d %s", errRc, GeneralUtils::errorToString(errRc));
BLEDevice::removePeerDevice(m_appId, true);
return false;
}
@ -123,7 +122,6 @@ bool BLEClient::connect(BLEAddress address, esp_ble_addr_type_t type) {
);
if (errRc != ESP_OK) {
log_e("esp_ble_gattc_open: rc=%d %s", errRc, GeneralUtils::errorToString(errRc));
BLEDevice::removePeerDevice(m_appId, true);
return false;
}
@ -180,13 +178,12 @@ void BLEClient::gattClientEventHandler(
// - uint16_t conn_id
// - esp_bd_addr_t remote_bda
case ESP_GATTC_DISCONNECT_EVT: {
if (evtParam->disconnect.conn_id != getConnId()) break;
// If we receive a disconnect event, set the class flag that indicates that we are
// no longer connected.
if (m_isConnected && m_pClientCallbacks != nullptr) {
m_isConnected = false;
if (m_pClientCallbacks != nullptr) {
m_pClientCallbacks->onDisconnect(this);
}
m_isConnected = false;
esp_ble_gattc_app_unregister(m_gattc_if);
m_semaphoreOpenEvt.give(ESP_GATT_IF_NONE);
m_semaphoreRssiCmplEvt.give();
@ -205,13 +202,11 @@ void BLEClient::gattClientEventHandler(
//
case ESP_GATTC_OPEN_EVT: {
m_conn_id = evtParam->open.conn_id;
if (evtParam->open.status == ESP_GATT_OK) {
m_isConnected = true; // Flag us as connected.
if (m_pClientCallbacks != nullptr) {
m_pClientCallbacks->onConnect(this);
}
} else {
log_e("Failed to connect, status=%s", GeneralUtils::errorToString(evtParam->open.status));
if (evtParam->open.status == ESP_GATT_OK) {
m_isConnected = true; // Flag us as connected.
}
m_semaphoreOpenEvt.give(evtParam->open.status);
break;
@ -232,7 +227,6 @@ void BLEClient::gattClientEventHandler(
} // ESP_GATTC_REG_EVT
case ESP_GATTC_CFG_MTU_EVT:
if (evtParam->cfg_mtu.conn_id != getConnId()) break;
if(evtParam->cfg_mtu.status != ESP_GATT_OK) {
log_e("Config mtu failed");
}
@ -240,8 +234,7 @@ void BLEClient::gattClientEventHandler(
break;
case ESP_GATTC_CONNECT_EVT: {
if (evtParam->connect.conn_id != getConnId()) break;
BLEDevice::updatePeerDevice(this, true, m_appId);
BLEDevice::updatePeerDevice(this, true, m_gattc_if);
esp_err_t errRc = esp_ble_gattc_send_mtu_req(gattc_if, evtParam->connect.conn_id);
if (errRc != ESP_OK) {
log_e("esp_ble_gattc_send_mtu_req: rc=%d %s", errRc, GeneralUtils::errorToString(errRc));
@ -262,7 +255,6 @@ void BLEClient::gattClientEventHandler(
// - uint16_t conn_id
//
case ESP_GATTC_SEARCH_CMPL_EVT: {
if (evtParam->search_cmpl.conn_id != getConnId()) break;
esp_ble_gattc_cb_param_t* p_data = (esp_ble_gattc_cb_param_t*)evtParam;
if (p_data->search_cmpl.status != ESP_GATT_OK){
log_e("search service failed, error status = %x", p_data->search_cmpl.status);
@ -293,7 +285,6 @@ void BLEClient::gattClientEventHandler(
// - esp_gatt_id_t srvc_id
//
case ESP_GATTC_SEARCH_RES_EVT: {
if (evtParam->search_res.conn_id != getConnId()) break;
BLEUUID uuid = BLEUUID(evtParam->search_res.srvc_id);
BLERemoteService* pRemoteService = new BLERemoteService(
evtParam->search_res.srvc_id,
@ -535,4 +526,4 @@ std::string BLEClient::toString() {
} // toString
#endif // CONFIG_BLUEDROID_ENABLED
#endif // CONFIG_BT_ENABLED

View File

@ -9,7 +9,7 @@
#define MAIN_BLEDEVICE_H_
#include "sdkconfig.h"
#if defined(CONFIG_BLUEDROID_ENABLED)
#if defined(CONFIG_BT_ENABLED)
#include <esp_gattc_api.h>
#include <string.h>
@ -99,5 +99,5 @@ public:
virtual void onDisconnect(BLEClient *pClient) = 0;
};
#endif // CONFIG_BLUEDROID_ENABLED
#endif // CONFIG_BT_ENABLED
#endif /* MAIN_BLEDEVICE_H_ */

View File

@ -5,7 +5,7 @@
* Author: kolban
*/
#include "sdkconfig.h"
#if defined(CONFIG_BLUEDROID_ENABLED)
#if defined(CONFIG_BT_ENABLED)
#include <sstream>
#include <string.h>
#include <iomanip>
@ -284,4 +284,4 @@ void BLEDescriptorCallbacks::onWrite(BLEDescriptor* pDescriptor) {
} // onWrite
#endif /* CONFIG_BLUEDROID_ENABLED */
#endif /* CONFIG_BT_ENABLED */

View File

@ -8,7 +8,7 @@
#ifndef COMPONENTS_CPP_UTILS_BLEDESCRIPTOR_H_
#define COMPONENTS_CPP_UTILS_BLEDESCRIPTOR_H_
#include "sdkconfig.h"
#if defined(CONFIG_BLUEDROID_ENABLED)
#if defined(CONFIG_BT_ENABLED)
#include <string>
#include "BLEUUID.h"
#include "BLECharacteristic.h"
@ -73,5 +73,5 @@ public:
virtual void onRead(BLEDescriptor* pDescriptor);
virtual void onWrite(BLEDescriptor* pDescriptor);
};
#endif /* CONFIG_BLUEDROID_ENABLED */
#endif /* CONFIG_BT_ENABLED */
#endif /* COMPONENTS_CPP_UTILS_BLEDESCRIPTOR_H_ */

View File

@ -5,7 +5,7 @@
* Author: kolban
*/
#include "sdkconfig.h"
#if defined(CONFIG_BLUEDROID_ENABLED)
#if defined(CONFIG_BT_ENABLED)
#include <sstream>
#include <iomanip>
#include "BLECharacteristic.h"
@ -145,4 +145,4 @@ BLEDescriptor* BLEDescriptorMap::getNext() {
m_iterator++;
return pRet;
} // getNext
#endif /* CONFIG_BLUEDROID_ENABLED */
#endif /* CONFIG_BT_ENABLED */

View File

@ -5,7 +5,7 @@
* Author: kolban
*/
#include "sdkconfig.h"
#if defined(CONFIG_BLUEDROID_ENABLED)
#if defined(CONFIG_BT_ENABLED)
#include <freertos/FreeRTOS.h>
#include <freertos/event_groups.h>
#include <freertos/task.h>
@ -669,4 +669,4 @@ void BLEDevice::setCustomGattsHandler(gatts_event_handler handler) {
m_customGattsHandler = handler;
}
#endif // CONFIG_BLUEDROID_ENABLED
#endif // CONFIG_BT_ENABLED

View File

@ -8,7 +8,7 @@
#ifndef MAIN_BLEDevice_H_
#define MAIN_BLEDevice_H_
#include "sdkconfig.h"
#if defined(CONFIG_BLUEDROID_ENABLED)
#if defined(CONFIG_BT_ENABLED)
#include <esp_gap_ble_api.h> // ESP32 BLE
#include <esp_gattc_api.h> // ESP32 BLE
#include <map> // Part of C++ STL
@ -96,5 +96,5 @@ public:
}; // class BLE
#endif // CONFIG_BLUEDROID_ENABLED
#endif // CONFIG_BT_ENABLED
#endif /* MAIN_BLEDevice_H_ */

View File

@ -3,14 +3,9 @@
*
* Created on: Mar 12, 2018
* Author: pcbreflux
* Edited on: Mar 20, 2020 by beegee-tokyo
* Fix temperature value (8.8 fixed format)
* Fix time stamp (0.1 second resolution)
* Fixes based on EddystoneTLM frame specification https://github.com/google/eddystone/blob/master/eddystone-tlm/tlm-plain.md
*
*/
#include "sdkconfig.h"
#if defined(CONFIG_BLUEDROID_ENABLED)
#if defined(CONFIG_BT_ENABLED)
#include <string.h>
#include <stdio.h>
#include "esp32-hal-log.h"
@ -25,7 +20,7 @@ BLEEddystoneTLM::BLEEddystoneTLM() {
m_eddystoneData.frameType = EDDYSTONE_TLM_FRAME_TYPE;
m_eddystoneData.version = 0;
m_eddystoneData.volt = 3300; // 3300mV = 3.3V
m_eddystoneData.temp = (uint16_t) ((float) 23.00)/256;
m_eddystoneData.temp = (uint16_t) ((float) 23.00);
m_eddystoneData.advCount = 0;
m_eddystoneData.tmil = 0;
} // BLEEddystoneTLM
@ -43,50 +38,41 @@ uint8_t BLEEddystoneTLM::getVersion() {
} // getVersion
uint16_t BLEEddystoneTLM::getVolt() {
return ENDIAN_CHANGE_U16(m_eddystoneData.volt);
return m_eddystoneData.volt;
} // getVolt
float BLEEddystoneTLM::getTemp() {
return ENDIAN_CHANGE_U16(m_eddystoneData.temp) / 256.0f;
return (float)m_eddystoneData.temp;
} // getTemp
uint32_t BLEEddystoneTLM::getCount() {
return ENDIAN_CHANGE_U32(m_eddystoneData.advCount);
return m_eddystoneData.advCount;
} // getCount
uint32_t BLEEddystoneTLM::getTime() {
return (ENDIAN_CHANGE_U32(m_eddystoneData.tmil)) / 10;
return m_eddystoneData.tmil;
} // getTime
std::string BLEEddystoneTLM::toString() {
std::string out = "";
uint32_t rawsec = ENDIAN_CHANGE_U32(m_eddystoneData.tmil);
char val[12];
char val[6];
out += "Version "; // + std::string(m_eddystoneData.version);
snprintf(val, sizeof(val), "%d", m_eddystoneData.version);
out += val;
out += "Version " + m_eddystoneData.version;
out += "\n";
out += "Battery Voltage "; // + ENDIAN_CHANGE_U16(m_eddystoneData.volt);
snprintf(val, sizeof(val), "%d", ENDIAN_CHANGE_U16(m_eddystoneData.volt));
out += val;
out += "Battery Voltage " + ENDIAN_CHANGE_U16(m_eddystoneData.volt);
out += " mV\n";
out += "Temperature ";
snprintf(val, sizeof(val), "%.2f", ENDIAN_CHANGE_U16(m_eddystoneData.temp) / 256.0f);
snprintf(val, sizeof(val), "%d", m_eddystoneData.temp);
out += val;
out += " C\n";
out += ".0 °C\n";
out += "Adv. Count ";
snprintf(val, sizeof(val), "%d", ENDIAN_CHANGE_U32(m_eddystoneData.advCount));
out += val;
out += "\n";
out += "Time in seconds ";
snprintf(val, sizeof(val), "%d", rawsec/10);
out += val;
out += "\n";
out += "Time ";
snprintf(val, sizeof(val), "%04d", rawsec / 864000);

View File

@ -5,7 +5,7 @@
* Author: pcbreflux
*/
#include "sdkconfig.h"
#if defined(CONFIG_BLUEDROID_ENABLED)
#if defined(CONFIG_BT_ENABLED)
#include <string.h>
#include "esp32-hal-log.h"
#include "BLEEddystoneURL.h"

View File

@ -5,7 +5,7 @@
* Author: chegewara
*/
#include "sdkconfig.h"
#if defined(CONFIG_BLUEDROID_ENABLED)
#if defined(CONFIG_BT_ENABLED)
#include "BLEHIDDevice.h"
#include "BLE2904.h"
@ -194,7 +194,6 @@ BLECharacteristic* BLEHIDDevice::protocolMode() {
void BLEHIDDevice::setBatteryLevel(uint8_t level) {
m_batteryLevelCharacteristic->setValue(&level, 1);
m_batteryLevelCharacteristic->notify();
}
/*
* @brief Returns battery level characteristic
@ -240,5 +239,5 @@ BLEService* BLEHIDDevice::batteryService() {
return m_batteryService;
}
#endif // CONFIG_BLUEDROID_ENABLED
#endif // CONFIG_BT_ENABLED

View File

@ -9,7 +9,7 @@
#define _BLEHIDDEVICE_H_
#include "sdkconfig.h"
#if defined(CONFIG_BLUEDROID_ENABLED)
#if defined(CONFIG_BT_ENABLED)
#include "BLECharacteristic.h"
#include "BLEService.h"
@ -71,5 +71,5 @@ private:
BLECharacteristic* m_protocolModeCharacteristic; //0x2a4e
BLECharacteristic* m_batteryLevelCharacteristic; //0x2a19
};
#endif // CONFIG_BLUEDROID_ENABLED
#endif // CONFIG_BT_ENABLED
#endif /* _BLEHIDDEVICE_H_ */

View File

@ -8,7 +8,7 @@
#include "BLERemoteCharacteristic.h"
#include "sdkconfig.h"
#if defined(CONFIG_BLUEDROID_ENABLED)
#if defined(CONFIG_BT_ENABLED)
#include <esp_gattc_api.h>
#include <esp_err.h>
@ -237,13 +237,6 @@ void BLERemoteCharacteristic::gattClientEventHandler(esp_gattc_cb_event_t event,
break;
} // ESP_GATTC_WRITE_CHAR_EVT
case ESP_GATTC_READ_DESCR_EVT:
case ESP_GATTC_WRITE_DESCR_EVT:
for (auto &myPair : m_descriptorMap) {
myPair.second->gattClientEventHandler(
event, gattc_if, evtParam);
}
break;
default:
break;
@ -474,8 +467,7 @@ void BLERemoteCharacteristic::registerForNotify(notify_callback notifyCallback,
uint8_t val[] = {0x01, 0x00};
if(!notifications) val[0] = 0x02;
BLERemoteDescriptor* desc = getDescriptor(BLEUUID((uint16_t)0x2902));
if (desc != nullptr)
desc->writeValue(val, 2, true);
desc->writeValue(val, 2);
} // End Register
else { // If we weren't passed a callback function, then this is an unregistration.
esp_err_t errRc = ::esp_ble_gattc_unregister_for_notify(
@ -490,8 +482,7 @@ void BLERemoteCharacteristic::registerForNotify(notify_callback notifyCallback,
uint8_t val[] = {0x00, 0x00};
BLERemoteDescriptor* desc = getDescriptor((uint16_t)0x2902);
if (desc != nullptr)
desc->writeValue(val, 2, true);
desc->writeValue(val, 2);
} // End Unregister
m_semaphoreRegForNotifyEvt.wait("registerForNotify");
@ -542,7 +533,7 @@ std::string BLERemoteCharacteristic::toString() {
* @return N/A.
*/
void BLERemoteCharacteristic::writeValue(std::string newValue, bool response) {
writeValue((uint8_t*)newValue.data(), newValue.length(), response);
writeValue((uint8_t*)newValue.c_str(), strlen(newValue.c_str()), response);
} // writeValue
@ -613,4 +604,4 @@ void BLERemoteCharacteristic::setAuth(esp_gatt_auth_req_t auth) {
m_auth = auth;
}
#endif /* CONFIG_BLUEDROID_ENABLED */
#endif /* CONFIG_BT_ENABLED */

View File

@ -8,7 +8,7 @@
#ifndef COMPONENTS_CPP_UTILS_BLEREMOTECHARACTERISTIC_H_
#define COMPONENTS_CPP_UTILS_BLEREMOTECHARACTERISTIC_H_
#include "sdkconfig.h"
#if defined(CONFIG_BLUEDROID_ENABLED)
#if defined(CONFIG_BT_ENABLED)
#include <string>
@ -83,5 +83,5 @@ private:
// We maintain a map of descriptors owned by this characteristic keyed by a string representation of the UUID.
std::map<std::string, BLERemoteDescriptor*> m_descriptorMap;
}; // BLERemoteCharacteristic
#endif /* CONFIG_BLUEDROID_ENABLED */
#endif /* CONFIG_BT_ENABLED */
#endif /* COMPONENTS_CPP_UTILS_BLEREMOTECHARACTERISTIC_H_ */

View File

@ -5,7 +5,7 @@
* Author: kolban
*/
#include "sdkconfig.h"
#if defined(CONFIG_BLUEDROID_ENABLED)
#if defined(CONFIG_BT_ENABLED)
#include <sstream>
#include "BLERemoteDescriptor.h"
#include "GeneralUtils.h"
@ -49,23 +49,6 @@ BLEUUID BLERemoteDescriptor::getUUID() {
return m_uuid;
} // getUUID
void BLERemoteDescriptor::gattClientEventHandler(esp_gattc_cb_event_t event, esp_gatt_if_t gattc_if, esp_ble_gattc_cb_param_t* evtParam) {
switch(event) {
case ESP_GATTC_READ_DESCR_EVT:
if (evtParam->read.handle != getHandle())
break;
m_semaphoreReadDescrEvt.give();
break;
case ESP_GATTC_WRITE_DESCR_EVT:
if (evtParam->write.handle != getHandle())
break;
m_semaphoreWriteDescrEvt.give();
break;
default:
break;
}
}
std::string BLERemoteDescriptor::readValue() {
log_v(">> readValue: %s", toString().c_str());
@ -154,8 +137,6 @@ void BLERemoteDescriptor::writeValue(uint8_t* data, size_t length, bool response
return;
}
m_semaphoreWriteDescrEvt.take("writeValue");
esp_err_t errRc = ::esp_ble_gattc_write_char_descr(
m_pRemoteCharacteristic->getRemoteService()->getClient()->getGattcIf(),
m_pRemoteCharacteristic->getRemoteService()->getClient()->getConnId(),
@ -168,8 +149,6 @@ void BLERemoteDescriptor::writeValue(uint8_t* data, size_t length, bool response
if (errRc != ESP_OK) {
log_e("esp_ble_gattc_write_char_descr: %d", errRc);
}
m_semaphoreWriteDescrEvt.wait("writeValue");
log_v("<< writeValue");
} // writeValue
@ -201,4 +180,4 @@ void BLERemoteDescriptor::setAuth(esp_gatt_auth_req_t auth) {
m_auth = auth;
}
#endif /* CONFIG_BLUEDROID_ENABLED */
#endif /* CONFIG_BT_ENABLED */

View File

@ -8,7 +8,7 @@
#ifndef COMPONENTS_CPP_UTILS_BLEREMOTEDESCRIPTOR_H_
#define COMPONENTS_CPP_UTILS_BLEREMOTEDESCRIPTOR_H_
#include "sdkconfig.h"
#if defined(CONFIG_BLUEDROID_ENABLED)
#if defined(CONFIG_BT_ENABLED)
#include <string>
#include <esp_gattc_api.h>
@ -35,7 +35,7 @@ public:
void writeValue(std::string newValue, bool response = false);
void writeValue(uint8_t newValue, bool response = false);
void setAuth(esp_gatt_auth_req_t auth);
void gattClientEventHandler(esp_gattc_cb_event_t event, esp_gatt_if_t gattc_if, esp_ble_gattc_cb_param_t* evtParam);
private:
friend class BLERemoteCharacteristic;
@ -49,10 +49,9 @@ private:
std::string m_value; // Last received value of the descriptor.
BLERemoteCharacteristic* m_pRemoteCharacteristic; // Reference to the Remote characteristic of which this descriptor is associated.
FreeRTOS::Semaphore m_semaphoreReadDescrEvt = FreeRTOS::Semaphore("ReadDescrEvt");
FreeRTOS::Semaphore m_semaphoreWriteDescrEvt = FreeRTOS::Semaphore("WriteDescrEvt");
esp_gatt_auth_req_t m_auth;
};
#endif /* CONFIG_BLUEDROID_ENABLED */
#endif /* CONFIG_BT_ENABLED */
#endif /* COMPONENTS_CPP_UTILS_BLEREMOTEDESCRIPTOR_H_ */

View File

@ -5,7 +5,7 @@
* Author: kolban
*/
#include "sdkconfig.h"
#if defined(CONFIG_BLUEDROID_ENABLED)
#if defined(CONFIG_BT_ENABLED)
#include <sstream>
#include "BLERemoteService.h"
@ -244,14 +244,6 @@ std::map<uint16_t, BLERemoteCharacteristic*>* BLERemoteService::getCharacteristi
* @brief This function is designed to get characteristics map when we have multiple characteristics with the same UUID
*/
void BLERemoteService::getCharacteristics(std::map<uint16_t, BLERemoteCharacteristic*>** pCharacteristicMap) {
log_v(">> getCharacteristics() for service: %s", getUUID().toString().c_str());
// If is possible that we have not read the characteristics associated with the service so do that
// now. The request to retrieve the characteristics by calling "retrieveCharacteristics" is a blocking
// call and does not return until all the characteristics are available.
if (!m_haveCharacteristics) {
retrieveCharacteristics();
}
log_v("<< getCharacteristics() for service: %s", getUUID().toString().c_str());
*pCharacteristicMap = &m_characteristicMapByHandle;
} // Get the characteristics map.
@ -310,10 +302,13 @@ std::string BLERemoteService::getValue(BLEUUID characteristicUuid) {
* @return N/A.
*/
void BLERemoteService::removeCharacteristics() {
for (auto &myPair : m_characteristicMap) {
delete myPair.second;
//m_characteristicMap.erase(myPair.first); // Should be no need to delete as it will be deleted by the clear
}
m_characteristicMap.clear(); // Clear the map
for (auto &myPair : m_characteristicMapByHandle) {
delete myPair.second;
// delete the characteristics only once
}
m_characteristicMapByHandle.clear(); // Clear the map
} // removeCharacteristics
@ -359,4 +354,4 @@ std::string BLERemoteService::toString() {
} // toString
#endif /* CONFIG_BLUEDROID_ENABLED */
#endif /* CONFIG_BT_ENABLED */

View File

@ -8,7 +8,7 @@
#ifndef COMPONENTS_CPP_UTILS_BLEREMOTESERVICE_H_
#define COMPONENTS_CPP_UTILS_BLEREMOTESERVICE_H_
#include "sdkconfig.h"
#if defined(CONFIG_BLUEDROID_ENABLED)
#if defined(CONFIG_BT_ENABLED)
#include <map>
@ -81,5 +81,5 @@ private:
uint16_t m_endHandle; // The ending handle of this service.
}; // BLERemoteService
#endif /* CONFIG_BLUEDROID_ENABLED */
#endif /* CONFIG_BT_ENABLED */
#endif /* COMPONENTS_CPP_UTILS_BLEREMOTESERVICE_H_ */

View File

@ -5,7 +5,7 @@
* Author: kolban
*/
#include "sdkconfig.h"
#if defined(CONFIG_BLUEDROID_ENABLED)
#if defined(CONFIG_BT_ENABLED)
#include <esp_err.h>
@ -22,15 +22,12 @@
* Constructor
*/
BLEScan::BLEScan() {
memset(&m_scan_params, 0, sizeof(m_scan_params)); // Initialize all params
m_scan_params.scan_type = BLE_SCAN_TYPE_PASSIVE; // Default is a passive scan.
m_scan_params.own_addr_type = BLE_ADDR_TYPE_PUBLIC;
m_scan_params.scan_filter_policy = BLE_SCAN_FILTER_ALLOW_ALL;
m_scan_params.scan_duplicate = BLE_SCAN_DUPLICATE_DISABLE;
m_pAdvertisedDeviceCallbacks = nullptr;
m_stopped = true;
m_wantDuplicates = false;
m_shouldParse = true;
setInterval(100);
setWindow(100);
} // BLEScan
@ -91,19 +88,16 @@ void BLEScan::handleGAPEvent(
// ignore it.
BLEAddress advertisedAddress(param->scan_rst.bda);
bool found = false;
bool shouldDelete = true;
if (!m_wantDuplicates) {
if (m_scanResults.m_vectorAdvertisedDevices.count(advertisedAddress.toString()) != 0) {
found = true;
}
if (found) { // If we found a previous entry AND we don't want duplicates, then we are done.
if (found && !m_wantDuplicates) { // If we found a previous entry AND we don't want duplicates, then we are done.
log_d("Ignoring %s, already seen it.", advertisedAddress.toString().c_str());
vTaskDelay(1); // <--- allow to switch task in case we scan infinity and dont have new devices to report, or we are blocked here
break;
}
}
// We now construct a model of the advertised device that we have just found for the first
// time.
@ -113,23 +107,19 @@ void BLEScan::handleGAPEvent(
advertisedDevice->setAddress(advertisedAddress);
advertisedDevice->setRSSI(param->scan_rst.rssi);
advertisedDevice->setAdFlag(param->scan_rst.flag);
if (m_shouldParse) {
advertisedDevice->parseAdvertisement((uint8_t*)param->scan_rst.ble_adv, param->scan_rst.adv_data_len + param->scan_rst.scan_rsp_len);
} else {
advertisedDevice->setPayload((uint8_t*)param->scan_rst.ble_adv, param->scan_rst.adv_data_len + param->scan_rst.scan_rsp_len);
}
advertisedDevice->setScan(this);
advertisedDevice->setAddressType(param->scan_rst.ble_addr_type);
if (m_pAdvertisedDeviceCallbacks) { // if has callback, no need to record to vector
m_pAdvertisedDeviceCallbacks->onResult(*advertisedDevice);
} else if (!m_wantDuplicates && !found) { // if no callback and not want duplicate, and not already in vector, record it
if (!found) { // If we have previously seen this device, don't record it again.
m_scanResults.m_vectorAdvertisedDevices.insert(std::pair<std::string, BLEAdvertisedDevice*>(advertisedAddress.toString(), advertisedDevice));
shouldDelete = false;
}
if (shouldDelete) {
if (m_pAdvertisedDeviceCallbacks) {
m_pAdvertisedDeviceCallbacks->onResult(*advertisedDevice);
}
if(found)
delete advertisedDevice;
}
break;
} // ESP_GAP_SEARCH_INQ_RES_EVT
@ -169,14 +159,13 @@ void BLEScan::setActiveScan(bool active) {
* @brief Set the call backs to be invoked.
* @param [in] pAdvertisedDeviceCallbacks Call backs to be invoked.
* @param [in] wantDuplicates True if we wish to be called back with duplicates. Default is false.
* @param [in] shouldParse True if we wish to parse advertised package or raw payload. Default is true.
*/
void BLEScan::setAdvertisedDeviceCallbacks(BLEAdvertisedDeviceCallbacks* pAdvertisedDeviceCallbacks, bool wantDuplicates, bool shouldParse) {
void BLEScan::setAdvertisedDeviceCallbacks(BLEAdvertisedDeviceCallbacks* pAdvertisedDeviceCallbacks, bool wantDuplicates) {
m_wantDuplicates = wantDuplicates;
m_pAdvertisedDeviceCallbacks = pAdvertisedDeviceCallbacks;
m_shouldParse = shouldParse;
} // setAdvertisedDeviceCallbacks
/**
* @brief Set the interval to scan.
* @param [in] The interval in msecs.
@ -330,4 +319,4 @@ void BLEScan::clearResults() {
m_scanResults.m_vectorAdvertisedDevices.clear();
}
#endif /* CONFIG_BLUEDROID_ENABLED */
#endif /* CONFIG_BT_ENABLED */

View File

@ -8,7 +8,7 @@
#ifndef COMPONENTS_CPP_UTILS_BLESCAN_H_
#define COMPONENTS_CPP_UTILS_BLESCAN_H_
#include "sdkconfig.h"
#if defined(CONFIG_BLUEDROID_ENABLED)
#if defined(CONFIG_BT_ENABLED)
#include <esp_gap_ble_api.h>
// #include <vector>
@ -51,8 +51,7 @@ public:
void setActiveScan(bool active);
void setAdvertisedDeviceCallbacks(
BLEAdvertisedDeviceCallbacks* pAdvertisedDeviceCallbacks,
bool wantDuplicates = false,
bool shouldParse = true);
bool wantDuplicates = false);
void setInterval(uint16_t intervalMSecs);
void setWindow(uint16_t windowMSecs);
bool start(uint32_t duration, void (*scanCompleteCB)(BLEScanResults), bool is_continue = false);
@ -74,12 +73,11 @@ private:
esp_ble_scan_params_t m_scan_params;
BLEAdvertisedDeviceCallbacks* m_pAdvertisedDeviceCallbacks = nullptr;
bool m_stopped = true;
bool m_shouldParse = true;
FreeRTOS::Semaphore m_semaphoreScanEnd = FreeRTOS::Semaphore("ScanEnd");
BLEScanResults m_scanResults;
bool m_wantDuplicates;
void (*m_scanCompleteCB)(BLEScanResults scanResults);
}; // BLEScan
#endif /* CONFIG_BLUEDROID_ENABLED */
#endif /* CONFIG_BT_ENABLED */
#endif /* COMPONENTS_CPP_UTILS_BLESCAN_H_ */

View File

@ -7,7 +7,7 @@
#include "BLESecurity.h"
#include "sdkconfig.h"
#if defined(CONFIG_BLUEDROID_ENABLED)
#if defined(CONFIG_BT_ENABLED)
BLESecurity::BLESecurity() {
}
@ -61,17 +61,6 @@ void BLESecurity::setKeySize(uint8_t key_size) {
esp_ble_gap_set_security_param(ESP_BLE_SM_MAX_KEY_SIZE, &m_keySize, sizeof(uint8_t));
} //setKeySize
/**
* Setup for static PIN connection, call it first and then call setAuthenticationMode eventually to change it
*/
void BLESecurity::setStaticPIN(uint32_t pin){
uint32_t passkey = pin;
esp_ble_gap_set_security_param(ESP_BLE_SM_SET_STATIC_PASSKEY, &passkey, sizeof(uint32_t));
setCapability(ESP_IO_CAP_OUT);
setKeySize();
setAuthenticationMode(ESP_LE_AUTH_REQ_SC_ONLY);
setInitEncryptionKey(ESP_BLE_ENC_KEY_MASK | ESP_BLE_ID_KEY_MASK);
}
/**
* @brief Debug function to display what keys are exchanged by peers
@ -112,4 +101,4 @@ char* BLESecurity::esp_key_type_to_str(esp_ble_key_type_t key_type) {
}
return key_str;
} // esp_key_type_to_str
#endif // CONFIG_BLUEDROID_ENABLED
#endif // CONFIG_BT_ENABLED

View File

@ -8,7 +8,7 @@
#ifndef COMPONENTS_CPP_UTILS_BLESECURITY_H_
#define COMPONENTS_CPP_UTILS_BLESECURITY_H_
#include "sdkconfig.h"
#if defined(CONFIG_BLUEDROID_ENABLED)
#if defined(CONFIG_BT_ENABLED)
#include <esp_gap_ble_api.h>
@ -21,7 +21,6 @@ public:
void setInitEncryptionKey(uint8_t init_key);
void setRespEncryptionKey(uint8_t resp_key);
void setKeySize(uint8_t key_size = 16);
void setStaticPIN(uint32_t pin);
static char* esp_key_type_to_str(esp_ble_key_type_t key_type);
private:
@ -69,5 +68,5 @@ public:
virtual bool onConfirmPIN(uint32_t pin) = 0;
}; // BLESecurityCallbacks
#endif // CONFIG_BLUEDROID_ENABLED
#endif // CONFIG_BT_ENABLED
#endif // COMPONENTS_CPP_UTILS_BLESECURITY_H_

View File

@ -6,7 +6,7 @@
*/
#include "sdkconfig.h"
#if defined(CONFIG_BLUEDROID_ENABLED)
#if defined(CONFIG_BT_ENABLED)
#include <esp_bt.h>
#include <esp_bt_main.h>
#include "GeneralUtils.h"
@ -423,4 +423,4 @@ void BLEServer::disconnect(uint16_t connId) {
esp_ble_gatts_close(m_gatts_if, connId);
}
#endif // CONFIG_BLUEDROID_ENABLED
#endif // CONFIG_BT_ENABLED

View File

@ -8,7 +8,7 @@
#ifndef COMPONENTS_CPP_UTILS_BLESERVER_H_
#define COMPONENTS_CPP_UTILS_BLESERVER_H_
#include "sdkconfig.h"
#if defined(CONFIG_BLUEDROID_ENABLED)
#if defined(CONFIG_BT_ENABLED)
#include <esp_gatts_api.h>
#include <string>
@ -137,5 +137,5 @@ public:
}; // BLEServerCallbacks
#endif /* CONFIG_BLUEDROID_ENABLED */
#endif /* CONFIG_BT_ENABLED */
#endif /* COMPONENTS_CPP_UTILS_BLESERVER_H_ */

View File

@ -8,7 +8,7 @@
// A service is identified by a UUID. A service is also the container for one or more characteristics.
#include "sdkconfig.h"
#if defined(CONFIG_BLUEDROID_ENABLED)
#if defined(CONFIG_BT_ENABLED)
#include <esp_err.h>
#include <esp_gatts_api.h>
@ -410,4 +410,4 @@ BLEServer* BLEService::getServer() {
return m_pServer;
} // getServer
#endif // CONFIG_BLUEDROID_ENABLED
#endif // CONFIG_BT_ENABLED

View File

@ -8,7 +8,7 @@
#ifndef COMPONENTS_CPP_UTILS_BLESERVICE_H_
#define COMPONENTS_CPP_UTILS_BLESERVICE_H_
#include "sdkconfig.h"
#if defined(CONFIG_BLUEDROID_ENABLED)
#if defined(CONFIG_BT_ENABLED)
#include <esp_gatts_api.h>
@ -93,5 +93,5 @@ private:
}; // BLEService
#endif // CONFIG_BLUEDROID_ENABLED
#endif // CONFIG_BT_ENABLED
#endif /* COMPONENTS_CPP_UTILS_BLESERVICE_H_ */

View File

@ -5,7 +5,7 @@
* Author: kolban
*/
#include "sdkconfig.h"
#if defined(CONFIG_BLUEDROID_ENABLED)
#if defined(CONFIG_BT_ENABLED)
#include <stdio.h>
#include <iomanip>
#include "BLEService.h"
@ -134,4 +134,4 @@ int BLEServiceMap::getRegisteredServiceCount(){
return m_handleMap.size();
}
#endif /* CONFIG_BLUEDROID_ENABLED */
#endif /* CONFIG_BT_ENABLED */

View File

@ -5,7 +5,7 @@
* Author: kolban
*/
#include "sdkconfig.h"
#if defined(CONFIG_BLUEDROID_ENABLED)
#if defined(CONFIG_BT_ENABLED)
#include <string.h>
#include <sstream>
#include <iomanip>
@ -383,4 +383,4 @@ std::string BLEUUID::toString() {
return res;
} // toString
#endif /* CONFIG_BLUEDROID_ENABLED */
#endif /* CONFIG_BT_ENABLED */

View File

@ -8,9 +8,9 @@
#ifndef COMPONENTS_CPP_UTILS_BLEUUID_H_
#define COMPONENTS_CPP_UTILS_BLEUUID_H_
#include "sdkconfig.h"
#include <string>
#if CONFIG_BLUEDROID_ENABLED
#if defined(CONFIG_BT_ENABLED)
#include <esp_gatt_defs.h>
#include <string>
/**
* @brief A model of a %BLE UUID.
@ -35,5 +35,5 @@ private:
esp_bt_uuid_t m_uuid; // The underlying UUID structure that this class wraps.
bool m_valueSet = false; // Is there a value set for this instance.
}; // BLEUUID
#endif /* CONFIG_BLUEDROID_ENABLED */
#endif /* CONFIG_BT_ENABLED */
#endif /* COMPONENTS_CPP_UTILS_BLEUUID_H_ */

View File

@ -5,7 +5,7 @@
* Author: kolban
*/
#include "sdkconfig.h"
#if defined(CONFIG_BLUEDROID_ENABLED)
#if defined(CONFIG_BT_ENABLED)
#include "BLEAddress.h"
#include "BLEClient.h"
#include "BLEUtils.h"
@ -2037,4 +2037,4 @@ const char* BLEUtils::searchEventTypeToString(esp_gap_search_evt_t searchEvt) {
}
} // searchEventTypeToString
#endif // CONFIG_BLUEDROID_ENABLED
#endif // CONFIG_BT_ENABLED

View File

@ -8,7 +8,7 @@
#ifndef COMPONENTS_CPP_UTILS_BLEUTILS_H_
#define COMPONENTS_CPP_UTILS_BLEUTILS_H_
#include "sdkconfig.h"
#if defined(CONFIG_BLUEDROID_ENABLED)
#if defined(CONFIG_BT_ENABLED)
#include <esp_gattc_api.h> // ESP32 BLE
#include <esp_gatts_api.h> // ESP32 BLE
#include <esp_gap_ble_api.h> // ESP32 BLE
@ -59,5 +59,5 @@ public:
static const char* searchEventTypeToString(esp_gap_search_evt_t searchEvt);
};
#endif // CONFIG_BLUEDROID_ENABLED
#endif // CONFIG_BT_ENABLED
#endif /* COMPONENTS_CPP_UTILS_BLEUTILS_H_ */

View File

@ -5,7 +5,7 @@
* Author: kolban
*/
#include "sdkconfig.h"
#if defined(CONFIG_BLUEDROID_ENABLED)
#if defined(CONFIG_BT_ENABLED)
#include "BLEValue.h"
#include "esp32-hal-log.h"
@ -127,4 +127,4 @@ void BLEValue::setValue(uint8_t* pData, size_t length) {
} // setValue
#endif // CONFIG_BLUEDROID_ENABLED
#endif // CONFIG_BT_ENABLED

View File

@ -8,7 +8,7 @@
#ifndef COMPONENTS_CPP_UTILS_BLEVALUE_H_
#define COMPONENTS_CPP_UTILS_BLEVALUE_H_
#include "sdkconfig.h"
#if defined(CONFIG_BLUEDROID_ENABLED)
#if defined(CONFIG_BT_ENABLED)
#include <string>
/**
@ -35,5 +35,5 @@ private:
std::string m_value;
};
#endif // CONFIG_BLUEDROID_ENABLED
#endif // CONFIG_BT_ENABLED
#endif /* COMPONENTS_CPP_UTILS_BLEVALUE_H_ */

View File

@ -193,8 +193,8 @@ bool FreeRTOS::Semaphore::take(std::string owner) {
} else {
rc = ::xSemaphoreTake(m_semaphore, portMAX_DELAY) == pdTRUE;
}
if (rc) {
m_owner = owner;
if (rc) {
log_v("Semaphore taken: %s", toString().c_str());
} else {
log_e("Semaphore NOT taken: %s", toString().c_str());
@ -218,8 +218,8 @@ bool FreeRTOS::Semaphore::take(uint32_t timeoutMs, std::string owner) {
} else {
rc = ::xSemaphoreTake(m_semaphore, timeoutMs / portTICK_PERIOD_MS) == pdTRUE;
}
if (rc) {
m_owner = owner;
if (rc) {
log_v("Semaphore taken: %s", toString().c_str());
} else {
log_e("Semaphore NOT taken: %s", toString().c_str());

View File

@ -2,7 +2,7 @@
#include <DNSServer.h>
const byte DNS_PORT = 53;
IPAddress apIP(8,8,4,4); // The default android DNS
IPAddress apIP(192, 168, 1, 1);
DNSServer dnsServer;
WiFiServer server(80);
@ -12,9 +12,11 @@ String responseHTML = ""
"be redirected here.</p></body></html>";
void setup() {
WiFi.disconnect(); //added to start with the wifi off, avoid crashing
WiFi.mode(WIFI_OFF); //added to start with the wifi off, avoid crashing
WiFi.mode(WIFI_AP);
WiFi.softAP("ESP32-DNSServer");
WiFi.softAPConfig(apIP, apIP, IPAddress(255, 255, 255, 0));
WiFi.softAP("DNSServer CaptivePortal example");
// if DNSServer is started with "*" for domain name, it will reply with
// provided IP to all DNS request

View File

@ -2,12 +2,6 @@
#include <lwip/def.h>
#include <Arduino.h>
// #define DEBUG_ESP_DNS
#ifdef DEBUG_ESP_PORT
#define DEBUG_OUTPUT DEBUG_ESP_PORT
#else
#define DEBUG_OUTPUT Serial
#endif
DNSServer::DNSServer()
{
@ -190,11 +184,6 @@ void DNSServer::replyWithIP()
_udp.write((unsigned char*) &answerIPv4, 2 );
_udp.write(_resolvedIP, sizeof(_resolvedIP)); // The IP address to return
_udp.endPacket();
#ifdef DEBUG_ESP_DNS
DEBUG_OUTPUT.printf("DNS responds: %s for %s\n",
IPAddress(_resolvedIP).toString().c_str(), getDomainNameWithoutWwwPrefix().c_str() );
#endif
}
void DNSServer::replyWithCustomCode()

View File

@ -17,7 +17,6 @@ EEPROMClass AGE("eeprom2", 0x100);
void setup() {
Serial.begin(115200);
delay(1000);
Serial.println("Testing EEPROMClass\n");
if (!NAMES.begin(NAMES.length())) {
Serial.println("Failed to initialise NAMES");
@ -44,7 +43,7 @@ void setup() {
uint32_t age = 47;
// Write: Variables ---> EEPROM stores
NAMES.writeString(0, name);
NAMES.put(0, name);
HEIGHT.put(0, height);
AGE.put(0, age);
Serial.print("name: "); Serial.println(name);

View File

@ -1,29 +1,13 @@
/* The true ESP32 chip ID is essentially its MAC address.
This sketch provides an alternate chip ID that matches
the output of the ESP.getChipId() function on ESP8266
(i.e. a 32-bit integer matching the last 3 bytes of
the MAC address. This is less unique than the
MAC address chip ID, but is helpful when you need
an identifier that can be no more than a 32-bit integer
(like for switch...case).
created 2020-06-07 by cweinhofer
with help from Cicicok */
uint32_t chipId = 0;
uint64_t chipid;
void setup() {
Serial.begin(115200);
}
void loop() {
for(int i=0; i<17; i=i+8) {
chipId |= ((ESP.getEfuseMac() >> (40 - i)) & 0xff) << i;
}
Serial.printf("ESP32 Chip model = %s Rev %d\n", ESP.getChipModel(), ESP.getChipRevision());
Serial.printf("This chip has %d cores\n", ESP.getChipCores());
Serial.print("Chip ID: "); Serial.println(chipId);
chipid=ESP.getEfuseMac();//The chip ID is essentially its MAC address(length: 6 bytes).
Serial.printf("ESP32 Chip ID = %04X",(uint16_t)(chipid>>32));//print High 2 bytes
Serial.printf("%08X\n",(uint32_t)chipid);//print Low 4bytes.
delay(3000);

View File

@ -1,64 +0,0 @@
#include "Arduino.h"
#include "esp32-hal.h"
extern "C" void receive_trampoline(uint32_t *data, size_t len, void * arg);
class MyProcessor {
private:
rmt_obj_t* rmt_recv = NULL;
float realNanoTick;
uint32_t buff; // rolling buffer of most recent 32 bits.
int at = 0;
public:
MyProcessor(uint8_t pin, float nanoTicks) {
assert((rmt_recv = rmtInit(21, false, RMT_MEM_192)));
realNanoTick = rmtSetTick(rmt_recv, nanoTicks);
};
void begin() {
rmtRead(rmt_recv, receive_trampoline, this);
};
void process(rmt_data_t *data, size_t len) {
for (int i = 0; len; len--) {
if (data[i].duration0 == 0)
break;
buff = (buff << 1) | (data[i].level0 ? 1 : 0);
i++;
if (data[i].duration1 == 0)
break;
buff = (buff << 1) | (data[i].level1 ? 1 : 0);
i++;
};
};
uint32_t val() {
return buff;
}
};
void receive_trampoline(uint32_t *data, size_t len, void * arg)
{
MyProcessor * p = (MyProcessor *)arg;
p->process((rmt_data_t*) data, len);
}
// Attach 3 processors to GPIO 4, 5 and 10 with different tick/speeds.
MyProcessor mp1 = MyProcessor(4, 1000);
MyProcessor mp2 = MyProcessor(5, 1000);
MyProcessor mp3 = MyProcessor(10, 500);
void setup()
{
Serial.begin(115200);
mp1.begin();
mp2.begin();
mp3.begin();
}
void loop()
{
Serial.printf("GPIO 4: %08x 5: %08x 6: %08x\n", mp1.val(), mp2.val(), mp3.val());
delay(500);
}

View File

@ -16,7 +16,6 @@ static EventGroupHandle_t events;
void setup()
{
Serial.begin(115200);
events = xEventGroupCreate();
if ((rmt_send = rmtInit(18, true, RMT_MEM_64)) == NULL)
{

View File

@ -172,7 +172,7 @@ void parseRmt(rmt_data_t* items, size_t len, uint32_t* channels){
}
}
extern "C" void receive_data(uint32_t *data, size_t len, void * arg)
extern "C" void receive_data(uint32_t *data, size_t len)
{
parseRmt((rmt_data_t*) data, len, channels);
}
@ -192,7 +192,7 @@ void setup()
Serial.printf("real tick set to: %fns\n", realTick);
// Ask to start reading
rmtRead(rmt_recv, receive_data, NULL);
rmtRead(rmt_recv, receive_data);
}
void loop()

Some files were not shown because too many files have changed in this diff Show More