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.

Modification Basic wifi app

Hello everyone:
I'm changing the wifi app Basic application, a small piece of code I do not understand

In the function "void CC3000_UsynchCallback (long lEventType, char * data, unsigned char length)" has the following code.

if (== lEventType HCI_EVNT_WLAN_UNSOL_DHCP)
{
if (* (data + NETAPP_IPCONFIG_MAC_OFFSET) == 0)
{
sprintf ((char *) pucCC3000_Rx_Buffer, "... IP:% d% d% d% d \ f \ r", data [3], data [2], data [1], data [0]);

ulCC3000DHCP = 1;


turnLedOn (8);
}

 In the section that says if (* (data + NETAPP_IPCONFIG_MAC_OFFSET), then you have already received data from the CC3000, but in what moment did this happen?
When you see an event unsolicited DHCP also the IP data is sent?

only one call is made to hci_unsolicited_event (), is this function receives data from any unsolicited event?
What would be the unsolicited events that send data?
In the wiki are not explained .What part of the wiki is detailed this doubt?

Sorry for the kind of writing, my English is not very good.
Greetings Agustín I.
Thank you very much.

  • Hi Agustin,

    This event will come up only if the DHCP_DONE event is returned by the Controller (whenever the AP assigns IP address to CC3000). And 'data + NETAPP_IPCONFIG_MAC_OFFSET' is the bit which indicates the status bit. If this is '0' then the address is valid.

    Thanks & Regards,

    Raghavendra 

  • Hi Raghavendra

    Thank you very much for your help.

    A query more, sorry

    I have the following code, a app wifi basic application that connects to the wifi network explicitly.
    After exiting the function wlan_connect (xxxxx) intro in while (1) and then the MCU is reset. What could be the cause?

    The CC3000 device connected to the wifi network. I can see from the list of devices connected in the router

           
            WDTCTL = WDTPW | WDTHOLD;    // Stop watchdog timer
    
    
            unsigned char key[]="3.141592653589";
    
            ulCC3000DHCP = 0;
            ulCC3000DHCP_configured = 0;
            ulCC3000Connected=0;
            long garbage;
    
           // Init GPIO's
        	pio_init();
    
        	//Init Spi
        	init_spi();
    
    
    
        	DispatcherUARTConfigure();
    
        	// WLAN On API Implementation
        	wlan_init( CC3000_UsynchCallback, sendWLFWPatch, sendDriverPatch, sendBootLoaderPatch, ReadWlanInterruptPin, WlanInterruptEnable, WlanInterruptDisable, WriteWlanPin);
    
        	// Trigger a WLAN device
        	wlan_start(0);
    
        	__delay_cycles(100000);
    
        	garbage=wlan_set_event_mask(0);
    
        	
    
    
        	// Mask out all non-required events from CC3000
        	garbage=wlan_set_event_mask(HCI_EVNT_WLAN_KEEPALIVE|HCI_EVNT_WLAN_UNSOL_INIT|HCI_EVNT_WLAN_ASYNC_PING_REPORT|HCI_EVNT_WLAN_ASYNC_SIMPLE_CONFIG_DONE);
    
        	
        	garbage=wlan_ioctl_set_connection_policy(0,0,0);
    
        	
        	wlan_stop();
    
        	__delay_cycles(10000);
    
        	wlan_start(0);
    
        	__delay_cycles(1000);
    
        	garbage=wlan_connect(WLAN_SEC_WPA2,"casa",4,NULL,key,14);
    
        	while(1) {}
    

    Thanks & Regards
    Agustin Isasmendi

  • Hi Agustin,

    Is this an empty while loop? Looks like this is running an infinite loop without a check for any condition.

    I think you should replace the while(1) with below:

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

    Thanks & Regards,

    Raghavendra