0

CC3000 connection problems again...
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

CC3000 connection problems again...

by ravik on Sun Aug 10, 2014 7:42 am

Hello,
I had my CC3000 shield working fine a few days ago. I am using a separate 9V, 1A power supply. I had upgraded the firmware to version 1.28 and the test programs were working fine on my home network.
Now, I am not even able to ping google using the buildtest sketch. CC3000 connects to my network, gets the DHCP, prints "connecting to google" and then just hangs! This is frustrating because a few days back this worked smoothly. I have tested this a few dozen times and the same thing happens every time...
Any help appreciated...

Ravi
ravik
 
Posts: 21
Joined: Fri Jul 25, 2014 11:31 pm

Re: CC3000 connection problems again...

by franklin97355 on Sun Aug 10, 2014 2:25 pm

Are you using the IP or Domain name to connect? Check to make sure your router gave you a correct DNS address.

franklin97355
 
Posts: 20979
Joined: Mon Apr 21, 2008 2:33 pm
Location: Lacomb, OR.

Re: CC3000 connection problems again...

by ravik on Sun Aug 10, 2014 10:30 pm

I am using the domain name to connect. How do I check if the router gives me a correct DNS address?
Also, my point is that the same code worked a week ago...

Ravi
ravik
 
Posts: 21
Joined: Fri Jul 25, 2014 11:31 pm

Re: CC3000 connection problems again...

by franklin97355 on Sun Aug 10, 2014 10:42 pm

Running buildtest.ino should give you that information

franklin97355
 
Posts: 20979
Joined: Mon Apr 21, 2008 2:33 pm
Location: Lacomb, OR.

Re: CC3000 connection problems again...

by ravik on Mon Aug 11, 2014 9:24 am

I am still not sure what you mean by the DNS address - here's the output when I run buildtest.ino:

...
Deleting old connection profiles

Attempting to connect to Ravi-WIFI
Connected!
Request DHCP

IP Addr: 192.168.2.4
Netmask: 255.255.255.0
Gateway: 192.168.2.1
DHCPsrv: 192.168.2.1
DNSserv: 10.10.10.2
www.google.co.in ->

And that's where it stays forever...

Ravi
ravik
 
Posts: 21
Joined: Fri Jul 25, 2014 11:31 pm

Re: CC3000 connection problems again...

by ravik on Mon Aug 11, 2014 9:39 am

This is with reference to the output of buildtest.ino that I showed in my previous post.
I can connect to 192.168.2.1 in a browser - that is the control panel of my router.
But I get nothing when I try to connect to 10.10.10.2 in a browser - is that what you were asking?
ravik
 
Posts: 21
Joined: Fri Jul 25, 2014 11:31 pm

Re: CC3000 connection problems again...

by adafruit_support_mike on Tue Aug 12, 2014 4:35 pm

Your DNS address is in the 10.x.x.x range, which is specified to be a 'private' block.. not visible on the internet and not relayed by routers. To work at all, that address would have to point to a machine in your local network that knows how to do DNS queries. That seems a bit unlikely since your gateway address is in the 192.168.x.x block.

The program is hanging as it waits for the DNS server to respond to its query for the human readable machine name 'www.google.co.in'.

Double check your network settings and see if you can find where that 10.x.x.x address is coming from.

adafruit_support_mike
 
Posts: 58448
Joined: Thu Feb 11, 2010 2:51 pm

Re: CC3000 connection problems again...

by ravik on Wed Aug 13, 2014 6:57 am

Aha! I think I know what happened.
After trying out the CC3000 at home where it worked fine, I tried it out in my workplace where I am on a LAN behind a firewall (see my posts on July 28). I could not connect to the internet because of the firewall - which has address 10.10.x.x.
So after that, when I got the CC3000 back home (and reloaded the buildtest.ino) somehow the CC3000 still remembers the firewall address - which I find strange...
So will re-installing the firmware help? Or is there some other solution?

Ravi
ravik
 
Posts: 21
Joined: Fri Jul 25, 2014 11:31 pm

Re: CC3000 connection problems again...

by adafruit_support_mike on Sat Aug 16, 2014 12:52 am

We've seen some problems with CC3000s holding DNS addresses they shouldn't, but usually a call to reboot(), deleteProfiles(), and reboot() again clears things out.

adafruit_support_mike
 
Posts: 58448
Joined: Thu Feb 11, 2010 2:51 pm

Re: CC3000 connection problems again...

by ravik on Sat Aug 16, 2014 2:02 am

So, do I just say reboot() or deleteProfiles() at the beginning of the setup() function?
If not, some example code will help...
Thanks!

Ravi
ravik
 
Posts: 21
Joined: Fri Jul 25, 2014 11:31 pm

Re: CC3000 connection problems again...

by adafruit_support_mike on Mon Aug 18, 2014 7:49 pm

You should only need to do it as a one-time thing.

Create a new sketch, put that sequence of commands in the setup() function, then blink the LED or something in loop() so you know when the reconfiguration is done. They try it again with your regular sketch.

adafruit_support_mike
 
Posts: 58448
Joined: Thu Feb 11, 2010 2:51 pm

Re: CC3000 connection problems again...

by ravik on Tue Aug 19, 2014 10:40 am

I tried what you said and it did not work - I still see the 10.x.x.x address:
Here is what I did to delete the old profiles:

#include <Adafruit_CC3000.h>
#include <ccspi.h>
#include <SPI.h>
#include <string.h>
#include "utility/debug.h"

#define ADAFRUIT_CC3000_IRQ 3
#define ADAFRUIT_CC3000_VBAT 5
#define ADAFRUIT_CC3000_CS 10
Adafruit_CC3000 cc3000 = Adafruit_CC3000(ADAFRUIT_CC3000_CS, ADAFRUIT_CC3000_IRQ, ADAFRUIT_CC3000_VBAT, SPI_CLOCK_DIVIDER);

void setup() {
cc3000.reboot();
cc3000.deleteProfiles();
cc3000.reboot();
Serial.begin(9600);
}

void loop () {
delay(1000);
Serial.println("Done...");
delay(1000);
}

And after this ran, I tried buildtest.ino again and here is the output:

Request DHCP

IP Addr: 192.168.2.2
Netmask: 255.255.255.0
Gateway: 192.168.2.1
DHCPsrv: 192.168.2.1
DNSserv: 10.10.10.2

So what do I do now?

Ravi
ravik
 
Posts: 21
Joined: Fri Jul 25, 2014 11:31 pm

Re: CC3000 connection problems again...

by franklin97355 on Tue Aug 19, 2014 11:02 pm

ravik Please use the code button "</>" in the button bar when posting code to the forums.
Attachments
Code Button.jpg
Code Button.jpg (4.49 KiB) Viewed 2487 times

franklin97355
 
Posts: 20979
Joined: Mon Apr 21, 2008 2:33 pm
Location: Lacomb, OR.

Re: CC3000 connection problems again...

by tdicola on Thu Aug 21, 2014 1:39 am

Let's try setting a static IP address and DNS server to override anything the CC3000 might have saved in its non-volatile memory. Make sure you have the latest CC3000 library code from github installed, then open the buildtest sketch and scroll down to this commented out section in the setup() function:

Code: Select all | TOGGLE FULL SIZE
/* Optional: Set a static IP address instead of using DHCP.
     Note that the setStaticIPAddress function will save its state
     in the CC3000's internal non-volatile memory and the details
     will be used the next time the CC3000 connects to a network.
     This means you only need to call the function once and the
     CC3000 will remember the connection details.  To switch back
     to using DHCP, call the setDHCP() function (again only needs
     to be called once).
  */
  /*
  uint32_t ipAddress = cc3000.IP2U32(192, 168, 1, 19);
  uint32_t netMask = cc3000.IP2U32(255, 255, 255, 0);
  uint32_t defaultGateway = cc3000.IP2U32(192, 168, 1, 1);
  uint32_t dns = cc3000.IP2U32(8, 8, 4, 4);
  if (!cc3000.setStaticIPAddress(ipAddress, netMask, defaultGateway, dns)) {
    Serial.println(F("Failed to set static IP!"));
    while(1);
  }
*/


Uncomment the code and fill in the details for IP address, net mask, and default gateway for your home network. It looks like from the previous sketch output you want something like:

IP address = 192.168.2.x (where x is something unused and outside your router's DHCP range, perhaps try 100?)
Netmask = 255.255.255.0
Default gateway = 192.168.2.1

For the DNS server I would leave in the 8.8.4.4 value--it's a public DNS server Google provides so it's a known working server. If you know you have a DNS server to use you can put its IP there instead of 8.8.4.4.

Make sure the code to set those values and most importantly call the setStaticIPAddress is uncommented, then load the sketch on your hardware and see what the output shows. If it works you can actually comment it out again because the CC3000 will remember the static IP address configuration in its non-volatile storage.

If you want to go back to using DHCP at some point, you can uncomment the block of code below the static IP setup which calls the setDHCP function.

Give using a static IP address a shot and let me know if you still see issues. Thanks!

tdicola
 
Posts: 1074
Joined: Thu Oct 17, 2013 9:11 pm

Re: CC3000 connection problems again...

by ravik on Fri Aug 22, 2014 1:04 am

No, that did not work for me...
I paste the entire code below for my buildtest.ino after setting a static IP address. Now my CC3000 appears to be truly bricked.
Here is the output first:
-------------------------------------------------
Hello, CC3000!

RX Buffer : 131 bytes
TX Buffer : 131 bytes
Free RAM: 1248

Initialising the CC3000 ...
-------------------------------------------------

And it stays there forever...

And here is the code:

Code: Select all | TOGGLE FULL SIZE
/***************************************************
  This is an example for the Adafruit CC3000 Wifi Breakout & Shield

  Designed specifically to work with the Adafruit WiFi products:
  ----> https://www.adafruit.com/products/1469

  Adafruit invests time and resources providing this open source code,
  please support Adafruit and open-source hardware by purchasing
  products from Adafruit!

  Written by Kevin Townsend & Limor Fried for Adafruit Industries. 
  BSD license, all text above must be included in any redistribution
 ****************************************************/

/*

This example does a full test of core connectivity:
* Initialization
* SSID Scan
* AP connection
* DHCP printout
* DNS lookup
* Ping
* Disconnect
It's a good idea to run this sketch when first setting up the
module.

*/

#include <Adafruit_CC3000.h>
#include <ccspi.h>
#include <SPI.h>
#include <string.h>
#include "utility/debug.h"

// These are the interrupt and control pins
#define ADAFRUIT_CC3000_IRQ   3  // MUST be an interrupt pin!
// These can be any two pins
#define ADAFRUIT_CC3000_VBAT  5
#define ADAFRUIT_CC3000_CS    10
// Use hardware SPI for the remaining pins
// On an UNO, SCK = 13, MISO = 12, and MOSI = 11
Adafruit_CC3000 cc3000 = Adafruit_CC3000(ADAFRUIT_CC3000_CS, ADAFRUIT_CC3000_IRQ, ADAFRUIT_CC3000_VBAT,
                                         SPI_CLOCK_DIVIDER); // you can change this clock speed but DI

#define WLAN_SSID       "Ravi-WIFI"        // cannot be longer than 32 characters!
#define WLAN_PASS       "**********"        // don't want to share my password with everybody!
// Security can be WLAN_SEC_UNSEC, WLAN_SEC_WEP, WLAN_SEC_WPA or WLAN_SEC_WPA2
#define WLAN_SECURITY   WLAN_SEC_WPA2



/**************************************************************************/
/*!
    @brief  Sets up the HW and the CC3000 module (called automatically
            on startup)
*/
/**************************************************************************/
void setup(void)
{
  Serial.begin(115200);
  Serial.println(F("Hello, CC3000!\n"));

  displayDriverMode();
  Serial.print("Free RAM: "); Serial.println(getFreeRam(), DEC);
 
  /* Initialise the module */
  Serial.println(F("\nInitialising the CC3000 ..."));
  if (!cc3000.begin())
  {
    Serial.println(F("Unable to initialise the CC3000! Check your wiring?"));
    while(1);
  }

  /* Optional: Update the Mac Address to a known value */
/*
  uint8_t macAddress[6] = { 0x08, 0x00, 0x28, 0x01, 0x79, 0xB7 };
   if (!cc3000.setMacAddress(macAddress))
   {
     Serial.println(F("Failed trying to update the MAC address"));
     while(1);
   }
*/
 
  uint16_t firmware = checkFirmwareVersion();
  if (firmware < 0x113) {
    Serial.println(F("Wrong firmware version!"));
    for(;;);
  }
 
  displayMACAddress();
 
  /* Optional: Get the SSID list (not available in 'tiny' mode) */
#ifndef CC3000_TINY_DRIVER
  listSSIDResults();
#endif
 
  /* Delete any old connection data on the module */
  Serial.println(F("\nDeleting old connection profiles"));
  if (!cc3000.deleteProfiles()) {
    Serial.println(F("Failed!"));
    while(1);
  }

  /* Optional: Set a static IP address instead of using DHCP.
     Note that the setStaticIPAddress function will save its state
     in the CC3000's internal non-volatile memory and the details
     will be used the next time the CC3000 connects to a network.
     This means you only need to call the function once and the
     CC3000 will remember the connection details.  To switch back
     to using DHCP, call the setDHCP() function (again only needs
     to be called once).
  */
 
  uint32_t ipAddress = cc3000.IP2U32(192, 168, 2, 100);
  uint32_t netMask = cc3000.IP2U32(255, 255, 255, 0);
  uint32_t defaultGateway = cc3000.IP2U32(192, 168, 2, 1);
  uint32_t dns = cc3000.IP2U32(8, 8, 4, 4);
  if (!cc3000.setStaticIPAddress(ipAddress, netMask, defaultGateway, dns)) {
    Serial.println(F("Failed to set static IP!"));
    while(1);
  }
 
  /* Optional: Revert back from static IP addres to use DHCP.
     See note for setStaticIPAddress above, this only needs to be
     called once and will be remembered afterwards by the CC3000.
  */
  /*
  if (!cc3000.setDHCP()) {
    Serial.println(F("Failed to set DHCP!"));
    while(1);
  }
  */

  /* Attempt to connect to an access point */
  char *ssid = WLAN_SSID;             /* Max 32 chars */
  Serial.print(F("\nAttempting to connect to ")); Serial.println(ssid);
 
  /* NOTE: Secure connections are not available in 'Tiny' mode!
     By default connectToAP will retry indefinitely, however you can pass an
     optional maximum number of retries (greater than zero) as the fourth parameter.
  */
  if (!cc3000.connectToAP(WLAN_SSID, WLAN_PASS, WLAN_SECURITY)) {
    Serial.println(F("Failed!"));
    while(1);
  }
   
  Serial.println(F("Connected!"));
 
  /* Wait for DHCP to complete */
  Serial.println(F("Request DHCP"));
  while (!cc3000.checkDHCP())
  {
    delay(100); // ToDo: Insert a DHCP timeout!
  } 

  /* Display the IP address DNS, Gateway, etc. */ 
  while (! displayConnectionDetails()) {
    delay(1000);
  }
 
#ifndef CC3000_TINY_DRIVER
  /* Try looking up www.google.co.in */
  uint32_t ip = 0;
  Serial.print(F("www.google.co.in -> "));
  while  (ip  ==  0)  {
    if  (!  cc3000.getHostByName("www.google.co.in", &ip))  {
      Serial.println(F("Couldn't resolve!"));
    }
    delay(500);
  } 
  cc3000.printIPdotsRev(ip);
 
  /* Do a quick ping test on google.co.in */ 
  Serial.print(F("\n\rPinging ")); cc3000.printIPdotsRev(ip); Serial.print("..."); 
  uint8_t replies = cc3000.ping(ip, 5);
  Serial.print(replies); Serial.println(F(" replies"));
  if (replies)
    Serial.println(F("Ping successful!"));
#endif

  /* You need to make sure to clean up after yourself or the CC3000 can freak out */
  /* the next time you try to connect ... */
  Serial.println(F("\n\nClosing the connection"));
  cc3000.disconnect();
}

void loop(void)
{
  delay(1000);
}

/**************************************************************************/
/*!
    @brief  Displays the driver mode (tiny of normal), and the buffer
            size if tiny mode is not being used

    @note   The buffer size and driver mode are defined in cc3000_common.h
*/
/**************************************************************************/
void displayDriverMode(void)
{
  #ifdef CC3000_TINY_DRIVER
    Serial.println(F("CC3000 is configure in 'Tiny' mode"));
  #else
    Serial.print(F("RX Buffer : "));
    Serial.print(CC3000_RX_BUFFER_SIZE);
    Serial.println(F(" bytes"));
    Serial.print(F("TX Buffer : "));
    Serial.print(CC3000_TX_BUFFER_SIZE);
    Serial.println(F(" bytes"));
  #endif
}

/**************************************************************************/
/*!
    @brief  Tries to read the CC3000's internal firmware patch ID
*/
/**************************************************************************/
uint16_t checkFirmwareVersion(void)
{
  uint8_t major, minor;
  uint16_t version;
 
#ifndef CC3000_TINY_DRIVER 
  if(!cc3000.getFirmwareVersion(&major, &minor))
  {
    Serial.println(F("Unable to retrieve the firmware version!\r\n"));
    version = 0;
  }
  else
  {
    Serial.print(F("Firmware V. : "));
    Serial.print(major); Serial.print(F(".")); Serial.println(minor);
    version = major; version <<= 8; version |= minor;
  }
#endif
  return version;
}

/**************************************************************************/
/*!
    @brief  Tries to read the 6-byte MAC address of the CC3000 module
*/
/**************************************************************************/
void displayMACAddress(void)
{
  uint8_t macAddress[6];
 
  if(!cc3000.getMacAddress(macAddress))
  {
    Serial.println(F("Unable to retrieve MAC Address!\r\n"));
  }
  else
  {
    Serial.print(F("MAC Address : "));
    cc3000.printHex((byte*)&macAddress, 6);
  }
}


/**************************************************************************/
/*!
    @brief  Tries to read the IP address and other connection details
*/
/**************************************************************************/
bool displayConnectionDetails(void)
{
  uint32_t ipAddress, netmask, gateway, dhcpserv, dnsserv;
 
  if(!cc3000.getIPAddress(&ipAddress, &netmask, &gateway, &dhcpserv, &dnsserv))
  {
    Serial.println(F("Unable to retrieve the IP Address!\r\n"));
    return false;
  }
  else
  {
    Serial.print(F("\nIP Addr: ")); cc3000.printIPdotsRev(ipAddress);
    Serial.print(F("\nNetmask: ")); cc3000.printIPdotsRev(netmask);
    Serial.print(F("\nGateway: ")); cc3000.printIPdotsRev(gateway);
    Serial.print(F("\nDHCPsrv: ")); cc3000.printIPdotsRev(dhcpserv);
    Serial.print(F("\nDNSserv: ")); cc3000.printIPdotsRev(dnsserv);
    Serial.println();
    return true;
  }
}

/**************************************************************************/
/*!
    @brief  Begins an SSID scan and prints out all the visible networks
*/
/**************************************************************************/

void listSSIDResults(void)
{
  uint8_t valid, rssi, sec, index;
  char ssidname[33];

  index = cc3000.startSSIDscan();

  Serial.print(F("Networks found: ")); Serial.println(index);
  Serial.println(F("================================================"));

  while (index) {
    index--;

    valid = cc3000.getNextSSID(&rssi, &sec, ssidname);
   
    Serial.print(F("SSID Name    : ")); Serial.print(ssidname);
    Serial.println();
    Serial.print(F("RSSI         : "));
    Serial.println(rssi);
    Serial.print(F("Security Mode: "));
    Serial.println(sec);
    Serial.println();
  }
  Serial.println(F("================================================"));

  cc3000.stopSSIDscan();
}


Since this appears to be a problem with Adafruit's product, will Adafruit consider replacing my CC3000 shield?

Ravi
ravik
 
Posts: 21
Joined: Fri Jul 25, 2014 11:31 pm

Please be positive and constructive with your questions and comments.