How do I enable debugging using Adafruit CC3000?

I am using the Adafruit_CC3000_Library. I've followed the WebClient.ino example sketch. I'm able to make 300 to 400 HTTP requests, but eventually the connection will hang.

I have looked at the CC3000 source and utilities and found that the Adafruit_CC3000_Library has a &Printer reference in a local variable called CC3KPrinter. I can't figure out how to enable or activate CC3KPrinter, as it is in a code block contingent on CHECK_PRINTER. I thought that #define-ing some variables in my sketch would help:

// None of these flags seem to enable debug within the CC3000 code.
#define _CC3000_DEBUG  1
#define DEBUG_MODE     1

An example code snippet within the CC3000 library that I'm trying to enable is at line 916:

    CC3KPrinter->println(F("Timed out waiting to connect"));
  • Have you tested that the board actually connects to your wifi with more basic code? Did you put any print statement debugging into your code to see where it hangs? You're referring to this Printer section, but I feel that it is probably a red herring without knowing more about why you've picked it out. The other options look like the debugging, but if they aren't producing results then I'd just go through the library and put in print statements to see where you get to. They might not be returning anything if for some reason it doesn't get that far. Make sure your changes are correct. – bladepanthera Aug 12 '15 at 8:47
  • @bladepanthera: I've edited the question to show that the connection works for 300-400 cycles; typically about 40 minutes. I've confirmed via print statements that the hang happens within the CC3000 code. This question pertains solely to enabling the CC3000 debugging code blocks. – JJ Zabkar Aug 12 '15 at 14:59
  • 1
    From what I've been looking at the CC3KPrinter will print to serial when debugging is enabled, which is what you want. I'm not sure why it's not when you seem to have it enabled. I can only think of the obvious things like make sure #include "utility/debug.h isn't commented out and are you using the library you think you're using (I have two versions of Arduino on my laptop). If still no luck, then debug the library yourself with prints to find out exactly where the hang is. Make sure the buffer is clearing properly etc. Sorry can't help more. – bladepanthera Aug 12 '15 at 15:32
  • @bladepanthera: I did re-confirm that I have the utility/debug included. I think "debug the library yourself" is a great idea, but I'm not sure where to start. In my Arduino IDE (v1.6.5) I can only open *.ino sketches. The libraries are written in C++. Are you suggesting I modify the *.cpp library files (i.e., Adafruit_CC3000.cpp)? – JJ Zabkar Aug 12 '15 at 18:21
  • Yup. Literally put print statements in the cpp file. – bladepanthera Aug 17 '15 at 9:08

To enable debugging, you need to

  • uncomment ENABLE_CC3K_PRINTER in Adafruit_CC3000.h
  • If you want to pass in some debug stream other than the default Serial, you should pass a pointer to the object (which should inherit from Print, such as SD or Client) as the last argument to the constructor in your sketch:

    Adafruit_CC3000(uint8_t csPin, uint8_t irqPin, uint8_t vbatPin, uint8_t spispeed = SPI_CLOCK_DIVIDER, Print* cc3kPrinter = CC3K_DEFAULT_PRINTER);
  • In utility/debug.h, change the value of DEBUG_MODE to 1 (or any non-zero value)

I don't know what caused your issue but you shouldn't put this in your code:

#define _CC3000_DEBUG  1

Because most of utility/debug.h is wrapped in the usual:

#ifndef _CC3000_DEBUG

Your #define, depending on where it's placed, could cause most of the file to be skipped by the compiler and result in compilation errors. To be on the safe side, get rid of it and simply include utility/debug.h as needed.


Poor workaround: since I was trying to solve a connection hang, I opted to use a watchdog timer solution, leveraging the lightly documented <avr/wdt.h> library.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.