SWRU455M February 2017 – October 2020 CC3120 , CC3120MOD , CC3130 , CC3135 , CC3135MOD , CC3220MOD , CC3220MODA , CC3220R , CC3220S , CC3220SF , CC3230S , CC3230SF , CC3235MODAS , CC3235MODASF , CC3235MODS , CC3235MODSF , CC3235S , CC3235SF
In the following code example, the event ID is set in byte 3 of the action arguments and may be set to a value between 0 and SL_RX_FILTER_MAX_USER_EVENT_ID (=63).
The code example for adding a filter with an event (the event input is highlighted in yellow, and the event output parsing is highlighted in gray):
void AddSomeFilters()
{
// declarations
SlWlanRxFilterID_t FilterId;
SlWlanRxFilterRuleType_t RuleType;
SlWlanRxFilterFlags_u FilterFlags;
SlWlanRxFilterRuleHeader_t Rule;
SlWlanRxFilterTrigger_t Trigger;
SlWlanRxFilterAction_t Action;
...
// here comes the code for adding a header rule filter
...
// now for action args setting.
// request an event as one of the actions to perform
Action.Type = SL_WLAN_RX_FILTER_ACTION_EVENT_TO_HOST;
// The output of the event is to set bit number (in this case it is bit 2).
Action.UserId = 2;
...
// finally the code to add the event.
RetVal = sl_WlanRxFilterAdd(
RuleType,
FilterFlags,
( const SlWlanRxFilterRule_u* const )&Rule,
( const SlWlanRxFilterTrigger_t* const)&Trigger,
( const SlWlanRxFilterAction_t* const )&ction,
&FilterId);
// rx filters events handling is a specific case in the WLAN events handlingvoid SLWlanEventHandler(SlWlanEvent_t *pWlanEventHandler)
{
int i = 0;
switch(pWlanEventHandler->Id)
{
case SL_WLAN_EVENT_CONNECT:
break;
case SL_WLAN_EVENT_STA_ADDED:
break;
case SL_WLAN_EVENT_DISCONNECT:
break;
case SL_WLAN_EVENT_RXFILTER:
{
SlWlanEventRxFilterInfo_t *pEventData =
(SlWlanEventRxFilterInfo_t *)&pWlanEventHandler->Data;
/*
printf("\n\nRx filter event %d, event type = %d
\n",g_RxFilterEventsCounter,pEventData->Type);
for(i = 0;i < 64;i++)
{
if(SL_WLAN_ISBITSET8(pEventData->UserActionIdBitmap,i))
{
printf("User action %d filter event
arrived\n",i);
}
}
*/
}
break;
}
}