From dfa5e8dbffbd42d72778b2206d09be7596972637 Mon Sep 17 00:00:00 2001 From: Tyeth Gundry Date: Mon, 10 Apr 2023 13:21:20 +0100 Subject: [PATCH 1/4] Update installing to use CDN backed github links (#7876) This increases the reliability of users hitting the boardsmanager urls, improving speed and avoiding request throttling, by using the github CDN frontend as mentioned in this old ticket: https://github.com/espressif/arduino-esp32/issues/3505#issuecomment-1438813967 Co-authored-by: Me No Dev --- docs/source/installing.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/source/installing.rst b/docs/source/installing.rst index 6120973fb87..c3bd268949b 100644 --- a/docs/source/installing.rst +++ b/docs/source/installing.rst @@ -25,11 +25,11 @@ This is the way to install Arduino-ESP32 directly from the Arduino IDE. - Stable release link:: - https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json + https://espressif.github.io/arduino-esp32/package_esp32_index.json - Development release link:: - https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_dev_index.json + https://espressif.github.io/arduino-esp32/package_esp32_dev_index.json .. note:: From ab7ce5a51172e9bdde4f6792124bae96cb6e3f6b Mon Sep 17 00:00:00 2001 From: Sanket Wadekar <67091512+sanketwadekar@users.noreply.github.com> Date: Mon, 10 Apr 2023 20:16:02 +0530 Subject: [PATCH 2/4] Add Insights in Rainmaker Switch example (#8011) * insights: add support for custom transport * Added insights in rainmaker switch example --- CMakeLists.txt | 1 + libraries/Insights/src/Insights.cpp | 9 ++- libraries/Insights/src/Insights.h | 2 +- .../examples/RMakerSwitch/RMakerSwitch.ino | 4 + libraries/RainMaker/src/AppInsights.cpp | 81 +++++++++++++++++++ libraries/RainMaker/src/AppInsights.h | 12 +++ 6 files changed, 106 insertions(+), 3 deletions(-) create mode 100644 libraries/RainMaker/src/AppInsights.cpp create mode 100644 libraries/RainMaker/src/AppInsights.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 851d1488eca..2518b0be093 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -99,6 +99,7 @@ set(LIBRARY_SRCS libraries/RainMaker/src/RMakerType.cpp libraries/RainMaker/src/RMakerQR.cpp libraries/RainMaker/src/RMakerUtils.cpp + libraries/RainMaker/src/AppInsights.cpp libraries/SD_MMC/src/SD_MMC.cpp libraries/SD/src/SD.cpp libraries/SD/src/sd_diskio.cpp diff --git a/libraries/Insights/src/Insights.cpp b/libraries/Insights/src/Insights.cpp index 0ec65e86727..49de5b2035a 100644 --- a/libraries/Insights/src/Insights.cpp +++ b/libraries/Insights/src/Insights.cpp @@ -49,13 +49,18 @@ ESPInsightsClass::~ESPInsightsClass(){ end(); } -bool ESPInsightsClass::begin(const char *auth_key, const char *node_id, uint32_t log_type, bool alloc_ext_ram){ +bool ESPInsightsClass::begin(const char *auth_key, const char *node_id, uint32_t log_type, bool alloc_ext_ram, bool use_default_transport){ if(!initialized){ if(log_type == 0xFFFFFFFF){ log_type = (ESP_DIAG_LOG_TYPE_ERROR | ESP_DIAG_LOG_TYPE_WARNING | ESP_DIAG_LOG_TYPE_EVENT); } esp_insights_config_t config = {.log_type = log_type, .node_id = node_id, .auth_key = auth_key, .alloc_ext_ram = alloc_ext_ram}; - esp_err_t err = esp_insights_init(&config); + esp_err_t err = ESP_OK; + if (use_default_transport) { + err = esp_insights_init(&config); + } else { + err = esp_insights_enable(&config); + } if (err != ESP_OK) { log_e("Failed to initialize ESP Insights, err:0x%x", err); } diff --git a/libraries/Insights/src/Insights.h b/libraries/Insights/src/Insights.h index b950b937b14..d572c35a012 100644 --- a/libraries/Insights/src/Insights.h +++ b/libraries/Insights/src/Insights.h @@ -90,7 +90,7 @@ class ESPInsightsClass ESPInsightsClass(); ~ESPInsightsClass(); - bool begin(const char *auth_key, const char *node_id = NULL, uint32_t log_type = 0xFFFFFFFF, bool alloc_ext_ram = false); + bool begin(const char *auth_key, const char *node_id = NULL, uint32_t log_type = 0xFFFFFFFF, bool alloc_ext_ram = false, bool use_default_transport = true); void end(); bool send(); const char * nodeID(); diff --git a/libraries/RainMaker/examples/RMakerSwitch/RMakerSwitch.ino b/libraries/RainMaker/examples/RMakerSwitch/RMakerSwitch.ino index 32a1a28601f..688feed9bf7 100644 --- a/libraries/RainMaker/examples/RMakerSwitch/RMakerSwitch.ino +++ b/libraries/RainMaker/examples/RMakerSwitch/RMakerSwitch.ino @@ -2,6 +2,7 @@ #include "RMaker.h" #include "WiFi.h" #include "WiFiProv.h" +#include "AppInsights.h" #define DEFAULT_POWER_MODE true const char *service_name = "PROV_1234"; @@ -98,6 +99,9 @@ void setup() RMaker.enableSchedule(); RMaker.enableScenes(); + // Enable ESP Insights. Insteads of using the default http transport, this function will + // reuse the existing MQTT connection of Rainmaker, thereby saving memory space. + initAppInsights(); RMaker.enableSystemService(SYSTEM_SERV_FLAGS_ALL, 2, 2, 2); diff --git a/libraries/RainMaker/src/AppInsights.cpp b/libraries/RainMaker/src/AppInsights.cpp new file mode 100644 index 00000000000..591f5e65dcc --- /dev/null +++ b/libraries/RainMaker/src/AppInsights.cpp @@ -0,0 +1,81 @@ +/* + * SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include "sdkconfig.h" +#include +#if defined(CONFIG_ESP_INSIGHTS_ENABLED) && defined(CONFIG_ESP_RMAKER_WORK_QUEUE_TASK_STACK) +#include "Arduino.h" +#include "AppInsights.h" +#include "Insights.h" +#include +#include +#include +#include +#include + +extern "C" { + bool esp_rmaker_mqtt_is_budget_available(); +} + +#define INSIGHTS_TOPIC_SUFFIX "diagnostics/from-node" +#define INSIGHTS_TOPIC_RULE "insights_message_delivery" + +static void _rmakerCommonEventHandler(void* arg, esp_event_base_t event_base, int32_t event_id, void* event_data) +{ + if (event_base != RMAKER_COMMON_EVENT) { + return; + } + esp_insights_transport_event_data_t data; + switch(event_id) { + case RMAKER_MQTT_EVENT_PUBLISHED: + memset(&data, 0, sizeof(data)); + data.msg_id = *(int *)event_data; + esp_event_post(INSIGHTS_EVENT, INSIGHTS_EVENT_TRANSPORT_SEND_SUCCESS, &data, sizeof(data), portMAX_DELAY); + break; + default: + break; + } +} + +static int _appInsightsDataSend(void *data, size_t len) +{ + char topic[128]; + int msg_id = -1; + if (data == NULL) { + return 0; + } + char *node_id = esp_rmaker_get_node_id(); + if (!node_id) { + return -1; + } + if (esp_rmaker_mqtt_is_budget_available() == false) { + return ESP_FAIL; + } + esp_rmaker_create_mqtt_topic(topic, sizeof(topic), INSIGHTS_TOPIC_SUFFIX, INSIGHTS_TOPIC_RULE); + esp_rmaker_mqtt_publish(topic, data, len, RMAKER_MQTT_QOS1, &msg_id); + return msg_id; +} + +bool initAppInsights(uint32_t log_type, bool alloc_ext_ram) +{ + char *node_id = esp_rmaker_get_node_id(); + esp_insights_transport_config_t transport; + transport.userdata = NULL; + transport.callbacks.data_send = _appInsightsDataSend; + transport.callbacks.init = NULL; + transport.callbacks.deinit = NULL; + transport.callbacks.connect = NULL; + transport.callbacks.disconnect = NULL; + esp_insights_transport_register(&transport); + esp_event_handler_register(RMAKER_COMMON_EVENT, ESP_EVENT_ANY_ID, _rmakerCommonEventHandler, NULL); + return Insights.begin(NULL, node_id, log_type, alloc_ext_ram, false); +} +#else +bool initAppInsights(uint32_t log_type, bool alloc_ext_ram) +{ + return false; +} +#endif diff --git a/libraries/RainMaker/src/AppInsights.h b/libraries/RainMaker/src/AppInsights.h new file mode 100644 index 00000000000..ddb32f1e266 --- /dev/null +++ b/libraries/RainMaker/src/AppInsights.h @@ -0,0 +1,12 @@ +/* + * SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#pragma once +#include "sdkconfig.h" +#include "Arduino.h" +#include + +bool initAppInsights(uint32_t log_type = 0xffffffff, bool alloc_ext_ram = false); From c7eeeda5067a6a83306b92cb733c1773cff860ae Mon Sep 17 00:00:00 2001 From: Dogus Cendek Date: Mon, 10 Apr 2023 18:20:37 +0300 Subject: [PATCH 3/4] Update UploadMode Config of Deneyap Kart 1A v2 (#8046) --- boards.txt | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/boards.txt b/boards.txt index a8f1725380f..48c0b8b940a 100644 --- a/boards.txt +++ b/boards.txt @@ -17817,12 +17817,12 @@ deneyapkart1Av2.menu.DFUOnBoot.default.build.dfu_on_boot=0 deneyapkart1Av2.menu.DFUOnBoot.dfu=Enabled (Requires USB-OTG Mode) deneyapkart1Av2.menu.DFUOnBoot.dfu.build.dfu_on_boot=1 -deneyapkart1Av2.menu.UploadMode.default=UART0 / Hardware CDC -deneyapkart1Av2.menu.UploadMode.default.upload.use_1200bps_touch=false -deneyapkart1Av2.menu.UploadMode.default.upload.wait_for_upload_port=false deneyapkart1Av2.menu.UploadMode.cdc=USB-OTG CDC (TinyUSB) deneyapkart1Av2.menu.UploadMode.cdc.upload.use_1200bps_touch=true deneyapkart1Av2.menu.UploadMode.cdc.upload.wait_for_upload_port=true +deneyapkart1Av2.menu.UploadMode.default=UART0 / Hardware CDC +deneyapkart1Av2.menu.UploadMode.default.upload.use_1200bps_touch=false +deneyapkart1Av2.menu.UploadMode.default.upload.wait_for_upload_port=false deneyapkart1Av2.menu.PartitionScheme.default=Default 4MB with spiffs (1.2MB APP/1.5MB SPIFFS) deneyapkart1Av2.menu.PartitionScheme.default.build.partitions=default @@ -22714,5 +22714,3 @@ crabik_slot_esp32_s3.menu.EraseFlash.all=Enabled crabik_slot_esp32_s3.menu.EraseFlash.all.upload.erase_cmd=-e ############################################################## - - From 224e778b8ed7728a2b104c98c232f34fa34a357c Mon Sep 17 00:00:00 2001 From: Rodrigo Garcia Date: Mon, 10 Apr 2023 17:43:09 -0300 Subject: [PATCH 4/4] Makes Gamepad example able to be tested with Windows 10/11 (#8058) * Makes sure it can be tested with Windows 10/11 Initial code had no effect with Win10/11 because BUTTON_START was not recognized. This change makes it visible in the Windows Game Controller Testing TAB. * Examples tests all USB gamepad APIs. It is possible to change the selected gamepad button when pressing BOOT (long/short press). The selected button is used as parameter to change R/L Stick and Trigger as well as the Hat. --- libraries/USB/examples/Gamepad/Gamepad.ino | 34 ++++++++++++++++++++-- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/libraries/USB/examples/Gamepad/Gamepad.ino b/libraries/USB/examples/Gamepad/Gamepad.ino index dad75723797..fa2a2a3bc6f 100644 --- a/libraries/USB/examples/Gamepad/Gamepad.ino +++ b/libraries/USB/examples/Gamepad/Gamepad.ino @@ -14,13 +14,41 @@ void setup() { pinMode(buttonPin, INPUT_PULLUP); Gamepad.begin(); USB.begin(); + Serial.begin(115200); + Serial.println("\n==================\nUSB Gamepad Testing\n==================\n"); + Serial.println("Press BOOT Button to activate the USB gamepad."); + Serial.println("Longer press will change the affected button and controls."); + Serial.println("Shorter press/release just activates the button and controls."); } void loop() { + static uint8_t padID = 0; + static long lastPress = 0; + int buttonState = digitalRead(buttonPin); - if ((buttonState != previousButtonState) && (buttonState == LOW)) { - Gamepad.pressButton(BUTTON_START); - Gamepad.releaseButton(BUTTON_START); + if (buttonState != previousButtonState) { + if (buttonState == LOW) { // BOOT Button pressed + Gamepad.pressButton(padID); // Buttons 1 to 32 + Gamepad.leftStick(padID << 3, padID << 3); // X Axis, Y Axis + Gamepad.rightStick(-(padID << 2), padID << 2); // Z Axis, Z Rotation + Gamepad.leftTrigger(padID << 4); // X Rotation + Gamepad.rightTrigger(-(padID << 4)); // Y Rotation + Gamepad.hat((padID & 0x7) + 1); // Point of View Hat + log_d("Pressed PadID [%d]", padID); + lastPress = millis(); + } else { + Gamepad.releaseButton(padID); + Gamepad.leftStick(0, 0); + Gamepad.rightStick(0, 0); + Gamepad.leftTrigger(0); + Gamepad.rightTrigger(0); + Gamepad.hat(HAT_CENTER); + log_d("Released PadID [%d]\n", padID); + if (millis() - lastPress > 300) { + padID = (padID + 1) & 0x1F; + log_d("Changed padID to %d\n", padID); + } + } } previousButtonState = buttonState; }