@ScruffR I am actually curious about this same thing. My ultimate goal is to have devices that communicate over WLAN with static IP addressing via OSC. Currently I am able to run my firmware no problem and communicate via OSC and UDP while in automatic mode and connected to the cloud.
I am able to generate a static IP that works and connects to the cloud by following this thread: I need to set a static IP on a Photon
Upon connection I can easily ping my particle and there are no indications of network failure on the board. When trying to implement a simple UDP message like this:
Udp.beginPacket(IPAddress(192,168,0,22), 7100);
Udp.write(TxMsg, 12);
Udp.endPacket();
Serial.println("message_sent");
delay(1000);
I am seeing nothing on the other end and getting serial confirmation of message sent.
Full code (bits and pieces from the forum mostly):
SYSTEM_MODE(SEMI_AUTOMATIC);
define STATUS_LED D7
UDP Udp;
//Global variables
boolean useStaticIP = true;
unsigned char TxMsg[12] = { 1, 254, 1, 254, 1, 254, 43, 212, 71, 184, 3, 252 };
void setup(void) {
// debug LED setup
pinMode(STATUS_LED, OUTPUT);
digitalWrite(STATUS_LED, HIGH);
Time.zone(-8);
delay(5000);
Serial.begin(57600);
delay(2000);
Serial.println("Hello there!");
Udp.begin(8888);
// read wifi .INI and connect to network
networkConnect();
}
void loop() {
Udp.beginPacket(IPAddress(192,168,0,22), 7100);
Udp.write(TxMsg, 12);
Udp.endPacket();
Serial.println("message_sent");
delay(1000);
}
void networkConnect()
{
char networkSSID[33] = "xxxx";
char networkPass[65] = "xxxx";
// WLAN_SEC_UNSEC = 0
// WLAN_SEC_WEP = 1
// WLAN_SEC_WPA = 2
// WLAN_SEC_WPA2 = 3
int authValue = 3;
// WLAN_CIPHER_NOT_SET = 0
// WLAN_CIPHER_AES = 1
// WLAN_CIPHER_TKIP = 2
// WLAN_CIPHER_AES_TKIP = 3
int cipherValue = 1;
uint8_t serverIP[] = {192, 168, 0, 150};
IPAddress myAddress = serverIP;
uint8_t serverNM[] = {255, 255, 255, 0};
IPAddress netmask = serverNM;
uint8_t serverGW[] = {192, 168, 0, 1};
IPAddress gateway = serverGW;
uint8_t serverDNS[] = {209, 18, 47, 62};
IPAddress dns = serverDNS;
// Static IP or DHCP?
if (useStaticIP)
{
Serial.print("Using Static IP Address: ");
Serial.print(serverIP[0]);
Serial.print(".");
Serial.print(serverIP[1]);
Serial.print(".");
Serial.print(serverIP[2]);
Serial.print(".");
Serial.println(serverIP[3]);
WiFi.setStaticIP(myAddress, netmask, gateway, dns);
WiFi.useStaticIP();
}
Serial.println("---");
Serial.print("deviceID: ");
String myID = System.deviceID();
Serial.println(myID);
Serial.printlnf("System version: %s", System.version().c_str());
uint32_t freemem = System.freeMemory();
Serial.print("free memory: ");
Serial.println(freemem);
}