TI中文支持网
TI专业的中文技术问题搜集分享网站

service uuid 从128位改成16bit

我使用的是CC2640R2F SDK:simplelink_cc2640r2_sdk_2_30_00_28

oad reset service uuid在样例中,是使用了128bit,使用lightblue在手机上查看,也是128位。

现有个需求:实现在手机上查看这个reset service uuid,是16位就可以。

自己做了代码修改,但发现没有实现这个需求,是不是我没有改全?

// OAD Reset GATT Profile Service UUID
static const uint8_t resetServUUID[ATT_BT_UUID_SIZE] =
{
//TI_BASE_UUID_128(OAD_RESET_SERVICE_UUID)
LO_UINT16( OAD_RESET_SERVICE_UUID ), HI_UINT16( OAD_RESET_SERVICE_UUID )
};

static const uint8_t resetCharUUID[ATT_BT_UUID_SIZE] =
{
//TI_BASE_UUID_128(OAD_RESET_CHAR_UUID)
LO_UINT16( OAD_RESET_CHAR_UUID ), HI_UINT16( OAD_RESET_CHAR_UUID )
};

// Simple Profile Service attribute
static CONST gattAttrType_t resetProfileService = { ATT_BT_UUID_SIZE, resetServUUID };

// OAD Reset Characteristic Value
{
{ ATT_BT_UUID_SIZE, resetCharUUID },
OAD_WRITE_PERMIT,
0,
&resetCharVal
},

Viki Shi:

有个例子是从16位改成128位的,你可以反向修改,同样适用于CC2640R2F:processors.wiki.ti.com/…/128_Bit_UUID_SimpleBLE

user4250809:

回复 Viki Shi:

看起来,例子就是使用了128 bit,我也是要将128bit反向做成16bit.

这个例子和我SDK例子差异还是比较大,比如USE_128_BIT_UUID这个定义在我的例子里并没有。

我是一个新手,研究了半天,还是不知道如何去修改好,请指教!

Viki Shi:

回复 user4250809:

那你可以参考下CC2640SDK里的simple peripheral example ,这个用的是16bit UUID

user4250809:

回复 Viki Shi:

我参考了simple peripheral example 代码当中确实是使用了16bit,但在手机中发现还是被扩展成128bit的,不知道什么原因?

我这边要实现的需求,就是在手机上看到的UUID是16bit,也就是图中 FFF0,FFF1就可以了。

我进一步去查看 00805F9B34FB 是在哪里加入的,发现有宏 BT_BASE_UUID_128定义了它,但修改这个宏,并没有达到我要的效果,因此,再次求助。

static gattAttribute_t simpleProfileAttrTbl[SERVAPP_NUM_ATTR_SUPPORTED] =
{// Simple Profile Service{{ ATT_BT_UUID_SIZE, primaryServiceUUID }, /* type */GATT_PERMIT_READ,/* permissions */0,/* handle */(uint8 *)&simpleProfileService/* pValue */},// Characteristic 1 Declaration{{ ATT_BT_UUID_SIZE, characterUUID },GATT_PERMIT_READ,0,&simpleProfileChar1Props},// Characteristic Value 1{{ ATT_BT_UUID_SIZE, simpleProfilechar1UUID },GATT_PERMIT_READ | GATT_PERMIT_WRITE,0,&simpleProfileChar1},// Characteristic 1 User Description{{ ATT_BT_UUID_SIZE, charUserDescUUID },GATT_PERMIT_READ,0,simpleProfileChar1UserDesp},// Characteristic 2 Declaration{{ ATT_BT_UUID_SIZE, characterUUID },GATT_PERMIT_READ,0,&simpleProfileChar2Props},// Characteristic Value 2{{ ATT_BT_UUID_SIZE, simpleProfilechar2UUID },GATT_PERMIT_READ,0,&simpleProfileChar2},// Characteristic 2 User Description{{ ATT_BT_UUID_SIZE, charUserDescUUID },GATT_PERMIT_READ,0,simpleProfileChar2UserDesp},// Characteristic 3 Declaration{{ ATT_BT_UUID_SIZE, characterUUID },GATT_PERMIT_READ,0,&simpleProfileChar3Props},// Characteristic Value 3{{ ATT_BT_UUID_SIZE, simpleProfilechar3UUID },GATT_PERMIT_WRITE,0,&simpleProfileChar3},// Characteristic 3 User Description{{ ATT_BT_UUID_SIZE, charUserDescUUID },GATT_PERMIT_READ,0,simpleProfileChar3UserDesp},// Characteristic 4 Declaration{{ ATT_BT_UUID_SIZE, characterUUID },GATT_PERMIT_READ,0,&simpleProfileChar4Props},// Characteristic Value 4{{ ATT_BT_UUID_SIZE, simpleProfilechar4UUID },0,0,&simpleProfileChar4},// Characteristic 4 configuration{{ ATT_BT_UUID_SIZE, clientCharCfgUUID },GATT_PERMIT_READ | GATT_PERMIT_WRITE,0,(uint8 *)&simpleProfileChar4Config},// Characteristic 4 User Description{{ ATT_BT_UUID_SIZE, charUserDescUUID },GATT_PERMIT_READ,0,simpleProfileChar4UserDesp},// Characteristic 5 Declaration{{ ATT_BT_UUID_SIZE, characterUUID },GATT_PERMIT_READ,0,&simpleProfileChar5Props},// Characteristic Value 5{{ ATT_BT_UUID_SIZE, simpleProfilechar5UUID },GATT_PERMIT_AUTHEN_READ,0,simpleProfileChar5},// Characteristic 5 User Description{{ ATT_BT_UUID_SIZE, charUserDescUUID },GATT_PERMIT_READ,0,simpleProfileChar5UserDesp},
}

user4250809:

回复 user4250809:

找了ipad去看这个例子当中的UUID,发现已经是16bit的了。

那么就有疑问了:为什么android当中显示成128bit,而在iphone当中就会显示成16bit?

user4250809:

回复 Viki Shi:

Hello Viki,
可以帮忙再看下这个问题吗?

Alvin Chen:

回复 user4250809:

UUID(Universally Unique Identifier)是通用唯一识别码。
在蓝牙设备中,每个服务、特征值都有一个对应的UUID。
UUID是128bit的,但是为了降低存储和传输的负担,我们预分配一些常用的UUID的值,比如Bluetooth_Base_UUID的值是00000000-0000-1000-8000-00805F9B34FB。通常预分配的值都是16bit或者32bit的UUID。但是实际上,它们还是128bit的值。
你可能是显示问题,Demo的0xfff0 默认为16bit,用手机的scanner 去看则会发现最后不全了128bit。

赞(0)
未经允许不得转载:TI中文支持网 » service uuid 从128位改成16bit
分享到: 更多 (0)