我正在构建BLE自动化IO卡,因此我尝试使用BLE自动化I / O https://www.bluetooth.com/wp-content/uploads/Sitecore-Media-Library/Gatt/Xml/Services/org.bluetooth.service.automation_io.xml
它说它支持1个或多个Analog(0x2a58)或Digital Attributes(0x2a56)...因此我创建了一个完整的模拟和数字属性列表:
Digital - "Output energized" [RO]
Analog - "Current Temp" [RO]
Digital - "Self-test" [RW]
Digital - "Self-test results" [RO]
Analog - "Temp setpoint" [RW]
-但是,由于它们是BLE SIG属性,因此它们都具有相同的UUID,这会混淆客户端软件。
我应该使用自己的128位UUID使它们“自定义”,还是应该使用“索引”或类似字段来正确地序列化它们?
我正在使用BlueNRG1芯片,而我当前正在使用的代码是
suuid.Service_UUID_16 = 0x1815; //Automation
ret = aci_gatt_add_service(UUID_TYPE_16, &suuid, PRIMARY_SERVICE, 35, &AutomationHandle);
if (ret != BLE_STATUS_SUCCESS) {PRINTF("j"); goto fail;}
cuuid.Char_UUID_16=0x2A56; //[0]Digital: Bar Detected
ret = aci_gatt_add_char(AutomationHandle, UUID_TYPE_16, &cuuid, 1, CHAR_PROP_READ, ATTR_PERMISSION_NONE, GATT_NOTIFY_READ_REQ_AND_WAIT_FOR_APPL_RESP, 16, CHAR_VALUE_LEN_CONSTANT, &OutCharHandle);
if (ret != BLE_STATUS_SUCCESS) {PRINTF("k"); goto fail;}
cuuid.Char_UUID_16= 0x2A58; //[1]Analog: Current Temp
ret = aci_gatt_add_char(AutomationHandle, UUID_TYPE_16, &cuuid, 2, CHAR_PROP_READ, ATTR_PERMISSION_NONE, GATT_NOTIFY_READ_REQ_AND_WAIT_FOR_APPL_RESP, 16, CHAR_VALUE_LEN_CONSTANT, &CurDetectCharHandle);
if (ret != BLE_STATUS_SUCCESS) {PRINTF("l"); goto fail;}
ApplyFormat_Temp16(AutomationHandle,CurDetectCharHandle);
cuuid.Char_UUID_16= 0x2A58; //[2]Analog: BarCount
ret = aci_gatt_add_char(AutomationHandle, UUID_TYPE_16, &cuuid, 2, CHAR_PROP_READ | CHAR_PROP_WRITE | GATT_NOTIFY_ATTRIBUTE_WRITE , ATTR_PERMISSION_NONE, GATT_NOTIFY_WRITE_REQ_AND_WAIT_FOR_APPL_RESP | GATT_NOTIFY_READ_REQ_AND_WAIT_FOR_APPL_RESP, 16, CHAR_VALUE_LEN_CONSTANT, &LastbarcountCharHandle);
if (ret != BLE_STATUS_SUCCESS) {PRINTF("r"); goto fail;}
cuuid.Char_UUID_16= 0x2A58; //[3]Analog: Last Bar Temp
ret = aci_gatt_add_char(AutomationHandle, UUID_TYPE_16, &cuuid, 2, CHAR_PROP_READ, ATTR_PERMISSION_NONE, GATT_NOTIFY_READ_REQ_AND_WAIT_FOR_APPL_RESP, 16, CHAR_VALUE_LEN_CONSTANT, &LastbartempCharHandle);
cuuid.Char_UUID_16= 0x2A56; //[5]Digital: Self Test
ret = aci_gatt_add_char(AutomationHandle, UUID_TYPE_16, &cuuid, 1, CHAR_PROP_READ | CHAR_PROP_WRITE | GATT_NOTIFY_ATTRIBUTE_WRITE , ATTR_PERMISSION_NONE, GATT_NOTIFY_WRITE_REQ_AND_WAIT_FOR_APPL_RESP | GATT_NOTIFY_READ_REQ_AND_WAIT_FOR_APPL_RESP,
16, CHAR_VALUE_LEN_CONSTANT, &SelftestCharHandle);
if (ret != BLE_STATUS_SUCCESS) {PRINTF("o"); goto fail;}
cuuid.Char_UUID_16= 0x2A56; //[6]Digital: Self Test Passed
ret = aci_gatt_add_char(AutomationHandle, UUID_TYPE_16, &cuuid, 1, CHAR_PROP_READ | CHAR_PROP_WRITE | GATT_NOTIFY_ATTRIBUTE_WRITE , ATTR_PERMISSION_NONE, GATT_NOTIFY_WRITE_REQ_AND_WAIT_FOR_APPL_RESP | GATT_NOTIFY_READ_REQ_AND_WAIT_FOR_APPL_RESP, 16, CHAR_VALUE_LEN_CONSTANT, &STpassedCharHandle);
if (ret != BLE_STATUS_SUCCESS) {PRINTF("p"); goto fail;}
...
我可以在应用程序中看到它们,但是它们都具有相同的UUID,因此应用程序看不到访问权限的差异。