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.

CC3000 Fail Connecting to AP

Hi, I'ven trying to connect to an AP using CC3000 boosterpack and the MSP-EXP430G2, the problem I'm having is that when I ping the IP of the module (I'm using an static IP) it shows no connection, and after a while it appears to be connected and disconnect again this is the code I'm using, it's based on the basic wifi application.

void main(void){
 WDTCTL = WDTPW + WDTHOLD;

 initDriver();

 wlan_ioctl_set_connection_policy(0x00, 0x00, 0x00);

 ip_config();
	 while(wlan_connect(WLAN_SEC_WPA2,"hardware",0x08,NULL,"danieldorado",0x0C) != 0);

 while(1);
}

void ip_config(void){

 unsigned char IP_Addr[4];
 unsigned char IP_GWAddr[4];
 unsigned char SubnetMask[4];
 unsigned char DNS[4];

 SubnetMask[0] = 255;
 SubnetMask[1] = 255;
 SubnetMask[2] = 255;
 SubnetMask[3] = 0;

 IP_Addr[0] = 10;//IP
 IP_Addr[1] = 0;//IP
 IP_Addr[2] = 0;//IP
 IP_Addr[3] = 2;//IP

 IP_GWAddr[0] = 10;
 IP_GWAddr[1] = 0;
 IP_GWAddr[2] = 0;
 IP_GWAddr[3] = 1;
 
 DNS[0] = 0;
 DNS[1] = 0;
 DNS[2] = 0;
 DNS[3] = 0;
 
 netapp_dhcp((unsigned long *)IP_Addr, (unsigned long *)SubnetMask, (unsigned long *)IP_GWAddr, (unsigned long *)DNS);
}

Also there are days that the module doesn't connect at all. Thanks.

  • Hi Luis,

    I would suggest slight changes in the way you are calling the APIs.

    1) Try not to call the wlan_connect API in a loop. Its a non blocking API. Issue a call to this API and wait for the unsolicited events HCI_EVNT_WLAN_UNSOL_CONNECT and HCI_EVNT_WLAN_UNSOL_DHCP.

    2) Similar to the above point, try not to loop in a while(1). Instead, loop until you get the above Unsolicited events. This is the confirmation of a successful connection. After you receive these events, ping from the remote device.

    Thanks & Regards,
    Raghavendra

  • Hi, I change my code so I only call wlan_connect once and after that I use hci_unsolicited_event_handler to check for the HCI_EVNT_WLAN_UNSOL_CONNECT event, with the CC3000_UsynchCallback, but I get no event, and also the module is not connecting to the AP.

    wlan_connect(WLAN_SEC_WPA2,"hardware",0x08,NULL,"danieldorado",0x0C);
    
    while (ulCC3000Connected == 0){
    	hci_unsolicited_event_handler();
            _delay_cycles(8000);
    }

    The events that I'm masking are HCI_EVNT_WLAN_KEEPALIVE, HCI_EVNT_WLAN_UNSOL_INIT, HCI_EVNT_WLAN_ASYNC_PING_REPORT.




  • I think I found the problem, it seems that the CC3000BOOST I was using has some problem, because I change it and it start working, thanks.