Skip to content

Commit fef0ee0

Browse files
authored
Merge pull request #206 from tasmota/master
Upstream
2 parents 610aa22 + 9b4064b commit fef0ee0

File tree

8 files changed

+141
-13
lines changed

8 files changed

+141
-13
lines changed

boards.txt

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17817,12 +17817,12 @@ deneyapkart1Av2.menu.DFUOnBoot.default.build.dfu_on_boot=0
1781717817
deneyapkart1Av2.menu.DFUOnBoot.dfu=Enabled (Requires USB-OTG Mode)
1781817818
deneyapkart1Av2.menu.DFUOnBoot.dfu.build.dfu_on_boot=1
1781917819

17820-
deneyapkart1Av2.menu.UploadMode.default=UART0 / Hardware CDC
17821-
deneyapkart1Av2.menu.UploadMode.default.upload.use_1200bps_touch=false
17822-
deneyapkart1Av2.menu.UploadMode.default.upload.wait_for_upload_port=false
1782317820
deneyapkart1Av2.menu.UploadMode.cdc=USB-OTG CDC (TinyUSB)
1782417821
deneyapkart1Av2.menu.UploadMode.cdc.upload.use_1200bps_touch=true
1782517822
deneyapkart1Av2.menu.UploadMode.cdc.upload.wait_for_upload_port=true
17823+
deneyapkart1Av2.menu.UploadMode.default=UART0 / Hardware CDC
17824+
deneyapkart1Av2.menu.UploadMode.default.upload.use_1200bps_touch=false
17825+
deneyapkart1Av2.menu.UploadMode.default.upload.wait_for_upload_port=false
1782617826

1782717827
deneyapkart1Av2.menu.PartitionScheme.default=Default 4MB with spiffs (1.2MB APP/1.5MB SPIFFS)
1782817828
deneyapkart1Av2.menu.PartitionScheme.default.build.partitions=default
@@ -22714,5 +22714,3 @@ crabik_slot_esp32_s3.menu.EraseFlash.all=Enabled
2271422714
crabik_slot_esp32_s3.menu.EraseFlash.all.upload.erase_cmd=-e
2271522715

2271622716
##############################################################
22717-
22718-

docs/source/installing.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ This is the way to install Arduino-ESP32 directly from the Arduino IDE.
2525

2626
- Stable release link::
2727

28-
https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json
28+
https://espressif.github.io/arduino-esp32/package_esp32_index.json
2929

3030
- Development release link::
3131

32-
https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_dev_index.json
32+
https://espressif.github.io/arduino-esp32/package_esp32_dev_index.json
3333

3434

3535
.. note::

libraries/Insights/src/Insights.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,18 @@ ESPInsightsClass::~ESPInsightsClass(){
4949
end();
5050
}
5151

52-
bool ESPInsightsClass::begin(const char *auth_key, const char *node_id, uint32_t log_type, bool alloc_ext_ram){
52+
bool ESPInsightsClass::begin(const char *auth_key, const char *node_id, uint32_t log_type, bool alloc_ext_ram, bool use_default_transport){
5353
if(!initialized){
5454
if(log_type == 0xFFFFFFFF){
5555
log_type = (ESP_DIAG_LOG_TYPE_ERROR | ESP_DIAG_LOG_TYPE_WARNING | ESP_DIAG_LOG_TYPE_EVENT);
5656
}
5757
esp_insights_config_t config = {.log_type = log_type, .node_id = node_id, .auth_key = auth_key, .alloc_ext_ram = alloc_ext_ram};
58-
esp_err_t err = esp_insights_init(&config);
58+
esp_err_t err = ESP_OK;
59+
if (use_default_transport) {
60+
err = esp_insights_init(&config);
61+
} else {
62+
err = esp_insights_enable(&config);
63+
}
5964
if (err != ESP_OK) {
6065
log_e("Failed to initialize ESP Insights, err:0x%x", err);
6166
}

libraries/Insights/src/Insights.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ class ESPInsightsClass
9090
ESPInsightsClass();
9191
~ESPInsightsClass();
9292

93-
bool begin(const char *auth_key, const char *node_id = NULL, uint32_t log_type = 0xFFFFFFFF, bool alloc_ext_ram = false);
93+
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);
9494
void end();
9595
bool send();
9696
const char * nodeID();

libraries/RainMaker/examples/RMakerSwitch/RMakerSwitch.ino

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#include "RMaker.h"
33
#include "WiFi.h"
44
#include "WiFiProv.h"
5+
#include "AppInsights.h"
56

67
#define DEFAULT_POWER_MODE true
78
const char *service_name = "PROV_1234";
@@ -98,6 +99,9 @@ void setup()
9899
RMaker.enableSchedule();
99100

100101
RMaker.enableScenes();
102+
// Enable ESP Insights. Insteads of using the default http transport, this function will
103+
// reuse the existing MQTT connection of Rainmaker, thereby saving memory space.
104+
initAppInsights();
101105

102106
RMaker.enableSystemService(SYSTEM_SERV_FLAGS_ALL, 2, 2, 2);
103107

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
/*
2+
* SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#include "sdkconfig.h"
8+
#include <inttypes.h>
9+
#if defined(CONFIG_ESP_INSIGHTS_ENABLED) && defined(CONFIG_ESP_RMAKER_WORK_QUEUE_TASK_STACK)
10+
#include "Arduino.h"
11+
#include "AppInsights.h"
12+
#include "Insights.h"
13+
#include <esp_rmaker_mqtt.h>
14+
#include <esp_insights.h>
15+
#include <esp_diagnostics.h>
16+
#include <esp_rmaker_core.h>
17+
#include <esp_rmaker_common_events.h>
18+
19+
extern "C" {
20+
bool esp_rmaker_mqtt_is_budget_available();
21+
}
22+
23+
#define INSIGHTS_TOPIC_SUFFIX "diagnostics/from-node"
24+
#define INSIGHTS_TOPIC_RULE "insights_message_delivery"
25+
26+
static void _rmakerCommonEventHandler(void* arg, esp_event_base_t event_base, int32_t event_id, void* event_data)
27+
{
28+
if (event_base != RMAKER_COMMON_EVENT) {
29+
return;
30+
}
31+
esp_insights_transport_event_data_t data;
32+
switch(event_id) {
33+
case RMAKER_MQTT_EVENT_PUBLISHED:
34+
memset(&data, 0, sizeof(data));
35+
data.msg_id = *(int *)event_data;
36+
esp_event_post(INSIGHTS_EVENT, INSIGHTS_EVENT_TRANSPORT_SEND_SUCCESS, &data, sizeof(data), portMAX_DELAY);
37+
break;
38+
default:
39+
break;
40+
}
41+
}
42+
43+
static int _appInsightsDataSend(void *data, size_t len)
44+
{
45+
char topic[128];
46+
int msg_id = -1;
47+
if (data == NULL) {
48+
return 0;
49+
}
50+
char *node_id = esp_rmaker_get_node_id();
51+
if (!node_id) {
52+
return -1;
53+
}
54+
if (esp_rmaker_mqtt_is_budget_available() == false) {
55+
return ESP_FAIL;
56+
}
57+
esp_rmaker_create_mqtt_topic(topic, sizeof(topic), INSIGHTS_TOPIC_SUFFIX, INSIGHTS_TOPIC_RULE);
58+
esp_rmaker_mqtt_publish(topic, data, len, RMAKER_MQTT_QOS1, &msg_id);
59+
return msg_id;
60+
}
61+
62+
bool initAppInsights(uint32_t log_type, bool alloc_ext_ram)
63+
{
64+
char *node_id = esp_rmaker_get_node_id();
65+
esp_insights_transport_config_t transport;
66+
transport.userdata = NULL;
67+
transport.callbacks.data_send = _appInsightsDataSend;
68+
transport.callbacks.init = NULL;
69+
transport.callbacks.deinit = NULL;
70+
transport.callbacks.connect = NULL;
71+
transport.callbacks.disconnect = NULL;
72+
esp_insights_transport_register(&transport);
73+
esp_event_handler_register(RMAKER_COMMON_EVENT, ESP_EVENT_ANY_ID, _rmakerCommonEventHandler, NULL);
74+
return Insights.begin(NULL, node_id, log_type, alloc_ext_ram, false);
75+
}
76+
#else
77+
bool initAppInsights(uint32_t log_type, bool alloc_ext_ram)
78+
{
79+
return false;
80+
}
81+
#endif

libraries/RainMaker/src/AppInsights.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/*
2+
* SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#pragma once
8+
#include "sdkconfig.h"
9+
#include "Arduino.h"
10+
#include <inttypes.h>
11+
12+
bool initAppInsights(uint32_t log_type = 0xffffffff, bool alloc_ext_ram = false);

libraries/USB/examples/Gamepad/Gamepad.ino

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,41 @@ void setup() {
1414
pinMode(buttonPin, INPUT_PULLUP);
1515
Gamepad.begin();
1616
USB.begin();
17+
Serial.begin(115200);
18+
Serial.println("\n==================\nUSB Gamepad Testing\n==================\n");
19+
Serial.println("Press BOOT Button to activate the USB gamepad.");
20+
Serial.println("Longer press will change the affected button and controls.");
21+
Serial.println("Shorter press/release just activates the button and controls.");
1722
}
1823

1924
void loop() {
25+
static uint8_t padID = 0;
26+
static long lastPress = 0;
27+
2028
int buttonState = digitalRead(buttonPin);
21-
if ((buttonState != previousButtonState) && (buttonState == LOW)) {
22-
Gamepad.pressButton(BUTTON_START);
23-
Gamepad.releaseButton(BUTTON_START);
29+
if (buttonState != previousButtonState) {
30+
if (buttonState == LOW) { // BOOT Button pressed
31+
Gamepad.pressButton(padID); // Buttons 1 to 32
32+
Gamepad.leftStick(padID << 3, padID << 3); // X Axis, Y Axis
33+
Gamepad.rightStick(-(padID << 2), padID << 2); // Z Axis, Z Rotation
34+
Gamepad.leftTrigger(padID << 4); // X Rotation
35+
Gamepad.rightTrigger(-(padID << 4)); // Y Rotation
36+
Gamepad.hat((padID & 0x7) + 1); // Point of View Hat
37+
log_d("Pressed PadID [%d]", padID);
38+
lastPress = millis();
39+
} else {
40+
Gamepad.releaseButton(padID);
41+
Gamepad.leftStick(0, 0);
42+
Gamepad.rightStick(0, 0);
43+
Gamepad.leftTrigger(0);
44+
Gamepad.rightTrigger(0);
45+
Gamepad.hat(HAT_CENTER);
46+
log_d("Released PadID [%d]\n", padID);
47+
if (millis() - lastPress > 300) {
48+
padID = (padID + 1) & 0x1F;
49+
log_d("Changed padID to %d\n", padID);
50+
}
51+
}
2452
}
2553
previousButtonState = buttonState;
2654
}

0 commit comments

Comments
 (0)