update 1.8

This commit is contained in:
qiyongshuang
2023-09-06 10:08:11 +08:00
parent b79c6ac80d
commit 64be955461
760 changed files with 42517 additions and 30957 deletions
Binary file not shown.
Binary file not shown.
+10 -3
View File
@@ -1,10 +1,12 @@
/********************************** (C) COPYRIGHT *******************************
* File Name : mesh_lib.h
* Author : WCH
* Version : V1.67
* Version : V1.70
* Date : 2022/10/26
* Description :
* Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd.
* Copyright (c) 2023 Nanjing Qinheng Microelectronics Co., Ltd.
* Attention: This software (modified or not) and binary are used for
* microcontroller manufactured by Nanjing Qinheng Microelectronics.
*******************************************************************************/
#ifndef mesh_lib_H
@@ -118,7 +120,7 @@ typedef signed int ssize_t;
#endif
/******************************************************************************/
#define VER_MESH_FILE "MESH_LIB_V1.6"
#define VER_MESH_FILE "MESH_LIB_V1.7"
extern const uint8_t VER_MESH_LIB[];
// Global_Error_Code
@@ -3506,6 +3508,11 @@ void MeshDeamon_Init( void );
*/
void hal_rf_init( void );
/**
* @brief Weather wait for end when RF tx.
*/
void hal_rf_tx_wait_enable(uint8_t enable );
/**
* @brief Config the RF.
*
File diff suppressed because it is too large Load Diff
@@ -1,2 +0,0 @@
eclipse.preferences.version=1
formatter_settings_version=1
@@ -22,9 +22,7 @@
* GLOBAL TYPEDEFS
*/
__attribute__((aligned(4))) uint32_t MEM_BUF[BLE_MEMHEAP_SIZE / 4];
#if(defined(BLE_MAC)) && (BLE_MAC == TRUE)
const uint8_t MacAddr[6] = {0x84, 0xC2, 0xE4, 0x03, 0x02, 0x02};
#endif
/*********************************************************************
* @fn bt_mesh_lib_init
@@ -91,6 +89,7 @@ void Main_Circulation(void)
*/
int main(void)
{
SystemCoreClockUpdate();
Delay_Init();
#ifdef DEBUG
USART_Printf_Init( 115200 );
@@ -22,7 +22,6 @@
void NMI_Handler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
void HardFault_Handler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
void BB_IRQHandler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
void LLE_IRQHandler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
/*********************************************************************
* @fn NMI_Handler
@@ -60,15 +59,3 @@ void BB_IRQHandler(void)
{
BB_IRQLibHandler();
}
/*********************************************************************
* @fn LLE_IRQHandler
*
* @brief LLE Interrupt for BLE.
*
* @return None
*/
void LLE_IRQHandler(void)
{
LLE_IRQLibHandler();
}
@@ -168,10 +168,10 @@ extern "C" {
#define CONFIG_MESH_FRIEND_RECV_WIN_DEF (30)
#define CONFIG_MESH_FRIEND_RECV_WIN_MAX (255)
// 低功耗节点的请求消息队列大小
// 低功耗节点的请求消息队列大小(log2(N)),例配置为4,则大小为2^4=16
#define CONFIG_MESH_LPN_REQ_QUEUE_SIZE_MIN (2)
#define CONFIG_MESH_LPN_REQ_QUEUE_SIZE_DEF (2)
#define CONFIG_MESH_LPN_REQ_QUEUE_SIZE_MAX (20)
#define CONFIG_MESH_LPN_REQ_QUEUE_SIZE_MAX (4)
// 低功耗节点的请求消息间隔(100ms)
#define CONFIG_MESH_LPN_POLLINTERVAL_MIN (1)
@@ -22,9 +22,7 @@
* GLOBAL TYPEDEFS
*/
__attribute__((aligned(4))) uint32_t MEM_BUF[BLE_MEMHEAP_SIZE / 4];
#if(defined(BLE_MAC)) && (BLE_MAC == TRUE)
const uint8_t MacAddr[6] = {0x84, 0xC2, 0xE4, 0x03, 0x02, 0x02};
#endif
/*********************************************************************
* @fn bt_mesh_lib_init
@@ -91,6 +89,7 @@ void Main_Circulation(void)
*/
int main(void)
{
SystemCoreClockUpdate();
Delay_Init();
#ifdef DEBUG
USART_Printf_Init( 115200 );
@@ -22,7 +22,6 @@
void NMI_Handler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
void HardFault_Handler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
void BB_IRQHandler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
void LLE_IRQHandler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
/*********************************************************************
* @fn NMI_Handler
@@ -60,15 +59,3 @@ void BB_IRQHandler(void)
{
BB_IRQLibHandler();
}
/*********************************************************************
* @fn LLE_IRQHandler
*
* @brief LLE Interrupt for BLE.
*
* @return None
*/
void LLE_IRQHandler(void)
{
LLE_IRQLibHandler();
}
@@ -168,10 +168,10 @@ extern "C" {
#define CONFIG_MESH_FRIEND_RECV_WIN_DEF (30)
#define CONFIG_MESH_FRIEND_RECV_WIN_MAX (255)
// 低功耗节点的请求消息队列大小
// 低功耗节点的请求消息队列大小(log2(N)),例配置为4,则大小为2^4=16
#define CONFIG_MESH_LPN_REQ_QUEUE_SIZE_MIN (2)
#define CONFIG_MESH_LPN_REQ_QUEUE_SIZE_DEF (2)
#define CONFIG_MESH_LPN_REQ_QUEUE_SIZE_MAX (20)
#define CONFIG_MESH_LPN_REQ_QUEUE_SIZE_MAX (4)
// 低功耗节点的请求消息间隔(100ms)
#define CONFIG_MESH_LPN_POLLINTERVAL_MIN (1)
@@ -22,9 +22,7 @@
* GLOBAL TYPEDEFS
*/
__attribute__((aligned(4))) uint32_t MEM_BUF[BLE_MEMHEAP_SIZE / 4];
#if(defined(BLE_MAC)) && (BLE_MAC == TRUE)
const uint8_t MacAddr[6] = {0x84, 0xC2, 0xE4, 0x03, 0x02, 0x02};
#endif
/*********************************************************************
* @fn bt_mesh_lib_init
@@ -91,6 +89,7 @@ void Main_Circulation(void)
*/
int main(void)
{
SystemCoreClockUpdate();
Delay_Init();
#ifdef DEBUG
USART_Printf_Init( 115200 );
@@ -22,7 +22,6 @@
void NMI_Handler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
void HardFault_Handler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
void BB_IRQHandler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
void LLE_IRQHandler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
/*********************************************************************
* @fn NMI_Handler
@@ -60,15 +59,3 @@ void BB_IRQHandler(void)
{
BB_IRQLibHandler();
}
/*********************************************************************
* @fn LLE_IRQHandler
*
* @brief LLE Interrupt for BLE.
*
* @return None
*/
void LLE_IRQHandler(void)
{
LLE_IRQLibHandler();
}
@@ -168,10 +168,10 @@ extern "C" {
#define CONFIG_MESH_FRIEND_RECV_WIN_DEF (30)
#define CONFIG_MESH_FRIEND_RECV_WIN_MAX (255)
// 低功耗节点的请求消息队列大小
// 低功耗节点的请求消息队列大小(log2(N)),例配置为4,则大小为2^4=16
#define CONFIG_MESH_LPN_REQ_QUEUE_SIZE_MIN (2)
#define CONFIG_MESH_LPN_REQ_QUEUE_SIZE_DEF (2)
#define CONFIG_MESH_LPN_REQ_QUEUE_SIZE_MAX (20)
#define CONFIG_MESH_LPN_REQ_QUEUE_SIZE_MAX (4)
// 低功耗节点的请求消息间隔(100ms)
#define CONFIG_MESH_LPN_POLLINTERVAL_MIN (1)
@@ -333,7 +333,7 @@ void send_support_attr(void)
{
struct bt_mesh_indicate *ind;
struct bt_mesh_indicate *ind2;
uint32_t color;
uint8_t color[6];
APP_DBG("");
if(!bt_mesh_is_provisioned())
@@ -371,11 +371,11 @@ void send_support_attr(void)
// 添加led_color属性
{
/* Add led_color attrbute opcode */
net_buf_simple_add_le16(&(ind->buf->b), ALI_GEN_ATTR_TYPE_LIGHTCOLOR_ADJ);
net_buf_simple_add_le16(&(ind->buf->b), ALI_GEN_ATTR_TYPE_COLOR);
/* Add led_color status */
read_led_color(&color);
net_buf_simple_add_u8(&(ind->buf->b), color);
read_led_color(color);
net_buf_simple_add_mem(&(ind->buf->b), color, 6);
}
bt_mesh_indicate_send(ind);
@@ -24,7 +24,7 @@
#define ALI_DEF_TTL (10)
// 模拟led_color值
int32_t device_led_color_adj = 0;
uint8_t device_led_color[6] = {0};
/*******************************************************************************
* Function Name : read_led_color
@@ -32,10 +32,10 @@ int32_t device_led_color_adj = 0;
* Input : None
* Return : None
*******************************************************************************/
void read_led_color(int32_t *pcolor)
void read_led_color(uint8_t *pcolor)
{
APP_DBG("device_led_color_adj: %d ", (int32_t)device_led_color_adj);
*pcolor = device_led_color_adj;
APP_DBG("device_led_color_adj: %d ", device_led_color[0]);
tmos_memcpy(pcolor, device_led_color, 6);
}
/*******************************************************************************
@@ -44,9 +44,9 @@ void read_led_color(int32_t *pcolor)
* Input : None
* Return : None
*******************************************************************************/
void set_led_color(int32_t color)
void set_led_color(uint8_t *pcolor)
{
device_led_color_adj = color;
tmos_memcpy(device_led_color, pcolor, 6);
}
/*******************************************************************************
@@ -61,16 +61,14 @@ static void gen_led_color_status(struct bt_mesh_model *model,
{
NET_BUF_SIMPLE_DEFINE(msg, 32);
int err;
int32_t color;
////////////////////////////////////////////////////////////////////////
// 0xD3 0xA8 0x01 | 0x## | 0x## 0x## | 0x## 0x## ....//
// Opcode | TID | Attribute Type | Attribute Value //
////////////////////////////////////////////////////////////////////////
bt_mesh_model_msg_init(&msg, OP_VENDOR_MESSAGE_ATTR_STATUS);
net_buf_simple_add_u8(&msg, als_avail_tid_get());
net_buf_simple_add_le16(&msg, ALI_GEN_ATTR_TYPE_LIGHTCOLOR_ADJ);
read_led_color(&color);
net_buf_simple_add_le32(&msg, color);
net_buf_simple_add_le16(&msg, ALI_GEN_ATTR_TYPE_COLOR);
net_buf_simple_add_mem(&msg, device_led_color, 6);
APP_DBG("ttl: 0x%02x dst: 0x%04x", ctx->recv_ttl, ctx->recv_dst);
@@ -129,13 +127,13 @@ void gen_led_color_set(struct bt_mesh_model *model,
APP_DBG("ttl: 0x%02x dst: 0x%04x rssi: %d len %d",
ctx->recv_ttl, ctx->recv_dst, ctx->recv_rssi, buf->len);
if((buf->data[1] | (buf->data[2] << 8)) == ALI_GEN_ATTR_TYPE_LIGHTCOLOR_ADJ)
if((buf->data[1] | (buf->data[2] << 8)) == ALI_GEN_ATTR_TYPE_COLOR)
{
APP_DBG("%x %x %x %x %x %x ",
buf->data[0], buf->data[1], buf->data[2], buf->data[3], buf->data[4], buf->data[5]);
int32_t color = (buf->data[3] | (buf->data[4] << 8) | (buf->data[5] << 16) | (buf->data[6] << 24));
APP_DBG("%x %x %x %x %x %x %x %x %x",
buf->data[0], buf->data[1], buf->data[2], buf->data[3], buf->data[4], buf->data[5]
, buf->data[6], buf->data[7], buf->data[8]);
// 命令为设定值
set_led_color(color);
set_led_color(&(buf->data[3]));
}
if(ctx->recv_ttl != ALI_DEF_TTL)
@@ -170,11 +168,13 @@ void gen_led_color_set_unack(struct bt_mesh_model *model,
{
APP_DBG(" ");
if((buf->data[1] | (buf->data[2] << 8)) == ALI_GEN_ATTR_TYPE_LIGHTCOLOR_ADJ)
if((buf->data[1] | (buf->data[2] << 8)) == ALI_GEN_ATTR_TYPE_COLOR)
{
uint32_t color = (buf->data[3] | (buf->data[4] << 8) | (buf->data[5] << 16) | (buf->data[6] << 24));
APP_DBG("%x %x %x %x %x %x %x %x %x",
buf->data[0], buf->data[1], buf->data[2], buf->data[3], buf->data[4], buf->data[5]
, buf->data[6], buf->data[7], buf->data[8]);
// 命令为设定值
set_led_color(color);
set_led_color(&(buf->data[3]));
}
}
@@ -22,9 +22,7 @@
* GLOBAL TYPEDEFS
*/
__attribute__((aligned(4))) uint32_t MEM_BUF[BLE_MEMHEAP_SIZE / 4];
#if(defined(BLE_MAC)) && (BLE_MAC == TRUE)
const uint8_t MacAddr[6] = {0x84, 0xC2, 0xE4, 0x03, 0x02, 0x02};
#endif
/*********************************************************************
* @fn bt_mesh_lib_init
@@ -91,6 +89,7 @@ void Main_Circulation(void)
*/
int main(void)
{
SystemCoreClockUpdate();
Delay_Init();
#ifdef DEBUG
USART_Printf_Init( 115200 );
@@ -92,7 +92,7 @@ static void tm_attr_get(struct bt_mesh_model *model,
{
case ALI_GEN_ATTR_TYPE_RGBCOLOR:
{
gen_led_color_get(model, ctx, buf);
// gen_led_color_get(model, ctx, buf);
break;
}
@@ -131,7 +131,7 @@ static void tm_attr_set(struct bt_mesh_model *model,
switch(attr_type)
{
case ALI_GEN_ATTR_TYPE_LIGHTCOLOR_ADJ:
case ALI_GEN_ATTR_TYPE_COLOR:
{
gen_led_color_set(model, ctx, buf);
break;
@@ -173,7 +173,7 @@ static void tm_attr_set_unack(struct bt_mesh_model *model,
{
case ALI_GEN_ATTR_TYPE_RGBCOLOR:
{
gen_led_color_set_unack(model, ctx, buf);
// gen_led_color_set_unack(model, ctx, buf);
break;
}
@@ -626,7 +626,7 @@ void send_led_indicate(struct indicate_param *param)
void send_led_color_indicate(struct indicate_param *param)
{
struct bt_mesh_indicate *ind;
uint32_t color;
uint8_t color[6];
ind = bt_mesh_ind_alloc(32);
if(!ind)
@@ -643,11 +643,11 @@ void send_led_color_indicate(struct indicate_param *param)
net_buf_simple_add_u8(&(ind->buf->b), param->tid);
/* Add led_color attrbute opcode */
net_buf_simple_add_le16(&(ind->buf->b), ALI_GEN_ATTR_TYPE_LIGHTCOLOR_ADJ);
net_buf_simple_add_le16(&(ind->buf->b), ALI_GEN_ATTR_TYPE_COLOR);
/* Add led_color status */
read_led_color(&color);
net_buf_simple_add_le32(&(ind->buf->b), color);
read_led_color(color);
net_buf_simple_add_mem(&(ind->buf->b), color, 6);
bt_mesh_indicate_send(ind);
}
@@ -22,7 +22,6 @@
void NMI_Handler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
void HardFault_Handler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
void BB_IRQHandler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
void LLE_IRQHandler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
/*********************************************************************
* @fn NMI_Handler
@@ -60,15 +59,3 @@ void BB_IRQHandler(void)
{
BB_IRQLibHandler();
}
/*********************************************************************
* @fn LLE_IRQHandler
*
* @brief LLE Interrupt for BLE.
*
* @return None
*/
void LLE_IRQHandler(void)
{
LLE_IRQLibHandler();
}
@@ -19,9 +19,9 @@ extern "C" {
#include "MESH_LIB.h"
void read_led_color(int32_t *pcolor);
void read_led_color(uint8_t *pcolor);
void set_led_color(int32_t color);
void set_led_color(uint8_t *pcolor);
void gen_led_color_get(struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
@@ -168,10 +168,10 @@ extern "C" {
#define CONFIG_MESH_FRIEND_RECV_WIN_DEF (30)
#define CONFIG_MESH_FRIEND_RECV_WIN_MAX (255)
// 低功耗节点的请求消息队列大小
// 低功耗节点的请求消息队列大小(log2(N)),例配置为4,则大小为2^4=16
#define CONFIG_MESH_LPN_REQ_QUEUE_SIZE_MIN (2)
#define CONFIG_MESH_LPN_REQ_QUEUE_SIZE_DEF (2)
#define CONFIG_MESH_LPN_REQ_QUEUE_SIZE_MAX (20)
#define CONFIG_MESH_LPN_REQ_QUEUE_SIZE_MAX (4)
// 低功耗节点的请求消息间隔(100ms)
#define CONFIG_MESH_LPN_POLLINTERVAL_MIN (1)
@@ -145,6 +145,8 @@ void send_led_color_indicate(struct indicate_param *param);
void bt_mesh_indicate_reset(void);
void send_color_indicate(struct indicate_param *param); //添加处
/**
* @brief 阿里 厂家模型 初始化
*
@@ -22,9 +22,7 @@
* GLOBAL TYPEDEFS
*/
__attribute__((aligned(4))) uint32_t MEM_BUF[BLE_MEMHEAP_SIZE / 4];
#if(defined(BLE_MAC)) && (BLE_MAC == TRUE)
const uint8_t MacAddr[6] = {0x84, 0xC2, 0xE4, 0x03, 0x02, 0x02};
#endif
/*********************************************************************
* @fn bt_mesh_lib_init
@@ -91,6 +89,7 @@ void Main_Circulation(void)
*/
int main(void)
{
SystemCoreClockUpdate();
Delay_Init();
#ifdef DEBUG
USART_Printf_Init( 115200 );
@@ -22,7 +22,6 @@
void NMI_Handler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
void HardFault_Handler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
void BB_IRQHandler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
void LLE_IRQHandler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
/*********************************************************************
* @fn NMI_Handler
@@ -60,15 +59,3 @@ void BB_IRQHandler(void)
{
BB_IRQLibHandler();
}
/*********************************************************************
* @fn LLE_IRQHandler
*
* @brief LLE Interrupt for BLE.
*
* @return None
*/
void LLE_IRQHandler(void)
{
LLE_IRQLibHandler();
}
@@ -168,10 +168,10 @@ extern "C" {
#define CONFIG_MESH_FRIEND_RECV_WIN_DEF (30)
#define CONFIG_MESH_FRIEND_RECV_WIN_MAX (255)
// 低功耗节点的请求消息队列大小
// 低功耗节点的请求消息队列大小(log2(N)),例配置为4,则大小为2^4=16
#define CONFIG_MESH_LPN_REQ_QUEUE_SIZE_MIN (2)
#define CONFIG_MESH_LPN_REQ_QUEUE_SIZE_DEF (2)
#define CONFIG_MESH_LPN_REQ_QUEUE_SIZE_MAX (20)
#define CONFIG_MESH_LPN_REQ_QUEUE_SIZE_MAX (4)
// 低功耗节点的请求消息间隔(100ms)
#define CONFIG_MESH_LPN_POLLINTERVAL_MIN (1)
@@ -176,7 +176,8 @@ static gapRolesBroadcasterCBs_t Broadcaster_BroadcasterCBs = {
// GAP Bond Manager Callbacks
static gapBondCBs_t Peripheral_BondMgrCBs = {
NULL, // Passcode callback (not used by application)
NULL // Pairing / Bonding state Callback (not used by application)
NULL, // Pairing / Bonding state Callback (not used by application)
NULL // oob callback
};
// Simple GATT Profile Callbacks
@@ -217,7 +218,7 @@ void Peripheral_Init(void)
}
// Set the GAP Characteristics
GGS_SetParameter(GGS_DEVICE_NAME_ATT, GAP_DEVICE_NAME_LEN, attDeviceName);
GGS_SetParameter(GGS_DEVICE_NAME_ATT, sizeof(attDeviceName), attDeviceName);
// Set advertising interval
{
@@ -3,7 +3,9 @@
* Author : WCH
* Version : V1.0
* Date : 2018/12/10
* Description : 自定义包含五种不同属性的服务,包含可读、可写、通知、可读可写、安全可读
* Description : Customize services with five different attributes,
* including readable, writable, notification, readable and writable,
* and safe readable
*********************************************************************************
* Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd.
* Attention: This software (modified or not) and binary are used for
@@ -116,7 +118,7 @@ static uint8_t simpleProfileChar4[SIMPLEPROFILE_CHAR4_LEN] = {0};
// instantiation of the Client Characteristic Configuration. Reads of the
// Client Characteristic Configuration only shows the configuration for
// that client and writes only affect the configuration of that client.
static gattCharCfg_t simpleProfileChar4Config[4];
static gattCharCfg_t simpleProfileChar4Config[PERIPHERAL_MAX_CONNECTION];
// Simple Profile Characteristic 4 User Description
static uint8_t simpleProfileChar4UserDesp[] = "Characteristic 4\0";
@@ -511,6 +513,7 @@ static bStatus_t simpleProfile_ReadAttrCB(uint16_t connHandle, gattAttribute_t *
{
bStatus_t status = SUCCESS;
// Make sure it's not a blob operation (no attributes in the profile are long)
if(offset > 0)
{
+2 -2
View File
@@ -68,8 +68,8 @@
</option>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.std.2020844713" name="Language standard" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.std" useByScannerDiscovery="true" value="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.std.gnu99" valueType="enumerated"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.defs.177116515" name="Defined symbols (-D)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.defs" useByScannerDiscovery="true" valueType="definedSymbols">
<listOptionValue builtIn="false" value="BLE_MEMHEAP_SIZE=4096"/>
<listOptionValue builtIn="false" value="CH32V20x_D8W"/>
<listOptionValue builtIn="false" value="BLE_MAC=1"/>
<listOptionValue builtIn="false" value="HAL_KEY=1"/>
</option>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="true" id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.include.files.288896968" name="Include files (-include)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.include.files" useByScannerDiscovery="true" valueType="includeFiles"/>
@@ -159,5 +159,5 @@
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
<storageModule moduleId="org.eclipse.cdt.make.core.buildtargets"/>
<storageModule moduleId="refreshScope"/>
</cproject>
@@ -91,6 +91,7 @@ void Main_Circulation(void)
*/
int main(void)
{
SystemCoreClockUpdate();
Delay_Init();
#ifdef DEBUG
USART_Printf_Init( 115200 );
@@ -22,7 +22,6 @@
void NMI_Handler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
void HardFault_Handler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
void BB_IRQHandler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
void LLE_IRQHandler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
/*********************************************************************
* @fn NMI_Handler
@@ -60,15 +59,3 @@ void BB_IRQHandler(void)
{
BB_IRQLibHandler();
}
/*********************************************************************
* @fn LLE_IRQHandler
*
* @brief LLE Interrupt for BLE.
*
* @return None
*/
void LLE_IRQHandler(void)
{
LLE_IRQLibHandler();
}
@@ -168,10 +168,10 @@ extern "C" {
#define CONFIG_MESH_FRIEND_RECV_WIN_DEF (30)
#define CONFIG_MESH_FRIEND_RECV_WIN_MAX (255)
// 低功耗节点的请求消息队列大小
// 低功耗节点的请求消息队列大小(log2(N)),例配置为4,则大小为2^4=16
#define CONFIG_MESH_LPN_REQ_QUEUE_SIZE_MIN (2)
#define CONFIG_MESH_LPN_REQ_QUEUE_SIZE_DEF (2)
#define CONFIG_MESH_LPN_REQ_QUEUE_SIZE_MAX (20)
#define CONFIG_MESH_LPN_REQ_QUEUE_SIZE_MAX (4)
// 低功耗节点的请求消息间隔(100ms)
#define CONFIG_MESH_LPN_POLLINTERVAL_MIN (1)
+12 -4
View File
@@ -44,7 +44,6 @@ static uint8_t App_TaskID = 0; // Task ID for internal task/event processing
static uint16_t App_ProcessEvent(uint8_t task_id, uint16_t events);
static uint8_t dev_uuid[16] = {0}; // 此设备的UUID
uint8_t MACAddr[6]; // 此设备的mac
#if(!CONFIG_BLE_MESH_PB_GATT)
NET_BUF_SIMPLE_DEFINE_STATIC(rx_buf, 65);
@@ -471,9 +470,18 @@ void blemesh_on_sync(void)
lpn_init_register(bt_mesh_lpn_init, lpn_state);
#endif /* LPN */
FLASH_GetMACAddress(MACAddr);
tmos_memcpy(dev_uuid, MACAddr, 6);
err = bt_mesh_cfg_set(&app_mesh_cfg, &app_dev, MACAddr, &info);
#if(defined(BLE_MAC)) && (BLE_MAC == TRUE)
tmos_memcpy(dev_uuid, MacAddr, 6);
err = bt_mesh_cfg_set(&app_mesh_cfg, &app_dev, MacAddr, &info);
#else
{
uint8_t MacAddr[6];
FLASH_GetMACAddress(MacAddr);
tmos_memcpy(dev_uuid, MacAddr, 6);
// 使用芯片mac地址
err = bt_mesh_cfg_set(&app_mesh_cfg, &app_dev, MacAddr, &info);
}
#endif
if(err)
{
APP_DBG("Unable set configuration (err:%d)", err);
@@ -91,6 +91,7 @@ void Main_Circulation(void)
*/
int main(void)
{
SystemCoreClockUpdate();
Delay_Init();
#ifdef DEBUG
USART_Printf_Init( 115200 );
@@ -22,7 +22,6 @@
void NMI_Handler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
void HardFault_Handler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
void BB_IRQHandler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
void LLE_IRQHandler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
/*********************************************************************
* @fn NMI_Handler
@@ -60,15 +59,3 @@ void BB_IRQHandler(void)
{
BB_IRQLibHandler();
}
/*********************************************************************
* @fn LLE_IRQHandler
*
* @brief LLE Interrupt for BLE.
*
* @return None
*/
void LLE_IRQHandler(void)
{
LLE_IRQLibHandler();
}
@@ -168,10 +168,10 @@ extern "C" {
#define CONFIG_MESH_FRIEND_RECV_WIN_DEF (30)
#define CONFIG_MESH_FRIEND_RECV_WIN_MAX (255)
// 低功耗节点的请求消息队列大小
// 低功耗节点的请求消息队列大小(log2(N)),例配置为4,则大小为2^4=16
#define CONFIG_MESH_LPN_REQ_QUEUE_SIZE_MIN (2)
#define CONFIG_MESH_LPN_REQ_QUEUE_SIZE_DEF (2)
#define CONFIG_MESH_LPN_REQ_QUEUE_SIZE_MAX (20)
#define CONFIG_MESH_LPN_REQ_QUEUE_SIZE_MAX (4)
// 低功耗节点的请求消息间隔(100ms)
#define CONFIG_MESH_LPN_POLLINTERVAL_MIN (1)
+12 -4
View File
@@ -44,7 +44,6 @@ static uint8_t App_TaskID = 0; // Task ID for internal task/event processing
static uint16_t App_ProcessEvent(uint8_t task_id, uint16_t events);
static uint8_t dev_uuid[16] = {0}; // 此设备的UUID
uint8_t MACAddr[6]; // 此设备的mac
#if(!CONFIG_BLE_MESH_PB_GATT)
NET_BUF_SIMPLE_DEFINE_STATIC(rx_buf, 65);
@@ -497,9 +496,18 @@ void blemesh_on_sync(void)
lpn_init_register(bt_mesh_lpn_init, lpn_state);
#endif /* LPN */
FLASH_GetMACAddress(MACAddr);
tmos_memcpy(dev_uuid, MACAddr, 6);
err = bt_mesh_cfg_set(&app_mesh_cfg, &app_dev, MACAddr, &info);
#if(defined(BLE_MAC)) && (BLE_MAC == TRUE)
tmos_memcpy(dev_uuid, MacAddr, 6);
err = bt_mesh_cfg_set(&app_mesh_cfg, &app_dev, MacAddr, &info);
#else
{
uint8_t MacAddr[6];
FLASH_GetMACAddress(MacAddr);
tmos_memcpy(dev_uuid, MacAddr, 6);
// 使用芯片mac地址
err = bt_mesh_cfg_set(&app_mesh_cfg, &app_dev, MacAddr, &info);
}
#endif
if(err)
{
APP_DBG("Unable set configuration (err:%d)", err);
@@ -91,6 +91,7 @@ void Main_Circulation(void)
*/
int main(void)
{
SystemCoreClockUpdate();
Delay_Init();
#ifdef DEBUG
USART_Printf_Init( 115200 );
@@ -22,7 +22,6 @@
void NMI_Handler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
void HardFault_Handler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
void BB_IRQHandler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
void LLE_IRQHandler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
/*********************************************************************
* @fn NMI_Handler
@@ -60,15 +59,3 @@ void BB_IRQHandler(void)
{
BB_IRQLibHandler();
}
/*********************************************************************
* @fn LLE_IRQHandler
*
* @brief LLE Interrupt for BLE.
*
* @return None
*/
void LLE_IRQHandler(void)
{
LLE_IRQLibHandler();
}
@@ -168,10 +168,10 @@ extern "C" {
#define CONFIG_MESH_FRIEND_RECV_WIN_DEF (30)
#define CONFIG_MESH_FRIEND_RECV_WIN_MAX (255)
// 低功耗节点的请求消息队列大小
// 低功耗节点的请求消息队列大小(log2(N)),例配置为4,则大小为2^4=16
#define CONFIG_MESH_LPN_REQ_QUEUE_SIZE_MIN (2)
#define CONFIG_MESH_LPN_REQ_QUEUE_SIZE_DEF (2)
#define CONFIG_MESH_LPN_REQ_QUEUE_SIZE_MAX (20)
#define CONFIG_MESH_LPN_REQ_QUEUE_SIZE_MAX (4)
// 低功耗节点的请求消息间隔(100ms)
#define CONFIG_MESH_LPN_POLLINTERVAL_MIN (1)
@@ -44,7 +44,6 @@ static uint8_t App_TaskID = 0; // Task ID for internal task/event processing
static uint16_t App_ProcessEvent(uint8_t task_id, uint16_t events);
static uint8_t dev_uuid[16] = {0}; // 此设备的UUID
uint8_t MACAddr[6]; // 此设备的mac
#if(!CONFIG_BLE_MESH_PB_GATT)
NET_BUF_SIMPLE_DEFINE_STATIC(rx_buf, 65);
@@ -64,7 +63,7 @@ static void prov_reset(void);
static struct bt_mesh_cfg_srv cfg_srv = {
.relay = BLE_MESH_RELAY_DISABLED,
.beacon = BLE_MESH_BEACON_ENABLED,
.beacon = BLE_MESH_BEACON_DISABLED,
#if(CONFIG_BLE_MESH_FRIEND)
.frnd = BLE_MESH_FRIEND_ENABLED,
#endif
@@ -308,16 +307,16 @@ static void cfg_srv_rsp_handler( const cfg_srv_status_t *val )
*
* @brief 朋友关系建立回调
*
* @param friend_addr - 朋友节点地址
* @param frd_addr - 朋友节点地址
* state - 回调状态
*
* @return none
*/
static void lpn_state(uint16_t friend_addr, uint8_t state)
static void lpn_state(uint16_t frd_addr, uint8_t state)
{
if(state == LPN_FRIENDSHIP_ESTABLISHED)
{
APP_DBG("lpn friendship established");
APP_DBG("lpn friendship established %d",frd_addr);
}
else if(state == LPN_FRIENDSHIP_TERMINATED)
{
@@ -500,9 +499,18 @@ void blemesh_on_sync(void)
lpn_init_register(bt_mesh_lpn_init, lpn_state);
#endif /* LPN */
FLASH_GetMACAddress(MACAddr);
tmos_memcpy(dev_uuid, MACAddr, 6);
err = bt_mesh_cfg_set(&app_mesh_cfg, &app_dev, MACAddr, &info);
#if(defined(BLE_MAC)) && (BLE_MAC == TRUE)
tmos_memcpy(dev_uuid, MacAddr, 6);
err = bt_mesh_cfg_set(&app_mesh_cfg, &app_dev, MacAddr, &info);
#else
{
uint8_t MacAddr[6];
FLASH_GetMACAddress(MacAddr);
tmos_memcpy(dev_uuid, MacAddr, 6);
// 使用芯片mac地址
err = bt_mesh_cfg_set(&app_mesh_cfg, &app_dev, MacAddr, &info);
}
#endif
if(err)
{
APP_DBG("Unable set configuration (err:%d)", err);
@@ -91,6 +91,7 @@ void Main_Circulation(void)
*/
int main(void)
{
SystemCoreClockUpdate();
Delay_Init();
#ifdef DEBUG
USART_Printf_Init( 115200 );
@@ -22,7 +22,6 @@
void NMI_Handler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
void HardFault_Handler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
void BB_IRQHandler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
void LLE_IRQHandler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
/*********************************************************************
* @fn NMI_Handler
@@ -60,15 +59,3 @@ void BB_IRQHandler(void)
{
BB_IRQLibHandler();
}
/*********************************************************************
* @fn LLE_IRQHandler
*
* @brief LLE Interrupt for BLE.
*
* @return None
*/
void LLE_IRQHandler(void)
{
LLE_IRQLibHandler();
}
@@ -168,10 +168,10 @@ extern "C" {
#define CONFIG_MESH_FRIEND_RECV_WIN_DEF (30)
#define CONFIG_MESH_FRIEND_RECV_WIN_MAX (255)
// 低功耗节点的请求消息队列大小
// 低功耗节点的请求消息队列大小(log2(N)),例配置为4,则大小为2^4=16
#define CONFIG_MESH_LPN_REQ_QUEUE_SIZE_MIN (2)
#define CONFIG_MESH_LPN_REQ_QUEUE_SIZE_DEF (2)
#define CONFIG_MESH_LPN_REQ_QUEUE_SIZE_MAX (20)
#define CONFIG_MESH_LPN_REQ_QUEUE_SIZE_MAX (4)
// 低功耗节点的请求消息间隔(100ms)
#define CONFIG_MESH_LPN_POLLINTERVAL_MIN (1)
@@ -42,7 +42,6 @@ static uint8_t App_TaskID = 0; // Task ID for internal task/event processing
static uint16_t App_ProcessEvent(uint8_t task_id, uint16_t events);
static uint8_t dev_uuid[16] = {0}; // 此设备的UUID
uint8_t MACAddr[6]; // 此设备的mac
static const uint8_t self_prov_net_key[16] = {
0x00, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
@@ -612,9 +611,18 @@ void blemesh_on_sync(void)
lpn_init_register(bt_mesh_lpn_init, lpn_state);
#endif /* LPN */
FLASH_GetMACAddress(MACAddr);
tmos_memcpy(dev_uuid, MACAddr, 6);
err = bt_mesh_cfg_set(&app_mesh_cfg, &app_dev, MACAddr, &info);
#if(defined(BLE_MAC)) && (BLE_MAC == TRUE)
tmos_memcpy(dev_uuid, MacAddr, 6);
err = bt_mesh_cfg_set(&app_mesh_cfg, &app_dev, MacAddr, &info);
#else
{
uint8_t MacAddr[6];
FLASH_GetMACAddress(MacAddr);
tmos_memcpy(dev_uuid, MacAddr, 6);
// 使用芯片mac地址
err = bt_mesh_cfg_set(&app_mesh_cfg, &app_dev, MacAddr, &info);
}
#endif
if(err)
{
APP_DBG("Unable set configuration (err:%d)", err);
@@ -91,6 +91,7 @@ void Main_Circulation(void)
*/
int main(void)
{
SystemCoreClockUpdate();
Delay_Init();
#ifdef DEBUG
USART_Printf_Init( 115200 );
@@ -22,7 +22,6 @@
void NMI_Handler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
void HardFault_Handler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
void BB_IRQHandler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
void LLE_IRQHandler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
/*********************************************************************
* @fn NMI_Handler
@@ -60,15 +59,3 @@ void BB_IRQHandler(void)
{
BB_IRQLibHandler();
}
/*********************************************************************
* @fn LLE_IRQHandler
*
* @brief LLE Interrupt for BLE.
*
* @return None
*/
void LLE_IRQHandler(void)
{
LLE_IRQLibHandler();
}
@@ -168,10 +168,10 @@ extern "C" {
#define CONFIG_MESH_FRIEND_RECV_WIN_DEF (30)
#define CONFIG_MESH_FRIEND_RECV_WIN_MAX (255)
// 低功耗节点的请求消息队列大小
// 低功耗节点的请求消息队列大小(log2(N)),例配置为4,则大小为2^4=16
#define CONFIG_MESH_LPN_REQ_QUEUE_SIZE_MIN (2)
#define CONFIG_MESH_LPN_REQ_QUEUE_SIZE_DEF (2)
#define CONFIG_MESH_LPN_REQ_QUEUE_SIZE_MAX (20)
#define CONFIG_MESH_LPN_REQ_QUEUE_SIZE_MAX (4)
// 低功耗节点的请求消息间隔(100ms)
#define CONFIG_MESH_LPN_POLLINTERVAL_MIN (1)
@@ -147,6 +147,7 @@ void ReadImageFlag(void)
*/
int main(void)
{
SystemCoreClockUpdate();
Delay_Init();
#ifdef DEBUG
USART_Printf_Init( 115200 );
@@ -21,7 +21,6 @@
void NMI_Handler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
void HardFault_Handler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
void BB_IRQHandler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
void LLE_IRQHandler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
/*********************************************************************
* @fn NMI_Handler
@@ -58,14 +57,3 @@ void HardFault_Handler(void)
void BB_IRQHandler(void)
{
}
/*********************************************************************
* @fn LLE_IRQHandler
*
* @brief LLE Interrupt for BLE.
*
* @return None
*/
void LLE_IRQHandler(void)
{
}
@@ -165,5 +165,4 @@
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
<storageModule moduleId="org.eclipse.cdt.make.core.buildtargets"/>
</cproject>
@@ -47,7 +47,6 @@ static uint8_t App_TaskID = 0; // Task ID for internal task/event processing
static uint16_t App_ProcessEvent(uint8_t task_id, uint16_t events);
static uint8_t dev_uuid[16] = {0}; // 此设备的UUID
uint8_t MACAddr[6]; // 此设备的mac
static uint8_t self_prov_net_key[16] = {0};
@@ -534,7 +533,6 @@ static int vendor_model_srv_send(uint16_t addr, uint8_t *pData, uint16_t len)
.tid = vendor_srv_tid_get(), // tid,每个独立消息递增循环,srv使用128~191
.send_ttl = BLE_MESH_TTL_DEFAULT, // ttl,无特定则使用默认值
};
// return vendor_message_srv_indicate(&param, pData, len); // 调用自定义模型服务的有应答指示函数发送数据,默认超时2s
vendor_message_srv_trans_reset();
return vendor_message_srv_send_trans(&param, pData, len); // 或者调用自定义模型服务的透传函数发送数据,只发送,无应答机制
}
@@ -652,9 +650,18 @@ void blemesh_on_sync(void)
lpn_init_register(bt_mesh_lpn_init, lpn_state);
#endif /* LPN */
FLASH_GetMACAddress(MACAddr);
tmos_memcpy(dev_uuid, MACAddr, 6);
err = bt_mesh_cfg_set(&app_mesh_cfg, &app_dev, MACAddr, &info);
#if(defined(BLE_MAC)) && (BLE_MAC == TRUE)
tmos_memcpy(dev_uuid, MacAddr, 6);
err = bt_mesh_cfg_set(&app_mesh_cfg, &app_dev, MacAddr, &info);
#else
{
uint8_t MacAddr[6];
FLASH_GetMACAddress(MacAddr);
tmos_memcpy(dev_uuid, MacAddr, 6);
// 使用芯片mac地址
err = bt_mesh_cfg_set(&app_mesh_cfg, &app_dev, MacAddr, &info);
}
#endif
if(err)
{
APP_DBG("Unable set configuration (err:%d)", err);
@@ -91,6 +91,7 @@ void Main_Circulation(void)
*/
int main(void)
{
SystemCoreClockUpdate();
Delay_Init();
#ifdef DEBUG
USART_Printf_Init( 115200 );
@@ -22,7 +22,6 @@
void NMI_Handler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
void HardFault_Handler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
void BB_IRQHandler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
void LLE_IRQHandler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
/*********************************************************************
* @fn NMI_Handler
@@ -60,15 +59,3 @@ void BB_IRQHandler(void)
{
BB_IRQLibHandler();
}
/*********************************************************************
* @fn LLE_IRQHandler
*
* @brief LLE Interrupt for BLE.
*
* @return None
*/
void LLE_IRQHandler(void)
{
LLE_IRQLibHandler();
}
@@ -16,7 +16,7 @@
#ifdef __cplusplus
extern "C" {
#endif
/**************************功能配置***************************************************/
/**************************功能配置,建议直接参考不同例程*****************************/
// relay功能
#define CONFIG_BLE_MESH_RELAY 1
@@ -168,10 +168,10 @@ extern "C" {
#define CONFIG_MESH_FRIEND_RECV_WIN_DEF (30)
#define CONFIG_MESH_FRIEND_RECV_WIN_MAX (255)
// 低功耗节点的请求消息队列大小
// 低功耗节点的请求消息队列大小(log2(N)),例配置为4,则大小为2^4=16
#define CONFIG_MESH_LPN_REQ_QUEUE_SIZE_MIN (2)
#define CONFIG_MESH_LPN_REQ_QUEUE_SIZE_DEF (2)
#define CONFIG_MESH_LPN_REQ_QUEUE_SIZE_MAX (20)
#define CONFIG_MESH_LPN_REQ_QUEUE_SIZE_MAX (4)
// 低功耗节点的请求消息间隔(100ms)
#define CONFIG_MESH_LPN_POLLINTERVAL_MIN (1)
@@ -165,7 +165,8 @@ static gapRolesBroadcasterCBs_t Broadcaster_BroadcasterCBs = {
// GAP Bond Manager Callbacks
static gapBondCBs_t Peripheral_BondMgrCBs = {
NULL, // Passcode callback (not used by application)
NULL // Pairing / Bonding state Callback (not used by application)
NULL, // Pairing / Bonding state Callback (not used by application)
NULL // oob callback
};
// Simple GATT Profile Callbacks
@@ -209,7 +210,7 @@ void Peripheral_Init()
}
// Set the GAP Characteristics
GGS_SetParameter(GGS_DEVICE_NAME_ATT, GAP_DEVICE_NAME_LEN, attDeviceName);
GGS_SetParameter(GGS_DEVICE_NAME_ATT, sizeof(attDeviceName), attDeviceName);
// Set advertising interval
{
@@ -3,7 +3,9 @@
* Author : WCH
* Version : V1.0
* Date : 2018/12/10
* Description : 自定义包含五种不同属性的服务,包含可读、可写、通知、可读可写、安全可读
* Description : Customize services with five different attributes,
* including readable, writable, notification, readable and writable,
* and safe readable
*********************************************************************************
* Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd.
* Attention: This software (modified or not) and binary are used for
@@ -117,7 +119,7 @@ static uint8_t simpleProfileChar4[SIMPLEPROFILE_CHAR4_LEN] = {0};
// instantiation of the Client Characteristic Configuration. Reads of the
// Client Characteristic Configuration only shows the configuration for
// that client and writes only affect the configuration of that client.
static gattCharCfg_t simpleProfileChar4Config[4];
static gattCharCfg_t simpleProfileChar4Config[PERIPHERAL_MAX_CONNECTION];
// Simple Profile Characteristic 4 User Description
static uint8_t simpleProfileChar4UserDesp[] = "Characteristic 4\0";
@@ -352,7 +354,7 @@ bStatus_t SimpleProfile_RegisterAppCBs(simpleProfileCBs_t *appCallbacks)
*
* @return bStatus_t
*/
bStatus_t SimpleProfile_SetParameter(uint8_t param, uint8_t len, void *value)
bStatus_t SimpleProfile_SetParameter(uint8_t param, uint16_t len, void *value)
{
bStatus_t ret = SUCCESS;
switch(param)
@@ -104,7 +104,7 @@ extern bStatus_t SimpleProfile_RegisterAppCBs(simpleProfileCBs_t *appCallbacks);
* data type (example: data type of uint16_t will be cast to
* uint16_t pointer).
*/
extern bStatus_t SimpleProfile_SetParameter(uint8_t param, uint8_t len, void *value);
extern bStatus_t SimpleProfile_SetParameter(uint8_t param, uint16_t len, void *value);
/*
* SimpleProfile_GetParameter - Get a Simple GATT Profile parameter.
@@ -40,7 +40,6 @@ static uint8_t App_TaskID = 0; // Task ID for internal task/event processing
static uint16_t App_ProcessEvent(uint8_t task_id, uint16_t events);
static uint8_t dev_uuid[16] = {0}; // 此设备的UUID
uint8_t MACAddr[6]; // 此设备的mac
static const uint8_t self_prov_net_key[16] = {
0x00, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
@@ -1000,9 +999,18 @@ void blemesh_on_sync(void)
#if(CONFIG_BLE_MESH_LOW_POWER)
lpn_init_register(bt_mesh_lpn_init);
#endif /* LPN */
FLASH_GetMACAddress(MACAddr);
tmos_memcpy(dev_uuid, MACAddr, 6);
err = bt_mesh_cfg_set(&app_mesh_cfg, &app_dev, MACAddr, &info);
#if(defined(BLE_MAC)) && (BLE_MAC == TRUE)
tmos_memcpy(dev_uuid, MacAddr, 6);
err = bt_mesh_cfg_set(&app_mesh_cfg, &app_dev, MacAddr, &info);
#else
{
uint8_t MacAddr[6];
FLASH_GetMACAddress(MacAddr);
tmos_memcpy(dev_uuid, MacAddr, 6);
// 使用芯片mac地址
err = bt_mesh_cfg_set(&app_mesh_cfg, &app_dev, MacAddr, &info);
}
#endif
if(err)
{
APP_DBG("Unable set configuration (err:%d)", err);
@@ -91,6 +91,7 @@ void Main_Circulation(void)
*/
int main(void)
{
SystemCoreClockUpdate();
Delay_Init();
#ifdef DEBUG
USART_Printf_Init( 115200 );
@@ -22,7 +22,6 @@
void NMI_Handler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
void HardFault_Handler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
void BB_IRQHandler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
void LLE_IRQHandler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
/*********************************************************************
* @fn NMI_Handler
@@ -60,15 +59,3 @@ void BB_IRQHandler(void)
{
BB_IRQLibHandler();
}
/*********************************************************************
* @fn LLE_IRQHandler
*
* @brief LLE Interrupt for BLE.
*
* @return None
*/
void LLE_IRQHandler(void)
{
LLE_IRQLibHandler();
}
@@ -168,10 +168,10 @@ extern "C" {
#define CONFIG_MESH_FRIEND_RECV_WIN_DEF (30)
#define CONFIG_MESH_FRIEND_RECV_WIN_MAX (255)
// 低功耗节点的请求消息队列大小
// 低功耗节点的请求消息队列大小(log2(N)),例配置为4,则大小为2^4=16
#define CONFIG_MESH_LPN_REQ_QUEUE_SIZE_MIN (2)
#define CONFIG_MESH_LPN_REQ_QUEUE_SIZE_DEF (2)
#define CONFIG_MESH_LPN_REQ_QUEUE_SIZE_MAX (20)
#define CONFIG_MESH_LPN_REQ_QUEUE_SIZE_MAX (4)
// 低功耗节点的请求消息间隔(100ms)
#define CONFIG_MESH_LPN_POLLINTERVAL_MIN (1)
@@ -41,7 +41,6 @@ static uint8_t App_TaskID = 0; // Task ID for internal task/event processing
static uint16_t App_ProcessEvent(uint8_t task_id, uint16_t events);
static uint8_t dev_uuid[16] = {0}; // 此设备的UUID
uint8_t MACAddr[6]; // 此设备的mac
static const uint8_t self_prov_net_key[16] = {
0x00, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
@@ -1005,9 +1004,18 @@ void blemesh_on_sync(void)
#if(CONFIG_BLE_MESH_LOW_POWER)
lpn_init_register(bt_mesh_lpn_init);
#endif /* LPN */
FLASH_GetMACAddress(MACAddr);
tmos_memcpy(dev_uuid, MACAddr, 6);
err = bt_mesh_cfg_set(&app_mesh_cfg, &app_dev, MACAddr, &info);
#if(defined(BLE_MAC)) && (BLE_MAC == TRUE)
tmos_memcpy(dev_uuid, MacAddr, 6);
err = bt_mesh_cfg_set(&app_mesh_cfg, &app_dev, MacAddr, &info);
#else
{
uint8_t MacAddr[6];
FLASH_GetMACAddress(MacAddr);
tmos_memcpy(dev_uuid, MacAddr, 6);
// 使用芯片mac地址
err = bt_mesh_cfg_set(&app_mesh_cfg, &app_dev, MacAddr, &info);
}
#endif
if(err)
{
APP_DBG("Unable set configuration (err:%d)", err);
@@ -91,6 +91,7 @@ void Main_Circulation(void)
*/
int main(void)
{
SystemCoreClockUpdate();
Delay_Init();
#ifdef DEBUG
USART_Printf_Init( 115200 );
@@ -22,7 +22,6 @@
void NMI_Handler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
void HardFault_Handler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
void BB_IRQHandler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
void LLE_IRQHandler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
/*********************************************************************
* @fn NMI_Handler
@@ -60,15 +59,3 @@ void BB_IRQHandler(void)
{
BB_IRQLibHandler();
}
/*********************************************************************
* @fn LLE_IRQHandler
*
* @brief LLE Interrupt for BLE.
*
* @return None
*/
void LLE_IRQHandler(void)
{
LLE_IRQLibHandler();
}
@@ -168,10 +168,10 @@ extern "C" {
#define CONFIG_MESH_FRIEND_RECV_WIN_DEF (30)
#define CONFIG_MESH_FRIEND_RECV_WIN_MAX (255)
// 低功耗节点的请求消息队列大小
// 低功耗节点的请求消息队列大小(log2(N)),例配置为4,则大小为2^4=16
#define CONFIG_MESH_LPN_REQ_QUEUE_SIZE_MIN (2)
#define CONFIG_MESH_LPN_REQ_QUEUE_SIZE_DEF (2)
#define CONFIG_MESH_LPN_REQ_QUEUE_SIZE_MAX (20)
#define CONFIG_MESH_LPN_REQ_QUEUE_SIZE_MAX (4)
// 低功耗节点的请求消息间隔(100ms)
#define CONFIG_MESH_LPN_POLLINTERVAL_MIN (1)
@@ -173,7 +173,8 @@ static gapRolesBroadcasterCBs_t Broadcaster_BroadcasterCBs = {
// GAP Bond Manager Callbacks
static gapBondCBs_t Peripheral_BondMgrCBs = {
NULL, // Passcode callback (not used by application)
NULL // Pairing / Bonding state Callback (not used by application)
NULL, // Pairing / Bonding state Callback (not used by application)
NULL // oob callback
};
// Simple GATT Profile Callbacks
@@ -214,7 +215,7 @@ void Peripheral_Init()
}
// Set the GAP Characteristics
GGS_SetParameter(GGS_DEVICE_NAME_ATT, GAP_DEVICE_NAME_LEN, attDeviceName);
GGS_SetParameter(GGS_DEVICE_NAME_ATT, sizeof(attDeviceName), attDeviceName);
// Set advertising interval
{
@@ -1,11 +1,16 @@
/********************************** (C) COPYRIGHT *******************************
* File Name : gattprofile.C
* Author : WCH
* Version : V1.0
* Date : 2018/12/10
* Description : 自定义包含五种不同属性的服务,包含可读、可写、通知、可读可写、安全可读
*******************************************************************************/
* File Name : gattprofile.C
* Author : WCH
* Version : V1.0
* Date : 2018/12/10
* Description : Customize services with five different attributes,
* including readable, writable, notification, readable and writable,
* and safe readable
*********************************************************************************
* Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd.
* Attention: This software (modified or not) and binary are used for
* microcontroller manufactured by Nanjing Qinheng Microelectronics.
*******************************************************************************/
/*********************************************************************
* INCLUDES
@@ -113,7 +118,7 @@ static uint8_t simpleProfileChar4[SIMPLEPROFILE_CHAR4_LEN] = {0};
// instantiation of the Client Characteristic Configuration. Reads of the
// Client Characteristic Configuration only shows the configuration for
// that client and writes only affect the configuration of that client.
static gattCharCfg_t simpleProfileChar4Config[4];
static gattCharCfg_t simpleProfileChar4Config[PERIPHERAL_MAX_CONNECTION];
// Simple Profile Characteristic 4 User Description
static uint8_t simpleProfileChar4UserDesp[] = "Characteristic 4\0";
@@ -508,6 +513,7 @@ static bStatus_t simpleProfile_ReadAttrCB(uint16_t connHandle, gattAttribute_t *
{
bStatus_t status = SUCCESS;
// Make sure it's not a blob operation (no attributes in the profile are long)
if(offset > 0)
{
@@ -529,23 +535,51 @@ static bStatus_t simpleProfile_ReadAttrCB(uint16_t connHandle, gattAttribute_t *
// characteristic 4 does not have read permissions, but because it
// can be sent as a notification, it is included here
case SIMPLEPROFILE_CHAR1_UUID:
*pLen = SIMPLEPROFILE_CHAR1_LEN;
tmos_memcpy(pValue, pAttr->pValue, SIMPLEPROFILE_CHAR1_LEN);
if(maxLen > SIMPLEPROFILE_CHAR1_LEN)
{
*pLen = SIMPLEPROFILE_CHAR1_LEN;
}
else
{
*pLen = maxLen;
}
tmos_memcpy(pValue, pAttr->pValue, *pLen);
break;
case SIMPLEPROFILE_CHAR2_UUID:
*pLen = SIMPLEPROFILE_CHAR2_LEN;
tmos_memcpy(pValue, pAttr->pValue, SIMPLEPROFILE_CHAR2_LEN);
if(maxLen > SIMPLEPROFILE_CHAR2_LEN)
{
*pLen = SIMPLEPROFILE_CHAR2_LEN;
}
else
{
*pLen = maxLen;
}
tmos_memcpy(pValue, pAttr->pValue, *pLen);
break;
case SIMPLEPROFILE_CHAR4_UUID:
*pLen = SIMPLEPROFILE_CHAR4_LEN;
tmos_memcpy(pValue, pAttr->pValue, SIMPLEPROFILE_CHAR4_LEN);
if(maxLen > SIMPLEPROFILE_CHAR4_LEN)
{
*pLen = SIMPLEPROFILE_CHAR4_LEN;
}
else
{
*pLen = maxLen;
}
tmos_memcpy(pValue, pAttr->pValue, *pLen);
break;
case SIMPLEPROFILE_CHAR5_UUID:
*pLen = SIMPLEPROFILE_CHAR5_LEN;
tmos_memcpy(pValue, pAttr->pValue, SIMPLEPROFILE_CHAR5_LEN);
if(maxLen > SIMPLEPROFILE_CHAR5_LEN)
{
*pLen = SIMPLEPROFILE_CHAR5_LEN;
}
else
{
*pLen = maxLen;
}
tmos_memcpy(pValue, pAttr->pValue, *pLen);
break;
default:
@@ -1,11 +1,14 @@
/********************************** (C) COPYRIGHT *******************************
* File Name : gattprofile.h
* Author : WCH
* Version : V1.0
* Date : 2018/12/11
* Description :
*******************************************************************************/
* File Name : gattprofile.h
* Author : WCH
* Version : V1.0
* Date : 2018/12/11
* Description :
*********************************************************************************
* Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd.
* Attention: This software (modified or not) and binary are used for
* microcontroller manufactured by Nanjing Qinheng Microelectronics.
*******************************************************************************/
#ifndef GATTPROFILE_H
#define GATTPROFILE_H