I keep getting an "expected unqualified-id before 'while' " error at the line I labeled in the code.
I cant figure out why..
Serial.print(F("\nDHCPsrv: ")); cc3000.printIPdotsRev(dhcpserv);
Serial.print(F("\nDNSserv: ")); cc3000.printIPdotsRev(dnsserv);
Serial.println();
return true;
}
}
while (WiFi.begin) { // Try to get an IP (DHCP). For a custom IP config, change to Ethernet.begin(mac, ip, myDns)
Serial.println("Failed to configure Ethernet");
delay(5000);
}
Serial.print("IP address:\t");
// Serial.println(Ethernet.localIP());
while (!createBucket()) {}; // -ERROR HERE- -expected unqualified-id before 'while'-
next_serial_time = millis() + send_readings_every * 3; // wait a little longer before sending serial data the first time
next_cloud_update = millis() + cloud_update_interval;
}
I believe the error is here:
while (WiFi.begin) {
That is a function, is it not?
SurferTim:
I believe the error is here:
while (WiFi.begin) {
That is a function, is it not?
Correct. I take it this is not correct to initiate the wifi connection
Post the whole code. My guess is that you've got your braces mixed up and the while loop it is complaining about is outside of any function.
Delta_G:
Post the whole code. My guess is that you've got your braces mixed up and the while loop it is complaining about is outside of any function.
#include <Wire.h> // enable I2C.
#include <SPI.h> // ethernet shield libraries
#include <WiFi.h>
#include <Adafruit_CC3000.h>
#include <ccspi.h>
#include <SPI.h>
#include <string.h>
#include "utility/debug.h"
#define NUM_CIRCUITS 2 // <-- CHANGE THIS set how many I2C circuits are attached to the Tentacle
#define IDLE_TIMEOUT_MS 3000 // Amount of time to wait (in milliseconds) with no data
// received before closing the connection. If you know the server
// you're accessing is quick to respond, you can reduce this value
// What page to grab!
#define WEBSITE "insecure-groker.initialstate.com"
#define WEBPAGE "https://groker.initialstate.com/api/events?accessKey=vLOwqDrMjLJXUrKXMC6pWLhWgUBM40gO&bucketKey=UPU9YVDHL6DL"
// NETWORK CONFIGURATION
WiFiClient client;
uint32_t ip;
void setup(void)
{
Serial.begin(115200);
Serial.println(F("Hello, CC3000!\n"));
// Serial.print("Free RAM: "); Serial.println(getFreeRam(), DEC);
/* Initialise the module */
Serial.println(F("\nInitializing..."));
if (!cc3000.begin())
{
Serial.println(F("Couldn't begin()! Check your wiring?"));
while(1);
}
// Optional SSID scan
// listSSIDResults();
Serial.print(F("\nAttempting to connect to ")); Serial.println(WLAN_SSID);
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);
}
ip = 0;
// Try looking up the website's IP address
Serial.print(WEBSITE); Serial.print(F(" -> "));
while (ip == 0) {
if (! cc3000.getHostByName(WEBSITE, &ip)) {
Serial.println(F("Couldn't resolve!"));
}
delay(500);
}
cc3000.printIPdotsRev(ip);
// Optional: Do a ping test on the website
/*
Serial.print(F("\n\rPinging ")); cc3000.printIPdotsRev(ip); Serial.print("...");
replies = cc3000.ping(ip, 5);
Serial.print(replies); Serial.println(F(" replies"));
*/
/* Try connecting to the website.
Note: HTTP/1.1 protocol is used to keep the server from closing the connection before all data is read.
*/
Adafruit_CC3000_Client www = cc3000.connectTCP(ip, 80);
if (www.connected()) {
www.fastrprint(F("GET "));
www.fastrprint(WEBPAGE);
www.fastrprint(F(" HTTP/1.1\r\n"));
www.fastrprint(F("Host: ")); www.fastrprint(WEBSITE); www.fastrprint(F("\r\n"));
www.fastrprint(F("\r\n"));
www.println();
} else {
Serial.println(F("Connection failed"));
return;
}
Serial.println(F("-------------------------------------"));
/* Read data until either the connection is closed, or the idle timeout is reached. */
unsigned long lastRead = millis();
while (www.connected() && (millis() - lastRead < IDLE_TIMEOUT_MS)) {
while (www.available()) {
char c = www.read();
Serial.print(c);
lastRead = millis();
}
}
www.close();
Serial.println(F("-------------------------------------"));
/* You need to make sure to clean up after yourself or the CC3000 can freak out */
/* the next time your try to connect ... */
Serial.println(F("\n\nDisconnecting"));
cc3000.disconnect();
}
void loop(void)
{
delay(1000);
}
/**************************************************************************/
/*!
@brief Begins an SSID scan and prints out all the visible networks
*/
/**************************************************************************/
void listSSIDResults(void)
{
uint32_t index;
uint8_t valid, rssi, sec;
char ssidname[33];
if (!cc3000.startSSIDscan(&index)) {
Serial.println(F("SSID scan failed!"));
return;
}
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();
}
/**************************************************************************/
/*!
@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;
}
}
while (WiFi.begin()) { // Try to get an IP (DHCP). For a custom IP config, change to Ethernet.begin(mac, ip, myDns)
Serial.println("Failed to configure Ethernet");
delay(5000);
}
Serial.print("IP address:\t");
// Serial.println(Ethernet.localIP());
while (!createBucket()) {}; // create a bucket, if it doesn't exist yet
next_serial_time = millis() + send_readings_every * 3; // wait a little longer before sending serial data the first time
next_cloud_update = millis() + cloud_update_interval;
}
void loop() {
updateSensors(); // read / write to the sensors. returns fast, does not wait for the data to arrive
updateSerial(); // write sensor data to the serial port
updateCloud(); // send the sensor data to the cloud. returns fast, except when a cloud update is due.
// arduino stuff here
}
Yeah, those lines aren't in any function. They have to be inside one of your functions.
Delta_G:
Yeah, those lines aren't in any function. They have to be inside one of your functions.
thank you for the point to the right direction!
ageno125:
thank you for the point to the right direction!
Four of your lines..
#include <SPI.h> // ethernet shield libraries
#include <SPI.h>
void loop(void)
void loop() {
Gabriel_swe:
#include <SPI.h> // ethernet shield libraries
#include <SPI.h>
thank you, I deleted the duplication.
Gabriel_swe:
void loop(void)
void loop() {
these lines came from the adafruit example. ?