9 years, 5 months ago.

Connecting without internet parameters?

I can connect by defining the internet parameters with the pins and using wifi.connect() but cannot connect using wifi.connect_secure(SSID,PASSWORD,TYPE) or wifi.connect_to_AP(SSID,PASSWORD,TYPE). They pass the if == false test and print IP: but won't print the ip address and fail the is_connected test. Here is my code:

#include "mbed.h"
#include "cc3000.h"
#include "main.h"
#include "TCPSocketConnection.h"
#include "TCPSocketServer.h"
#include "TextLCD.h"

using namespace mbed_cc3000;
 
cc3000 wifi(PB_3, PB_4, PB_10, SPI(PA_7, PA_6, PA_5)); //not connecting if using this and connect_secure()/connect_to_AP()
//cc3000 wifi(PB_3, PB_4, PB_10, SPI(PA_7, PA_6, PA_5), "SSID", "PASSWORD", WPA2, false); //connecting if using this and connect()
Serial pc(PA_11, PA_12);

int main() 
{
    init(); 
    
    pc.printf("***WIFI***\n\r");
    
    wifi.init();
    if(wifi.connect_secure("NETGEAR33", "luckytomato441", WPA) == false) //NOT WORKING
    {
        pc.printf("No Internet\n\r");
    } 
    else
    {
        pc.printf("IP: %s\n\r", wifi.getIPAddress());
    } 
    /*if(wifi.connect_to_AP("NETGEAR33", "luckytomato441", WPA2) == false) //NOT WORKING
    {
        pc.printf("No Internet\n\r");
    } 
    else
    {
        pc.printf("IP: %s\n\r", wifi.getIPAddress());
    } */
  /*  if (wifi.connect() == -1) //WORKING
    {
        pc.printf("No Internet\n\r");
    } 
    else
    {
        pc.printf("IP: %s\n\r", wifi.getIPAddress());
    } */
    
    if(wifi.is_connected()) 
    {
        pc.printf("connected\n\r");    
    }
    else
    {
        pc.printf("Not Connected\n\r");    
    }
}

Thanks for any help.

Question relating to:

which platform are you using, i mean which mbed board have a look on the following code, it might help you out

#include "mbed.h"
#include "cc3000.h"
#include "main.h"
 
using namespace mbed_cc3000;
 DigitalOut ledr (LED_RED);
DigitalOut ledg (LED_GREEN);
DigitalOut ledb (LED_BLUE);

/* cc3000 module declaration specific for user's board. Check also init() */
#if (MY_BOARD == WIGO)
cc3000 wifi(PTA16, PTA13, PTD0, SPI(PTD2, PTD3, PTC5), "username","password",WPA2, false);
Serial pc(USBTX, USBRX);
#elif (MY_BOARD == WIFI_DIPCORTEX)
cc3000 wifi(p28, p27, p30, SPI(p21, p14, p37), "ssid", "key", WPA2, false);
Serial pc(UART_TX, UART_RX);
#elif (MY_BOARD == MBED_BOARD_EXAMPLE)
cc3000 wifi(p9, p10, p8, SPI(p5, p6, p7), "ssid", "key", WPA2, false);
Serial pc(USBTX, USBRX);
#else
 
#endif
 
/**
 *  \brief Hello World
 *  \param none
 *  \return int
 */
int main() {
    init(); /* board dependent init */
    pc.baud(115200);
 
    printf("cc3000 Hello World demo. \r\n");
    wifi.init();
  

    if (wifi.connect() == -1) {
        printf("Failed to connect. Please verify connection details and try again. \r\n");
    } else {
        printf("IP address: %s \r\n",wifi.getIPAddress());
        printf("\r\ncc3000 connected to the Internet. Demo completed. \r\n");
             printf("gw address: %s \r\n",  wifi.getGateway());
    }
}
posted by zain aftab 03 Nov 2014

I'm using a Nucleo F401 and a adafruit cc3000 shield

posted by Marcus Parker 04 Nov 2014

1 Answer

9 years, 5 months ago.

Try this, Look at c3000.h, find #define CC3000_ETH_COMPAT 1, then change the 1 to a 0, for your connect_secure example only. I have not tried it but it may work.

Dave.

I've done this but it now says cc3000 has not got member "getIPAddress". This disappears if i change it back to 1.

posted by Marcus Parker 03 Nov 2014