From 42698bc931be33d9f6cff876cae856e86529f8ae Mon Sep 17 00:00:00 2001 From: xiezhipeng Date: Mon, 11 Jul 2022 09:51:07 +0800 Subject: [PATCH 1/2] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8Dblegap.h=E7=BC=96?= =?UTF-8?q?=E8=AF=91=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I16581764b2f8577a228b49580b9ad9df1f7f36fc Signed-off-by: xiezhipeng --- .../hals/driver/bluetooth_lite/blegap.h | 4 +--- .../driver/bluetooth_lite/bluetooth_device.c | 18 +++++++++++++----- .../driver/bluetooth_lite/bluetooth_device.h | 2 +- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/niobeu4/liteos_m/hals/driver/bluetooth_lite/blegap.h b/niobeu4/liteos_m/hals/driver/bluetooth_lite/blegap.h index 04234d9..77c3a82 100755 --- a/niobeu4/liteos_m/hals/driver/bluetooth_lite/blegap.h +++ b/niobeu4/liteos_m/hals/driver/bluetooth_lite/blegap.h @@ -30,7 +30,6 @@ #define BleGapParam esp_ble_gap_cb_param_t #define BleGattcParam esp_ble_gattc_cb_param_t #define BleScanParams esp_ble_scan_params_t -#define DataLength 4 #define BT_DEBUG printf #define OHOS_GATT_PREP_WRITE_CANCEL 0x00 @@ -59,7 +58,6 @@ #define OHOS_GATT_CHAR_PROP_BIT_INDICATE (1 << 5) #define OHOS_GATT_CHAR_PROP_BIT_AUTH (1 << 6) #define OHOS_GATT_CHAR_PROP_BIT_EXT_PROP (1 << 7) -uint8_t BdAddrs[OHOS_BD_ADDR_LEN]; typedef enum { BT_ERROR = -1, @@ -186,7 +184,7 @@ BtError BleGapUpdateConnParams(BleConnUpdateParams *params); BtError BleGatSetScanParams(BleScanParams *scan_params); -BtError BleGapDisconnect(BdAddrs remote_device); +BtError BleGapDisconnect(BdAddr remote_device); uint8_t *BleResolveAdvData(uint8_t *adv_data, uint8_t type, uint8_t *length); #endif diff --git a/niobeu4/liteos_m/hals/driver/bluetooth_lite/bluetooth_device.c b/niobeu4/liteos_m/hals/driver/bluetooth_lite/bluetooth_device.c index 39e0660..ca955c8 100755 --- a/niobeu4/liteos_m/hals/driver/bluetooth_lite/bluetooth_device.c +++ b/niobeu4/liteos_m/hals/driver/bluetooth_lite/bluetooth_device.c @@ -71,11 +71,15 @@ BtError SetLocalName(unsigned char *localName, unsigned char length) BtError GetLocalAddr(unsigned char *mac, unsigned int len) { + int ret; if ((mac == NULL) || (len <= 0)) { BT_DEBUG("GetLocalAddr param is NULL! \n"); return BT_PARAMINPUT_ERROR; } - memcpy_S(mac, esp_bt_dev_get_address(), len); + ret = memcpy_s(mac, sizeof(mac), esp_bt_dev_get_address(), len); + if (!ret) { + return ret; + } return BT_SUCCESS; } @@ -111,9 +115,11 @@ BtError BleGattcDisconnect(int clientId, int conn_id) return esp_ble_gattc_close(clientId, conn_id); } -BtError BleGapDisconnect(BdAddrs remote_device) +BtError BleGapDisconnect(BdAddr remote_device) { - return esp_ble_gap_disconnect(remote_device); + uint8_t BdAddrs[OHOS_BD_ADDR_LEN]; + memcpy_s(BdAddrs, sizeof(BdAddrs), remote_device.addr, sizeof(remote_device.addr)); + return esp_ble_gap_disconnect(BdAddrs); } uint8_t *BleResolveAdvData(uint8_t *adv_data, uint8_t type, uint8_t *length) @@ -221,10 +227,12 @@ GattStatus BleGattcGetCharByUuid(GattInterfaceType gattc_if, uint16_t conn_id, u } BtError BleGattcRegisterForNotify(GattInterfaceType gattc_if, - BdAddrs server_bda, + BdAddr server_bda, uint16_t handle) { - return esp_ble_gattc_register_for_notify(gattc_if, server_bda, handle); + uint8_t BdAddrs[OHOS_BD_ADDR_LEN]; + memcpy_s(BdAddrs, sizeof(BdAddrs), server_bda.addr, sizeof(server_bda.addr)); + return esp_ble_gattc_register_for_notify(gattc_if, BdAddrs, handle); } GattStatus BleGattcGetDescrByCharHandle(GattInterfaceType gattc_if, diff --git a/niobeu4/liteos_m/hals/driver/bluetooth_lite/bluetooth_device.h b/niobeu4/liteos_m/hals/driver/bluetooth_lite/bluetooth_device.h index db80581..d53aaf0 100755 --- a/niobeu4/liteos_m/hals/driver/bluetooth_lite/bluetooth_device.h +++ b/niobeu4/liteos_m/hals/driver/bluetooth_lite/bluetooth_device.h @@ -133,7 +133,7 @@ GattStatus BleGattcGetCharByUuid(GattInterfaceType gattc_if, uint16_t conn_id, u BleGattcCharElem *result, uint16_t *count); BtError BleGattcRegisterForNotify(GattInterfaceType gattc_if, - BdAddrs server_bda, + BdAddr server_bda, uint16_t handle); GattStatus BleGattcGetDescrByCharHandle(GattInterfaceType gattc_if, uint16_t conn_id, uint16_t char_handle, -- Gitee From d3239d25b3f6127ed3dcbd0cf5e5836aabb8db4b Mon Sep 17 00:00:00 2001 From: xiezhipeng Date: Wed, 13 Jul 2022 16:15:22 +0800 Subject: [PATCH 2/2] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8Dwifi=E8=BF=9E?= =?UTF-8?q?=E6=8E=A5=E5=B4=A9=E6=BA=83=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: xiezhipeng --- niobeu4/liteos_m/hals/driver/wifi_lite/wifi_device.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/niobeu4/liteos_m/hals/driver/wifi_lite/wifi_device.c b/niobeu4/liteos_m/hals/driver/wifi_lite/wifi_device.c index 750738c..ce40035 100755 --- a/niobeu4/liteos_m/hals/driver/wifi_lite/wifi_device.c +++ b/niobeu4/liteos_m/hals/driver/wifi_lite/wifi_device.c @@ -90,7 +90,7 @@ static void MEMCPY_S(void *dst, int dstSize, void *src, int srcSize) return; } int ret; - ret = memcpy_s(dst, src, (dstSize > srcSize) ? srcSize : dstSize); + ret = memcpy_s(dst, dstSize, src, (dstSize > srcSize) ? srcSize : dstSize); if (ret != 0) { LOGE("memcpy_s fail!!\n"); } -- Gitee