update 1.8
This commit is contained in:
@@ -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 阿里 厂家模型 初始化
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user