Skip to content

Commit

Permalink
tuya iotos embeded wifi&ble sdk for bk7231t version 1.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
flyingcys committed Jan 27, 2021
0 parents commit dd9c585
Show file tree
Hide file tree
Showing 10,872 changed files with 2,615,960 additions and 0 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
15 changes: 15 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
*.o
*.d
*.map
*.nmap
*.asm
*.axf
*.bin
platforms/bk7231t/bk7231t_os/Debug
platforms/bk7231t/bk7231t_os/tools/generate/config.json
platforms/bk7231t/bk7231t_os/tools/generate/*.cpr
platforms/bk7231t/bk7231t_os/tools/generate/*.out
platforms/bk7231t/bk7231t_os/tools/generate/*.bin
!platforms/bk7231t/bk7231t_os/tools/generate/bootloader.bin
!platforms/bk7231t/bk7231t_os/tools/generate/bootloader_enc.bin
!platforms/bk7231t/bk7231t_os/tools/generate/package.bin
82 changes: 82 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
Tuya IoTOS Embeded SDK WiFi & BLE for BK7231T

[English] | [中文版](https://github.com/tuya/tuya-iotos-embeded-sdk-wifi-ble-bk7231t/README_zh.md)

## Introduction

Tuya IoTOS is independently developed by TuyaSmart, the world's only IoT operating system covering all levels of IoT sensing, interruption, network, platform, and application. Benefiting from Tuya Smart's accumulation in the IoT industry, TuyaIoTOS provides a full range of products from product design, R&D, access to post-operation solutions.

Tuya IoTOS embedded SDK is an important part of Tuya IoTOS. Through good design, it provides customers with a unified development interface, rich development kits and self-service customization functions, shielding the fragmented characteristics of the IoT industry, which can be applied to IoT applications in industries such as industrial IoT, vehicle networking, security monitoring, outdoor travel, smart home development.

Tuya IoTOS embedded SDK has the following features.

* Flexible tailoring: Tuya IoTOS embedded SDK provides a rich development kit covering IoT operating system kernel, general IoT functions, IoT technology stacks in different fields, developers can choose the corresponding solutions according to the needs of their products, and developers with the ability to do deep customization online and on demand.
* Cross-platform: The Tuya IoTOS embedded SDK design level supports cross-hardware platform and operating system features that can be ported on any hardware chip and system, greatly improving the development efficiency of developers.
* Security and privacy: Tuya IoTOS embedded SDK provides features such as secure data storage, secure network communication, identity verification, secure startup, secure upgrade, and strict compliance with security and privacy policies around the world, effectively guaranteeing the security and privacy features of the product.
* Rich ecology: Tuya Smart has worked closely with major chip originators and imported 100+ models for developers to choose from, while all products developed with Tuya IoTOS are able to interoperate and scene linkage, Powered by Tuya has formed a complete IoT industry ecology.



## Get Started

### Requirements and Dependencies

Some package dependencies need to be installed before compilation:

#### Debian/Ubuntu
``` bash
$ sudo apt-get install wget git python libc6-i386
```

#### Windows

Supports compilation under Cygwin, MinGW, WSL2 and other environments

### Download SDK

Be sure to clone recursively to download SDK:
``` bash
$ git clone --recursive https://github.com/tuya/tuya-iotos-embeded-sdk-wifi-ble-bk7231t.git
```
or
``` bash
$ git clone https://github.com/tuya/tuya-iotos-embeded-sdk-wifi-ble-bk7231t.git
$ git submodule update --init
```

### Compile

The project is located in the `apps` directory, you can use the `template_demo` project to quickly complete the compile, burn, run process, use the following command in the root directory to compile:
``` bash
$ sh build_app.sh apps/template_demo template_demo 1.0.0
```
- apps/template_demo: compile project path

- template_demo: compile project name

- 1.0.0: compile project version

### Compile clean

To clear the compiled intermediate files, use the following command:

``` bash
$ sh build_app.sh apps/template_demo template_demo 1.0.0 clean
```

### Program and authorization

Firmware program and authorization information please refer to the relevant :[Wi-Fi + BLE module program and authorization](https://developer.tuya.com/cn/docs/iot/device-development/burn-and-authorization/burn-and-authorize-wifi-ble-modules/burn-and-authorize-wb-series-modules?id=Ka78f4pttsytd)

### Evaluation kits

Evaluation kits information please refer to the relevant:[Sandwich Evaluation Kits](https://developer.tuya.com/en/docs/iot/device-development/tuya-development-board-kit/tuya-sandwich-evaluation-kits/-tuya-sandwich-evaluation-kits?id=K97o0ixytemvr)



## Support

You can get support from Tuya with the following methods:
- Tuya Developer Center: https://developer.tuya.com/en/
- Tuya Smart Help Center: https://support.tuya.com/en/help
- Technical Support Council: https://iot.tuya.com/council/
80 changes: 80 additions & 0 deletions README_zh.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
Tuya IoTOS Embeded SDK WiFi & BLE for BK7231T

[English](https://github.com/tuya/tuya-iotos-embeded-sdk-wifi-ble-bk7231t/README.md) | [中文版]

## 简介

涂鸦 IoTOS 是涂鸦智能自主开发的,全球唯一的覆盖物联网感知、中断、网络、平台、应用各个层次的物联网操作系统。受益于涂鸦智能在物联网行业的积累,涂鸦IoTOS提供了全品类的从产品设计、研发、接入到后期运营解决方案。

涂鸦IoTOS embedded SDK是涂鸦 IoTOS 的重要组成部分,通过良好的设计,为客户提供了统一的开发接口,丰富的开发套件以及自助化定制功能,屏蔽了物联网行业的碎片化特征,可以应用于工业物联网、车联网、安防监控、户外出行、智能家居等行业的物联网应用开发。

涂鸦IoTOS embedded SDK具有以下特点:

* 弹性裁剪:涂鸦IoTOS embedded SDK提供了丰富的开发套件,涵盖了物联网操作系统内核、通用物联网功能、不同领域的物联网技术栈,开发者可以根据自己的产品的需求进行选择对应的解决方案,有能力的开发者,可以在线按需进行深度的定制。
* 跨平台:涂鸦IoTOS embedded SDK设计层面支持了跨硬件平台、操作系统的特性,可以在任意的硬件芯片和系统上进行移植,极大的提高了开发者的开发效率。
* 安全隐私:涂鸦IoTOS embedded SDK提供了安全数据存储、安全网络通信、身份验证、安全启动、安全升级等特性,并严格遵守全球各地的安全、隐私政策,有效的保障产品的安全、隐私特性。
* 丰富生态:涂鸦智能和各大芯片原厂进行了密切的合作,导入了100+款供开发者选择,同时所有使用涂鸦IoTOS 开发的产品都能够进行互联互通,场景联动,Powered by Tuya已经形成了完整的物联网产业生态。



## 快速上手

### 依赖
在编译前需要安装部分软件包依赖:
#### Debian/Ubuntu
``` bash
$ sudo apt-get install wget git python libc6-i386
```


#### Windows

支持Cygwin、Mingw、WSL2等环境下编译

### 获取SDK
请确认使用git递归模式clone获取SDK:
``` bash
$ git clone --recursive https://github.com/tuya/tuya-iotos-embeded-sdk-wifi-ble-bk7231t.git
```
或者
``` bash
$ git clone https://github.com/tuya/tuya-iotos-embeded-sdk-wifi-ble-bk7231t.git
$ git submodule update --init
```

### 编译

编译工程位于apps目录下,你可以使用`template_demo`工程快速完成编译、烧录、运行流程,在根目录下使用以下命令编译:
``` bash
$ sh build_app.sh apps/template_demo template_demo 1.0.0
```
apps/template_demo:编译工程路径

template_demo:编译工程名称

1.0.0:当前编译固件版本,可根据实际情况自行修改

### 编译清除

如需清除编译中间文件,可使用以下命令:

``` bash
$ sh build_app.sh apps/template_demo template_demo 1.0.0 clean
```

### 烧录授权

固件烧录授权相关信息请参考:[Wi-Fi + BLE 系列模组烧录授权](https://developer.tuya.com/cn/docs/iot/device-development/burn-and-authorization/burn-and-authorize-wifi-ble-modules/burn-and-authorize-wb-series-modules?id=Ka78f4pttsytd)

### 开发套件

开发板套件相关详情请参考:[三明治开发套件](https://developer.tuya.com/cn/docs/iot/device-development/tuya-development-board-kit/tuya-sandwich-evaluation-kits/-tuya-sandwich-evaluation-kits?id=K97o0ixytemvr)



## 技术支持

您可以通过以下方法获得涂鸦的支持:
- 开发者中心:https://developer.tuya.com/cn/
- 帮助中心: https://support.tuya.com/en/help
- 技术支持工单中心: [https://service.console.tuya.com](https://service.console.tuya.com/)
37 changes: 37 additions & 0 deletions apps/bk7231t_bl0937_1_plug_demo/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# 电量统计单插( PID:aumib22ytuftcydk)

## 1.硬件IO口说明
(1)继电器:PWM5,高电平有效;

(2)开关按键:PWM3,低电平有效;

(3)wifi指示灯:PWM0,低电平有效;

(4)计量部分信息:工作电压220V,过流点17A,采样电阻1毫欧;计量芯片:bl0937;

(5)电量统计(CF):PWM1;电流电压检测(CF1):PWM2;电流电压切换(SEL):PWM4,电平为直连模式;

## 2.网络状态对应指示灯
(1)未配网:指示继电器状态;

(2)配网中:快闪(250ms闪烁)和慢闪(1500ms闪烁);

(3)配网失败:指示继电器状态;

(4)配网成功:指示继电器状态;

## 3.其他功能

(1)wifi模式为WCM_OLD_LOW,上电低功耗模式,长按按键5秒进入配网模式;

(2)上电默认为断电状态;

## 4.文件说明

(1)device.h/device.c:主要是模块框架部分的头文件和功能,主要包含设备初始化,产测部分的回调,app操作部分的回调等;

(2)app_switch.h/app_switch.c:这部分主要是开关部分的头文件和功能逻辑,主要包括硬件按键操作对应开关状态的显示,app操作对应开关状态的显示,指示灯的显示,倒计时功能等;

(3)app_dltj.c/app_dltj.h:这部分是电量统计的应用层的头文件和功能代码,主要电量实时参数(电流电压功率)上报逻辑和对应的事件处理,电量增量上报逻辑/离线电量存储/未配网状态下电量的存储等;

(4)bl0937.h/bl0937.c:这部分是电量统计芯片bl0937的驱动部分,主要是芯片的硬件初始化/电流电压功率电量的计算/产测部分的处理等;
132 changes: 132 additions & 0 deletions apps/bk7231t_bl0937_1_plug_demo/include/app_dltj.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
/**
* @File: app_dltj.h
* @Author: caojq
* @Last Modified time: 2020-07-29
* @Description: 电量统计上层应用
*.
*/

#ifndef __APP_DLTJ_H__
#define __APP_DLTJ_H__
#include "bl0937.h"
#include "tuya_cloud_types.h"
#include "tuya_cloud_error_code.h"

#ifdef __cplusplus
extern "C" {
#endif
#ifdef _APP_DLTJ_GLOBAL
#define _APP_DLTJ_EXT
#else
#define _APP_DLTJ_EXT extern
#endif

/***********************************************************
*************************micro define***********************
***********************************************************/
#define _APP_DLTJ_DEBUG 0

#define DP_ELE 17 //增加电量上报
#define DP_CURRENT 18 //电流上报
#define DP_POWER 19 //功率上报
#define DP_VOLTAGE 20 //电压上报
//以下可选择上报或不上报
#define DP_PTRSLT 21 //产测结果,0为失败,1为成功,2为未产测
#define DP_VREF 22 //电压系数
#define DP_IREF 23 //电流系数
#define DP_PREF 24 //功率系数
#define DP_EREF 25 //电量系数

#define DP_FAULT 26

/* 220V 产测电压、电流、功率 */
#define V_DEF_220 2200
#define I_DEF_220 392
#define P_DEF_220 864

/* 120V 产测电压、电流、功率 */
#define V_DEF_120 1200
#define I_DEF_120 833
#define P_DEF_120 1000

/* hlw8012芯片,电流采样电阻1mR,电压采样电阻1KR/2MR,220V产测环境
下的校准系数 */
#define V_COE_HLW 1680
#define I_COE_HLW 34586
#define P_COE_HLW 98363
#define E_COE_HLW 212

/* bl0937芯片,电流采样电阻1mR,电压采样电阻1KR/2MR,220V产测环境
下的校准系数 */
#define V_COE_BL 586
#define I_COE_BL 31281
#define P_COE_BL 16192
#define E_COE_BL 1400

/***********************************************************
*************************variable define********************
***********************************************************/
typedef enum{
APP_DLTJ_NORMAL,
APP_DLTJ_PRODTEST
}APP_DLTJ_MODE;

typedef struct{
UCHAR_T edpid;
UCHAR_T idpid;
UCHAR_T pdpid;
UCHAR_T vdpid;
UCHAR_T fault_dpid; //故障告警dpid
}APP_DLTJ_DPID;

typedef struct{
BOOL_T if_have;
UINT_T over_curr;
APP_DLTJ_DPID dp_info;
DLTJ_CONFIG drv_cfg;
}APP_DLTJ_CFG;

/***********************************************************
*************************function define********************
***********************************************************/
/*********************************************************************************
* FUNCTION: app_dltj_init
* DESCRIPTION: 电量统计初始化
* INPUT: mode:电量统计设备模式:正常模式和产测模式
* OUTPUT: none
* RETURN: OPERATE_RET:初始化状态,返回数值型状态值
* OTHERS: bl0937芯片初始化/电量统计参数上报线程
* HISTORY: 2020-03-04
*******************************************************************************/
_APP_DLTJ_EXT \
OPERATE_RET app_dltj_init(IN APP_DLTJ_MODE mode);

/*********************************************************************************
* FUNCTION: report_over_curr
* DESCRIPTION: 上报过流事件
* INPUT: none
* OUTPUT: none
* RETURN: none
* OTHERS: 过流数据上报
* HISTORY: 2020-03-04
*******************************************************************************/
_APP_DLTJ_EXT \
VOID report_over_curr(VOID);

_APP_DLTJ_EXT \
VOID reset_clear_temp_ele(VOID);

_APP_DLTJ_EXT \
VOID reset_clear_ele(VOID);

_APP_DLTJ_EXT \
VOID switch_ele_dp_query(VOID);

_APP_DLTJ_EXT \
VOID hw_report_all_dp_status(VOID);

#ifdef __cplusplus
}
#endif
#endif

Loading

0 comments on commit dd9c585

Please sign in to comment.