Skip to content

Commit

Permalink
Merge branch 'master' into args
Browse files Browse the repository at this point in the history
  • Loading branch information
SuGlider authored Jul 14, 2022
2 parents 480e4fb + 205db02 commit 2c12bcd
Show file tree
Hide file tree
Showing 1,107 changed files with 79,640 additions and 8,880 deletions.
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/Issue-report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ body:
options:
- latest master (checkout manually)
- latest development Release Candidate (RC-X)
- v2.0.4
- v2.0.3
- v2.0.2
- v2.0.1
Expand Down
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ set(CORE_SRCS
cores/esp32/esp32-hal-matrix.c
cores/esp32/esp32-hal-misc.c
cores/esp32/esp32-hal-psram.c
cores/esp32/esp32-hal-rgb-led.c
cores/esp32/esp32-hal-sigmadelta.c
cores/esp32/esp32-hal-spi.c
cores/esp32/esp32-hal-time.c
Expand Down
1,099 changes: 915 additions & 184 deletions boards.txt

Large diffs are not rendered by default.

5 changes: 1 addition & 4 deletions cores/esp32/Tone.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,8 @@ static void tone_task(void*){
log_d("Task received from queue TONE_START: _pin=%d, frequency=%u Hz, duration=%lu ms", tone_msg.pin, tone_msg.frequency, tone_msg.duration);

log_d("Setup LED controll on channel %d", _channel);
// ledcSetup(_channel, tone_msg.frequency, 11);
// ledcAttachPin(tone_msg.pin, _channel);
// ledcWrite(_channel, 1024);
ledcWriteTone(_channel, tone_msg.frequency);
ledcAttachPin(tone_msg.pin, _channel);
ledcWriteTone(_channel, tone_msg.frequency);

if(tone_msg.duration){
delay(tone_msg.duration);
Expand Down
15 changes: 15 additions & 0 deletions cores/esp32/esp32-hal-gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,13 @@ static InterruptHandle_t __pinInterruptHandlers[SOC_GPIO_PIN_COUNT] = {0,};

extern void ARDUINO_ISR_ATTR __pinMode(uint8_t pin, uint8_t mode)
{
#ifdef BOARD_HAS_NEOPIXEL
if (pin == LED_BUILTIN){
__pinMode(LED_BUILTIN-SOC_GPIO_PIN_COUNT, mode);
return;
}
#endif

if (!GPIO_IS_VALID_GPIO(pin)) {
log_e("Invalid pin selected");
return;
Expand Down Expand Up @@ -127,6 +134,14 @@ extern void ARDUINO_ISR_ATTR __pinMode(uint8_t pin, uint8_t mode)

extern void ARDUINO_ISR_ATTR __digitalWrite(uint8_t pin, uint8_t val)
{
#ifdef BOARD_HAS_NEOPIXEL
if(pin == LED_BUILTIN){
//use RMT to set all channels on/off
const uint8_t comm_val = val != 0 ? LED_BRIGHTNESS : 0;
neopixelWrite(LED_BUILTIN, comm_val, comm_val, comm_val);
return;
}
#endif
gpio_set_level((gpio_num_t)pin, val);
}

Expand Down
2 changes: 2 additions & 0 deletions cores/esp32/esp32-hal-gpio.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ extern "C" {

#include "esp32-hal.h"
#include "soc/soc_caps.h"
#include "pins_arduino.h"

#if (CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3)
#define NUM_OUPUT_PINS 46
Expand Down Expand Up @@ -63,6 +64,7 @@ extern "C" {
#define ONLOW_WE 0x0C
#define ONHIGH_WE 0x0D


#define digitalPinIsValid(pin) GPIO_IS_VALID_GPIO(pin)
#define digitalPinCanOutput(pin) GPIO_IS_VALID_OUTPUT_GPIO(pin)

Expand Down
47 changes: 47 additions & 0 deletions cores/esp32/esp32-hal-rgb-led.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#include "esp32-hal-rgb-led.h"


void neopixelWrite(uint8_t pin, uint8_t red_val, uint8_t green_val, uint8_t blue_val){
rmt_data_t led_data[24];
static rmt_obj_t* rmt_send = NULL;
static bool initialized = false;

uint8_t _pin = pin;
#ifdef BOARD_HAS_NEOPIXEL
if(pin == LED_BUILTIN){
_pin = LED_BUILTIN-SOC_GPIO_PIN_COUNT;
}
#endif

if(!initialized){
if((rmt_send = rmtInit(_pin, RMT_TX_MODE, RMT_MEM_64)) == NULL){
log_e("RGB LED driver initialization failed!");
rmt_send = NULL;
return;
}
rmtSetTick(rmt_send, 100);
initialized = true;
}

int color[] = {green_val, red_val, blue_val}; // Color coding is in order GREEN, RED, BLUE
int i = 0;
for(int col=0; col<3; col++ ){
for(int bit=0; bit<8; bit++){
if((color[col] & (1<<(7-bit)))){
// HIGH bit
led_data[i].level0 = 1; // T1H
led_data[i].duration0 = 8; // 0.8us
led_data[i].level1 = 0; // T1L
led_data[i].duration1 = 4; // 0.4us
}else{
// LOW bit
led_data[i].level0 = 1; // T0H
led_data[i].duration0 = 4; // 0.4us
led_data[i].level1 = 0; // T0L
led_data[i].duration1 = 8; // 0.8us
}
i++;
}
}
rmtWrite(rmt_send, led_data, 24);
}
20 changes: 20 additions & 0 deletions cores/esp32/esp32-hal-rgb-led.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#ifndef MAIN_ESP32_HAL_RGB_LED_H_
#define MAIN_ESP32_HAL_RGB_LED_H_

#ifdef __cplusplus
extern "C" {
#endif

#include "esp32-hal.h"

#ifndef LED_BRIGHTNESS
#define LED_BRIGHTNESS 64
#endif

void neopixelWrite(uint8_t pin, uint8_t red_val, uint8_t green_val, uint8_t blue_val);

#ifdef __cplusplus
}
#endif

#endif /* MAIN_ESP32_HAL_RGB_LED_H_ */
1 change: 1 addition & 0 deletions cores/esp32/esp32-hal.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ void yield(void);
#include "esp32-hal-timer.h"
#include "esp32-hal-bt.h"
#include "esp32-hal-psram.h"
#include "esp32-hal-rgb-led.h"
#include "esp32-hal-cpu.h"

void analogWrite(uint8_t pin, int value);
Expand Down
36 changes: 18 additions & 18 deletions docs/source/api/wifi.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ The Wi-Fi API provides support for the 802.11b/g/n protocol driver. This API inc

* AP mode (aka Soft-AP mode or Access Point mode). Devices connect to the ESP32

* Security modes (WPA, WPA2, WEP, etc.)
* Security modes (WPA2, WPA3 etc.)

* Scanning for access points

Expand Down Expand Up @@ -446,26 +446,12 @@ Return the connection state.
setAutoConnect
**************

Function used to set the automatic connection.

.. code-block:: arduino
bool setAutoConnect(bool autoConnect);
Where:

* ``bool autoConnect`` is set to ``true`` to enable this option.
Function is deprecated.

getAutoConnect
**************

Function used to get the automatic connection setting value.

.. code-block:: arduino
bool getAutoConnect();
The function will return ``true`` if the setting is enabled.
Function is deprecated.

setAutoReconnect
****************
Expand All @@ -484,11 +470,25 @@ getAutoReconnect
****************

Function used to get the automatic reconnection if the connection is lost.

.. code-block:: arduino
bool getAutoReconnect();
The function will return ``true`` if this setting is enabled.
The function will return ``true`` if this setting is enabled.

setMinSecurity
**************

Function used to set the minimum security for AP to be considered connectable.

.. code-block:: arduino
bool setMinSecurity(wifi_auth_mode_t minSecurity);
Where:

* ``minSecurity`` is the minimum security for AP to be considered connectable. Default is ``WIFI_AUTH_WPA2_PSK``.

WiFiMulti
---------
Expand Down
39 changes: 39 additions & 0 deletions docs/source/troubleshooting.rst
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,42 @@ Solution
* Change the USB port.
* Check your power supply.
* Check if the board is damaged or defective.

Wi-Fi
-----

Why does the board not connect to WEP/WPA-"encrypted" Wi-Fi?
************************************************************

Please note that WEP/WPA has significant security vulnerabilities and its use is strongly discouraged.
The support may therefore be removed in the future. Please migrate to WPA2 or newer.

Solution
^^^^^^^^

Nevertheless, it may be necessary to connect to insecure networks. To do this, the security requirement of the ESP32 must be lowered to an insecure level by using:

.. code-block:: arduino
WiFi.setMinSecurity(WIFI_AUTH_WEP); // Lower min security to WEP.
// or
WiFi.setMinSecurity(WIFI_AUTH_WPA_PSK); // Lower min security to WPA.
Why does the board not connect to WPA3-encrypted Wi-Fi?
*******************************************************

WPA3 support is resource intensive and may not be compiled into the used SDK.

Solution
^^^^^^^^

* Check WPA3 support by your SDK.
* Compile your custom SDK with WPA3 support.

Sample code to check SDK WPA3 support at compile time:

.. code-block:: arduino
#ifndef CONFIG_ESP32_WIFI_ENABLE_WPA3_SAE
#warning "No WPA3 support."
#endif
2 changes: 2 additions & 0 deletions libraries/BLE/src/BLE2902.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ void BLE2902::setIndications(bool flag) {
uint8_t *pValue = getValue();
if (flag) pValue[0] |= 1 << 1;
else pValue[0] &= ~(1 << 1);
setValue(pValue, 2);
} // setIndications


Expand All @@ -57,6 +58,7 @@ void BLE2902::setNotifications(bool flag) {
uint8_t *pValue = getValue();
if (flag) pValue[0] |= 1 << 0;
else pValue[0] &= ~(1 << 0);
setValue(pValue, 2);
} // setNotifications

#endif
6 changes: 5 additions & 1 deletion libraries/BLE/src/BLEDescriptor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ BLEDescriptor::BLEDescriptor(const char* uuid, uint16_t len) : BLEDescriptor(BLE
BLEDescriptor::BLEDescriptor(BLEUUID uuid, uint16_t max_len) {
m_bleUUID = uuid;
m_value.attr_len = 0; // Initial length is 0.
m_value.attr_max_len = max_len; // Maximum length of the data.
m_value.attr_max_len = max_len; // Maximum length of the data.
m_handle = NULL_HANDLE; // Handle is initially unknown.
m_pCharacteristic = nullptr; // No initial characteristic.
m_pCallback = nullptr; // No initial callback.
Expand Down Expand Up @@ -235,6 +235,10 @@ void BLEDescriptor::setValue(uint8_t* data, size_t length) {
}
m_value.attr_len = length;
memcpy(m_value.attr_value, data, length);
if (m_handle != NULL_HANDLE) {
esp_ble_gatts_set_attr_value(m_handle, length, (const uint8_t *)data);
log_d("Set the value in the GATTS database using handle 0x%x", m_handle);
}
} // setValue


Expand Down
2 changes: 1 addition & 1 deletion libraries/BLE/src/BLEDescriptor.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class BLEDescriptor {
uint16_t m_handle;
BLEDescriptorCallbacks* m_pCallback;
BLECharacteristic* m_pCharacteristic;
esp_gatt_perm_t m_permissions = ESP_GATT_PERM_READ | ESP_GATT_PERM_WRITE;
esp_gatt_perm_t m_permissions = ESP_GATT_PERM_READ | ESP_GATT_PERM_WRITE;
FreeRTOS::Semaphore m_semaphoreCreateEvt = FreeRTOS::Semaphore("CreateEvt");
esp_attr_value_t m_value;

Expand Down
21 changes: 19 additions & 2 deletions libraries/BLE/src/BLERemoteDescriptor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,26 @@ BLEUUID BLERemoteDescriptor::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) {
// ESP_GATTC_READ_DESCR_EVT
// This event indicates that the server has responded to the read request.
//
// read:
// - esp_gatt_status_t status
// - uint16_t conn_id
// - uint16_t handle
// - uint8_t* value
// - uint16_t value_len
case ESP_GATTC_READ_DESCR_EVT:
if (evtParam->read.handle != getHandle())
break;
// If this event is not for us, then nothing further to do.
if (evtParam->read.handle != getHandle()) break;
// At this point, we have determined that the event is for us, so now we save the value
if (evtParam->read.status == ESP_GATT_OK) {
// it will read the cached value of the descriptor
m_value = std::string((char*) evtParam->read.value, evtParam->read.value_len);
} else {
m_value = "";
}
// Unlock the semaphore to ensure that the requestor of the data can continue.
m_semaphoreReadDescrEvt.give();
break;

Expand Down
Loading

0 comments on commit 2c12bcd

Please sign in to comment.