测试了蓝牙和服务器的交互通过
This commit is contained in:
parent
6eac058911
commit
99e0b3ba14
|
@ -1284,24 +1284,6 @@ void Master_Connect(void)
|
|||
uint8_t def_mac[6] = {0xFF};
|
||||
uint8_t cnt = Flash_Get_Valve_Num();
|
||||
logDebug("cnt:%d\r\n", cnt);
|
||||
// if (cnt == 0)
|
||||
// {
|
||||
// GAPRole_CentralEstablishLink(DEFAULT_LINK_HIGH_DUTY_CYCLE,
|
||||
// DEFAULT_LINK_WHITE_LIST,
|
||||
// ADDRTYPE_PUBLIC,
|
||||
// def_mac);
|
||||
// tmos_start_task(centralTaskId, ESTABLISH_LINK_TIMEOUT_EVT, ESTABLISH_LINK_TIMEOUT);
|
||||
|
||||
// // uint8_t mac_addr[6] = {0x93, 0xB4, 0x8F, 0x10, 0x53, 0x5C};
|
||||
// // logHexDumpAll(mac_addr, 6);
|
||||
// // GAPRole_CentralEstablishLink(DEFAULT_LINK_HIGH_DUTY_CYCLE,
|
||||
// // DEFAULT_LINK_WHITE_LIST,
|
||||
// // ADDRTYPE_PUBLIC,
|
||||
// // mac_addr);
|
||||
// // tmos_start_task(centralTaskId, ESTABLISH_LINK_TIMEOUT_EVT, ESTABLISH_LINK_TIMEOUT);
|
||||
// return;
|
||||
// }
|
||||
|
||||
for (uint8_t i = 0; i < cnt; i++)
|
||||
{
|
||||
if (valve_list.valve_data[i].valve_id != 0)
|
||||
|
@ -1321,7 +1303,7 @@ void Master_Connect(void)
|
|||
void Master_DisConnect(void)
|
||||
{
|
||||
GAPRole_TerminateLink(centralConnList[0].connHandle);
|
||||
// centralConnList[0].state = BLE_STATE_IDLE;
|
||||
centralConnList[0].state = BLE_STATE_IDLE;
|
||||
logDebug("主动断开连接\r\n");
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* @Author: mbw
|
||||
* @Date: 2024-12-06 16:52:30
|
||||
* @LastEditors: mbw && 1600520629@qq.com
|
||||
* @LastEditTime: 2024-12-16 20:03:21
|
||||
* @LastEditTime: 2024-12-17 14:17:49
|
||||
* @FilePath: \ble_-tyq_-bjq_-ch584-m\bsp\src\bsp_uart.c
|
||||
* @Description:
|
||||
*
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* @Author: mbw
|
||||
* @Date: 2024-12-09 11:40:10
|
||||
* @LastEditors: mbw && 1600520629@qq.com
|
||||
* @LastEditTime: 2024-12-16 20:35:38
|
||||
* @LastEditTime: 2024-12-17 14:43:12
|
||||
* @FilePath: \ble_-tyq_-bjq_-ch584-m\bsp\src\bsp_valve.c
|
||||
* @Description:
|
||||
*
|
||||
|
@ -123,7 +123,7 @@ int BSP_Bt_Register_Valve(uint8_t *data, uint8_t len)
|
|||
if (tmos_memcmp(&data[1], mac_addr, FLASH_MAC_INFO_LEN) == TRUE)
|
||||
{
|
||||
logError("已经注册过了");
|
||||
return 2; // 说明已经注册过了
|
||||
return 0; // 说明已经注册过了
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -197,7 +197,8 @@ int BSP_Bt_Replace_Valve(uint8_t *data, uint8_t len)
|
|||
{
|
||||
size_t i = 0;
|
||||
uint8_t mac_addr[FLASH_MAC_INFO_LEN] = {0};
|
||||
|
||||
logDebug("更换阀门信息:");
|
||||
logHexDumpAll(data, len);
|
||||
if ((len == 0) || (len < 13))//新旧MAC地址长度加id 6 + 6 + 1 = 13至少要大于12
|
||||
{
|
||||
logError("data len error");
|
||||
|
@ -212,21 +213,20 @@ int BSP_Bt_Replace_Valve(uint8_t *data, uint8_t len)
|
|||
logError("valve id error");
|
||||
return -2;
|
||||
}
|
||||
if (tmos_memcmp(&data[1], mac_addr, FLASH_MAC_INFO_LEN) == TRUE)
|
||||
if (tmos_memcmp(&data[7], mac_addr, FLASH_MAC_INFO_LEN) == TRUE)
|
||||
{
|
||||
logError("已经注册过了"); // 不需要重复写入
|
||||
return 2; // 说明已经注册过了
|
||||
return 0; // 说明已经注册过了
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Flash_Set_Mac_Addr(&data[1], data[0] - 1) != 0)
|
||||
if (Flash_Set_Mac_Addr(&data[7], data[0] - 1) != 0)
|
||||
{
|
||||
logError("阀门注册写入flash 错误");
|
||||
return 3;
|
||||
}
|
||||
BSP_Bt_Valve_Updata(); // 更新阀门信息
|
||||
|
||||
|
||||
Master_DisConnect();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue