创建一个与UUID128 UUID16服务特征cs

3 posts / 0 new
Last post
Matthieu ANTOINE
Offline
Last seen:4 years 4 months ago
Expert
Joined:2014-01-14 14:51
创建一个与UUID128 UUID16服务特征cs

Hello,

I would like to create a service with a 16-bit UUID. Inside this service, several characteristics have a 128-bit UUID and one has a 16-bit UUID.
What is the method to create that kind of architecture?

Thanks!
_Matthieu

Device:
Joacimwe
Offline
Last seen:1 year 4 months ago
Guru
Joined:2014-01-14 06:45
You can use the sample128

You can use the sample128 code. What you have to change is simply to use a 16-bit value for the service declaration attribute instead of a 128-bit value.

// Add the primary service attribute /////////////////////////////////////////////////////////////////
status = attmdb_add_attribute( sample128_env.sample128_shdl, // Attribute Handle
ATT_UUID_128_LEN, // Data size = 16 (ATT_UUID_128_LEN)
ATT_UUID_16_LEN, // Size of declaration type ID
(uint8_t*)&att_decl_svc, // 0x2800 for a primary service declaration
PERM(RD, ENABLE), // Permissions
&(sample128_env.sample128_shdl) // Attribute Handle
);

// Add the value of the primary service attribute (The custom UUID)
status = attmdb_att_set_value( sample128_env.sample128_shdl, // Attribute handle
ATT_UUID_128_LEN, // The value is the 128 bit UUID of the service
(uint8_t *)sample128_svc.uuid // UUID of the service
);

Change that to

// Add the primary service attribute /////////////////////////////////////////////////////////////////
status = attmdb_add_attribute( sample128_env.sample128_shdl, // Attribute Handle
ATT_UUID_16_LEN, // Data size = 2 (ATT_UUID_16_LEN)
ATT_UUID_16_LEN, // Size of declaration type ID
(uint8_t*)&att_decl_svc, // 0x2800 for a primary service declaration
PERM(RD, ENABLE), // Permissions
&(sample128_env.sample128_shdl) // Attribute Handle
);

// Add the value of the primary service attribute (The custom UUID)
status = attmdb_att_set_value( sample128_env.sample128_shdl, // Attribute handle
ATT_UUID_16_LEN, // The value is the 16 bit UUID of the service
(uint8_t *)sample128_svc.uuid // UUID of the service
);

Note that you also have to update nb_att_16, nb_att_128 and total size of service.

Matthieu ANTOINE
Offline
Last seen:4 years 4 months ago
Expert
Joined:2014-01-14 14:51
Thanks for your answer. It

Thanks for your answer. It works now.