SmartConfigCreate and SmartConfigReconnect
These two SmartConfig sketches should be used together to demonstrate how the SmartConfig app can be used on your smartphone to pass connection details to your CC3000.SmartConfigCreate
This sketch will initialise the CC3000, erasing any previous connection details stored on the device. It will then enter SmartConfig mode with a 60 second timeout where it waits for configuration data to arrive from the SmartPhone.If a connection was successfully established, the connection details will be stored in the non-volatile memory of the CC3000, and the module will be configured to automatically reconnect to this network on startup (meaning you don't need to run the SmartConfig app unless your AP details change or you erase the stored connection details on the module).
There's no need to edit the sketch to add your SSID and password - the SmartConfig app does that for you!
SmartConfigReconnect
This sketch shows how to use the CC3000 in 'reconnect' mode, and avoid erasing all stored connection profiles, which is unfortunately necessary with other sketches where manual config data is provided.- Initializates the CC3000 with a special SmartConfig flag so it doesn't erase the profile data
- Access Point connection (based on saved AP details)
- DHCP address assignment
- Disconnect
Using the SmartConfigCreate Sketch
Step One: Install the SmartConfig App
Before you can use SmartConfig to provide your AP connection details, you need to install the SmartConfig app:- For iOS devices simply search for the TI WiFi SmartConfig app from the app store.
- For Android devices, you can download the app directly from TI's CC3000 Wiki
Step Two: Configure the SmartConfig App on your Phone
Once you've installed the SmartConfig app, you need to connect to the AP that the CC3000 will be using (HOMENETWORK in the images below), and then load the app.You should see a screen similar to the following, with the AP's SSID, Gateway IP Address and Device Name fields already populated:
Step Three: Open and Run 'SmartConfigCreate'
- In the File > Examples > Adafruit_CC3000 menu select the SmartConfigCreate sketch.
- Run the sketch and open the Serial Monitor via Tools > Serial Monitor.
- You should see something similar to the following text:
Hello, CC3000! RX Buffer : 131 bytes TX Buffer : 131 bytes Free RAM: 595 Initialising the CC3000 ... Firmware V. : 1.24 MAC Address : 0x08 0x00 0x28 0x01 0xA8 0x1F Waiting for a SmartConfig connection (~60s) ...
Step Four: Start the SmartConfig app on your Phone
Before the Android sketch times out, click to 'Start' button in your TI app, and watch the serial monitor window of your sketch. After about 30 seconds you should see something similar to the following:Got smart config data Saved connection details and connected to AP! Request DHCP IP Addr: 192.168.0.103 Netmask: 255.255.255.0 Gateway: 192.168.0.1 DHCPsrv: 192.168.0.1 DNSserv: 192.168.0.1 To use these connection details be sure to use '.begin(false, true)' with your Adafruit_CC3000 code instead of the default '.begin()' values! Closing the connection
Step Five: Stop the SmartConfig App on the Phone
If everything worked out and you successfully connected to your AP, the connection details were also stored in non-volatile memory on the CC3000 module. You can now use the SmartConfigReconnect sketch to test the connection details, specifically paying attention to the extra flags in the Adafruit_CC3000.begin() function compared to other sketches..- Be sure to click 'Stat' in the SmartPhone app as soon as the 'Waiting for SmartConfig connection (~60s) ...' message pops up. The SmartConfig device will timeout after 60 seconds, so you may need to run the sketch again and be a bit quicker with your fingers.
- Make sure that the iPad or SmartPhone is connected to the same AP that you want the CC3000 to connect to!
- Check your password in case there is a typo
Using the SmartConfigReconnect Sketch
The SmartConfigReconnect sketch shows how to use (and retain) the connection details that were written to the device in the example above.The key to using and maintaining the connection details is to pass an optional flag to the Adafruit_CC3000 classes .begin() function to tell the driver NOT to delete existing connections, and to stay in auto connect mode:
/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */ /* !!! Note the additional arguments in .begin that tell the !!! */ /* !!! app NOT to deleted previously stored connection details !!! */ /* !!! and reconnected using the connection details in memory! !!! */ /* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */ if (!cc3000.begin(false, true)) { Serial.println(F("Unable to re-connect!? Did you run the SmartConfigCreate")); Serial.println(F("sketch to store your connection details?")); while(1); }
If you were able to successfully connect using the SmartConfigCreate sketch, SmartConfigReconnect should give you something similar to the following output:
Hello, CC3000! Trying to reconnect using SmartConfig values ... Reconnected! Requesting DHCP IP Addr: 192.168.0.103 Netmask: 255.255.255.0 Gateway: 192.168.0.1 DHCPsrv: 192.168.0.1 DNSserv: 192.168.0.1 Closing the connection