9 years, 1 month ago.

How do I set a static ip in cc3000 wifi breakout?

Hi The method [ void cc3000::init(const char *ip, const char *mask, const char *gateway) ] can't set a static ip. Can you tell me how to set a static ip. (LPC1768) Thanks!

Question relating to:

cc3000 hostdriver with the mbed socket interface CC3000, socket, TCP, UDP, wifi

1 Answer

9 years, 1 month ago.

You can use following code to set a static IP address.

Warning

For library up to Rev.47, you need to have the wifi.start(0); line present.
I did a pull request to fix this problem.
Once the pull request is accepted, you need to update your library and remove this line.

EDIT The pull request has been accepted - remove wifi.start(0);

    init(); /* board dependent init */

    //Static IP init
    wifi.start(0); // !!!!!!!NEEDS TO BE PRESENT - SHOULD BE IN cc3000::init(const char *ip, const char *mask, const char *gateway) 
    const char IP_ADDR[4] = {192,168,0,111};
    const char IP_MASK[4] = {255,255,255,0};
    const char IP_GWAY[4] = {192,168,0,1};
    wifi.init(IP_ADDR, IP_MASK, IP_GWAY);

    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());
    }
    .....