diff --git a/src/ble/gatt-service/device_information_service_server.c b/src/ble/gatt-service/device_information_service_server.c index 89100ff43..6c23592ce 100644 --- a/src/ble/gatt-service/device_information_service_server.c +++ b/src/ble/gatt-service/device_information_service_server.c @@ -57,6 +57,13 @@ #include "ble/gatt-service/device_information_service_server.h" +#define DEVICE_INFORMATION_MAX_STRING_LEN 32 + +#define UDI_FOR_MEDICAL_DEVICES_BITMASK_LABEL 1 +#define UDI_FOR_MEDICAL_DEVICES_BITMASK_DEVICE_ID 2 +#define UDI_FOR_MEDICAL_DEVICES_BITMASK_ISSUER 4 +#define UDI_FOR_MEDICAL_DEVICES_BITMASK_AUTHORITY 8 + typedef enum { MANUFACTURER_NAME = 0, MODEL_NUMBER, @@ -67,6 +74,7 @@ typedef enum { SYSTEM_ID, IEEE_REGULATORY_CERTIFICATION, PNP_ID, + UDI_FOR_MEDICAL_DEVICES, NUM_INFORMATION_FIELDS } device_information_field_id_t; @@ -81,8 +89,10 @@ static device_information_field_t device_information_fields[NUM_INFORMATION_FIEL static uint8_t device_information_system_id[8]; static uint8_t device_information_ieee_regulatory_certification[4]; static uint8_t device_information_pnp_id[7]; +static uint8_t device_information_udi_for_medical_devices[1 + 4 * DEVICE_INFORMATION_MAX_STRING_LEN]; static att_service_handler_t device_information_service; + static void set_string(device_information_field_id_t field_id, const char * text){ device_information_fields[field_id].data = (uint8_t*) text; device_information_fields[field_id].len = text != NULL ? (uint8_t) strlen(text) : 0; @@ -91,7 +101,7 @@ static void set_string(device_information_field_id_t field_id, const char * text static uint16_t device_information_service_read_callback(hci_con_handle_t con_handle, uint16_t attribute_handle, uint16_t offset, uint8_t * buffer, uint16_t buffer_size){ UNUSED(con_handle); // ok: info same for all devices unsigned int i; - for (i=0;i 0){ + data[0] |= (1 << UDI_FOR_MEDICAL_DEVICES_BITMASK_LABEL); + } + + bytes_copied = btstack_strcpy((char *) &data[pos], DEVICE_INFORMATION_MAX_STRING_LEN, device_id); + pos += bytes_copied; + if (bytes_copied > 0){ + data[0] |= (1 << UDI_FOR_MEDICAL_DEVICES_BITMASK_DEVICE_ID); + } + + bytes_copied = btstack_strcpy((char *) &data[pos], DEVICE_INFORMATION_MAX_STRING_LEN, issuer); + pos += bytes_copied; + if (bytes_copied > 0){ + data[0] |= (1 << UDI_FOR_MEDICAL_DEVICES_BITMASK_ISSUER); + } + + bytes_copied = btstack_strcpy((char *) &data[pos], DEVICE_INFORMATION_MAX_STRING_LEN, authority); + pos += bytes_copied; + if (bytes_copied > 0){ + data[0] |= (1 << UDI_FOR_MEDICAL_DEVICES_BITMASK_AUTHORITY); + } + + device_information_fields[UDI_FOR_MEDICAL_DEVICES].len = pos; +} + diff --git a/src/ble/gatt-service/device_information_service_server.h b/src/ble/gatt-service/device_information_service_server.h index 338a19f69..b959e4099 100644 --- a/src/ble/gatt-service/device_information_service_server.h +++ b/src/ble/gatt-service/device_information_service_server.h @@ -123,10 +123,19 @@ void device_information_service_server_set_ieee_regulatory_certification(uint16_ * @param vendor_source_id * @param vendor_id * @param product_id - * @Param product_versoin + * @param product_version */ 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); +/** + * @brief Set UDI for medical devices + * @param label + * @param device_id + * @param issuer + * @param authority + */ +void device_information_service_server_set_udi_for_medical_devices(const char * label, const char * device_id, const char * issuer, const char * authority); + /* API_END */ #if defined __cplusplus diff --git a/src/ble/gatt-service/device_information_service_v1.gatt b/src/ble/gatt-service/device_information_service_v1.gatt new file mode 100644 index 000000000..c8761c762 --- /dev/null +++ b/src/ble/gatt-service/device_information_service_v1.gatt @@ -0,0 +1,15 @@ +// Specification Type org.bluetooth.service.device_information +// https://www.bluetooth.com/api/gatt/xmlfile?xmlFileName=org.bluetooth.service.device_information.xml + +// Device Information 180A +PRIMARY_SERVICE, ORG_BLUETOOTH_SERVICE_DEVICE_INFORMATION +CHARACTERISTIC, ORG_BLUETOOTH_CHARACTERISTIC_MANUFACTURER_NAME_STRING, DYNAMIC | READ, +CHARACTERISTIC, ORG_BLUETOOTH_CHARACTERISTIC_MODEL_NUMBER_STRING, DYNAMIC | READ, +CHARACTERISTIC, ORG_BLUETOOTH_CHARACTERISTIC_SERIAL_NUMBER_STRING, DYNAMIC | READ, +CHARACTERISTIC, ORG_BLUETOOTH_CHARACTERISTIC_HARDWARE_REVISION_STRING, DYNAMIC | READ, +CHARACTERISTIC, ORG_BLUETOOTH_CHARACTERISTIC_FIRMWARE_REVISION_STRING, DYNAMIC | READ, +CHARACTERISTIC, ORG_BLUETOOTH_CHARACTERISTIC_SOFTWARE_REVISION_STRING, DYNAMIC | READ, +CHARACTERISTIC, ORG_BLUETOOTH_CHARACTERISTIC_SYSTEM_ID, DYNAMIC | READ, +CHARACTERISTIC, ORG_BLUETOOTH_CHARACTERISTIC_IEEE_11073_20601_REGULATORY_CERTIFICATION_DATA_LIST, DYNAMIC | READ, +CHARACTERISTIC, ORG_BLUETOOTH_CHARACTERISTIC_PNP_ID, DYNAMIC | READ, +CHARACTERISTIC, ORG_BLUETOOTH_CHARACTERISTIC_UDI_FOR_MEDICAL_DEVICES, DYNAMIC | READ, \ No newline at end of file