各位好,
我看了这篇文章还是不太懂,http://www.deyisupport.com/question_answer/wireless_connectivity/f/45/t/22874.aspx
如果我只想要在按了按键后显示BD_ADDR,例如0x7C669D9E7055
要怎么实现呢?
先定义char *sting;
然后再到按键设定
if ( keys & HAL_KEY_SW_6 )
{
string = HCI_ReadBDADDRCmd();
LCD_WRITE_STRING( string ,HAL_LCD_LINE_7 );
}
但这种做法有Error,请问具体如何实现?
Yue TANG:
读自己的地址吗?simpleperipherial例子里面就有。
/********************************************************************* * @fn bdAddr2Str * * @brief Convert Bluetooth address to string. Only needed when * LCD display is used. * * @return none */char *bdAddr2Str( uint8 *pAddr ){ uint8 i; char hex[] = "0123456789ABCDEF"; static char str[B_ADDR_STR_LEN]; char *pStr = str;
*pStr++ = '0'; *pStr++ = 'x';
// Start from end of addr pAddr += B_ADDR_LEN;
for ( i = B_ADDR_LEN; i > 0; i– ) { *pStr++ = hex[*–pAddr >> 4]; *pStr++ = hex[*pAddr & 0x0F]; }
uint8 ownAddress[B_ADDR_LEN];
GAPRole_GetParameter(GAPROLE_BD_ADDR, ownAddress);
HalLcdWriteString( bdAddr2Str( ownAddress ), HAL_LCD_LINE_7 );
Sco Lin:
回复 Yue TANG:
谢谢TY回复
是的,是取自已的地址,请问在simpleBLECenter也是用GAPRole_GetParameter(GAPROLE_BD_ADDR, ownAddress); 吗?
因为我在simpleBLECenter使用的时候,先定义#define GAPROLE_BD_ADDR 0x304
之后使用GAPRole_GetParameter(GAPROLE_BD_ADDR, ownAddress);
系统会显示GAPRole_GetParameter没定义
Yue TANG:
回复 Sco Lin:
就参考simplecenter自己的做法,如下:
static uint8 simpleBLECentralEventCB( gapCentralRoleEvent_t *pEvent ){ switch ( pEvent->gap.opcode ) { case GAP_DEVICE_INIT_DONE_EVENT: { LCD_WRITE_STRING( "BLE Central", HAL_LCD_LINE_1 ); LCD_WRITE_STRING( bdAddr2Str( pEvent->initDone.devAddr ), HAL_LCD_LINE_2 ); } break;
。。。。。
}