diff --git a/niobeu4/liteos_m/hals/driver/bluetooth_lite/blegap.h b/niobeu4/liteos_m/hals/driver/bluetooth_lite/blegap.h index 04234d98c24d71b6199dc1ebe6b016a1d7a34330..77c3a82e2f7c2845641fe2508dd015269af3d15c 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 39e0660937a3625177ee7cdcc9fba886aad58c07..ca955c8cf6617d481d64108362f4bc020c213752 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 db80581977c647f5823f85636fb28c0ea294a4d1..d53aaf00d6b5a3e68425f14aefb0a992e266a4ba 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, 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 750738c1f6065e4c67309045f18e9f4f9e51263a..ce40035cd1a784af09e30308f2e1091acdbb8ef8 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"); }