Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
23 changes: 9 additions & 14 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
### PR description
[Describe the PR content in detail here]
### PR 描述/PR description
[在此详细描述 PR 的内容]/[Describe the PR content in detail here]


### Code Quality:
As part of this pull request, I've considered the following:
- [ ] Ensure that the code comments and documentation are clear, and use English for comments to ensure code readability.

- [ ] Ensure that the file header follows the [File Header Format](https://www.tuyaopen.ai/docs/contribute/coding-style-guide#file-header-format).

- [ ] Ensure that function headers follow the Doxygen format as specified in [Comments](https://www.tuyaopen.ai/docs/contribute/coding-style-guide#comments).

- [ ] Reviewed the [Coding Style Guide](https://www.tuyaopen.ai/docs/contribute/coding-style-guide) and verified code style compliance, including indentation, spacing, naming conventions, and other style guidelines.

- [ ] Have used the [code-formatting](https://www.tuyaopen.ai/docs/contribute/coding-style-guide#code-formatting) source code formatting tool to ensure compliance with TuyaOpen coding standards.

### 代码质量/Code Quality:
在本次拉取请求中,我已考虑以下事项 As part of this pull request, I've considered the following:
- [ ] 确保代码注释和文档清晰,并使用英文注释以保证代码可读性。Ensure that the code comments and documentation are clear, and use English for comments to ensure code readability.
- [ ] 确保文件头遵循[文件头格式](https://www.tuyaopen.ai/zh/docs/contribute/coding-style-guide#%E5%A4%B4%E6%96%87%E4%BB%B6)。Ensure that the file header follows the [File Header Format](https://www.tuyaopen.ai/docs/contribute/coding-style-guide#file-header-format).
- [ ] 确保函数头遵循 [Doxygen 格式](https://www.tuyaopen.ai/zh/docs/contribute/coding-style-guide#%E6%B3%A8%E9%87%8A)。Ensure that function headers follow the Doxygen format as specified in [Comments](https://www.tuyaopen.ai/docs/contribute/coding-style-guide#comments).
- [ ] 已查阅 [编码风格指南](https://www.tuyaopen.ai/zh/docs/contribute/coding-style-guide),并核查代码风格合规性,包括缩进、空格、命名规范及其他风格要求。 Reviewed the [Coding Style Guide](https://www.tuyaopen.ai/docs/contribute/coding-style-guide) and verified code style compliance, including indentation, spacing, naming conventions, and other style guidelines.
- [ ] 已使用[代码格式化工具](https://www.tuyaopen.ai/zh/docs/contribute/coding-style-guide#%E6%A0%BC%E5%BC%8F%E5%8C%96%E4%BB%A3%E7%A0%81)确保符合 TuyaOpen 编码规范。Have used the [code-formatting](https://www.tuyaopen.ai/docs/contribute/coding-style-guide#code-formatting) source code formatting tool to ensure compliance with TuyaOpen coding standards.
5 changes: 5 additions & 0 deletions .github/workflows/check-build-apps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ jobs:
. ./export.sh
cd ${{ github.workspace }}/apps/tuya.ai/your_otto_robot
tos.py dev bac -d ${{ github.workspace }}/dist
- name: Check [camera_demo] Build
run: |
cd ${{ github.workspace }}
. ./export.sh
cd ${{ github.workspace }}/apps/tuya_cloud/camera_demo
- name: Check [weather_get_demo] Build
run: |
cd ${{ github.workspace }}
Expand Down
30 changes: 30 additions & 0 deletions apps/tuya_cloud/camera_demo/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
##
# @file CMakeLists.txt
# @brief
#/

# APP_PATH
set(APP_PATH ${CMAKE_CURRENT_LIST_DIR})

# APP_NAME
get_filename_component(APP_NAME ${APP_PATH} NAME)

# APP_SRCS
aux_source_directory(${APP_PATH}/src APP_SRCS)

set(APP_INC ${APP_PATH}/include)

########################################
# Target Configure
########################################
add_library(${EXAMPLE_LIB})

target_sources(${EXAMPLE_LIB}
PRIVATE
${APP_SRCS}
)

target_include_directories(${EXAMPLE_LIB}
PRIVATE
${APP_INC}
)
4 changes: 4 additions & 0 deletions apps/tuya_cloud/camera_demo/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
config CAMERA_DEMO
bool
default y
select ENABLE_TUYA_P2P
Empty file.
Empty file.
Binary file added apps/tuya_cloud/camera_demo/demo_video.264
Binary file not shown.
60 changes: 60 additions & 0 deletions apps/tuya_cloud/camera_demo/include/reset_netcfg.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/**
* @file reset_netcfg.c
* @brief Implements reset network configuration functionality for IoT devices
*
* This source file provides the implementation of the reset network configuration
* functionality required for IoT devices. It includes functionality for managing
* reset counters, handling reset events, and clearing network configurations.
* The implementation supports integration with the Tuya IoT platform and ensures
* proper handling of reset-related operations. This file is essential for developers
* working on IoT applications that require robust network configuration reset mechanisms.
*
* @copyright Copyright (c) 2021-2025 Tuya Inc. All Rights Reserved.
*/

#ifndef __RESET_NETCFG_H__
#define __RESET_NETCFG_H__

#include "tuya_cloud_types.h"

#ifdef __cplusplus
extern "C" {
#endif

/***********************************************************
************************macro define************************
***********************************************************/

/***********************************************************
***********************typedef define***********************
***********************************************************/

/***********************************************************
********************function declaration********************
***********************************************************/
/**
* @brief Starts the network configuration reset process.
*
* This function initiates the process to reset the network configuration
* of the device. It is typically used to clear existing network settings
* and prepare the device for reconfiguration.
*
* @return int Returns 0 on success, or a negative value on failure.
*/
int reset_netconfig_start(void);

/**
* @brief Checks the status of the network configuration reset process.
*
* This function verifies whether the network configuration reset process
* has been completed successfully or is still in progress.
*
* @return int Returns 0 on success, or a negative value on failure.
*/
int reset_netconfig_check(void);

#ifdef __cplusplus
}
#endif

#endif /* __RESET_NETCFG_H__ */
43 changes: 43 additions & 0 deletions apps/tuya_cloud/camera_demo/include/tuya_config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/**
* @file tuya_config.h
* @brief IoT specific configuration file
*
* @copyright Copyright (c) 2021-2024 Tuya Inc. All Rights Reserved.
*/

#ifndef TUYA_CONFIG_H_
#define TUYA_CONFIG_H_

/**
* @brief configure the product information
*
* TUYA_PRODUCT_ID: PID, create on the Tuya IoT platform
* TUYA_DEVICE_UUID: UUID, create on the Tuya IoT platform
* TUYA_DEVICE_AUTHKEY: AUTHKEY, create on the Tuya IoT platform
*
* detail please refer to:
* 1. Create the product and get the pid:
* https://developer.tuya.com/cn/docs/iot-device-dev/application-creation?id=Kbxw7ket3aujc
* 2. Get the open-sdk license code or module: https://platform.tuya.com/purchase/index?type=6
*
* warning: please replace these production information with your product id
* and license, otherwise the demo cannot work.
*
*/
// clang-format off
#define TUYA_PRODUCT_ID "urj3rcaetqy6l6zd" // Please change your product id
#define TUYA_OPENSDK_UUID "uuidxxxxxxxxxxxxxxxx" // Please change the correct uuid
#define TUYA_OPENSDK_AUTHKEY "keyxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" // Please change the correct authkey

/**
* @brief PINCODE for AP provisioning
*
* TUYA_NETCFG_PINCODE: a random PINCODE for AP provisioning, PINCODE was generated BY TUYA PMS system!!!
*
* WARNING: PINCODE is mandatory for AP provisioning
*/
// #define TUYA_NETCFG_PINCODE "69832860"

// clang-format on

#endif
59 changes: 59 additions & 0 deletions apps/tuya_cloud/camera_demo/include/tuya_ipc_demo.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/**
* @file tuya_ipc_demo.h
* @brief Header file for Tuya IPC demo functionality
*
* This header file provides the interface declarations for the Tuya IPC demo
* functionality required for video streaming applications. It includes function
* declarations for managing demo video files, handling video frame processing,
* and providing callback functions for media streaming. The interface supports
* integration with the Tuya IoT platform and ensures proper handling of video
* streaming operations. This file is essential for developers working on IoT
* camera applications that require robust video streaming mechanisms.
*
* @copyright Copyright (c) 2021-2025 Tuya Inc. All Rights Reserved.
*/

#ifndef __TUYA_IPC_DEMO_H__
#define __TUYA_IPC_DEMO_H__

#ifdef __cplusplus
extern "C" {
#endif

#include "tuya_ipc_p2p.h"

/**
* @brief Initialize demo video file
*/
void tuya_ipc_demo_start(void);

/**
* @brief Clean up demo resources
*/
void tuya_ipc_demo_end(void);

/**
* @brief Signal disconnect callback function
* @return 0 on success
*/
int demo_on_signal_disconnect_callback(void);

/**
* @brief Get video frame callback function
* @param media_frame Media frame structure
* @return 0 on success, -1 on failure
*/
int demo_on_get_video_frame_callback(MEDIA_FRAME *media_frame);

/**
* @brief Get audio frame callback function
* @param media_frame Media frame structure
* @return 0 on success
*/
int demo_on_get_audio_frame_callback(MEDIA_FRAME *media_frame);

#ifdef __cplusplus
}
#endif

#endif /*__TUYA_IPC_DEMO_H__*/
128 changes: 128 additions & 0 deletions apps/tuya_cloud/camera_demo/src/reset_netcfg.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
/**
* @file reset_netcfg.c
* @brief Implements reset network configuration functionality for IoT devices
*
* This source file provides the implementation of the reset network configuration
* functionality required for IoT devices. It includes functionality for managing
* reset counters, handling reset events, and clearing network configurations.
* The implementation supports integration with the Tuya IoT platform and ensures
* proper handling of reset-related operations. This file is essential for developers
* working on IoT applications that require robust network configuration reset mechanisms.
*
* @copyright Copyright (c) 2021-2025 Tuya Inc. All Rights Reserved.
*/

#include "tal_api.h"
#include "tuya_iot.h"

/***********************************************************
************************macro define************************
***********************************************************/
#define RESET_NETCNT_NAME "rst_cnt"
#define RESET_NETCNT_MAX 3

/***********************************************************
***********************typedef define***********************
***********************************************************/

/***********************************************************
********************function declaration********************
***********************************************************/

/***********************************************************
***********************variable define**********************
***********************************************************/

/***********************************************************
***********************function define**********************
***********************************************************/

static int reset_count_read(uint8_t *count)
{
int rt = OPRT_OK;

uint8_t *read_buf = NULL;
size_t read_len;

TUYA_CALL_ERR_RETURN(tal_kv_get(RESET_NETCNT_NAME, &read_buf, &read_len));
*count = read_buf[0];

PR_DEBUG("reset count is %d", *count);

if (NULL != read_buf) {
tal_kv_free(read_buf);
read_buf = NULL;
}

return rt;
}

static int reset_count_write(uint8_t count)
{
PR_DEBUG("reset count write %d", count);
return tal_kv_set(RESET_NETCNT_NAME, &count, 1);
}

static void reset_netconfig_timer(TIMER_ID timer_id, void *arg)
{
reset_count_write(0);
PR_DEBUG("reset cnt clear!");
}

static OPERATE_RET __reset_netconfig_clear(void *data)
{
reset_count_write(0);
PR_DEBUG("reset cnt clear by reset event!");
return OPRT_OK;
}

/**
* @brief Checks the status of the network configuration reset process.
*
* This function verifies whether the network configuration reset process
* has been completed successfully or is still in progress.
*
* @return int Returns 0 on success, or a negative value on failure.
*/
int reset_netconfig_check(void)
{
int rt;
uint8_t rst_cnt = 0;

TUYA_CALL_ERR_LOG(reset_count_read(&rst_cnt));
if (rst_cnt < RESET_NETCNT_MAX) {
return OPRT_OK;
}

tal_event_subscribe(EVENT_RESET, "reset_netconfig", __reset_netconfig_clear, SUBSCRIBE_TYPE_NORMAL);

PR_DEBUG("Reset ctrl data!");
tuya_iot_reset(tuya_iot_client_get());

return rt;
}

/**
* @brief Starts the network configuration reset process.
*
* This function initiates the process to reset the network configuration
* of the device. It is typically used to clear existing network settings
* and prepare the device for reconfiguration.
*
* @return int Returns 0 on success, or a negative value on failure.
*/
int reset_netconfig_start(void)
{
int rt = OPRT_OK;
uint8_t rst_cnt = 0;

TUYA_CALL_ERR_LOG(reset_count_read(&rst_cnt));
TUYA_CALL_ERR_LOG(reset_count_write(++rst_cnt));

PR_DEBUG("start reset cnt clear timer!!!!!");
TIMER_ID rst_config_timer;
tal_sw_timer_create(reset_netconfig_timer, NULL, &rst_config_timer);
tal_sw_timer_start(rst_config_timer, 5000, TAL_TIMER_ONCE);

return OPRT_OK;
}
Loading