Exemple #1
0
static void OutputDeviceInfo(void)
{
    char buf[20];
    tWFDeviceInfo deviceInfo;
    
    SYS_CONSOLE_MESSAGE("Device:          ");        
    
    WF_GetDeviceInfo(&deviceInfo);
    sprintf(buf, "MRF24WB (0x%02X%02X)\r\n", deviceInfo.romVersion, deviceInfo.patchVersion);
    SYS_CONSOLE_MESSAGE(buf);
}    
static void do_get_wfver_cmd(void)
{
 	tWFDeviceInfo  deviceInfo;

	WF_GetDeviceInfo(&deviceInfo);
	WFConsolePrintRomStr("Firmware version   0x", FALSE);
	WFConsolePrintHex(deviceInfo.romVersion, 2);
	WFConsolePrintHex(deviceInfo.patchVersion, 2);
	WFConsolePrintRomStr("", TRUE);  

	WFConsolePrintRomStr("Host Driver version        ", FALSE);
	WFConsolePrintRomStr(WF_HOST_DRIVER_VERSION_NUMBER, TRUE);
}
Exemple #3
0
/*****************************************************************************
 * FUNCTION: WF_Init
 *
 * RETURNS: true if success
 *          false otherwise
 *
 * PARAMS:
 *      N/A.
 *
 *
 *  NOTES: This function must be called once prior to calling any other WF...
 *          functions.  This function initializes the Wifi Driver internal State.
 *          It also verifies functionality of the lower level SPI driver and
 *          connected hardware.
 *****************************************************************************/
bool WF_Init(const void* pNetIf)
{
    tWFDeviceInfo deviceInfo;
    
    if(!WFHardwareInit())
    {
        return false;
    }

    RawInit();
    WFEnableMRF24WMode();
    WF_GetDeviceInfo(&deviceInfo);
    
    // if MRF24W
    if (deviceInfo.deviceType == MRF24WB0M_DEVICE)
    {
        SYS_ASSERT(deviceInfo.romVersion == 0x12, "");
        SYS_ASSERT(deviceInfo.patchVersion >= 0x02, "");

        if (deviceInfo.romVersion == 0x12 && deviceInfo.patchVersion >= 0x09)
        {
            gRFModuleVer1209orLater = true;
        }    
    }
    
    /* send init messages to MRF24W */
    WF_LibInitialize((NET_CONFIG*)pNetIf);
    
  	#if defined(WF_CONSOLE)
    	WFConsoleInit();

        #if defined(APP_USE_IPERF)
           // IperfConsoleInit();
            IperfAppInit("MRF24W");
        #endif
	#endif
	
	
	// save network handle
	SetNetworkConfig((NET_CONFIG *)pNetIf);
    	
    return true;
}
/*****************************************************************************
 * FUNCTION: WF_Init
 *
 * RETURNS: None
 *
 * PARAMS:
 *      N/A.
 *
 *
 *  NOTES: This function must be called once prior to calling any other WF...
 *          functions.  This function initializes the Wifi Driver internal State.
 *          It also verifies functionality of the lower level SPI driver and
 *          connected hardware.
 *****************************************************************************/
void WF_Init(void)
{
    tWFDeviceInfo deviceInfo;
    
    WFHardwareInit();
    RawInit();
    
    WFEnableMRF24WB0MMode();
    WF_GetDeviceInfo(&deviceInfo);
    
    // if MRF24WB   
    #if !defined(MRF24WG)
        WF_ASSERT(deviceInfo.romVersion == 0x12);
        WF_ASSERT(deviceInfo.patchVersion >= 0x02);
        if (deviceInfo.romVersion == 0x12 && deviceInfo.patchVersion >= 0x09)
        {
            gRFModuleVer1209orLater = TRUE;
        }    
   #else // must be a MRF24WG
        WF_ASSERT(deviceInfo.romVersion == 0x30 || deviceInfo.romVersion == 0x31);        
   #endif
    
    /* send init messages to MRF24W */
    WF_LibInitialize();
    
  	#if defined(WF_CONSOLE)
    	WFConsoleInit();
    	#if defined(WF_CONSOLE_DEMO)
    	    IperfAppInit();
    	#endif
	#endif
	
	if(DHCPIsEnabled(0))
	{
        SetDhcpProgressState();
    }   	


}
Exemple #5
0
static void do_get_wfver_cmd(void)
{
 	tWFDeviceInfo  deviceInfo;
	if (WF_hibernate.state)
	{
		WFConsolePrintRomStr("The Wi-Fi module is in hibernate mode - command failed.", TRUE);
		return;
	}
	WF_GetDeviceInfo(&deviceInfo);
	
	#if defined(MRF24WG)
	    WFConsolePrintRomStr("MRF24WG firmware version: 0x", FALSE);

	#else
	    WFConsolePrintRomStr("MRF24WB firmware version:     0x", FALSE);	
	#endif

	WFConsolePrintHex(deviceInfo.romVersion, 2);
	WFConsolePrintHex(deviceInfo.patchVersion, 2);
	WFConsolePrintRomStr("", TRUE);  

	WFConsolePrintRomStr("Host Driver version:      ", FALSE);
	WFConsolePrintRomStr(WF_HOST_DRIVER_VERSION_NUMBER, TRUE);
}
Exemple #6
0
/*****************************************************************************
 FUNCTION 	TCPIPTask
			Main function to handle the TCPIP stack
 
 RETURNS  	None
 
 PARAMS		None
*****************************************************************************/
void TCPIPTask()
{
	WFConnection = WF_CUSTOM;
	ConnectionProfileID = 0;
	static DWORD dwLastIP = 0;
	_WFStat = NOT_CONNECTED;
        
	dwLastIP = 0;
	//	Function pointers for the callback function of the TCP/IP and WiFi stack 

#if defined (FLYPORT_WF)
	FP[1] = cWFConnect;
	FP[2] = cWFDisconnect;
	FP[3] = cWFScan;
	FP[5] = cWFPsPollDisable;
	FP[6] = cWFPsPollEnable;
	FP[7] = cWFScanList;
#if defined (FLYPORT_G)
	FP[8] = cRSSIUpdate;
	FP[9] = cWFGetPSK;
#endif
	FP[10] = cWFStopConnecting;
	
#endif
#if defined (FLYPORT_ETH)
	FP[1] = cETHRestart;
#endif
#if defined (STACK_USE_SSL_CLIENT)
	FP[14] = cTCPSSLStatus;
	FP[15] = cTCPSSLStart;
#endif
	FP[16] = cTCPRxFlush;
	FP[17] = cTCPpRead;
	FP[18] = cTCPRemote;
	FP[19] = cTCPServerDetach;
	FP[20] = cTCPGenericOpen;
	FP[21] = cTCPRead;
	FP[22] = cTCPWrite;
	FP[23] = cTCPGenericClose;
	FP[24] = cTCPisConn;
	FP[25] = cTCPRxLen;


	#if defined(STACK_USE_SMTP_CLIENT)
	FP[26] = cSMTPStart;
	FP[27] = cSMTPSetServer;
	FP[28] = cSMTPSetMsg;
	FP[29] = cSMTPSend;
	FP[30] = cSMTPBusy;
	FP[31] = cSMTPStop;
	FP[32] = cSMTPReport;
	#endif
	
	FP[ARP_RESOLVE] = cARPResolveMAC;
	#if MAX_UDP_SOCKETS_FREERTOS>0	
	FP[35] = cUDPGenericOpen;
	FP[36] = cUDPWrite;
	FP[37] = cUDPGenericClose;
    FP[38] = cUDPMultiOn;
	#endif
	
	// Initialize stack-related hardware components that may be 
	// required by the UART configuration routines
	
	// Initialization of tick and of DHCPs SM only at the startup of the device
	if (hFlyTask == NULL)
	{
	    TickInit();
	    #if defined STACK_USE_DHCP_SERVER
	    DHCPServerSMInit();
	    #endif
	}  
	#if defined(STACK_USE_MPFS) || defined(STACK_USE_MPFS2)
	MPFSInit();
	#endif

	// Initialize Stack and application related NV variables into AppConfig.
	InitAppConfig();

	// Initialize core stack layers (MAC, ARP, TCP, UDP) and application modules (HTTP, SNMP, etc.)
    StackInit();

	if (hFlyTask == NULL)
	{
		NETConf[0] = AppConfig;
		NETConf[1] = AppConfig;
	}
	
	#if defined(WF_CS_TRIS)
	//	On startup no connection profile should be present inside WiFi module, so a new one is created
	UINT8 listIds = 0;
	WF_CPGetIds(&listIds);
	if (listIds == 0)
	{
		WF_CPCreate(&ConnectionProfileID);
	}
	//	Logical connection state initialization
	SetLogicalConnectionState(FALSE);
    #endif



	#if defined(STACK_USE_ZEROCONF_LINK_LOCAL)
    ZeroconfLLInitialize();
	#endif

	
	#if defined(STACK_USE_ZEROCONF_MDNS_SD)
	mDNSInitialize(MY_DEFAULT_HOST_NAME);
	mDNSServiceRegister(
		(const char *) "DemoWebServer",		// base name of the service
		"_http._tcp.local",			    	// type of the service
		80,				                	// TCP or UDP port, at which this service is available
		((const BYTE *)"path=/index.htm"),	// TXT info
		1,								    // auto rename the service when if needed
		NULL,							    // no callback function
		NULL							    // no application context
		);

    mDNSMulticastFilterRegister();			
	#endif

	//	INITIALIZING UDP
	#if MAX_UDP_SOCKETS_FREERTOS>0
	_dbgwrite("Initializing UDP...\r\n");
	UDPInit();
	activeUdpSocket=0;
	while (activeUdpSocket < MAX_UDP_SOCKETS_FREERTOS) 
	{
		tmp_len[activeUdpSocket]=0;
		if (activeUdpSocket == 0) 
		{
			BUFFER_UDP_LEN[0] = BUFFER1_UDP_LEN;
			udpBuffer[activeUdpSocket] = udpBuffer1;
			udpSocket[0] = INVALID_UDP_SOCKET;
		}
		#if MAX_UDP_SOCKETS_FREERTOS>1
		if (activeUdpSocket == 1)
		{
			BUFFER_UDP_LEN[1] = BUFFER2_UDP_LEN;
			udpBuffer[activeUdpSocket] = udpBuffer2;
			udpSocket[1] = INVALID_UDP_SOCKET;
		}
		#endif
		#if MAX_UDP_SOCKETS_FREERTOS>2
		if (activeUdpSocket == 2)
		{
			BUFFER_UDP_LEN[2] = BUFFER3_UDP_LEN;
			udpBuffer[activeUdpSocket] = udpBuffer3;
			udpSocket[2] = INVALID_UDP_SOCKET;
		}
		#endif
		#if MAX_UDP_SOCKETS_FREERTOS>3
		if (activeUdpSocket == 3)
		{
			BUFFER_UDP_LEN[3] = BUFFER4_UDP_LEN;
			udpBuffer[activeUdpSocket] = udpBuffer4;
			udpSocket[3] = INVALID_UDP_SOCKET;
		}
		#endif
		p_udp_wifiram[activeUdpSocket] = udpBuffer[activeUdpSocket];
		p_udp_data[activeUdpSocket] = udpBuffer[activeUdpSocket];
		activeUdpSocket++;
	}
	#endif
	if (hFlyTask == NULL)
	{
		//	Creates the task dedicated to user code
		xTaskCreate(FlyportTask,(signed char*) "FLY" , (configMINIMAL_STACK_SIZE * 4), 
		NULL, tskIDLE_PRIORITY + 1, &hFlyTask);	
	}

	//	DEBUG code - Firmware version on UART 1
	#ifdef FW_VER_ON_U1
	char fwVerString[30];
	tWFDeviceInfo deviceInfo;
	WF_GetDeviceInfo(&deviceInfo); 
	sprintf(fwVerString,"ver.%02x%02x\n", deviceInfo.romVersion , deviceInfo.patchVersion);
	_dbgwrite(fwVerString);
	#endif
//-------------------------------------------------------------------------------------------
//|							--- COOPERATIVE MULTITASKING LOOP ---							|
//-------------------------------------------------------------------------------------------
    while(1)
    {
        #if defined (FLYPORT_WF)
        if (_WFStat != TURNED_OFF)
        #endif
        {
				
	        // This task performs normal stack task including checking
	        // for incoming packet, type of packet and calling
	        // appropriate stack entity to process it.
			vTaskSuspendAll();
			StackTask();
			xTaskResumeAll();
			#if defined(STACK_USE_HTTP_SERVER) || defined(STACK_USE_HTTP2_SERVER)
			vTaskSuspendAll();
			HTTPServer();
			xTaskResumeAll();
			#endif
			// This tasks invokes each of the core stack application tasks
	        StackApplications();
	
	        #if defined(STACK_USE_ZEROCONF_LINK_LOCAL)
			ZeroconfLLProcess();
	        #endif
	
	        #if defined(STACK_USE_ZEROCONF_MDNS_SD)
	        mDNSProcess();
			// Use this function to exercise service update function
			// HTTPUpdateRecord();
	        #endif
	
			#if defined(STACK_USE_SNMP_SERVER) && !defined(SNMP_TRAP_DISABLED)
			//User should use one of the following SNMP demo
			// This routine demonstrates V1 or V2 trap formats with one variable binding.
			SNMPTrapDemo();
			#if defined(SNMP_STACK_USE_V2_TRAP)
			//This routine provides V2 format notifications with multiple (3) variable bindings
			//User should modify this routine to send v2 trap format notifications with the required varbinds.
			//SNMPV2TrapDemo();
			#endif 
			if(gSendTrapFlag)
				SNMPSendTrap();
			#endif
			
			#if defined(STACK_USE_BERKELEY_API)
			BerkeleyTCPClientDemo();
			BerkeleyTCPServerDemo();
			BerkeleyUDPClientDemo();
			#endif


			// Check on the queue to verify if other task have requested some stack function
			xStatus = xQueueReceive(xQueue,&Cmd,0);
			CmdCheck();
			#if defined (FLYPORT_WF)
			//	Check to verify the connection. If it's lost or failed, the device tries to reconnect
			switch(_WFStat)
			{
				case CONNECTION_LOST:
				case CONNECTION_FAILED:
					tick01 = TickGetDiv64K();
					_WFStat = RECONNECTING;		
					break;
				case RECONNECTING:
					tick02 = TickGetDiv64K();
					if ((tick02 - tick01) >= 3)
					{
						_WFStat = CONNECTING;
						WF_Connect(WFConnection);
					}	
					break;
			}
			//	RSSI management
			if (myRSSI.stat == RSSI_TO_READ)
			{
				tWFScanResult rssiScan;
				WF_ScanGetResult(0, &rssiScan);
				myRSSI.value = rssiScan.rssi;
				myRSSI.stat = RSSI_VALID;
			}
			#endif
	        // If the local IP address has changed (ex: due to DHCP lease change)
	        // write the new IP address to the LCD display, UART, and Announce 
	        // service
			if(dwLastIP != AppConfig.MyIPAddr.Val)
			{
				dwLastIP = AppConfig.MyIPAddr.Val;
				
				_dbgwrite("\r\nNew IP Address: ");

				DisplayIPValue(AppConfig.MyIPAddr);
	
				_dbgwrite("\r\n");
	
				#if defined(STACK_USE_ANNOUNCE)
					AnnounceIP();
				#endif
	
	            #if defined(STACK_USE_ZEROCONF_MDNS_SD)
					mDNSFillHostRecord();
				#endif
			}
		} //end check turnoff	
	}
}