Hello. I'm trying to use the Wifi and Arduino_USBHostMbed5 libraries together. I have a working Wifi example, and have successfully transferred data between two R1s using UDP packets just fine.
I have also used Arduino_USBHostMbed5 to read files from my USB device.
But, when I simply #include the Arduino_USBHostMbed5 header into my Wifi sketch, it causes the call to WiFi.beginAP() to fail.
I'm new to the Arduino world, so I don't really know a lot about debugging in this environment. I can say that calling WiFi.beginAP() causes the red light on the Giga to start flashing, and that's about it, lol.
I'm digging through the library source right now to see if I can spot anything. Clearly some globals must are being included that are causing some sort of conflict.
Any help would be much appreciated!
I hate to do this, but I'm a new user and cannot upload attachments, so here's the code inline:
#include <SPI.h>
#include <WiFi.h>
#include <WiFiUdp.h>
// Simply including this header causes the sketch to fail
// #include <Arduino_USBHostMbed5.h>
#include "arduino_secrets.h"
///////please enter your sensitive data in the Secret tab/arduino_secrets.h
char ssid[] = SECRET_SSID; // your AP SSID (name)
char pass[] = SECRET_PASS; // your AP password
unsigned int localPort = 2390; // local port to listen on
char packetBuffer[256]; // buffer to hold incoming packet
char ReplyBuffer[] = "acknowledged"; // a string to send back
WiFiUDP Udp;
void setup() {
// Initialize serial and wait for port to open:
Serial.begin(9600);
// while (!Serial) {
// ; // wait for serial port to connect. Needed for native USB port only
// }
Serial.println("Access Point UDP Server");
// check for the WiFi module:
if (WiFi.status() == WL_NO_MODULE) {
Serial.println("Communication with WiFi module failed!");
// don't continue
while (true);
}
// print the network name (SSID);
Serial.print("Creating access point named: ");
Serial.println(ssid);
// Create open network. Change this line if you want to create an WEP network:
int status = WiFi.beginAP(ssid, pass);
if (status != WL_AP_LISTENING) {
Serial.println("Creating access point failed");
// don't continue
while (true);
}
// wait 10 seconds for connection:
delay(10000);
// start UDP
Udp.begin(localPort);
// print the WiFi status
printWiFiStatus();
}
void loop() {
// if there's data available, read a packet
int packetSize = Udp.parsePacket();
if (packetSize) {
Serial.print("Received packet of size ");
Serial.println(packetSize);
Serial.print("From ");
IPAddress remoteIp = Udp.remoteIP();
Serial.print(remoteIp);
Serial.print(", port ");
Serial.println(Udp.remotePort());
// read the packet into packetBufffer
int len = Udp.read(packetBuffer, 255);
if (len > 0) {
packetBuffer[len] = 0;
}
Serial.println("Contents:");
Serial.println(packetBuffer);
// send a reply, to the IP address and port that sent us the packet we received
Udp.beginPacket(Udp.remoteIP(), Udp.remotePort());
Udp.write(ReplyBuffer);
Udp.endPacket();
}
}
void printWiFiStatus() {
// print the SSID of the network you're attached to:
Serial.print("SSID: ");
Serial.println(WiFi.SSID());
// print your board's IP address:
IPAddress ip = WiFi.localIP();
Serial.print("IP Address: ");
Serial.println(ip);
// print the received signal strength:
long rssi = WiFi.RSSI();
Serial.print("signal strength (RSSI):");
Serial.print(rssi);
Serial.println(" dBm");
}