PlatformIO package of the Teensy core framework compatible with GCC 10 & C++20
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

60 rindas
1.7KB

  1. /*---------------------------------------------------------------------------------------------
  2. Open Sound Control (OSC) library for the ESP8266
  3. Example for sending messages from the ESP8266 to a remote computer
  4. The example is sending "hello, osc." to the address "/test".
  5. This example code is in the public domain.
  6. --------------------------------------------------------------------------------------------- */
  7. #include <ESP8266WiFi.h>
  8. #include <WiFiUdp.h>
  9. #include <OSCMessage.h>
  10. char ssid[] = "*****************"; // your network SSID (name)
  11. char pass[] = "*******"; // your network password
  12. WiFiUDP Udp; // A UDP instance to let us send and receive packets over UDP
  13. const IPAddress outIp(10,40,10,105); // remote IP of your computer
  14. const unsigned int outPort = 9999; // remote port to receive OSC
  15. const unsigned int localPort = 8888; // local port to listen for OSC packets (actually not used for sending)
  16. void setup() {
  17. Serial.begin(115200);
  18. // Connect to WiFi network
  19. Serial.println();
  20. Serial.println();
  21. Serial.print("Connecting to ");
  22. Serial.println(ssid);
  23. WiFi.begin(ssid, pass);
  24. while (WiFi.status() != WL_CONNECTED) {
  25. delay(500);
  26. Serial.print(".");
  27. }
  28. Serial.println("");
  29. Serial.println("WiFi connected");
  30. Serial.println("IP address: ");
  31. Serial.println(WiFi.localIP());
  32. Serial.println("Starting UDP");
  33. Udp.begin(localPort);
  34. Serial.print("Local port: ");
  35. Serial.println(Udp.localPort());
  36. }
  37. void loop() {
  38. OSCMessage msg("/test");
  39. msg.add("hello, osc.");
  40. Udp.beginPacket(outIp, outPort);
  41. msg.send(Udp);
  42. Udp.endPacket();
  43. msg.empty();
  44. delay(500);
  45. }