微波EDA网,见证研发工程师的成长!
首页 > 研发问答 > 无线和射频 > TI蓝牙设计交流 > Get rssi value in cc2640 SimpleBLEPeripheral

Get rssi value in cc2640 SimpleBLEPeripheral

时间:10-02 整理:3721RD 点击:

Hi All

[目的]

我希望當pc dongle連上cc2640 simpleBLEPeripheral時,pc dongle下cmd向cc2640取得cc2640的rssi。

 

[Issue]

當我執行GAPRole_SetParameter(GAPROLE_RSSI_READ_RATE, sizeof(uint16_t), &rssi);

<peripheral.c>的gapRole_processStackMsg()的HCI_GAP_EVENT_EVENT不會被通知

 

[Code]

<simpleBLEPerpheral.c>

static void SimpleBLEPeripheral_taskFxn(UArg a0, UArg a1)
{
    ....
    Uint16_t rssiReadRate = 3000;
    GAPRole_SetParameter(GAPROLE_RSSI_READ_RATE, 
           sizeof(uint16_t), &rssiReadRate);
    ....

   }

<peripheral.c>

bStatus_t GAPRole_SetParameter(uint16_t param, uint8_t len, void *pValue)
{
    …………
    case GAPROLE_RSSI_READ_RATE:
    	if (len == sizeof(uint16_t))
    	{
    		gapRole_RSSIReadRate = *((uint16_t*)pValue);
    		if((gapRole_RSSIReadRate) && (gapRole_state == GAPROLE_CONNECTED))
    		{
    			Util_restartClock(&rssiReadClock, gapRole_RSSIReadRate);
    		}
    	}
    	else
    	{
    		ret = bleInvalidRange;
    	}
    	break;
     …………
}
Static void gapRole_init(void)
{
	GAP_RegisterForMsgs(selfEntity);
	Util_constructClock(&rssiReadClock, gapRole_clockHandler, 0, 0, false, RSSI_READ_EVT);
}
Static void gapRole_taskFxn(Uarg a0, Uarg a1)
{
	………
	if (events & RSSI_READ_EVT)
	{
		events &= ~RSSI_READ_EVT;
		// Only get RSSI when in a connection
		if ((gapRole_state == GAPROLE_CONNECTED) || (gapRole_state == GAPROLE_CONNECTED_ADV))
		{// Ask for RSSIhciStatus_t status = NULL;status = HCI_ReadRssiCmd(gapRole_ConnectionHandle); <======== return success// Setup the next eventif (gapRole_RSSIReadRate && !status){	Util_restartClock(&rssiReadClock, gapRole_RSSIReadRate);}
		}
	}
}
static void gapRole_processStackMsg(ICall_Hdr *pMsg)
{
	Switch (pMsg->event)
	{
		Case HCI_GAP_EVENT_EVENT:  <============ Never comingif (pMsg->status == HCI_COMMAND_COMPLETE_EVENT_CODE){  	hciEvt_CmdComplete_t* pPkt = (hciEvt_CmdComplete_t*)pMsg;  	if(pPkt->cmdOpcode == HCI_READ_RSSI)  	{	  	int8_t rssi = (int8_t)pPkt->pReturnParam[3];	  	if(((gapRole_state == GAPROLE_CONNECTED) || (gapRole_state == GAPROLE_CONNECTED_ADV)) && (rssi != RSSI_NOT_AVAILABLE))	  	{  	// Report RSSI to app  	if(pGapRoles_AppCGs && pGapRoles_AppCGs->pfnRssiRead)  	{	  	pGapRoles_AppCGs->pfnRssiRead(rssi);  	}	  	}  	}
		  	}Break;
           }
}

<peripheral.h>

typedef void (*gapRolesRssiRead_t)(int8_t newRSSI);

typedef struct
{
     gapRolesStateNotify_t    pfnStateChange;
     gapRolesRssiRead_t		pfnRssiRead;
} gapRolesCBs_t;


Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top