Socket programming question here.
My interface comprises of an Android device(client), A wireless module hosting an access point, and an Arduino Uno(server).
My Android client class works when 1 user connects and sends commands to my Arduino server class.
I want to make my program friendly to many users at the same time. My server will only read in values from 1 connected client at a time.
After some research I've found that Arduino does not allow multithreading naturally, which is why i've decided to look into a number of libraries.
The Arduino library that I've decided to use for this specific issue is protothreads
. Unfortunately, i've been unable to find any examples of creating a server with Arduino to accept a client's commands. Furthermore I'm having a lot of trouble figuring out how to make this library work in my favor.
Now for my question,
How exactly can I allow my Arduino server to constantly listen for incoming messages from more than 1 client device?
Or is there something I can do on the client side that would make this communication possible?
A lot of work is handled by my Wifly Module. I was able to telnet in and set my ipaddress/port#/etc.. Anything sent over IP goes straight through my Module and straight to my arduino.
My Client Code:
My Server:
WiFlySerial wifi(rxPin ,txPin);
void setup() {
pinMode(rxPin, INPUT);
pinMode(txPin, OUTPUT);
pinMode(led, OUTPUT);
}
void loop() {
//Serial.println("I'm in the LOOP!!");
androidLed();
serialLed();
}
void androidLed()
{
if(wifi.available() > 0){
data = wifi.read();
Serial.println(wifi.getDeviceStatus());
Serial.println(data);
}
}