test/device_information_service_server: update tests

This commit is contained in:
Milanka Ringwald 2024-12-16 23:15:15 +01:00 committed by Matthias Ringwald
parent 639880bae5
commit 26c453f70b
2 changed files with 22 additions and 7 deletions

View File

@ -24,6 +24,7 @@
#include "device_information_service_server_test.h"
#include "mock_att_server.h"
#define DEVICE_INFORMATION_CHARACTERISTIC_UUIDS_NUM 10
typedef struct {
uint8_t * data;
uint16_t len;
@ -39,13 +40,14 @@ const uint16_t device_information_characteristic_uuids[] = {
ORG_BLUETOOTH_CHARACTERISTIC_SOFTWARE_REVISION_STRING,
ORG_BLUETOOTH_CHARACTERISTIC_SYSTEM_ID,
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
};
TEST_GROUP(DEVICE_INFORMATION_SERVICE_SERVER){
att_service_handler_t * service;
uint16_t con_handle;
device_information_field_t device_information_fields[9];
device_information_field_t device_information_fields[DEVICE_INFORMATION_CHARACTERISTIC_UUIDS_NUM];
void setup(void){
// setup database
@ -54,7 +56,7 @@ TEST_GROUP(DEVICE_INFORMATION_SERVICE_SERVER){
device_information_service_server_init();
int i;
for (i=0;i<9;i++){
for (i=0;i<DEVICE_INFORMATION_CHARACTERISTIC_UUIDS_NUM;i++){
device_information_fields[i].value_handle = gatt_server_get_value_handle_for_characteristic_with_uuid16(0, 0xffff, device_information_characteristic_uuids[i]);
}
@ -68,7 +70,8 @@ TEST_GROUP(DEVICE_INFORMATION_SERVICE_SERVER){
device_information_service_server_set_system_id(0x01, 0x02);
device_information_service_server_set_ieee_regulatory_certification(0x03, 0x04);
device_information_service_server_set_pnp_id(0x05, 0x06, 0x07, 0x08);
device_information_service_server_set_udi_for_medical_devices("label", "device_id", "issuer", "authority");
service = mock_att_server_get_service();
con_handle = 0x00;
}
@ -81,7 +84,7 @@ TEST_GROUP(DEVICE_INFORMATION_SERVICE_SERVER){
TEST(DEVICE_INFORMATION_SERVICE_SERVER, lookup_attribute_handles){
// get characteristic value handles
int i;
for (i=0;i<9;i++){
for (i=0;i<DEVICE_INFORMATION_CHARACTERISTIC_UUIDS_NUM;i++){
CHECK(device_information_fields[i].value_handle != 0);
}
}
@ -95,7 +98,7 @@ TEST(DEVICE_INFORMATION_SERVICE_SERVER, read_values){
CHECK_EQUAL(0, response_len);
int i;
for (i=0;i<9;i++){
for (i=0;i<DEVICE_INFORMATION_CHARACTERISTIC_UUIDS_NUM;i++){
response_len = mock_att_service_read_callback(con_handle, device_information_fields[i].value_handle, 0, response, sizeof(response));
CHECK(response_len > 0);
}
@ -111,6 +114,18 @@ TEST(DEVICE_INFORMATION_SERVICE_SERVER, read_values){
CHECK(response_len == 0);
}
TEST(DEVICE_INFORMATION_SERVICE_SERVER, read_udi_for_medical_devices){
uint8_t response[8];
uint16_t response_len;
uint8_t udi_index = DEVICE_INFORMATION_CHARACTERISTIC_UUIDS_NUM - 1;
device_information_service_server_set_udi_for_medical_devices(NULL, NULL, NULL, NULL);
response_len = mock_att_service_read_callback(con_handle, device_information_fields[udi_index].value_handle, 0, response, sizeof(response));
CHECK(response_len > 0);
}
int main (int argc, const char * argv[]){
return CommandLineTestRunner::RunAllTests(argc, argv);
}

View File

@ -1,2 +1,2 @@
// add Battery Service
#import <device_information_service.gatt>
#import <device_information_service_v1.gatt>