32 #define TRACE_LEVEL NIC_TRACE_LEVEL
36 #include "sl_wfx_host.h"
37 #include "sl_wfx_host_api.h"
47 static sl_wfx_context_t wf200Context;
112 sl_wfx_mac_address_t macAddr;
118 TRACE_INFO(
"Initializing WF200 (STA mode)...\r\n");
120 wf200StaInterface = interface;
125 TRACE_INFO(
"Initializing WF200 (AP mode)...\r\n");
127 wf200ApInterface = interface;
131 if(wf200StaInterface == NULL || wf200ApInterface == NULL)
137 status = sl_wfx_init(&wf200Context);
142 status = SL_STATUS_OK;
146 if(status == SL_STATUS_OK)
152 if(interface == wf200StaInterface)
154 macCopyAddr(&interface->macAddr, wf200Context.mac_addr_0.octet);
158 macCopyAddr(&interface->macAddr, wf200Context.mac_addr_1.octet);
170 if(interface == wf200StaInterface)
172 status = sl_wfx_set_mac_address(&macAddr, SL_WFX_STA_INTERFACE);
176 status = sl_wfx_set_mac_address(&macAddr, SL_WFX_SOFTAP_INTERFACE);
185 if(status == SL_STATUS_OK)
256 sl_wfx_send_frame_req_t *req;
262 if(!interface->linkState)
271 n = SL_WFX_ROUND_UP(
length, 2);
274 sl_wfx_allocate_command_buffer((sl_wfx_generic_message_t **) &req,
275 SL_WFX_SEND_FRAME_REQ_ID, SL_WFX_TX_FRAME_BUFFER,
276 n +
sizeof(sl_wfx_send_frame_req_t));
285 if(interface == wf200StaInterface)
287 status = sl_wfx_send_ethernet_frame(req,
length, SL_WFX_STA_INTERFACE, 0);
291 status = sl_wfx_send_ethernet_frame(req,
length, SL_WFX_SOFTAP_INTERFACE, 0);
295 sl_wfx_free_command_buffer((sl_wfx_generic_message_t *) req,
296 SL_WFX_SEND_FRAME_REQ_ID, SL_WFX_TX_FRAME_BUFFER);
301 status = SL_STATUS_ALLOCATION_FAILED;
308 if(status == SL_STATUS_OK)
330 sl_wfx_mac_address_t macAddr;
333 TRACE_INFO(
"Updating WF200 multicast filter...\r\n");
336 status = SL_STATUS_OK;
343 entry = &interface->macAddrFilter[i];
355 if(interface == wf200StaInterface)
357 status = sl_wfx_add_multicast_address(&macAddr,
358 SL_WFX_STA_INTERFACE);
362 status = sl_wfx_add_multicast_address(&macAddr,
363 SL_WFX_SOFTAP_INTERFACE);
369 if(interface == wf200StaInterface)
371 status = sl_wfx_remove_multicast_address(&macAddr,
372 SL_WFX_STA_INTERFACE);
376 status = sl_wfx_remove_multicast_address(&macAddr,
377 SL_WFX_SOFTAP_INTERFACE);
384 if(status == SL_STATUS_OK)
402 if(wf200StaInterface != NULL)
405 wf200StaInterface->linkState =
TRUE;
424 if(wf200StaInterface != NULL)
427 wf200StaInterface->linkState =
FALSE;
446 if(wf200ApInterface != NULL)
449 wf200ApInterface->linkState =
TRUE;
468 if(wf200ApInterface != NULL)
471 wf200ApInterface->linkState =
FALSE;
494 if((ind->header.info & SL_WFX_MSG_INFO_INTERFACE_MASK) ==
495 (SL_WFX_STA_INTERFACE << SL_WFX_MSG_INFO_INTERFACE_OFFSET))
497 interface = wf200StaInterface;
501 interface = wf200ApInterface;
505 if(interface != NULL)
515 ind->body.frame_length, &ancillary);
@ ERROR_FAILURE
Generic error code.
const MacAddr MAC_UNSPECIFIED_ADDR
void macAddrToEui64(const MacAddr *macAddr, Eui64 *interfaceId)
Map a MAC address to the IPv6 modified EUI-64 identifier.
#define macCompAddr(macAddr1, macAddr2)
#define macCopyAddr(destMacAddr, srcMacAddr)
#define MAC_ADDR_FILTER_SIZE
size_t netBufferGetLength(const NetBuffer *buffer)
Get the actual length of a multi-part buffer.
size_t netBufferRead(void *dest, const NetBuffer *src, size_t srcOffset, size_t length)
Read data from a multi-part buffer.
const NetRxAncillary NET_DEFAULT_RX_ANCILLARY
void nicProcessPacket(NetInterface *interface, uint8_t *packet, size_t length, NetRxAncillary *ancillary)
Handle a packet received by the network controller.
void nicNotifyLinkChange(NetInterface *interface)
Process link state change notification.
@ NIC_TYPE_ETHERNET
Ethernet interface.
void osAcquireMutex(OsMutex *mutex)
Acquire ownership of the specified mutex object.
void osReleaseMutex(OsMutex *mutex)
Release ownership of the specified mutex object.
void osSetEvent(OsEvent *event)
Set the specified event object to the signaled state.
Structure describing a buffer that spans multiple chunks.
void wf200EventHandler(NetInterface *interface)
WF200 event handler.
void wf200ConnectCallback(void)
Station connected callback.
void wf200DisconnectCallback(void)
Station disconnected callback.
sl_status_t sl_wfx_host_init_pins(void)
void wf200Tick(NetInterface *interface)
WF200 timer handler.
void wf200EnableIrq(NetInterface *interface)
Enable interrupts.
void wf200StartApCallback(void)
Station connected callback.
void wf200DisableIrq(NetInterface *interface)
Disable interrupts.
void sl_wfx_host_received_frame_callback(sl_wfx_received_ind_t *ind)
Callback function that handles incoming packets.
const NicDriver wf200ApDriver
WF200 driver (AP mode)
void wf200StopApCallback(void)
Station disconnected callback.
const NicDriver wf200StaDriver
WF200 driver (STA mode)
error_t wf200UpdateMacAddrFilter(NetInterface *interface)
Configure MAC address filtering.
error_t wf200SendPacket(NetInterface *interface, const NetBuffer *buffer, size_t offset, NetTxAncillary *ancillary)
Send a packet.
error_t wf200Init(NetInterface *interface)
WF200 initialization.