From 6e1a1dc3ed61421bdedf090c01d5a45b51910ef0 Mon Sep 17 00:00:00 2001 From: stark1898y <1658608470@qq.com> Date: Mon, 16 Dec 2024 10:04:41 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9A=82=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- APP/peripheral.c | 25 +++++++++++++++++-------- BSP/src/bsp_flash.c | 4 ++-- HAL/include/CONFIG.h | 2 +- 3 files changed, 20 insertions(+), 11 deletions(-) diff --git a/APP/peripheral.c b/APP/peripheral.c index 7dd540e..3340987 100644 --- a/APP/peripheral.c +++ b/APP/peripheral.c @@ -42,19 +42,19 @@ */ // How often to perform periodic event -#define SBP_PERIODIC_EVT_PERIOD (160 * 10 * 5) // (160 = 100ms) +#define SBP_PERIODIC_EVT_PERIOD (160 * 10 * 1) // (160 = 100ms) // How often to perform read rssi event #define SBP_READ_RSSI_EVT_PERIOD (1600 * 3) // (160 = 100ms) // Parameter update delay -#define SBP_PARAM_UPDATE_DELAY (1600 * 4) +#define SBP_PARAM_UPDATE_DELAY (1600 * 1) // PHY update delay -#define SBP_PHY_UPDATE_DELAY (1600 * 2) +#define SBP_PHY_UPDATE_DELAY (1600 * 1) // What is the advertising interval when device is discoverable (units of 625us, 80=50ms) -#define DEFAULT_ADVERTISING_INTERVAL (160 * 1) +#define DEFAULT_ADVERTISING_INTERVAL (160 * 10) // Limited discoverable mode advertises for 30.72s, and then stops // General discoverable mode advertises indefinitely @@ -492,8 +492,8 @@ static void Peripheral_LinkEstablished(gapRoleEvent_t *pEvent) peripheralConnList.connInterval = event->connInterval; peripheralConnList.connSlaveLatency = event->connLatency; peripheralConnList.connTimeout = event->connTimeout; - peripheralMTU = ATT_MTU_SIZE; - // peripheralMTU = BLE_BUFF_MAX_LEN; + // peripheralMTU = ATT_MTU_SIZE; + peripheralMTU = BLE_BUFF_MAX_LEN - 4; // Set timer for periodic event tmos_start_task(Peripheral_TaskID, SBP_PERIODIC_EVT, SBP_PERIODIC_EVT_PERIOD); @@ -748,7 +748,7 @@ static void performPeriodicTask(void) // { // humi = 0; // } - // peripheralChar4Notify(&RawData.buf[0], RawData.len); + peripheralChar4Notify(&RawData.buf[0], RawData.len); } /********************************************************************* @@ -776,8 +776,10 @@ static void peripheralChar4Notify(uint8_t *pValue, uint16_t len) tmos_memcpy(noti.pValue, pValue, noti.len); if (simpleProfile_Notify(peripheralConnList.connHandle, ¬i) != SUCCESS) { + logError("Noti Err"); GATT_bm_free((gattMsg_t *)¬i, ATT_HANDLE_VALUE_NOTI); } + logDebug("Noti Success"); } } @@ -877,6 +879,9 @@ static void simpleProfileChangeCB(uint8_t paramID, uint8_t *pValue, uint16_t len } } +#if 0 + + // TODO:Ó¦ÓüÓÈë¹ã²¥Êý¾Ý¸üв¿·Ö״̬Êý¾Ý // ¶¯Ì¬¸üй㲥Êý¾Ý // taskID£º ÇëÇó¸ü¸Ä¹ã²¥ÈÎÎñµÄ ID @@ -888,10 +893,13 @@ void Peripheral_UpdateAdvertData(uint8_t adType, uint8_t dataLen, uint8_t *pAdve GAP_UpdateAdvertisingData(Peripheral_TaskID, adType, dataLen, pAdvertData); } + + + #include "stdio.h" #include "stdarg.h" -// TODO:Ó¦ÓüÓÈë¹ã²¥Êý¾Ý¸üв¿·Ö״̬Êý¾Ý +// TODO:ÏȲ»Åª£¬ºóÃæ¸Ä¹ã²¥Ãû£¬Ó¦ÓüÓÈë¹ã²¥Êý¾Ý¸üв¿·Ö״̬Êý¾Ý void Peripheral_SetMacName(void) { uint8_t mac_addr[6]; @@ -931,3 +939,4 @@ void Peripheral_SetMacName(void) // // ¸üÐÂɨÃèÏìÓ¦Ìå GAP_UpdateAdvertisingData(Peripheral_TaskID, FALSE, scan_rsp_data, len); } +#endif diff --git a/BSP/src/bsp_flash.c b/BSP/src/bsp_flash.c index 479c539..f2c078f 100644 --- a/BSP/src/bsp_flash.c +++ b/BSP/src/bsp_flash.c @@ -2,7 +2,7 @@ * @Author : stark1898y 1658608470@qq.com * @Date : 2024-12-12 15:54:57 * @LastEditors : stark1898y 1658608470@qq.com - * @LastEditTime : 2024-12-12 16:47:22 + * @LastEditTime : 2024-12-16 08:55:00 * @FilePath : \BLE_TYQ_CH592F\BSP\src\bsp_flash.c * @Description : * @@ -44,7 +44,7 @@ void BSP_FLASH_Init(void) EEPROM_ERASE(FLASH_INFO_ADDR, DATA_FLASH_PAGE_SIZE); // 擦除待写区 EEPROM_WRITE(FLASH_INFO_WRITE_FLAG_ADDR, &flash_write_flag, FLASH_INFO_WRITE_FLAG_LEN); - logWarning("First Init flash_write_flag:%d", flash_write_flag); + logWarning("First Init flash_write_flag:%04X", flash_write_flag); } logDebug("BSP_FLASH_Init"); } diff --git a/HAL/include/CONFIG.h b/HAL/include/CONFIG.h index 12ba2a6..4ae1d70 100644 --- a/HAL/include/CONFIG.h +++ b/HAL/include/CONFIG.h @@ -136,7 +136,7 @@ #define BLE_TX_NUM_EVENT 1 #endif #ifndef BLE_TX_POWER -#define BLE_TX_POWER LL_TX_POWEER_0_DBM +#define BLE_TX_POWER LL_TX_POWEER_4_DBM #endif #ifndef PERIPHERAL_MAX_CONNECTION #define PERIPHERAL_MAX_CONNECTION 1