ublox_spp_service_server: add read to FIFO characteristic, receive three wrties: Write credits CCCD, Write FIFO CCCD, Write credits, then give out/notify credits

This commit is contained in:
Milanka Ringwald 2018-11-09 14:39:04 +01:00
parent cf837c2859
commit 40a35d0a97
3 changed files with 10 additions and 7 deletions

View File

@ -76,7 +76,7 @@ const uint8_t adv_data[] = {
// Flags general discoverable, BR/EDR not supported
2, BLUETOOTH_DATA_TYPE_FLAGS, 0x06,
// Name
9, BLUETOOTH_DATA_TYPE_COMPLETE_LOCAL_NAME, 'u', 'B', 'l','o', 'x', 'S', 'P', 'P',
5, BLUETOOTH_DATA_TYPE_COMPLETE_LOCAL_NAME, '6', '-','5', '6',
// UUID ...
17, BLUETOOTH_DATA_TYPE_COMPLETE_LIST_OF_128_BIT_SERVICE_CLASS_UUIDS, 0x1, 0xd7, 0xe9, 0x1, 0x4f, 0xf3, 0x44, 0xe7, 0x83, 0x8f, 0xe2, 0x26, 0xb9, 0xe1, 0x56, 0x24,
};

View File

@ -3,7 +3,7 @@
// ublox SPP-like
PRIMARY_SERVICE, 2456E1B9-26E2-8F83-E744-F34F01E9D701
// FIFO
CHARACTERISTIC, 2456E1B9-26E2-8F83-E744-F34F01E9D703, DYNAMIC | NOTIFY | INDICATE | WRITE | WRITE_WITHOUT_RESPONSE,
CHARACTERISTIC, 2456E1B9-26E2-8F83-E744-F34F01E9D703, DYNAMIC | NOTIFY | WRITE | WRITE_WITHOUT_RESPONSE | READ,
// Credits
CHARACTERISTIC, 2456E1B9-26E2-8F83-E744-F34F01E9D704, DYNAMIC | NOTIFY | INDICATE | WRITE | WRITE_WITHOUT_RESPONSE,
CHARACTERISTIC, 2456E1B9-26E2-8F83-E744-F34F01E9D704, DYNAMIC | NOTIFY | WRITE | WRITE_WITHOUT_RESPONSE,

View File

@ -157,6 +157,7 @@ static int ublox_spp_service_write_callback(hci_con_handle_t con_handle, uint16_
return ATT_ERROR_INVALID_OFFSET;
}
instance->fifo_client_configuration_descriptor_value = little_endian_read_16(buffer, 0);
log_info("ublox spp service FIFO control: %d", instance->fifo_client_configuration_descriptor_value);
instance->client_data_callback(con_handle, NULL, 0);
}
@ -165,6 +166,11 @@ static int ublox_spp_service_write_callback(hci_con_handle_t con_handle, uint16_
int8_t credits = (int8_t)buffer[0];
if (credits <= 0) return 0;
instance->outgoing_credits += credits;
log_info("received outgoing credits, total %d", instance->outgoing_credits);
// Provide credits
att_server_request_to_send_notification(&instance->credits_callback, instance->con_handle);
// handle user request
if (instance->request){
btstack_context_callback_registration_t * request = instance->request;
instance->request = NULL;
@ -177,11 +183,8 @@ static int ublox_spp_service_write_callback(hci_con_handle_t con_handle, uint16_
return ATT_ERROR_INVALID_OFFSET;
}
instance->credits_client_configuration_descriptor_value = little_endian_read_16(buffer, 0);
log_info("ublox spp service Credits control: %d", instance->credits_client_configuration_descriptor_value);
ublox_spp_service_init_credits(instance);
if (instance->credits_client_configuration_descriptor_value){
att_server_request_to_send_notification(&instance->credits_callback, instance->con_handle);
}
}
return 0;