@@ -177,15 +177,21 @@ ble_error_t nRF5XGattClient::initialize()
177
177
178
178
ble_error_t nRF5XGattClient::exchange_mtu (connection_handle_t connection)
179
179
{
180
- // Note: Not supported by the current softdevice
181
180
// FIXME: implement when SD 140 5.x.x is present
181
+ // (see sd_ble_gatts_exchange_mtu_reply)
182
182
return BLE_ERROR_NOT_IMPLEMENTED;
183
183
}
184
184
185
185
ble_error_t nRF5XGattClient::get_mtu_size (
186
186
connection_handle_t connection_handle, uint16_t & mtu_size
187
187
) {
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
188
193
mtu_size = GATT_RX_MTU;
194
+ #endif
189
195
return BLE_ERROR_NONE;
190
196
}
191
197
@@ -1089,6 +1095,7 @@ struct nRF5XGattClient::DiscoverDescriptorsProcedure : RegularGattProcedure {
1089
1095
return response.count ;
1090
1096
}
1091
1097
1098
+ #ifndef TARGET_SDK13
1092
1099
virtual information_data_t operator [](size_t i) const
1093
1100
{
1094
1101
information_data_t result = {
@@ -1106,6 +1113,32 @@ struct nRF5XGattClient::DiscoverDescriptorsProcedure : RegularGattProcedure {
1106
1113
1107
1114
return result;
1108
1115
}
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
+
1109
1142
1110
1143
const ble_gattc_evt_attr_info_disc_rsp_t &response;
1111
1144
};
@@ -1174,6 +1207,27 @@ struct nRF5XGattClient::ReadUsingCharacteristicUUIDProcedure : RegularGattProced
1174
1207
return convert_sd_error (err);
1175
1208
}
1176
1209
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
1177
1231
/* *
1178
1232
* Adapt ble_gattc_evt_char_val_by_uuid_read_rsp_t into AttReadByTypeResponse.
1179
1233
*/
@@ -1205,6 +1259,7 @@ struct nRF5XGattClient::ReadUsingCharacteristicUUIDProcedure : RegularGattProced
1205
1259
1206
1260
terminate (CustomReadByTypeResponse(evt.params.char_val_by_uuid_read_rsp));
1207
1261
}
1262
+ #endif
1208
1263
};
1209
1264
1210
1265
/* *
0 commit comments