This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Unable to receive Data through UDP CC3000 on MSP-EXP430FG4618

Other Parts Discussed in Thread: MSP-EXP430FG4618, CC3000

Hello everyone,

 

I searched on several Threads to solve my problem but I am starting to get desperate with this module.

 

The driver of the WiFi modul has the version 1.7.2.2. My board is the MSP-EXP430FG4618.

 

I can send data through UDP to my laptop (program: packet sender). But on the other hand, I can not receive anything from the recvfrom function in the code.

ulSsidLen2 = 0x04;
	pcSsid2 = "fadi";

	rs232_printf("Wert von wlan_connect == %d",
			wlan_connect(0, (char *) pcSsid2, ulSsidLen2, NULL, NULL, 0));

	//IP Address 192.168.43.210

	pucSubnetMask[0] = 0xFF;
	pucSubnetMask[1] = 0xFF;
	pucSubnetMask[2] = 0xFF;
	pucSubnetMask[3] = 0x0;

	pucIP_Addr[0] = 192;
	pucIP_Addr[1] = 168;
	pucIP_Addr[2] = 43;
	pucIP_Addr[3] = 210;

	pucIP_DefaultGWAddr[0] = 192;
	pucIP_DefaultGWAddr[1] = 168;
	pucIP_DefaultGWAddr[2] = 43;
	pucIP_DefaultGWAddr[3] = 1;
	//
	// Currently no implementation of DHCP in hte demo
	//
	pucDNS[0] = 0;
	pucDNS[1] = 0;
	pucDNS[2] = 0;
	pucDNS[3] = 0;

	rs232_printf("IP == %d\n", pucIP_Addr[0]);
	rs232_printf("IP == %d\n", pucIP_Addr[1]);
	rs232_printf("IP == %d\n", pucIP_Addr[2]);
	rs232_printf("IP == %d\n", pucIP_Addr[3]);

	netapp_dhcp((unsigned long *) pucIP_Addr, (unsigned long *) pucSubnetMask,
			(unsigned long *) pucIP_DefaultGWAddr, (unsigned long *) pucDNS);

	//Opening the Socket

	ulSocket2 = socket(2, 2, 17);
	memset(&socketAddr, 0, sizeof(sockaddr_in));

	// REVEIVE UDP DATA**********************************************************
	localPort = 8888;
	socketAddr.sin_family = AF_INET;
	socketAddr.sin_addr.s_addr = 0;
	socketAddr.sin_port = htons(localPort);

	rs232_printf("bind = %d\n", bind(ulSocket, (sockaddr*) &socketAddr, sizeof(sockaddr)));

	//	rs232_printf("Bind connection == %d\n", bind(ulSocket, &tSocketAddr, sizeof(sockaddr)));

	sockLen = sizeof(sockaddr_in);
	rs232_printf("sockLen = %d\n", sockLen);

	while (1)
	{
		//call recvfrom
		ReturnValue = recvfrom(ulSocket2, pucCC3000_Rx_Buffer,
				CC3000_RX_BUFFER_SIZE, 0, (sockaddr*) &from, &tRxPacketLength);

		rs232_printf("ReturnValue = %d\nnow printing packet\n", ReturnValue);
		//print buffer
		DispatcherUartSendPacket(pucCC3000_Rx_Buffer, ReturnValue);
		rs232_printf("\n\nBuffer = %d\nnow printing packet\n",
				&pucCC3000_Rx_Buffer);
        }

Can anyone please help me or give me a few tips how to solve the problem? I am quite new to networks and have some problems understanding…

I can ping the device from my laptop. But if i send anything from Packet Sender nothing happens. I also tried the original software with opcode commands but this does not help me...

I would appreciate any kind of help you can offer me…

 

 

Regards

  • Hi,

    Can you please confirm the IP address that CC3000 is actually acquiring? Check this when you get the event 'HCI_EVNT_WLAN_UNSOL_DHCP'.
    I am asking this because, the static IP was set after the wlan_connect was called. Therefore, for the first time the CC3000 would acquire IP address using DHCP.

    Regards,
    Raghavendra
  • Hi Raghavendra,

    thank you for your post and your time. I put the wlan_connect after the IP configuration. The device is still pingable from my laptop. But for some reason the bind command returns -1. If I redo that, putting the wlan_connect before IP configuration, the bind command returns 0.

    I have problems understanding. I do not call the SmartConfig Command because I want to give the device a static IP Adress.

    What can be the problem...??

    Regards,

    F.S.

  • Hi,

    I would suggest you to call netapp_dhcp first. Then call wlan_connect.
    After wlan_connect, please make sure that you wait for connection event HCI_EVNT_WLAN_UNSOL_CONNECT and also the DHCP event HCI_EVNT_WLAN_UNSOL_DHCP.

    Proceed with socket operations only after receiving these events.

    Regards,
    Raghavendra
  • Hello,


    I tried this and it still does not working. The two flags you told me, arent they already checked in DemoInitDriver()??

    So far, my Code looks like this:

    void main(void)
    {
    
    	//Variables for IP wlan_connect
    
    	volatile uint16_t ReturnValue;
    	volatile uint32_t ulSsidLen2;
    	volatile uint8_t *pcSsid2, ulDataLength;
    	volatile uint8_t *pcData, *pcSockAddrAscii, *usBuffer;
    
    	//***********************
    
    	//Variables for IP Adress
    
    	uint8_t pucIP_Addr[4];
    	uint8_t pucIP_DefaultGWAddr[4];
    	uint8_t pucSubnetMask[4];
    	uint8_t pucDNS[4];
    
    	//***********************
    
    	volatile uint32_t ulCounter = 0, localPort = 0;
    	uint32_t sockLen = 0;
    	sockaddr socketAddr, from;
    	sockaddr tSocketAddr;
    
    	// Stop WDT
    	WDTCTL = WDTPW + WDTHOLD;
    	//Initialize clock and peripherals
    	halBoardInit();
    	/* Set the main clk to 8MHz */
    	halUartInit();
    	FLL_CTL0 |= DCOPLUS + XCAP18PF;           // DCO+ set, freq = xtal x D x N+1
    	SCFI0 |= FN_4;                            // x2 DCO freq, 8MHz nominal DCO
    	SCFQCTL = 121;                            // (121+1) x 32768 x 2 = 7.99 MHz
    	//Globally enable interrupts
    //	__enable_interrupt();
    	_BIS_SR(GIE);
    
    	/* Initialize Interface with CC3000 */
    	uart_putstring("Initialize Interface with CC3000...\n");
    	DemoInitDriver();
    	uart_have_cmd = 1;
    
    	//************************** MY PROGRAM ******************************
    
    	//IP Address 192.168.43.210
    
    	pucSubnetMask[0] = 0xFF;
    	pucSubnetMask[1] = 0xFF;
    	pucSubnetMask[2] = 0xFF;
    	pucSubnetMask[3] = 0x0;
    
    	pucIP_Addr[0] = 192;
    	pucIP_Addr[1] = 168;
    	pucIP_Addr[2] = 43;
    	pucIP_Addr[3] = 210;
    
    	pucIP_DefaultGWAddr[0] = 192;
    	pucIP_DefaultGWAddr[1] = 168;
    	pucIP_DefaultGWAddr[2] = 43;
    	pucIP_DefaultGWAddr[3] = 1;
    	//
    	// Currently no implementation of DHCP in hte demo
    	//
    	pucDNS[0] = 0;
    	pucDNS[1] = 0;
    	pucDNS[2] = 0;
    	pucDNS[3] = 0;
    
    	rs232_printf("IP == %d\n", pucIP_Addr[0]);
    	rs232_printf("IP == %d\n", pucIP_Addr[1]);
    	rs232_printf("IP == %d\n", pucIP_Addr[2]);
    	rs232_printf("IP == %d\n", pucIP_Addr[3]);
    
    	netapp_dhcp((unsigned long *) pucIP_Addr, (unsigned long *) pucSubnetMask,
    			(unsigned long *) pucIP_DefaultGWAddr, (unsigned long *) pucDNS);
    
    	//Connect to WLAN
    
    	ulSsidLen2 = 0x04;
    	pcSsid2 = "fadi";
    
    	rs232_printf("Wert von wlan_connect == %d\n",
    			wlan_connect(0, (char *) pcSsid2, ulSsidLen2, NULL, NULL, 0));
    
    	//Opening the Socket
    
    	ulSocket2 = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
    	memset(&tSocketAddr, 0, sizeof(sockaddr));
    
    	// TODO REVEIVE UDP DATA**********************************************************
    //	localPort = 1501;
    //	socketAddr.sin_family = AF_INET;
    //	socketAddr.sin_addr.s_addr = 0;
    //	socketAddr.sin_port = htons(localPort);
    
    	tSocketAddr.sa_family = AF_INET;
    
    	tSocketAddr.sa_data[0] = 15;
    	tSocketAddr.sa_data[1] = 01;
    	// IP Address
    	tSocketAddr.sa_data[2] = 192;
    	tSocketAddr.sa_data[3] = 168;
    	tSocketAddr.sa_data[4] = 43;
    	tSocketAddr.sa_data[5] = 210;
    
    	// all 0 IP address
    //	memset(&tSocketAddr.sa_data[2], 0, 4);
    
    //	rs232_printf("\nbind = %d\n",
    //			bind(ulSocket2, (sockaddr*) &socketAddr, sizeof(sockaddr)));
    
    	rs232_printf("Bind connection == %d\n",
    			bind(ulSocket2, (sockaddr*) &tSocketAddr, sizeof(sockaddr)));
    
    	sockLen = sizeof(sockaddr);
    	rs232_printf("sockLen = %d\n", sockLen);
    
    	//call recvfrom
    	ReturnValue = recvfrom(ulSocket2, pucCC3000_Rx_Buffer,
    			CC3000_RX_BUFFER_SIZE, 0, &tSocketAddr, &tRxPacketLength);
    //	ReturnValue = recvfrom(ulSocket2, pucCC3000_Rx_Buffer,
    //			CC3000_RX_BUFFER_SIZE, 0, (sockaddr*) &from, &tRxPacketLength);
    	rs232_printf("ReturnValue = %d\nnow printing packet\n", ReturnValue);
    	//print buffer
    	DispatcherUartSendPacket(pucCC3000_Rx_Buffer, ReturnValue);
    	rs232_printf("\n\nBuffer = %d\nnow printing packet\n",
    			&pucCC3000_Rx_Buffer);
    
    	while (1)
    	{
    		uart_putstring("Hello\n");
    //		if (uart_have_cmd)
    //		{
    //			/* Delay here for a bit while all the chars are being read */
    //			for (ulCounter = 0; ulCounter < 100; ulCounter++)
    //				SysCtlDelay(10000);
    //			/* Process the data */
    ////			DemoHandleUartCommand(received_char);
    //			DemoHandleUartCommand(g_ucRxBuffer);
    //			/*Reset the Rx Buffer pointer and counter*/
    //			memset(g_ucRxBuffer, 0, USART_IF_BUFFER);
    //			g_usRxBufferCounter = 0;
    ////			uart_have_cmd = 0;
    //		}
    		__delay_cycles(6000000);
    	}
    }
    

    Regards,

    F.S.

  • Hi,

    I am not sure about the flags checked in DemoInitDriver. But you would have to check for these flags after calling wlan_connect API.

    In the Basic Wifi Application there is a check as shown below:

    while ((ulCC3000DHCP == 0) || (ulCC3000Connected == 0))
    {		
        __delay_cycles(1000);
    }

    Regards,
    Raghavendra

  • Hello Raghavendra,

    again, thank you very much for your time!! If I may, I inserted the codeline you wrote. But, I had to create the ulCC3000DHCP global variable by myself. I was wondering that this flag was not implemented. I inserted it, the code passes it and still stuck after calling recvfrom. I can bind, I can ping, even when the device is polling a ping is possible.


    I have no Idea left. Hmm, can it be, that the driver I use, 1.7.2.2, has errors in receiving UDP pakets?

    Regards,

    F.S.

  • Hi F.S,

    I would suggest you to run the Basic Wifi Application from the SDK as it is. It has all the flags and checks implemented.
    You can then build rest of the logic around it.

    Regards,
    Raghavendra