Merge pull request #1787 from g-oikonomou/contrib/cc26xx/improve-cca-monitoring

Use `ccaInfo.ccaState` to decide whether CCA is complete
contiki
George Oikonomou 2017-04-24 16:02:47 +01:00 committed by GitHub
commit 3cc5505b69
1 changed files with 5 additions and 7 deletions

View File

@ -359,13 +359,12 @@ transmitting(void)
* It is the caller's responsibility to make sure the RF is on. This function
* will return RF_GET_CCA_INFO_ERROR if the RF is off
*
* This function will in fact wait for a valid RSSI signal
* This function will in fact wait for a valid CCA state
*/
static uint8_t
get_cca_info(void)
{
uint32_t cmd_status;
int8_t rssi;
rfc_CMD_IEEE_CCA_REQ_t cmd;
if(!rf_is_on()) {
@ -373,9 +372,10 @@ get_cca_info(void)
return RF_GET_CCA_INFO_ERROR;
}
rssi = RF_CMD_CCA_REQ_RSSI_UNKNOWN;
memset(&cmd, 0x00, sizeof(cmd));
cmd.ccaInfo.ccaState = RF_CMD_CCA_REQ_CCA_STATE_INVALID;
while(rssi == RF_CMD_CCA_REQ_RSSI_UNKNOWN || rssi == 0) {
while(cmd.ccaInfo.ccaState == RF_CMD_CCA_REQ_CCA_STATE_INVALID) {
memset(&cmd, 0x00, sizeof(cmd));
cmd.commandNo = CMD_IEEE_CCA_REQ;
@ -384,11 +384,9 @@ get_cca_info(void)
return RF_GET_CCA_INFO_ERROR;
}
rssi = cmd.currentRssi;
}
/* We have a valid RSSI signal. Return the CCA Info */
/* We have a valid CCA state. Return the CCA Info */
return *((uint8_t *)&cmd.ccaInfo);
}
/*---------------------------------------------------------------------------*/