Skip to content

Commit 84a6b1d

Browse files
committed
Merge remote-tracking branch 'internal/develop_rel_1_8_0' into develop
* internal/develop_rel_1_8_0: Sync-up with iot-core 1.8.0 add capability sample for pH Measurement (#653) Fix building warning caused by deprecated API support rmt led strip for esp32s2/esp32c3 Update sdkconfig file according to v4.3.1 SDK Rename 'ctx' in ESP32-S2 examples which is conflict with the one defined in esp libnet80211.a Update ESP32S2 SDK to V4.3.1
2 parents b3d83fd + b7b5781 commit 84a6b1d

File tree

36 files changed

+1707
-433
lines changed

36 files changed

+1707
-433
lines changed
Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
/* ***************************************************************************
2+
*
3+
* Copyright 2019-2022 Samsung Electronics All Rights Reserved.
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing,
12+
* software distributed under the License is distributed on an
13+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
14+
* either express or implied. See the License for the specific
15+
* language governing permissions and limitations under the License.
16+
*
17+
****************************************************************************/
18+
19+
#include <string.h>
20+
#include <stdio.h>
21+
#include <stdlib.h>
22+
23+
#include "st_dev.h"
24+
#include "caps_pHMeasurement.h"
25+
26+
static double caps_pHMeasurement_get_pH_value(caps_pHMeasurement_data_t *caps_data)
27+
{
28+
if (!caps_data) {
29+
printf("caps_data is NULL\n");
30+
return caps_helper_pHMeasurement.attr_pH.min - 1;
31+
}
32+
return caps_data->pH_value;
33+
}
34+
35+
static void caps_pHMeasurement_set_pH_value(caps_pHMeasurement_data_t *caps_data, double value)
36+
{
37+
if (!caps_data) {
38+
printf("caps_data is NULL\n");
39+
return;
40+
}
41+
caps_data->pH_value = value;
42+
}
43+
44+
static const char *caps_pHMeasurement_get_pH_unit(caps_pHMeasurement_data_t *caps_data)
45+
{
46+
if (!caps_data) {
47+
printf("caps_data is NULL\n");
48+
return NULL;
49+
}
50+
return caps_data->pH_unit;
51+
}
52+
53+
static void caps_pHMeasurement_set_pH_unit(caps_pHMeasurement_data_t *caps_data, const char *unit)
54+
{
55+
if (!caps_data) {
56+
printf("caps_data is NULL\n");
57+
return;
58+
}
59+
caps_data->pH_unit = (char *)unit;
60+
}
61+
62+
static void caps_pHMeasurement_attr_pH_send(caps_pHMeasurement_data_t *caps_data)
63+
{
64+
int sequence_no = -1;
65+
66+
if (!caps_data || !caps_data->handle) {
67+
printf("fail to get handle\n");
68+
return;
69+
}
70+
71+
ST_CAP_SEND_ATTR_NUMBER(caps_data->handle,
72+
(char *)caps_helper_pHMeasurement.attr_pH.name,
73+
caps_data->pH_value,
74+
caps_data->pH_unit,
75+
NULL,
76+
sequence_no);
77+
78+
if (sequence_no < 0)
79+
printf("fail to send pH value\n");
80+
else
81+
printf("Sequence number return : %d\n", sequence_no);
82+
}
83+
84+
85+
static void caps_pHMeasurement_init_cb(IOT_CAP_HANDLE *handle, void *usr_data)
86+
{
87+
caps_pHMeasurement_data_t *caps_data = usr_data;
88+
if (caps_data && caps_data->init_usr_cb)
89+
caps_data->init_usr_cb(caps_data);
90+
caps_pHMeasurement_attr_pH_send(caps_data);
91+
}
92+
93+
caps_pHMeasurement_data_t *caps_pHMeasurement_initialize(IOT_CTX *ctx, const char *component, void *init_usr_cb, void *usr_data)
94+
{
95+
caps_pHMeasurement_data_t *caps_data = NULL;
96+
97+
caps_data = malloc(sizeof(caps_pHMeasurement_data_t));
98+
if (!caps_data) {
99+
printf("fail to malloc for caps_pHMeasurement_data\n");
100+
return NULL;
101+
}
102+
103+
memset(caps_data, 0, sizeof(caps_pHMeasurement_data_t));
104+
105+
caps_data->init_usr_cb = init_usr_cb;
106+
caps_data->usr_data = usr_data;
107+
108+
caps_data->get_pH_value = caps_pHMeasurement_get_pH_value;
109+
caps_data->set_pH_value = caps_pHMeasurement_set_pH_value;
110+
caps_data->get_pH_unit = caps_pHMeasurement_get_pH_unit;
111+
caps_data->set_pH_unit = caps_pHMeasurement_set_pH_unit;
112+
caps_data->attr_pH_send = caps_pHMeasurement_attr_pH_send;
113+
caps_data->pH_value = 0;
114+
if (ctx) {
115+
caps_data->handle = st_cap_handle_init(ctx, component, caps_helper_pHMeasurement.id, caps_pHMeasurement_init_cb, caps_data);
116+
}
117+
if (!caps_data->handle) {
118+
printf("fail to init pHMeasurement handle\n");
119+
}
120+
121+
return caps_data;
122+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/* ***************************************************************************
2+
*
3+
* Copyright 2019-2022 Samsung Electronics All Rights Reserved.
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing,
12+
* software distributed under the License is distributed on an
13+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
14+
* either express or implied. See the License for the specific
15+
* language governing permissions and limitations under the License.
16+
*
17+
****************************************************************************/
18+
19+
#include "caps/iot_caps_helper_pHMeasurement.h"
20+
21+
#ifdef __cplusplus
22+
extern "C" {
23+
#endif
24+
25+
typedef struct caps_pHMeasurement_data {
26+
IOT_CAP_HANDLE* handle;
27+
void *usr_data;
28+
void *cmd_data;
29+
30+
double pH_value;
31+
char *pH_unit;
32+
33+
double (*get_pH_value)(struct caps_pHMeasurement_data *caps_data);
34+
void (*set_pH_value)(struct caps_pHMeasurement_data *caps_data, double value);
35+
const char *(*get_pH_unit)(struct caps_pHMeasurement_data *caps_data);
36+
void (*set_pH_unit)(struct caps_pHMeasurement_data *caps_data, const char *unit);
37+
void (*attr_pH_send)(struct caps_pHMeasurement_data *caps_data);
38+
39+
void (*init_usr_cb)(struct caps_pHMeasurement_data *caps_data);
40+
} caps_pHMeasurement_data_t;
41+
42+
caps_pHMeasurement_data_t *caps_pHMeasurement_initialize(IOT_CTX *ctx, const char *component, void *init_usr_cb, void *usr_data);
43+
#ifdef __cplusplus
44+
}
45+
#endif
46+

apps/esp32/light_example/sdkconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@ CONFIG_HTTPD_PURGE_BUF_LEN=32
462462
CONFIG_ESP_NETIF_IP_LOST_TIMER_INTERVAL=120
463463
CONFIG_ESP_NETIF_TCPIP_LWIP=y
464464
# CONFIG_ESP_NETIF_LOOPBACK is not set
465-
CONFIG_ESP_NETIF_TCPIP_ADAPTER_COMPATIBLE_LAYER=y
465+
# CONFIG_ESP_NETIF_TCPIP_ADAPTER_COMPATIBLE_LAYER is not set
466466
# end of ESP NETIF Adapter
467467

468468
#

apps/esp32/ota_demo/sdkconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@ CONFIG_HTTPD_PURGE_BUF_LEN=32
462462
CONFIG_ESP_NETIF_IP_LOST_TIMER_INTERVAL=120
463463
CONFIG_ESP_NETIF_TCPIP_LWIP=y
464464
# CONFIG_ESP_NETIF_LOOPBACK is not set
465-
CONFIG_ESP_NETIF_TCPIP_ADAPTER_COMPATIBLE_LAYER=y
465+
# CONFIG_ESP_NETIF_TCPIP_ADAPTER_COMPATIBLE_LAYER is not set
466466
# end of ESP NETIF Adapter
467467

468468
#

apps/esp32/switch_example/sdkconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@ CONFIG_HTTPD_PURGE_BUF_LEN=32
462462
CONFIG_ESP_NETIF_IP_LOST_TIMER_INTERVAL=120
463463
CONFIG_ESP_NETIF_TCPIP_LWIP=y
464464
# CONFIG_ESP_NETIF_LOOPBACK is not set
465-
CONFIG_ESP_NETIF_TCPIP_ADAPTER_COMPATIBLE_LAYER=y
465+
# CONFIG_ESP_NETIF_TCPIP_ADAPTER_COMPATIBLE_LAYER is not set
466466
# end of ESP NETIF Adapter
467467

468468
#
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
set(component_srcs "src/led_strip_rmt_ws2812.c")
2+
3+
idf_component_register(SRCS "${component_srcs}"
4+
INCLUDE_DIRS "include"
5+
PRIV_INCLUDE_DIRS ""
6+
PRIV_REQUIRES "driver"
7+
REQUIRES "")
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
COMPONENT_ADD_INCLUDEDIRS := include
2+
3+
COMPONENT_SRCDIRS := src
Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
// Copyright 2019 Espressif Systems (Shanghai) PTE LTD
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
#pragma once
15+
16+
#ifdef __cplusplus
17+
extern "C" {
18+
#endif
19+
20+
#include "esp_err.h"
21+
22+
/**
23+
* @brief LED Strip Type
24+
*
25+
*/
26+
typedef struct led_strip_s led_strip_t;
27+
28+
/**
29+
* @brief LED Strip Device Type
30+
*
31+
*/
32+
typedef void *led_strip_dev_t;
33+
34+
/**
35+
* @brief Declare of LED Strip Type
36+
*
37+
*/
38+
struct led_strip_s {
39+
/**
40+
* @brief Set RGB for a specific pixel
41+
*
42+
* @param strip: LED strip
43+
* @param index: index of pixel to set
44+
* @param red: red part of color
45+
* @param green: green part of color
46+
* @param blue: blue part of color
47+
*
48+
* @return
49+
* - ESP_OK: Set RGB for a specific pixel successfully
50+
* - ESP_ERR_INVALID_ARG: Set RGB for a specific pixel failed because of invalid parameters
51+
* - ESP_FAIL: Set RGB for a specific pixel failed because other error occurred
52+
*/
53+
esp_err_t (*set_pixel)(led_strip_t *strip, uint32_t index, uint32_t red, uint32_t green, uint32_t blue);
54+
55+
/**
56+
* @brief Refresh memory colors to LEDs
57+
*
58+
* @param strip: LED strip
59+
* @param timeout_ms: timeout value for refreshing task
60+
*
61+
* @return
62+
* - ESP_OK: Refresh successfully
63+
* - ESP_ERR_TIMEOUT: Refresh failed because of timeout
64+
* - ESP_FAIL: Refresh failed because some other error occurred
65+
*
66+
* @note:
67+
* After updating the LED colors in the memory, a following invocation of this API is needed to flush colors to strip.
68+
*/
69+
esp_err_t (*refresh)(led_strip_t *strip, uint32_t timeout_ms);
70+
71+
/**
72+
* @brief Clear LED strip (turn off all LEDs)
73+
*
74+
* @param strip: LED strip
75+
* @param timeout_ms: timeout value for clearing task
76+
*
77+
* @return
78+
* - ESP_OK: Clear LEDs successfully
79+
* - ESP_ERR_TIMEOUT: Clear LEDs failed because of timeout
80+
* - ESP_FAIL: Clear LEDs failed because some other error occurred
81+
*/
82+
esp_err_t (*clear)(led_strip_t *strip, uint32_t timeout_ms);
83+
84+
/**
85+
* @brief Free LED strip resources
86+
*
87+
* @param strip: LED strip
88+
*
89+
* @return
90+
* - ESP_OK: Free resources successfully
91+
* - ESP_FAIL: Free resources failed because error occurred
92+
*/
93+
esp_err_t (*del)(led_strip_t *strip);
94+
};
95+
96+
/**
97+
* @brief LED Strip Configuration Type
98+
*
99+
*/
100+
typedef struct {
101+
uint32_t max_leds; /*!< Maximum LEDs in a single strip */
102+
led_strip_dev_t dev; /*!< LED strip device (e.g. RMT channel, PWM channel, etc) */
103+
} led_strip_config_t;
104+
105+
/**
106+
* @brief Default configuration for LED strip
107+
*
108+
*/
109+
#define LED_STRIP_DEFAULT_CONFIG(number, dev_hdl) \
110+
{ \
111+
.max_leds = number, \
112+
.dev = dev_hdl, \
113+
}
114+
115+
/**
116+
* @brief Install a new ws2812 driver (based on RMT peripheral)
117+
*
118+
* @param config: LED strip configuration
119+
* @return
120+
* LED strip instance or NULL
121+
*/
122+
led_strip_t *led_strip_new_rmt_ws2812(const led_strip_config_t *config);
123+
124+
#ifdef __cplusplus
125+
}
126+
#endif

0 commit comments

Comments
 (0)