-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
277 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.pioenvs | ||
.piolibdeps | ||
.clang_complete | ||
.gcc-flags.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
# Continuous Integration (CI) is the practice, in software | ||
# engineering, of merging all developer working copies with a shared mainline | ||
# several times a day < http://docs.platformio.org/page/ci/index.html > | ||
# | ||
# Documentation: | ||
# | ||
# * Travis CI Embedded Builds with PlatformIO | ||
# < https://docs.travis-ci.com/user/integration/platformio/ > | ||
# | ||
# * PlatformIO integration with Travis CI | ||
# < http://docs.platformio.org/page/ci/travis.html > | ||
# | ||
# * User Guide for `platformio ci` command | ||
# < http://docs.platformio.org/page/userguide/cmd_ci.html > | ||
# | ||
# | ||
# Please choice one of the following templates (proposed below) and uncomment | ||
# it (remove "# " before each line) or use own configuration according to the | ||
# Travis CI documentation (see above). | ||
# | ||
|
||
|
||
# | ||
# Template #1: General project. Test it using existing `platformio.ini`. | ||
# | ||
|
||
# language: python | ||
# python: | ||
# - "2.7" | ||
# | ||
# sudo: false | ||
# cache: | ||
# directories: | ||
# - "~/.platformio" | ||
# | ||
# install: | ||
# - pip install -U platformio | ||
# | ||
# script: | ||
# - platformio run | ||
|
||
|
||
# | ||
# Template #2: The project is intended to by used as a library with examples | ||
# | ||
|
||
# language: python | ||
# python: | ||
# - "2.7" | ||
# | ||
# sudo: false | ||
# cache: | ||
# directories: | ||
# - "~/.platformio" | ||
# | ||
# env: | ||
# - PLATFORMIO_CI_SRC=path/to/test/file.c | ||
# - PLATFORMIO_CI_SRC=examples/file.ino | ||
# - PLATFORMIO_CI_SRC=path/to/test/directory | ||
# | ||
# install: | ||
# - pip install -U platformio | ||
# | ||
# script: | ||
# - platformio ci --lib="." --board=ID_1 --board=ID_2 --board=ID_N |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
Open Sound Control (OSC) library for the ESP8266 | ||
Example for sending messages from the ESP8266 to a remote computer | ||
The example is sending "hello, osc." to the address "/test". | ||
This example code is in the public domain. | ||
--------------------------------------------------------------------------------------------- */ | ||
#include <ESP8266WiFi.h> | ||
#include <WiFiUdp.h> | ||
#include <OSCMessage.h> | ||
|
||
char ssid[] = "*****************"; // your network SSID (name) | ||
char pass[] = "*******"; // your network password | ||
|
||
WiFiUDP Udp; // A UDP instance to let us send and receive packets over UDP | ||
const IPAddress outIp(10,40,10,105); // remote IP of your computer | ||
const unsigned int outPort = 9999; // remote port to receive OSC | ||
const unsigned int localPort = 8888; // local port to listen for OSC packets (actually not used for sending) | ||
|
||
void setup() { | ||
Serial.begin(115200); | ||
|
||
// Connect to WiFi network | ||
Serial.println(); | ||
Serial.println(); | ||
Serial.print("Connecting to "); | ||
Serial.println(ssid); | ||
WiFi.begin(ssid, pass); | ||
|
||
while (WiFi.status() != WL_CONNECTED) { | ||
delay(500); | ||
Serial.print("."); | ||
} | ||
Serial.println(""); | ||
|
||
Serial.println("WiFi connected"); | ||
Serial.println("IP address: "); | ||
Serial.println(WiFi.localIP()); | ||
|
||
Serial.println("Starting UDP"); | ||
Udp.begin(localPort); | ||
Serial.print("Local port: "); | ||
Serial.println(Udp.localPort()); | ||
|
||
} | ||
|
||
void loop() { | ||
OSCMessage msg("/test"); | ||
msg.add("hello, osc."); | ||
Udp.beginPacket(outIp, outPort); | ||
msg.send(Udp); | ||
Udp.endPacket(); | ||
msg.empty(); | ||
delay(500); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
|
||
This directory is intended for the project specific (private) libraries. | ||
PlatformIO will compile them to static libraries and link to executable file. | ||
|
||
The source code of each library should be placed in separate directory, like | ||
"lib/private_lib/[here are source files]". | ||
|
||
For example, see how can be organized `Foo` and `Bar` libraries: | ||
|
||
|--lib | ||
| |--Bar | ||
| | |--docs | ||
| | |--examples | ||
| | |--src | ||
| | |- Bar.c | ||
| | |- Bar.h | ||
| |--Foo | ||
| | |- Foo.c | ||
| | |- Foo.h | ||
| |- readme.txt --> THIS FILE | ||
|- platformio.ini | ||
|--src | ||
|- main.c | ||
|
||
Then in `src/main.c` you should use: | ||
|
||
#include <Foo.h> | ||
#include <Bar.h> | ||
|
||
// rest H/C/CPP code | ||
|
||
PlatformIO will find your libraries automatically, configure preprocessor's | ||
include paths and build them. | ||
|
||
More information about PlatformIO Library Dependency Finder | ||
- http://docs.platformio.org/page/librarymanager/ldf.html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
; PlatformIO Project Configuration File | ||
; | ||
; Build options: build flags, source filter | ||
; Upload options: custom upload port, speed and extra flags | ||
; Library options: dependencies, extra library storages | ||
; Advanced options: extra scripting | ||
; | ||
; Please visit documentation for the other options and examples | ||
; http://docs.platformio.org/page/projectconf.html | ||
|
||
[env:lolin32] | ||
platform = espressif32 | ||
board = lolin32 | ||
framework = arduino | ||
|
||
[platformio] | ||
lib_dir=~\Documents\Arduino\libraries |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
#include <WiFi.h> | ||
#include <WiFiUdp.h> | ||
#include <OSCMessage.h> | ||
|
||
|
||
const char * networkName = "A303"; | ||
const char * networkPswd = "Ijnition420"; | ||
|
||
//IP address to send UDP data to: | ||
const char * udpAddress = "192.168.1.255"; | ||
const int udpPort = 3333; | ||
|
||
//Are we currently connected? | ||
boolean connected = false; | ||
|
||
int ledPin = 5; | ||
|
||
//The udp library class | ||
WiFiUDP udp; | ||
|
||
|
||
void setup(void){ | ||
|
||
Serial.begin(115200); | ||
|
||
pinMode(ledPin, OUTPUT); | ||
digitalWrite(ledPin, HIGH); | ||
|
||
//Connect to the WiFi network | ||
connectToWiFi(networkName, networkPswd); | ||
|
||
//set in sta mode | ||
WiFi.mode(WIFI_STA); | ||
delay(100); | ||
|
||
//register event handler | ||
WiFi.onEvent(WiFiEvent); | ||
delay(100); | ||
} | ||
|
||
void loop(void){ | ||
|
||
if(connected){ | ||
int value = random(250); | ||
|
||
digitalWrite(ledPin, !digitalRead(ledPin)); | ||
|
||
OSCMessage msg("/bno"); | ||
msg.add((int) millis()); | ||
msg.add((int) value); | ||
|
||
udp.beginPacket(udpAddress,udpPort); | ||
msg.send(udp); | ||
udp.endPacket(); | ||
|
||
}else{ | ||
for(int i = 0 ; i<5;i++){ | ||
delay(2000); | ||
digitalWrite(ledPin, !digitalRead(ledPin)); | ||
} | ||
if(!connected){ | ||
connectToWiFi(networkName, networkPswd); | ||
} | ||
} | ||
//100 Hz | ||
delay(10); | ||
} | ||
|
||
void connectToWiFi(const char * ssid, const char * pwd){ | ||
Serial.println("Connecting to WiFi network: " + String(ssid)); | ||
|
||
// delete old config | ||
WiFi.disconnect(true); | ||
delay(500); | ||
|
||
//Initiate connection | ||
WiFi.begin(ssid, pwd); | ||
|
||
Serial.println("Waiting for WIFI connection..."); | ||
} | ||
|
||
//wifi event handler | ||
void WiFiEvent(WiFiEvent_t event){ | ||
switch(event) { | ||
case SYSTEM_EVENT_STA_GOT_IP: | ||
//When connected set | ||
Serial.print("WiFi connected! IP address: "); | ||
Serial.println(WiFi.localIP()); | ||
//initializes the UDP state | ||
//This initializes the transfer buffer | ||
udp.begin(WiFi.localIP(),udpPort); | ||
digitalWrite(ledPin, HIGH); | ||
connected = true; | ||
break; | ||
case SYSTEM_EVENT_STA_DISCONNECTED: | ||
Serial.println("WiFi lost connection"); | ||
connected = false; | ||
digitalWrite(ledPin, LOW); | ||
break; | ||
} | ||
} |