Skip to content

Commit e9ba841

Browse files
committed
Nordic BLE: Fix PalGattClient for SDK v13.
1 parent e8bad03 commit e9ba841

File tree

1 file changed

+56
-1
lines changed

1 file changed

+56
-1
lines changed

features/FEATURE_BLE/targets/TARGET_NORDIC/TARGET_NRF5/source/nRF5XPalGattClient.cpp

Lines changed: 56 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,15 +177,21 @@ ble_error_t nRF5XGattClient::initialize()
177177

178178
ble_error_t nRF5XGattClient::exchange_mtu(connection_handle_t connection)
179179
{
180-
// Note: Not supported by the current softdevice
181180
// FIXME: implement when SD 140 5.x.x is present
181+
// (see sd_ble_gatts_exchange_mtu_reply)
182182
return BLE_ERROR_NOT_IMPLEMENTED;
183183
}
184184

185185
ble_error_t nRF5XGattClient::get_mtu_size(
186186
connection_handle_t connection_handle, uint16_t& mtu_size
187187
) {
188+
#ifdef TARGET_SDK13
189+
// FIXME: implement when MTU size can be configured; the mtu size must be
190+
// stored locally when BLE_GATTC_EVT_EXCHANGE_MTU_RSP has been received
191+
mtu_size = BLE_GATT_MTU_SIZE_DEFAULT;
192+
#else
188193
mtu_size = GATT_RX_MTU;
194+
#endif
189195
return BLE_ERROR_NONE;
190196
}
191197

@@ -1089,6 +1095,7 @@ struct nRF5XGattClient::DiscoverDescriptorsProcedure : RegularGattProcedure {
10891095
return response.count;
10901096
}
10911097

1098+
#ifndef TARGET_SDK13
10921099
virtual information_data_t operator[](size_t i) const
10931100
{
10941101
information_data_t result = {
@@ -1106,6 +1113,32 @@ struct nRF5XGattClient::DiscoverDescriptorsProcedure : RegularGattProcedure {
11061113

11071114
return result;
11081115
}
1116+
#else /* TARGET_SDK13 */
1117+
virtual information_data_t operator[](size_t i) const
1118+
{
1119+
if (response.format == BLE_GATTC_ATTR_INFO_FORMAT_16BIT) {
1120+
information_data_t result = {
1121+
response.info.attr_info16[i].handle,
1122+
UUID(response.info.attr_info16[i].uuid.uuid)
1123+
};
1124+
1125+
return result;
1126+
} else {
1127+
information_data_t result = {
1128+
response.info.attr_info128[i].handle,
1129+
UUID(
1130+
response.info.attr_info128[i].uuid.uuid128,
1131+
UUID::LSB
1132+
)
1133+
};
1134+
1135+
return result;
1136+
}
1137+
}
1138+
1139+
1140+
#endif
1141+
11091142

11101143
const ble_gattc_evt_attr_info_disc_rsp_t &response;
11111144
};
@@ -1174,6 +1207,27 @@ struct nRF5XGattClient::ReadUsingCharacteristicUUIDProcedure : RegularGattProced
11741207
return convert_sd_error(err);
11751208
}
11761209

1210+
#ifdef TARGET_SDK13
1211+
/**
1212+
* Adapt ble_gattc_evt_char_val_by_uuid_read_rsp_t into AttReadByTypeResponse.
1213+
*/
1214+
virtual void do_handle(const ble_gattc_evt_t &evt)
1215+
{
1216+
const ble_gattc_evt_char_val_by_uuid_read_rsp_t &rsp =
1217+
evt.params.char_val_by_uuid_read_rsp;
1218+
1219+
uint8_t element_size = sizeof(uint16_t) + rsp.value_len;
1220+
1221+
terminate(SimpleAttReadByTypeResponse(
1222+
element_size,
1223+
make_const_ArrayView(
1224+
rsp.handle_value,
1225+
rsp.count * element_size
1226+
)
1227+
));
1228+
}
1229+
1230+
#else
11771231
/**
11781232
* Adapt ble_gattc_evt_char_val_by_uuid_read_rsp_t into AttReadByTypeResponse.
11791233
*/
@@ -1205,6 +1259,7 @@ struct nRF5XGattClient::ReadUsingCharacteristicUUIDProcedure : RegularGattProced
12051259

12061260
terminate(CustomReadByTypeResponse(evt.params.char_val_by_uuid_read_rsp));
12071261
}
1262+
#endif
12081263
};
12091264

12101265
/**

0 commit comments

Comments
 (0)