dis: set fixed-size field lengths on init

This commit is contained in:
Matthias Ringwald 2018-04-26 15:37:57 +02:00
parent 2aedd0f7d7
commit 0841522c68

View File

@ -123,6 +123,14 @@ void device_information_service_server_init(void){
int service_found = gatt_server_get_get_handle_range_for_service_with_uuid16(ORG_BLUETOOTH_SERVICE_DEVICE_INFORMATION, &start_handle, &end_handle);
if (!service_found) return;
// set length for fixed size characateristics
device_information_fields[SYSTEM_ID].data = device_information_system_id;
device_information_fields[SYSTEM_ID].len = 8;
device_information_fields[IEEE_REGULATORY_CERTIFICATION].data = device_information_ieee_regulatory_certification;
device_information_fields[IEEE_REGULATORY_CERTIFICATION].len = 4;
device_information_fields[PNP_ID].data = device_information_pnp_id;
device_information_fields[PNP_ID].len = 7;
// get characteristic value handles
int i;
for (i=0;i<NUM_INFORMATION_FIELDS;i++){
@ -191,9 +199,6 @@ void device_information_service_server_set_software_revision(const char * softwa
* @param organizationally_unique_identifier uint24
*/
void device_information_service_server_set_system_id(uint64_t manufacturer_identifier, uint32_t organizationally_unique_identifier){
device_information_fields[SYSTEM_ID].data = device_information_system_id;
device_information_fields[SYSTEM_ID].len = 8;
little_endian_store_32(device_information_system_id, 0, manufacturer_identifier);
device_information_system_id[4] = manufacturer_identifier >> 32;
little_endian_store_16(device_information_system_id, 5, organizationally_unique_identifier);
@ -206,9 +211,6 @@ void device_information_service_server_set_system_id(uint64_t manufacturer_ident
* @param ieee_regulatory_certification
*/
void device_information_service_server_set_ieee_regulatory_certification(uint16_t value_a, uint16_t value_b){
device_information_fields[IEEE_REGULATORY_CERTIFICATION].data = device_information_ieee_regulatory_certification;
device_information_fields[IEEE_REGULATORY_CERTIFICATION].len = 4;
little_endian_store_16(device_information_ieee_regulatory_certification, 0, value_a);
little_endian_store_16(device_information_ieee_regulatory_certification, 2, value_b);
}
@ -220,9 +222,6 @@ void device_information_service_server_set_ieee_regulatory_certification(uint16_
* @param product_id
*/
void device_information_service_server_set_pnp_id(uint8_t vendor_source_id, uint16_t vendor_id, uint16_t product_id, uint16_t product_version){
device_information_fields[PNP_ID].data = device_information_pnp_id;
device_information_fields[PNP_ID].len = 7;
device_information_pnp_id[0] = vendor_source_id;
little_endian_store_16(device_information_pnp_id, 1, vendor_id);
little_endian_store_16(device_information_pnp_id, 3, product_id);