mirror of
https://github.com/Ai-Thinker-Open/Ai-Thinker-Open_RTL8710BX_ALIOS_SDK.git
synced 2026-07-08 03:35:38 +00:00
rel_1.6.0 init
This commit is contained in:
commit
27b3e2883d
19359 changed files with 8093121 additions and 0 deletions
10
Living_SDK/example/bluetooth/breezeapp/Config.in
Normal file
10
Living_SDK/example/bluetooth/breezeapp/Config.in
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
menuconfig AOS_APP_BREEZEAPP
|
||||
bool "breezeapp"
|
||||
select AOS_COMP_BREEZE
|
||||
select AOS_COMP_OTA_BLE if @CONDITION@
|
||||
select AOS_COMP_CLI
|
||||
help
|
||||
|
||||
if AOS_APP_BREEZEAPP
|
||||
# Configurations for app breezeapp
|
||||
endif
|
||||
53
Living_SDK/example/bluetooth/breezeapp/README.md
Normal file
53
Living_SDK/example/bluetooth/breezeapp/README.md
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
## Contents
|
||||
|
||||
```
|
||||
breezeapp
|
||||
.
|
||||
├── breezeapp.c
|
||||
└── breezeapp.mk
|
||||
```
|
||||
|
||||
## Introduction
|
||||
|
||||
### Requirements
|
||||
|
||||
* Platform: Nordic's nRF52840/nRF52832 BLE SOCs or other BLE hardware already support AliOS things Breeze SDK.
|
||||
|
||||
* Quintuple: device info to access to Alibaba IoT cloud.
|
||||
|
||||
### Features
|
||||
|
||||
- Breeze transport : provide data transport over BLE link.
|
||||
- Breeze authentication : provice secure access to Alibaba IoT cloud.
|
||||
- Breeze auxiliary provision : provide provision ability(obtation SSID and password, etc) over BLE link.
|
||||
- Breeze OTA : provide unified OTA framework over BLE link.
|
||||
|
||||
### Dependencies
|
||||
|
||||
- yloop
|
||||
- breeze
|
||||
- CLI
|
||||
|
||||
## Usage
|
||||
|
||||
Breezeapp demonstrate usage of breeze SDK functionalities.
|
||||
|
||||
### Build
|
||||
|
||||
aos make bluetooth.breezeapp@pca10056
|
||||
|
||||
### Install
|
||||
|
||||
On ble device, take pca10056 for example, use J-flash or other tools download the compilied binary, on mobile, use Xlinkdemo APPs provided by Alibaba.
|
||||
|
||||
### Run
|
||||
|
||||
Use APP to connect and auth BLE device, APPs offers date exchange, OTA functation, etc.
|
||||
|
||||
### Result
|
||||
|
||||
Chech the hint and result on APP.
|
||||
|
||||
## Reference
|
||||
|
||||
[蓝牙辅助WiFi配网开发说明](https://github.com/alibaba/AliOS-Things/wiki/%E8%93%9D%E7%89%99%E8%BE%85%E5%8A%A9WiFi%E9%85%8D%E7%BD%91%E5%BC%80%E5%8F%91%E8%AF%B4%E6%98%8E)
|
||||
165
Living_SDK/example/bluetooth/breezeapp/breezeapp.c
Normal file
165
Living_SDK/example/bluetooth/breezeapp/breezeapp.c
Normal file
|
|
@ -0,0 +1,165 @@
|
|||
/*
|
||||
* Copyright (C) 2015-2017 Alibaba Group Holding Limited
|
||||
*/
|
||||
|
||||
#include "aos/kernel.h"
|
||||
#include <stdio.h>
|
||||
#include <stdbool.h>
|
||||
#include <breeze_export.h>
|
||||
|
||||
#ifdef CONFIG_AIS_OTA
|
||||
#include <ota_breeze_export.h>
|
||||
#endif
|
||||
|
||||
#define SOFTWARE_VERSION "0.2.0"
|
||||
#define SOFTWARE_VERSION_LEN 5
|
||||
|
||||
|
||||
#define PRODUCT_ID 850876
|
||||
#define DEVICE_SECRET "PJ5ixkKx7BCgnqpgKA8OKBZ6odbJs9KD"
|
||||
#define DEVICE_NAME "leo123456"
|
||||
#define PRODUCT_KEY "a1Nxcg9mErA"
|
||||
#define PRODUCT_SECRET "xaOXlxx6th1QNPY1"
|
||||
|
||||
static bool ble_connected = false;
|
||||
|
||||
/* @brief Event handler for Ali-SDK. */
|
||||
static void dev_status_changed_handler(breeze_event_t event)
|
||||
{
|
||||
switch (event) {
|
||||
case CONNECTED:
|
||||
ble_connected = true;
|
||||
printf("dev_status_changed(): Connected.\n");
|
||||
break;
|
||||
|
||||
case DISCONNECTED:
|
||||
ble_connected = false;
|
||||
printf("dev_status_changed(): Disconnected.\n");
|
||||
break;
|
||||
|
||||
case AUTHENTICATED:
|
||||
printf("dev_status_changed(): Authenticated.\n");
|
||||
break;
|
||||
|
||||
case TX_DONE:
|
||||
printf("dev_status_changed(): Tx-done.\n");
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* @brief Data handler for control command 0x00. */
|
||||
static void set_dev_status_handler(uint8_t *buffer, uint32_t length)
|
||||
{
|
||||
printf("%s command (len: %d) received.\r\n", __func__, length);
|
||||
}
|
||||
|
||||
/* @brief Data handler for query command 0x02. */
|
||||
static void get_dev_status_handler(uint8_t *buffer, uint32_t length)
|
||||
{
|
||||
/* echo the receiving data */
|
||||
uint8_t cmd = 0x03;
|
||||
breeze_post_ext(cmd, buffer, length);
|
||||
}
|
||||
|
||||
#ifdef CONTINUE_BEL_ADV
|
||||
static void adv_work(void *arg)
|
||||
{
|
||||
#ifdef APPEND_USER_ADV
|
||||
static uint8_t user_adv[] = {0x55, 0xaa};
|
||||
|
||||
user_adv[0]++;
|
||||
user_adv[1]++;
|
||||
breeze_append_adv_data(user_adv, sizeof(user_adv) / sizeof(user_adv[0]));
|
||||
#endif
|
||||
|
||||
if (!ble_connected) breeze_restart_advertising();
|
||||
|
||||
aos_post_delayed_action(2000, adv_work, NULL);
|
||||
}
|
||||
#endif
|
||||
|
||||
static void apinfo_handler(breeze_apinfo_t *ap)
|
||||
{
|
||||
printf("Hello %s\r\n", __func__);
|
||||
}
|
||||
|
||||
static void ota_handler(breeze_otainfo_t *ota)
|
||||
{
|
||||
/*need to move ota logic here*/
|
||||
if(ota != NULL){
|
||||
if(ota->type == OTA_CMD){
|
||||
printf("RECV OTA CMD\n");
|
||||
} else if(ota->type == OTA_EVT){
|
||||
printf("RECV OTA EVT (%d)\n", ota->cmd_evt.m_evt.evt);
|
||||
} else{
|
||||
printf("unknown ota info\r\n");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
static void alink_work(void *arg)
|
||||
{
|
||||
bool ret;
|
||||
uint32_t err_code;
|
||||
struct device_config init_bzlink;
|
||||
uint8_t bd_addr[BD_ADDR_LEN] = { 0 };
|
||||
#ifdef CONFIG_AIS_OTA
|
||||
ota_breeze_service_manage_t ota_module;
|
||||
#endif
|
||||
|
||||
(void)arg;
|
||||
|
||||
memset(&init_bzlink, 0, sizeof(struct device_config));
|
||||
init_bzlink.product_id = PRODUCT_ID;
|
||||
init_bzlink.status_changed_cb = dev_status_changed_handler;
|
||||
init_bzlink.set_cb = set_dev_status_handler;
|
||||
init_bzlink.get_cb = get_dev_status_handler;
|
||||
init_bzlink.apinfo_cb = apinfo_handler;
|
||||
|
||||
init_bzlink.device_secret_len = strlen(DEVICE_SECRET);
|
||||
memcpy(init_bzlink.device_secret, DEVICE_SECRET, init_bzlink.device_secret_len);
|
||||
|
||||
init_bzlink.product_secret_len = strlen(PRODUCT_SECRET);
|
||||
memcpy(init_bzlink.product_secret, PRODUCT_SECRET,
|
||||
init_bzlink.product_secret_len);
|
||||
|
||||
init_bzlink.product_key_len = strlen(PRODUCT_KEY);
|
||||
memcpy(init_bzlink.product_key, PRODUCT_KEY, init_bzlink.product_key_len);
|
||||
|
||||
init_bzlink.device_key_len = strlen(DEVICE_NAME);
|
||||
memcpy(init_bzlink.device_name, DEVICE_NAME, init_bzlink.device_key_len);
|
||||
#ifdef CONFIG_AIS_OTA
|
||||
ota_module.is_ota_enable = true;
|
||||
ota_module.verison.fw_ver_len = strlen(SOFTWARE_VERSION);
|
||||
if(ota_module.verison.fw_ver_len > 8) {
|
||||
printf("breeze version too long, make sure < 8 bytes");
|
||||
return;
|
||||
}
|
||||
memcpy(ota_module.verison.fw_ver, SOFTWARE_VERSION, ota_module.verison.fw_ver_len);
|
||||
ota_module.get_dat_cb = NULL;
|
||||
ota_breeze_service_init(&ota_module);
|
||||
init_bzlink.ota_cb = ota_module.get_dat_cb;
|
||||
#else
|
||||
init_bzlink.ota_cb = ota_handler;
|
||||
#endif
|
||||
ret = breeze_start(&init_bzlink);
|
||||
if (ret != 0) {
|
||||
printf("breeze_start failed.\r\n");
|
||||
} else {
|
||||
printf("breeze_start succeed.\r\n");
|
||||
}
|
||||
}
|
||||
|
||||
int application_start(int argc, char **argv)
|
||||
{
|
||||
alink_work(NULL);
|
||||
|
||||
#ifdef CONTINUE_BEL_ADV
|
||||
adv_work(NULL);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
38
Living_SDK/example/bluetooth/breezeapp/breezeapp.mk
Normal file
38
Living_SDK/example/bluetooth/breezeapp/breezeapp.mk
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
NAME := breezeapp
|
||||
|
||||
$(NAME)_MBINS_TYPE := app
|
||||
$(NAME)_VERSION := 1.0.0
|
||||
$(NAME)_SUMMARY := breezeapp
|
||||
$(NAME)_SOURCES := breezeapp.c
|
||||
|
||||
ble = 1
|
||||
bz_en_auth = 1
|
||||
bz_en_awss = 1
|
||||
bz_en_ota = 0
|
||||
|
||||
$(NAME)_COMPONENTS := framework.bluetooth.breeze
|
||||
|
||||
GLOBAL_DEFINES += DEBUG
|
||||
GLOBAL_DEFINES += CONFIG_BLE_LINK_PARAMETERS
|
||||
|
||||
GLOBAL_DEFINES += BUILD_AOS AOS_OTA_RSA
|
||||
|
||||
bz_en_ota ?= 0
|
||||
ifeq ($(bz_en_ota),1)
|
||||
ifeq ($(bz_en_auth), 0)
|
||||
$(error OTA need authentication, please set "bz_en_auth = 1")
|
||||
endif
|
||||
GLOBAL_DEFINES += CONFIG_AIS_OTA
|
||||
$(NAME)_COMPONENTS += ota_ble
|
||||
endif
|
||||
|
||||
ifeq ($(continue_ble_adv),1)
|
||||
GLOBAL_DEFINES += CONTINUE_BEL_ADV
|
||||
endif
|
||||
|
||||
ifeq ($(append_user_adv),1)
|
||||
GLOBAL_DEFINES += APPEND_USER_ADV
|
||||
endif
|
||||
|
||||
|
||||
GLOBAL_INCLUDES += ../
|
||||
Loading…
Add table
Add a link
Reference in a new issue