|
52 | 52 | #include <lib/core/ErrorStr.h>
|
53 | 53 | #include <lib/support/BitFlags.h>
|
54 | 54 | #include <lib/support/CodeUtils.h>
|
| 55 | +#include <lib/support/SafeInt.h> |
55 | 56 | #include <lib/support/SetupDiscriminator.h>
|
56 | 57 | #include <lib/support/Span.h>
|
57 | 58 | #include <platform/CHIPDeviceEvent.h>
|
@@ -1249,11 +1250,12 @@ CHIP_ERROR BLEManagerImpl::SendIndication(BLE_CONNECTION_OBJECT conId, const Ble
|
1249 | 1250 | conId = static_cast<BLEConnection *>(g_hash_table_lookup(mConnectionMap, conId->peerAddr));
|
1250 | 1251 | VerifyOrExit(conId != BLE_CONNECTION_UNINITIALIZED, ChipLogError(DeviceLayer, "Failed to find connection info"));
|
1251 | 1252 |
|
1252 |
| - ret = bt_gatt_set_value(mGattCharC2Handle, Uint8::to_const_char(pBuf->Start()), pBuf->DataLength()); |
| 1253 | + VerifyOrReturnError(CanCastTo<int>(pBuf->DataLength()), CHIP_ERROR_INTERNAL); |
| 1254 | + ret = bt_gatt_set_value(mGattCharC2Handle, Uint8::to_const_char(pBuf->Start()), static_cast<int>(pBuf->DataLength())); |
1253 | 1255 | VerifyOrExit(ret == BT_ERROR_NONE, ChipLogError(DeviceLayer, "bt_gatt_set_value() failed: %s", get_error_message(ret)));
|
1254 | 1256 |
|
1255 | 1257 | ChipLogProgress(DeviceLayer, "Sending indication for CHIPoBLE RX characteristic (con %s, len %u)", conId->peerAddr,
|
1256 |
| - pBuf->DataLength()); |
| 1258 | + static_cast<int>(pBuf->DataLength())); |
1257 | 1259 |
|
1258 | 1260 | ret = bt_gatt_server_notify_characteristic_changed_value(
|
1259 | 1261 | mGattCharC2Handle,
|
@@ -1283,11 +1285,12 @@ CHIP_ERROR BLEManagerImpl::SendWriteRequest(BLE_CONNECTION_OBJECT conId, const B
|
1283 | 1285 | ChipLogError(DeviceLayer, "SendWriteRequest() called with invalid characteristic ID"));
|
1284 | 1286 | VerifyOrExit(conId->gattCharC1Handle != nullptr, ChipLogError(DeviceLayer, "Char C1 is null"));
|
1285 | 1287 |
|
1286 |
| - ret = bt_gatt_set_value(conId->gattCharC1Handle, Uint8::to_const_char(pBuf->Start()), pBuf->DataLength()); |
| 1288 | + VerifyOrReturnError(CanCastTo<int>(pBuf->DataLength()), CHIP_ERROR_INTERNAL); |
| 1289 | + ret = bt_gatt_set_value(conId->gattCharC1Handle, Uint8::to_const_char(pBuf->Start()), static_cast<int>(pBuf->DataLength())); |
1287 | 1290 | VerifyOrExit(ret == BT_ERROR_NONE, ChipLogError(DeviceLayer, "bt_gatt_set_value() failed: %s", get_error_message(ret)));
|
1288 | 1291 |
|
1289 | 1292 | ChipLogProgress(DeviceLayer, "Sending Write Request for CHIPoBLE TX characteristic (con %s, len %u)", conId->peerAddr,
|
1290 |
| - pBuf->DataLength()); |
| 1293 | + static_cast<int>(pBuf->DataLength())); |
1291 | 1294 |
|
1292 | 1295 | ret = bt_gatt_client_write_value(conId->gattCharC1Handle, WriteCompletedCb, conId);
|
1293 | 1296 | VerifyOrExit(ret == BT_ERROR_NONE,
|
|
0 commit comments