mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-04-10 15:44:32 +00:00
gatt-service/dis-server: update for v1.2
This commit is contained in:
parent
1d3c1f7fa0
commit
afb581af3f
@ -57,6 +57,13 @@
|
|||||||
|
|
||||||
#include "ble/gatt-service/device_information_service_server.h"
|
#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 {
|
typedef enum {
|
||||||
MANUFACTURER_NAME = 0,
|
MANUFACTURER_NAME = 0,
|
||||||
MODEL_NUMBER,
|
MODEL_NUMBER,
|
||||||
@ -67,6 +74,7 @@ typedef enum {
|
|||||||
SYSTEM_ID,
|
SYSTEM_ID,
|
||||||
IEEE_REGULATORY_CERTIFICATION,
|
IEEE_REGULATORY_CERTIFICATION,
|
||||||
PNP_ID,
|
PNP_ID,
|
||||||
|
UDI_FOR_MEDICAL_DEVICES,
|
||||||
NUM_INFORMATION_FIELDS
|
NUM_INFORMATION_FIELDS
|
||||||
} device_information_field_id_t;
|
} 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_system_id[8];
|
||||||
static uint8_t device_information_ieee_regulatory_certification[4];
|
static uint8_t device_information_ieee_regulatory_certification[4];
|
||||||
static uint8_t device_information_pnp_id[7];
|
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 att_service_handler_t device_information_service;
|
||||||
|
|
||||||
static void set_string(device_information_field_id_t field_id, const char * text){
|
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].data = (uint8_t*) text;
|
||||||
device_information_fields[field_id].len = text != NULL ? (uint8_t) strlen(text) : 0;
|
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){
|
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
|
UNUSED(con_handle); // ok: info same for all devices
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
for (i=0;i<NUM_INFORMATION_FIELDS;i++){
|
for (i=0; i < NUM_INFORMATION_FIELDS; i++){
|
||||||
if ((device_information_fields[i].value_handle == attribute_handle) && (device_information_fields[i].data != NULL)){
|
if ((device_information_fields[i].value_handle == attribute_handle) && (device_information_fields[i].data != NULL)){
|
||||||
return att_read_callback_handle_blob(device_information_fields[i].data, device_information_fields[i].len, offset, buffer, buffer_size);
|
return att_read_callback_handle_blob(device_information_fields[i].data, device_information_fields[i].len, offset, buffer, buffer_size);
|
||||||
};
|
};
|
||||||
@ -110,7 +120,8 @@ void device_information_service_server_init(void){
|
|||||||
ORG_BLUETOOTH_CHARACTERISTIC_SOFTWARE_REVISION_STRING,
|
ORG_BLUETOOTH_CHARACTERISTIC_SOFTWARE_REVISION_STRING,
|
||||||
ORG_BLUETOOTH_CHARACTERISTIC_SYSTEM_ID,
|
ORG_BLUETOOTH_CHARACTERISTIC_SYSTEM_ID,
|
||||||
ORG_BLUETOOTH_CHARACTERISTIC_IEEE_11073_20601_REGULATORY_CERTIFICATION_DATA_LIST,
|
ORG_BLUETOOTH_CHARACTERISTIC_IEEE_11073_20601_REGULATORY_CERTIFICATION_DATA_LIST,
|
||||||
ORG_BLUETOOTH_CHARACTERISTIC_PNP_ID
|
ORG_BLUETOOTH_CHARACTERISTIC_PNP_ID,
|
||||||
|
ORG_BLUETOOTH_CHARACTERISTIC_UDI_FOR_MEDICAL_DEVICES
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -123,15 +134,18 @@ void device_information_service_server_init(void){
|
|||||||
|
|
||||||
// set length for fixed size characateristics
|
// set length for fixed size characateristics
|
||||||
device_information_fields[SYSTEM_ID].data = device_information_system_id;
|
device_information_fields[SYSTEM_ID].data = device_information_system_id;
|
||||||
device_information_fields[SYSTEM_ID].len = 8;
|
device_information_fields[SYSTEM_ID].len = sizeof(device_information_system_id);
|
||||||
device_information_fields[IEEE_REGULATORY_CERTIFICATION].data = device_information_ieee_regulatory_certification;
|
device_information_fields[IEEE_REGULATORY_CERTIFICATION].data = device_information_ieee_regulatory_certification;
|
||||||
device_information_fields[IEEE_REGULATORY_CERTIFICATION].len = 4;
|
device_information_fields[IEEE_REGULATORY_CERTIFICATION].len = sizeof(device_information_ieee_regulatory_certification);
|
||||||
device_information_fields[PNP_ID].data = device_information_pnp_id;
|
device_information_fields[PNP_ID].data = device_information_pnp_id;
|
||||||
device_information_fields[PNP_ID].len = 7;
|
device_information_fields[PNP_ID].len = sizeof(device_information_pnp_id);
|
||||||
|
// reserve max space for UDI
|
||||||
|
device_information_fields[UDI_FOR_MEDICAL_DEVICES].data = device_information_udi_for_medical_devices;
|
||||||
|
device_information_fields[UDI_FOR_MEDICAL_DEVICES].len = 0;
|
||||||
|
|
||||||
// get characteristic value handles
|
// get characteristic value handles
|
||||||
int i;
|
int i;
|
||||||
for (i=0;i<NUM_INFORMATION_FIELDS;i++){
|
for (i=0; i < NUM_INFORMATION_FIELDS; i++){
|
||||||
device_information_fields[i].value_handle = gatt_server_get_value_handle_for_characteristic_with_uuid16(start_handle, end_handle, device_information_characteristic_uuids[i]);
|
device_information_fields[i].value_handle = gatt_server_get_value_handle_for_characteristic_with_uuid16(start_handle, end_handle, device_information_characteristic_uuids[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -213,15 +227,45 @@ void device_information_service_server_set_ieee_regulatory_certification(uint16_
|
|||||||
little_endian_store_16(device_information_ieee_regulatory_certification, 2, value_b);
|
little_endian_store_16(device_information_ieee_regulatory_certification, 2, value_b);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Set PNP ID
|
|
||||||
* @param vendor_source_id
|
|
||||||
* @param vendor_id
|
|
||||||
* @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){
|
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_pnp_id[0] = vendor_source_id;
|
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, 1, vendor_id);
|
||||||
little_endian_store_16(device_information_pnp_id, 3, product_id);
|
little_endian_store_16(device_information_pnp_id, 3, product_id);
|
||||||
little_endian_store_16(device_information_pnp_id, 5, product_version);
|
little_endian_store_16(device_information_pnp_id, 5, product_version);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void device_information_service_server_set_udi_for_medical_devices(const char * label, const char * device_id, const char * issuer, const char * authority){
|
||||||
|
uint8_t * data = &device_information_fields[UDI_FOR_MEDICAL_DEVICES].data[0];
|
||||||
|
|
||||||
|
uint16_t bytes_copied;
|
||||||
|
uint16_t pos = 0;
|
||||||
|
data[pos++] = 0; // reserved for flags
|
||||||
|
|
||||||
|
bytes_copied = btstack_strcpy((char *) &data[pos], DEVICE_INFORMATION_MAX_STRING_LEN, label);
|
||||||
|
pos += bytes_copied;
|
||||||
|
if (bytes_copied > 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -123,10 +123,19 @@ void device_information_service_server_set_ieee_regulatory_certification(uint16_
|
|||||||
* @param vendor_source_id
|
* @param vendor_source_id
|
||||||
* @param vendor_id
|
* @param vendor_id
|
||||||
* @param product_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);
|
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 */
|
/* API_END */
|
||||||
|
|
||||||
#if defined __cplusplus
|
#if defined __cplusplus
|
||||||
|
15
src/ble/gatt-service/device_information_service_v1.gatt
Normal file
15
src/ble/gatt-service/device_information_service_v1.gatt
Normal file
@ -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,
|
Loading…
x
Reference in New Issue
Block a user