Filter Creation
188
SWRU455A – February 2017 – Revised March 2017
Copyright © 2017, Texas Instruments Incorporated
Rx Filters
11.4.6.4 Code Example
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()
{
// declerations
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 events 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 handling
void
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
;
}
}