Go to the documentation of this file.
32 #define TRACE_LEVEL NIC_TRACE_LEVEL
35 #include "driver/include/m2m_wifi.h"
38 #include "wilc1000_config.h"
110 tstrWifiInitParam param;
111 #if (M2M_FIRMWARE_VERSION_MAJOR_NO == 4)
120 TRACE_INFO(
"Initializing WILC1000 (STA mode)...\r\n");
127 TRACE_INFO(
"Initializing WILC1000 (AP mode)...\r\n");
139 status = nm_bsp_init();
141 if(status != M2M_SUCCESS)
151 param.pfAppMonCb = NULL;
152 #if (M2M_FIRMWARE_VERSION_MAJOR_NO == 3)
153 param.strEthInitParam.pfAppWifiCb = NULL;
158 param.strEthInitParam.au8ethRcvBuf =
rxBuffer;
162 status = m2m_wifi_init(¶m);
164 if(status != M2M_SUCCESS)
169 #if (M2M_FIRMWARE_VERSION_MAJOR_NO == 3)
174 status = m2m_wifi_get_mac_address(interface->macAddr.b);
176 if(status != M2M_SUCCESS)
187 status = m2m_wifi_set_mac_address(interface->macAddr.b);
189 if(status != M2M_SUCCESS)
199 status = M2M_SUCCESS;
202 #if (M2M_FIRMWARE_VERSION_MAJOR_NO == 3)
225 #elif (M2M_FIRMWARE_VERSION_MAJOR_NO == 4)
227 status = m2m_wifi_get_mac_address(apMacAddr.b, staMacAddr.b);
229 if(status != M2M_SUCCESS)
240 interface->macAddr = staMacAddr;
244 interface->macAddr = apMacAddr;
255 staMacAddr = interface->macAddr;
259 apMacAddr = interface->macAddr;
263 status = m2m_wifi_set_mac_address(staMacAddr.b, apMacAddr.b);
265 if(status != M2M_SUCCESS)
279 if(status == M2M_SUCCESS)
362 m2m_wifi_handle_events(NULL);
395 if(!interface->linkState)
403 #if (M2M_FIRMWARE_VERSION_MAJOR_NO == 3)
406 #elif (M2M_FIRMWARE_VERSION_MAJOR_NO == 4)
416 #if (M2M_FIRMWARE_VERSION_MAJOR_NO == 4 && M2M_FIRMWARE_VERSION_MINOR_NO >= 2)
417 status = m2m_wifi_send_ethernet_pkt(
txBuffer,
length, STATION_INTERFACE);
425 #if (M2M_FIRMWARE_VERSION_MAJOR_NO == 4 && M2M_FIRMWARE_VERSION_MINOR_NO >= 2)
426 status = m2m_wifi_send_ethernet_pkt(
txBuffer,
length, AP_INTERFACE);
436 if(status == M2M_SUCCESS)
460 TRACE_INFO(
"Updating WILC1000 multicast filter...\r\n");
467 entry = &interface->macAddrFilter[i];
490 m2m_wifi_enable_mac_mcast(entry->
addr.b,
TRUE);
495 m2m_wifi_enable_mac_mcast(entry->
addr.b,
FALSE);
523 if(interface != NULL)
529 entry = &interface->macAddrFilter[i];
560 tstrM2mWifiStateChanged *stateChangedMsg;
563 TRACE_INFO(
"WILC1000 Wi-Fi event callback\r\n");
566 if(
msgType == M2M_WIFI_RESP_FIRMWARE_STRTED)
569 TRACE_INFO(
" M2M_WIFI_RESP_FIRMWARE_STRTED\r\n");
571 else if(
msgType == M2M_WIFI_RESP_CON_STATE_CHANGED)
574 TRACE_INFO(
" M2M_WIFI_RESP_CON_STATE_CHANGED\r\n");
577 stateChangedMsg = (tstrM2mWifiStateChanged *) msg;
580 #if (M2M_FIRMWARE_VERSION_MAJOR_NO == 4 && M2M_FIRMWARE_VERSION_MINOR_NO >= 2)
581 if(stateChangedMsg->u8IfcId == STATION_INTERFACE)
583 if(stateChangedMsg->u8IfcId == INTERFACE_1)
590 if(stateChangedMsg->u8CurrState == M2M_WIFI_CONNECTED)
605 #if (M2M_FIRMWARE_VERSION_MAJOR_NO == 4 && M2M_FIRMWARE_VERSION_MINOR_NO >= 2)
606 else if(stateChangedMsg->u8IfcId == AP_INTERFACE)
608 else if(stateChangedMsg->u8IfcId == INTERFACE_2)
615 if(stateChangedMsg->u8CurrState == M2M_WIFI_CONNECTED)
630 #if defined(CONF_WILC_EVENT_HOOK)
634 CONF_WILC_EVENT_HOOK(
msgType, msg);
653 #if (M2M_FIRMWARE_VERSION_MAJOR_NO == 4 && M2M_FIRMWARE_VERSION_MINOR_NO >= 2)
654 tstrM2MDataBufCtrl *ctrl;
656 tstrM2mIpCtrlBuf *ctrl;
663 #if (M2M_FIRMWARE_VERSION_MAJOR_NO == 4 && M2M_FIRMWARE_VERSION_MINOR_NO >= 2)
664 ctrl = (tstrM2MDataBufCtrl *) ctrlBuf;
666 ctrl = (tstrM2mIpCtrlBuf *) ctrlBuf;
670 if(
msgType == M2M_WIFI_RESP_ETHERNET_RX_PACKET)
673 TRACE_DEBUG(
" M2M_WIFI_RESP_ETHERNET_RX_PACKET\r\n");
675 #if (M2M_FIRMWARE_VERSION_MAJOR_NO == 3)
678 #elif (M2M_FIRMWARE_VERSION_MAJOR_NO == 4)
680 packet =
rxBuffer + ctrl->u8DataOffset;
684 length = ctrl->u16DataSize;
687 #if (M2M_FIRMWARE_VERSION_MAJOR_NO == 4 && M2M_FIRMWARE_VERSION_MINOR_NO >= 2)
688 if(ctrl->u8IfcId == STATION_INTERFACE)
690 if(ctrl->u8IfcId == INTERFACE_1)
712 #if (M2M_FIRMWARE_VERSION_MAJOR_NO == 4 && M2M_FIRMWARE_VERSION_MINOR_NO >= 2)
713 else if(ctrl->u8IfcId == AP_INTERFACE)
715 else if(ctrl->u8IfcId == INTERFACE_2)
bool_t osSetEventFromIsr(OsEvent *event)
Set an event object to the signaled state from an interrupt service routine.
void nicNotifyLinkChange(NetInterface *interface)
Process link state change notification.
error_t wilc1000Init(NetInterface *interface)
WILC1000 initialization.
void macAddrToEui64(const MacAddr *macAddr, Eui64 *interfaceId)
Map a MAC address to the IPv6 modified EUI-64 identifier.
size_t netBufferRead(void *dest, const NetBuffer *src, size_t srcOffset, size_t length)
Read data from a multi-part buffer.
bool_t wilc1000GetAddrRefCount(NetInterface *interface, const MacAddr *macAddr)
Get reference count for the specified multicast MAC address.
Structure describing a buffer that spans multiple chunks.
#define MAC_ADDR_FILTER_SIZE
const NicDriver wilc1000StaDriver
WILC1000 driver (STA mode)
error_t wilc1000SendPacket(NetInterface *interface, const NetBuffer *buffer, size_t offset, NetTxAncillary *ancillary)
Send a packet.
uint_t refCount
Reference count for the current entry.
void wilc1000AppWifiEvent(uint8_t msgType, void *msg)
Callback function that handles Wi-Fi events.
NetInterface * wilc1000ApInterface
void nicProcessPacket(NetInterface *interface, uint8_t *packet, size_t length, NetRxAncillary *ancillary)
Handle a packet received by the network controller.
#define macCopyAddr(destMacAddr, srcMacAddr)
#define WILC1000_RX_BUFFER_SIZE
void wilc1000DisableIrq(NetInterface *interface)
Disable interrupts.
const NetRxAncillary NET_DEFAULT_RX_ANCILLARY
@ ERROR_FAILURE
Generic error code.
error_t wilc1000UpdateMacAddrFilter(NetInterface *interface)
Configure MAC address filtering.
size_t netBufferGetLength(const NetBuffer *buffer)
Get the actual length of a multi-part buffer.
WILC1000 Wi-Fi controller.
bool_t wilc1000IrqHandler(void)
WILC1000 interrupt service routine.
void wilc1000Tick(NetInterface *interface)
WILC1000 timer handler.
void osAcquireMutex(OsMutex *mutex)
Acquire ownership of the specified mutex object.
void osReleaseMutex(OsMutex *mutex)
Release ownership of the specified mutex object.
const NicDriver wilc1000ApDriver
WILC1000 driver (AP mode)
void wilc1000EnableIrq(NetInterface *interface)
Enable interrupts.
#define macCompAddr(macAddr1, macAddr2)
void wilc1000AppEthEvent(uint8_t msgType, void *msg, void *ctrlBuf)
Callback function that handles events in bypass mode.
void osSetEvent(OsEvent *event)
Set the specified event object to the signaled state.
#define osMemset(p, value, length)
void wilc1000EventHandler(NetInterface *interface)
WILC1000 event handler.
NetInterface * wilc1000StaInterface
#define WILC1000_TX_BUFFER_SIZE
const MacAddr MAC_UNSPECIFIED_ADDR
@ NIC_TYPE_ETHERNET
Ethernet interface.