I am having trouble getting the IDE 1.0 to compile the code listed below:
/*
* Socket App
*
* A simple socket application example using the WiShield 1.0
*/
#include <WiShield.h>
#define WIRELESS_MODE_INFRA 1
#define WIRELESS_MODE_ADHOC 2
// Wireless configuration parameters ----------------------------------------
unsigned char local_ip[] = {192,168,0,25}; // IP address of WiShield
unsigned char gateway_ip[] = {192,168,0,1}; // router or gateway IP address
unsigned char subnet_mask[] = {255,255,255,0}; // subnet mask for the local network
const prog_char ssid[] PROGMEM = {"ROUTER ID"}; // max 32 bytes
unsigned char security_type = 3; // 0 - open; 1 - WEP; 2 - WPA; 3 - WPA2
// WPA/WPA2 passphrase
const prog_char security_passphrase[] PROGMEM = {"WPA PASS"}; // max 64 characters
// WEP 128-bit keys
// sample HEX keys
prog_uchar wep_keys[] PROGMEM = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, // Key 0
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Key 1
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Key 2
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // Key 3
};
// setup the wireless mode
// infrastructure - connect to AP
// adhoc - connect to another WiFi device
unsigned char wireless_mode = WIRELESS_MODE_INFRA;
unsigned char ssid_len;
unsigned char security_passphrase_len;
char buffer[20];
//---------------------------------------------------------------------------
void setup()
{
Car_Setup();
WiFi.init();
Serial.begin(9600);
}
void loop()
{
WiFi.run();
if (buffer[0] == 'A') { // Control specific pin
//PSOCK_SEND_STR(&s->p, "LED Command: ");
if (buffer[1] >= 3 && buffer[1] <= 12) {
//PSOCK_SEND_STR(&s->p, "Correct, LED");
//PSOCK_SEND(&s->p, &s->inputbuffer[1], 1);
//PSOCK_SEND(&s->p, "=", 1);
if (buffer[2] == 0) {
pinMode(buffer[1], OUTPUT); // define as output
digitalWrite(buffer[1], LOW);
//PSOCK_SEND_STR(&s->p, "OFF");
} else {
pinMode(buffer[1], OUTPUT); // define as output
digitalWrite(buffer[1], HIGH);
//PSOCK_SEND_STR(&s->p, "ON");
}
} else {
//PSOCK_SEND_STR(&s->p, "Wrong!");
}
}
if (buffer[0] == 'D') { // Control specific pin
Serial.print("Drive ");
if (buffer[1] == 'F') {
Serial.print("forward: ");
if (buffer[2] > 127) {
Car_Drive(127);
Serial.println(127, DEC);
} else {
Car_Drive(buffer[2]);
Serial.println(buffer[2], DEC);
}
} else if (buffer[1] == 'B') {
Serial.println("backward: ");
if (buffer[2] > 127) {
Car_Drive(-127);
Serial.println(-127, DEC);
} else {
Car_Drive(-1 * buffer[2]);
Serial.println(-1 * buffer[2], DEC);
}
}
}
if (buffer[0] == 'T') { // Control specific pin
Serial.print("Turn ");
if (buffer[1] == 'R') { // Right
Serial.println("right");
Car_Turn(1);
} else if (buffer[1] == 'L') { // Left
Serial.println("left");
Car_Turn(-1);
} else if (buffer[1] == 'N') { // None
Serial.println("none");
Car_Turn(0);
}
}
memset(buffer, 0x00, sizeof(buffer)); // Empty buffer
}
void Car_Setup()
{
pinMode(3, OUTPUT); // Turn Right Pin
digitalWrite(3, LOW);
pinMode(4, OUTPUT); // Turn Left Pin
digitalWrite(4, LOW);
analogWrite(5, 0); // Go Forward PWM
analogWrite(6, 0); // Go Backward PWM
}
void Car_Drive(signed char Direction) // Forward/Backward speed
{
if (Direction > 0) {
analogWrite(5, 2 * Direction); // Go Forward PWM
analogWrite(6, 0); // Go Backward PWM
} else if (Direction < 0) {
analogWrite(5, 0); // Go Backward PWM
analogWrite(6, -2 * Direction); // Go Forward PWM
} else {
analogWrite(5, 0); // Go Forward PWM
analogWrite(6, 0); // Go Backward PWM
}
}
void Car_Turn(signed char Direction) // Positive=Right, Negative=Left
{
if (Direction > 0) {
digitalWrite(3, HIGH); // Turn Right Pin
digitalWrite(4, LOW); // Turn Left Pin
} else if (Direction < 0) {
digitalWrite(3, LOW); // Turn Right Pin
digitalWrite(4, HIGH); // Turn Left Pin
} else {
digitalWrite(3, LOW); // Turn Right Pin
digitalWrite(4, LOW); // Turn Left Pin
}
}
The error I recieve is:
WiFi_Controlled_Car.pde:-1: error: conflicting declaration 'const prog_char ssid []'
C:\Users\Kizz MyAnthia\Desktop\arduino-1.0\libraries\WiShield/config.h:44: error: 'ssid' has a previous declaration as 'char ssid []'
WiServer sample errors out:
WiServer:8: error: conflicting declaration 'const prog_char ssid []'
C:\Users\Kizz MyAnthia\Desktop\arduino-1.0\libraries\WiShield/config.h:44: error: 'ssid' has a previous declaration as 'char ssid []'
WiServer.cpp: In function 'int sendPage(char*)':
WiServer:42: error: no matching function for call to 'Server::print_P(char*, int&)'
C:\Users\Kizz MyAnthia\Desktop\arduino-1.0\libraries\WiShield/WiServer.h:203: note: candidates are: void Server::print_P(const char*)
WiServer.cpp: In function 'void setup()':
WiServer:81: error: invalid conversion from 'int (*)(char*)' to 'boolean (*)(char*)'
WiServer:81: error: initializing argument 1 of 'void Server::init(boolean (*)(char*))'
The specific parameter that is of issue is ssid[]. This variable is set in config.h and within the code above causing the multiple instance error. If I change the variable name in config.h then other pieces of the application that also use the function error because it can not be found. If I change the variable in my code the WiShield 2.0 does not connect.
Here is further information:
I know the WiShield & Arduino Uno (using IDE 1.0) works, the SimpleServer example works and provides the "Hello World!" text.
So I know the hardware, connection, and WiShield server function is working properly.
The specific part of the code that is the issue is:
const prog_char ssid[] PROGMEM = {"ROUTER ID"}; // max 32 bytes
If I change the "const prog_char" portion of the code to only "char" the code compiles successfully in IDE 1.0, but the WiShield does not connect to the WAP.
Any help is MUCH appreciated