diff --git a/@postman/src/main.cpp b/@postman/src/main.cpp
index 40ea1ed..22c4dae 100644
--- a/@postman/src/main.cpp
+++ b/@postman/src/main.cpp
@@ -126,7 +126,7 @@ void hello() {
MONITORING_SERIAL.println(" ==(esp_now_send/0)==> ");
//
if (hello_delay > 0) {
- if (hello_delay < 20) hello_delay = 20;
+ if (hello_delay < 100) hello_delay = 100;
hello_task.restartDelayed(hello_delay);
}
}
diff --git a/@sampler/platformio.ini b/@sampler/platformio.ini
index dd99e35..a81e40d 100644
--- a/@sampler/platformio.ini
+++ b/@sampler/platformio.ini
@@ -16,7 +16,7 @@ lib_ignore = Audio, SD
lib_deps =
721 ; TaskScheduler
SPI
-; 322@1.0.7 ; SdFat
+ 322@1.0.7 ; SdFat
[env:teensy35]
platform = teensy@3.6.0
diff --git a/crickets/src/main.cpp b/crickets/src/main.cpp
index b65a199..a70a17f 100755
--- a/crickets/src/main.cpp
+++ b/crickets/src/main.cpp
@@ -16,7 +16,17 @@
// always broadcasting. everyone is 'talkative'.
//
-//=====================
+// then, let it save a value in EEPROM (object with memory=mind?)
+
+//========================
+//
+#define MY_GROUP_ID (3000)
+#define MY_ID (MY_GROUP_ID + 1)
+#define MY_SIGN ("CRICKET")
+//
+//========================
+
+//=====================
//
// 'HAVE_CLIENT'
// --> i have a client. enable the client task.
@@ -28,24 +38,12 @@
// 'DISABLE_AP'
// --> (questioning)...
//
-//====================
-
-//=====================
+// 'HAVE_CLIENT_I2C'
+// --> i have a client w/ I2C i/f. enable the I2C client task.
//
-// (1) standalone
-#if 1
-// (2) osc client (the ROOT)
-#elif 0
-#define SERIAL_SWAP
-#define HAVE_CLIENT
+//====================
//
-#endif
-//
-//====================
-
-//========================
-#define ID_KEY 126
-//=======================
+// (EMPTY)
//========================
//
@@ -117,10 +115,18 @@ extern Task hello_task;
static int hello_delay = 0;
void hello() {
//
- Hello hello = {
- ID_KEY,
- speed
- };
+ byte mac[6];
+ WiFi.macAddress(mac);
+ uint32_t mac32 = (((((mac[2] << 8) + mac[3]) << 8) + mac[4]) << 8) + mac[5];
+ //
+ Hello hello(String(MY_SIGN), MY_ID, mac32); // the most basic 'hello'
+ // and you can append some floats
+ static int count = 0;
+ count++;
+ hello.h1 = (count % 1000);
+ hello.h2 = speed;
+ // hello.h3 = 0;
+ // hello.h4 = 0;
//
uint8_t frm_size = sizeof(Hello) + 2;
uint8_t frm[frm_size];
@@ -128,17 +134,17 @@ void hello() {
memcpy(frm + 1, (uint8_t *) &hello, sizeof(Hello));
frm[frm_size - 1] = '}';
//
- esp_now_send(NULL, frm, frm_size); // just broadcast.
+ esp_now_send(NULL, frm, frm_size); // to all peers in the list.
//
MONITORING_SERIAL.write(frm, frm_size);
- MONITORING_SERIAL.println(" ==(esp_now_send/BROADCAST)==> ");
+ MONITORING_SERIAL.println(" ==(esp_now_send/0)==> ");
//
if (hello_delay > 0) {
if (hello_delay < 100) hello_delay = 100;
hello_task.restartDelayed(hello_delay);
}
}
-Task hello_task(0, TASK_ONCE, &hello);
+Task hello_task(0, TASK_ONCE, &hello, &runner, false);
//task #0 : blink led
extern Task blink_task;
@@ -171,15 +177,17 @@ Task blink_task(0, TASK_FOREVER, &blink, &runner, true); // -> ENABLED, at start
// on 'Note'
void onNoteHandler(Note & n) {
//is it for me?
- if (n.pitch == ID_KEY) {
+ if (n.id == MY_GROUP_ID || n.id == MY_ID) {
//
- speed = n.velocity;
- // if (speed < 0) speed = 0;
- //
- if (n.onoff == 1) {
- set_speed_task.restartDelayed(10);
- } else if (n.onoff == 0) {
- rest_task.restartDelayed(10);
+ if (n.pitch == 1) {
+ speed = n.velocity;
+ // if (speed < 0) speed = 0;
+ //
+ if (n.onoff == 1) {
+ set_speed_task.restartDelayed(10);
+ } else if (n.onoff == 0) {
+ rest_task.restartDelayed(10);
+ }
}
//
}
@@ -188,16 +196,37 @@ void onNoteHandler(Note & n) {
// on 'receive'
void onDataReceive(uint8_t * mac, uint8_t *incomingData, uint8_t len) {
+ //
+ //MONITORING_SERIAL.write(incomingData, len);
+
+ //
#if defined(HAVE_CLIENT)
- Serial.write(incomingData, len); // we share it w/ the client.
+ Serial.write(incomingData, len); // we pass it over to the client.
#endif
- // on 'Note'
- if (incomingData[0] == '[' && incomingData[len - 1] == ']' && len == (sizeof(Note) + 2)) {
+ // open => identify => use.
+ if (incomingData[0] == '{' && incomingData[len - 1] == '}' && len == (sizeof(Hello) + 2)) {
+ Hello hello("");
+ memcpy((uint8_t *) &hello, incomingData + 1, sizeof(Hello));
//
+ MONITORING_SERIAL.println(hello.to_string());
+ //
+ }
+
+ // open => identify => use.
+ if (incomingData[0] == '[' && incomingData[len - 1] == ']' && len == (sizeof(Note) + 2)) {
Note note;
memcpy((uint8_t *) ¬e, incomingData + 1, sizeof(Note));
onNoteHandler(note);
+
+ //is it for me?
+ if (note.id == MY_GROUP_ID || note.id == MY_ID) {
+ hello_delay = note.ps;
+ if (hello_delay > 0 && hello_task.isEnabled() == false) {
+ hello_task.restart();
+ }
+ }
+
MONITORING_SERIAL.println(note.to_string());
}
}
@@ -222,26 +251,21 @@ void setup() {
Serial.println();
Serial.println("\"hi, i m your postman.\"");
Serial.println("-");
- Serial.println("- * info >>>");
-#if defined(ID_KEY)
- Serial.println("- identity (key): " + String(ID_KEY));
-#endif
- Serial.println("- mac address: " + WiFi.macAddress());
- Serial.println("- wifi channel: " + String(WIFI_CHANNEL));
- Serial.println("-");
- Serial.println("- * conf >>>");
+ Serial.println("- my id: " + String(MY_ID) + ", gid: " + String(MY_GROUP_ID) + ", call me ==> \"" + String(MY_SIGN) + "\"");
+ Serial.println("- mac address: " + WiFi.macAddress() + ", channel: " + String(WIFI_CHANNEL));
#if defined(HAVE_CLIENT)
- Serial.println("- ======== 'HAVE_CLIENT' ========");
+ Serial.println("- ======== 'HAVE_CLIENT' ========");
#endif
#if defined(SERIAL_SWAP)
- Serial.println("- ======== 'SERIAL_SWAP' ========");
+ Serial.println("- ======== 'SERIAL_SWAP' ========");
#endif
#if defined(DISABLE_AP)
- Serial.println("- ======== 'DISABLE_AP' ========");
+ Serial.println("- ======== 'DISABLE_AP' ========");
+#endif
+#if defined(HAVE_CLIENT_I2C)
+ Serial.println("- ======== 'HAVE_CLIENT_I2C' ========");
#endif
Serial.println("-");
- Serial.println("\".-.-.-. :)\"");
- Serial.println();
//wifi
WiFiMode_t node_type = WIFI_AP_STA;
@@ -260,8 +284,7 @@ void setup() {
esp_now_register_send_cb(onDataSent);
esp_now_register_recv_cb(onDataReceive);
//
- Serial.println("-");
- Serial.println("- we will broadcast everything. ==> add only the 'broadcast peer' (FF:FF:FF:FF:FF:FF).");
+ Serial.println("- ! (esp_now_add_peer) ==> add a 'broadcast peer' (FF:FF:FF:FF:FF:FF).");
uint8_t broadcastmac[6] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
esp_now_add_peer(broadcastmac, ESP_NOW_ROLE_COMBO, 1, NULL, 0);
@@ -290,8 +313,6 @@ void setup() {
//tasks
runner.addTask(set_speed_task);
runner.addTask(rest_task);
- runner.addTask(hello_task);
-
rest_task.restartDelayed(500);
}
diff --git a/gonggong/src/main.cpp b/gonggong/src/main.cpp
index 6087009..84edadb 100644
--- a/gonggong/src/main.cpp
+++ b/gonggong/src/main.cpp
@@ -16,7 +16,17 @@
// always broadcasting. everyone is 'talkative'.
//
-//=====================
+// then, let it save a value in EEPROM (object with memory=mind?)
+
+//========================
+//
+#define MY_GROUP_ID (4000)
+#define MY_ID (MY_GROUP_ID + 1)
+#define MY_SIGN ("GONGGONG")
+//
+//========================
+
+//=====================
//
// 'HAVE_CLIENT'
// --> i have a client. enable the client task.
@@ -28,25 +38,12 @@
// 'DISABLE_AP'
// --> (questioning)...
//
-//====================
-
-//=====================
+// 'HAVE_CLIENT_I2C'
+// --> i have a client w/ I2C i/f. enable the I2C client task.
//
-// (1) standalone
-#if 1
-// (2) osc client (the ROOT)
-#elif 0
-#define SERIAL_SWAP
-#define HAVE_CLIENT
-// (3) sampler client
-#elif 0
-#define SERIAL_SWAP
-#define HAVE_CLIENT
-#define DISABLE_AP
+//====================
//
-#endif
-//
-//====================
+// (EMPTY)
//========================
#define GONG_SIDE_KEY 1000 // X1 = start angle, X2 = hit angle
@@ -54,10 +51,6 @@
#define GONG_HEAD_KEY 1002 // random (HEAD)
//=======================
-//========================
-#define ID_KEY GONG_SIDE_KEY
-//=======================
-
//========================
//
#define LED_PERIOD (11111)
@@ -217,9 +210,18 @@ extern Task hello_task;
static int hello_delay = 0;
void hello() {
//
- Hello hello = {
- ID_KEY
- };
+ byte mac[6];
+ WiFi.macAddress(mac);
+ uint32_t mac32 = (((((mac[2] << 8) + mac[3]) << 8) + mac[4]) << 8) + mac[5];
+ //
+ Hello hello(String(MY_SIGN), MY_ID, mac32); // the most basic 'hello'
+ // and you can append some floats
+ static int count = 0;
+ count++;
+ hello.h1 = (count % 1000);
+ // hello.h2 = 0;
+ // hello.h3 = 0;
+ // hello.h4 = 0;
//
uint8_t frm_size = sizeof(Hello) + 2;
uint8_t frm[frm_size];
@@ -227,17 +229,17 @@ void hello() {
memcpy(frm + 1, (uint8_t *) &hello, sizeof(Hello));
frm[frm_size - 1] = '}';
//
- esp_now_send(NULL, frm, frm_size); // just broadcast.
+ esp_now_send(NULL, frm, frm_size); // to all peers in the list.
//
MONITORING_SERIAL.write(frm, frm_size);
- MONITORING_SERIAL.println(" ==(esp_now_send/BROADCAST)==> ");
+ MONITORING_SERIAL.println(" ==(esp_now_send/0)==> ");
//
if (hello_delay > 0) {
if (hello_delay < 100) hello_delay = 100;
hello_task.restartDelayed(hello_delay);
}
}
-Task hello_task(0, TASK_ONCE, &hello);
+Task hello_task(0, TASK_ONCE, &hello, &runner, false);
//task #0 : blink led
extern Task blink_task;
@@ -270,51 +272,71 @@ Task blink_task(0, TASK_FOREVER, &blink, &runner, true); // -> ENABLED, at start
// on 'Note'
void onNoteHandler(Note & n) {
//
- if (n.pitch == GONG_SIDE_KEY && n.onoff == 1) {
- side_start_angle = n.x1;
- side_hit_angle = n.x2;
+ if (n.id == MY_GROUP_ID || n.id == MY_ID) {
+ if (n.pitch == GONG_SIDE_KEY && n.onoff == 1) {
+ side_start_angle = n.x1;
+ side_hit_angle = n.x2;
+ //
+ if (side_start_angle < 0) side_start_angle = 0;
+ if (side_start_angle > 180) side_start_angle = 180;
+ //
+ if (side_hit_angle < 0) side_hit_angle = 0;
+ if (side_hit_angle > 180) side_hit_angle = 180;
+ //
+ ring_side_task.restartDelayed(10);
+ }
//
- if (side_start_angle < 0) side_start_angle = 0;
- if (side_start_angle > 180) side_start_angle = 180;
+ if (n.pitch == GONG_HEAD_KEY && n.onoff == 1) {
+ ring_head_task.restartDelayed(10);
+ }
//
- if (side_hit_angle < 0) side_hit_angle = 0;
- if (side_hit_angle > 180) side_hit_angle = 180;
- //
- ring_side_task.restartDelayed(10);
+ if (n.pitch == GONG_SIDE_MOVE_KEY && n.onoff == 1) {
+ side_set_angle = n.x3;
+ //
+ if (side_set_angle < 0) side_set_angle = 0;
+ if (side_set_angle > 180) side_set_angle = 180;
+ //
+ ring_side_move_task.restartDelayed(10);
+ //
+ }
}
- //
- if (n.pitch == GONG_HEAD_KEY && n.onoff == 1) {
- ring_head_task.restartDelayed(10);
- }
- //
- if (n.pitch == GONG_SIDE_MOVE_KEY && n.onoff == 1) {
- side_set_angle = n.x3;
- //
- if (side_set_angle < 0) side_set_angle = 0;
- if (side_set_angle > 180) side_set_angle = 180;
- //
- ring_side_move_task.restartDelayed(10);
- }
- //
}
// on 'receive'
void onDataReceive(uint8_t * mac, uint8_t *incomingData, uint8_t len) {
+ //
+ //MONITORING_SERIAL.write(incomingData, len);
+
//
#if defined(HAVE_CLIENT)
- Serial.write(incomingData, len); // we share it w/ the client.
+ Serial.write(incomingData, len); // we pass it over to the client.
#endif
- // on 'Note'
+ // open => identify => use.
+ if (incomingData[0] == '{' && incomingData[len - 1] == '}' && len == (sizeof(Hello) + 2)) {
+ Hello hello("");
+ memcpy((uint8_t *) &hello, incomingData + 1, sizeof(Hello));
+ //
+ MONITORING_SERIAL.println(hello.to_string());
+ //
+ }
+
+ // open => identify => use.
if (incomingData[0] == '[' && incomingData[len - 1] == ']' && len == (sizeof(Note) + 2)) {
Note note;
memcpy((uint8_t *) ¬e, incomingData + 1, sizeof(Note));
- //
- MONITORING_SERIAL.println(note.to_string());
- //
onNoteHandler(note);
- //
+
+ //is it for me?
+ if (note.id == MY_GROUP_ID || note.id == MY_ID) {
+ hello_delay = note.ps;
+ if (hello_delay > 0 && hello_task.isEnabled() == false) {
+ hello_task.restart();
+ }
+ }
+
+ MONITORING_SERIAL.println(note.to_string());
}
}
@@ -338,26 +360,21 @@ void setup() {
Serial.println();
Serial.println("\"hi, i m your postman.\"");
Serial.println("-");
- Serial.println("- * info >>>");
-#if defined(ID_KEY)
- Serial.println("- identity (key): " + String(ID_KEY));
-#endif
- Serial.println("- mac address: " + WiFi.macAddress());
- Serial.println("- wifi channel: " + String(WIFI_CHANNEL));
- Serial.println("-");
- Serial.println("- * conf >>>");
+ Serial.println("- my id: " + String(MY_ID) + ", gid: " + String(MY_GROUP_ID) + ", call me ==> \"" + String(MY_SIGN) + "\"");
+ Serial.println("- mac address: " + WiFi.macAddress() + ", channel: " + String(WIFI_CHANNEL));
#if defined(HAVE_CLIENT)
- Serial.println("- ======== 'HAVE_CLIENT' ========");
+ Serial.println("- ======== 'HAVE_CLIENT' ========");
#endif
#if defined(SERIAL_SWAP)
- Serial.println("- ======== 'SERIAL_SWAP' ========");
+ Serial.println("- ======== 'SERIAL_SWAP' ========");
#endif
#if defined(DISABLE_AP)
- Serial.println("- ======== 'DISABLE_AP' ========");
+ Serial.println("- ======== 'DISABLE_AP' ========");
+#endif
+#if defined(HAVE_CLIENT_I2C)
+ Serial.println("- ======== 'HAVE_CLIENT_I2C' ========");
#endif
Serial.println("-");
- Serial.println("\".-.-.-. :)\"");
- Serial.println();
//wifi
WiFiMode_t node_type = WIFI_AP_STA;
@@ -376,8 +393,7 @@ void setup() {
esp_now_register_send_cb(onDataSent);
esp_now_register_recv_cb(onDataReceive);
//
- Serial.println("-");
- Serial.println("- we will broadcast everything. ==> add only the 'broadcast peer' (FF:FF:FF:FF:FF:FF).");
+ Serial.println("- ! (esp_now_add_peer) ==> add a 'broadcast peer' (FF:FF:FF:FF:FF:FF).");
uint8_t broadcastmac[6] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
esp_now_add_peer(broadcastmac, ESP_NOW_ROLE_COMBO, 1, NULL, 0);
@@ -404,7 +420,6 @@ void setup() {
randomSeed(analogRead(0));
//tasks
- runner.addTask(hello_task);
runner.addTask(ring_side_task);
runner.addTask(ring_side_move_task);
runner.addTask(side_release_task);
diff --git a/postman/src/main.cpp b/postman/src/main.cpp
index cef2a06..7432b33 100644
--- a/postman/src/main.cpp
+++ b/postman/src/main.cpp
@@ -104,7 +104,9 @@ void hello() {
//
Hello hello(String(MY_SIGN), MY_ID, mac32); // the most basic 'hello'
// and you can append some floats
- // hello.h1 = 0;
+ static int count = 0;
+ count++;
+ hello.h1 = (count % 1000);
// hello.h2 = 0;
// hello.h3 = 0;
// hello.h4 = 0;
@@ -220,11 +222,28 @@ void onDataReceive(uint8_t * mac, uint8_t *incomingData, uint8_t len) {
Serial.write(incomingData, len); // we pass it over to the client.
#endif
+ // open => identify => use.
+ if (incomingData[0] == '{' && incomingData[len - 1] == '}' && len == (sizeof(Hello) + 2)) {
+ Hello hello("");
+ memcpy((uint8_t *) &hello, incomingData + 1, sizeof(Hello));
+ //
+ MONITORING_SERIAL.println(hello.to_string());
+ //
+ }
+
// open => identify => use.
if (incomingData[0] == '[' && incomingData[len - 1] == ']' && len == (sizeof(Note) + 2)) {
Note note;
memcpy((uint8_t *) ¬e, incomingData + 1, sizeof(Note));
- //
+
+ //is it for me?
+ if (note.id == MY_GROUP_ID || note.id == MY_ID) {
+ hello_delay = note.ps;
+ if (hello_delay > 0 && hello_task.isEnabled() == false) {
+ hello_task.restart();
+ }
+ }
+
MONITORING_SERIAL.println(note.to_string());
//-*-*-*-*-*-*-*-*-*-
diff --git a/puredata/piano_access_mesh_x_2.pd b/puredata/piano_access_mesh_x_2.pd
index 500e105..732bc8a 100644
--- a/puredata/piano_access_mesh_x_2.pd
+++ b/puredata/piano_access_mesh_x_2.pd
@@ -884,7 +884,7 @@
#X connect 369 0 82 0;
#X connect 370 0 165 0;
#X restore 57 368 pd crickets nanokontrol2;
-#N canvas 133 398 1214 393 roundly 1;
+#N canvas 133 398 1214 393 roundly 0;
#X msg 354 139 \$1 5000;
#X obj 354 162 unpack f f;
#X obj 354 185 s X1;
@@ -1071,7 +1071,7 @@
#X obj 79 64 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0 1
;
#X obj 408 177 s OSC;
-#N canvas 713 396 706 244 SAMPLER_NOTE-to-OSC 1;
+#N canvas 627 525 706 244 SAMPLER_NOTE-to-OSC 0;
#X obj 35 142 spigot;
#X obj 84 127 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0
1;
diff --git a/roundly/src/main.cpp b/roundly/src/main.cpp
index f8f4458..fb26f52 100644
--- a/roundly/src/main.cpp
+++ b/roundly/src/main.cpp
@@ -16,7 +16,17 @@
// always broadcasting. everyone is 'talkative'.
//
-//=====================
+// then, let it save a value in EEPROM (object with memory=mind?)
+
+//========================
+//
+#define MY_GROUP_ID (20000)
+#define MY_ID (MY_GROUP_ID + 1)
+#define MY_SIGN ("ROUNDLY")
+//
+//========================
+
+//=====================
//
// 'HAVE_CLIENT'
// --> i have a client. enable the client task.
@@ -28,24 +38,12 @@
// 'DISABLE_AP'
// --> (questioning)...
//
-//====================
-
-//=====================
+// 'HAVE_CLIENT_I2C'
+// --> i have a client w/ I2C i/f. enable the I2C client task.
//
-// (1) standalone
-#if 1
-// (2) osc client (the ROOT)
-#elif 0
-#define SERIAL_SWAP
-#define HAVE_CLIENT
+//====================
//
-#endif
-//
-//====================
-
-//========================
-#define ID_KEY 2000
-//=======================
+// (EMPTY)
//========================
//
@@ -166,11 +164,18 @@ extern Task hello_task;
static int hello_delay = 0;
void hello() {
//
- Hello hello = {
- ID_KEY,
- stepper.currentPosition(),
- stepper.distanceToGo()
- };
+ byte mac[6];
+ WiFi.macAddress(mac);
+ uint32_t mac32 = (((((mac[2] << 8) + mac[3]) << 8) + mac[4]) << 8) + mac[5];
+ //
+ Hello hello(String(MY_SIGN), MY_ID, mac32); // the most basic 'hello'
+ // and you can append some floats
+ static int count = 0;
+ count++;
+ hello.h1 = (count % 1000);
+ hello.h2 = stepper.currentPosition();
+ hello.h3 = stepper.distanceToGo();
+ // hello.h4 = 0;
//
uint8_t frm_size = sizeof(Hello) + 2;
uint8_t frm[frm_size];
@@ -178,17 +183,17 @@ void hello() {
memcpy(frm + 1, (uint8_t *) &hello, sizeof(Hello));
frm[frm_size - 1] = '}';
//
- esp_now_send(NULL, frm, frm_size); // just broadcast.
+ esp_now_send(NULL, frm, frm_size); // to all peers in the list.
//
MONITORING_SERIAL.write(frm, frm_size);
- MONITORING_SERIAL.println(" ==(esp_now_send/BROADCAST)==> ");
+ MONITORING_SERIAL.println(" ==(esp_now_send/0)==> ");
//
if (hello_delay > 0) {
if (hello_delay < 100) hello_delay = 100;
hello_task.restartDelayed(hello_delay);
}
}
-Task hello_task(0, TASK_ONCE, &hello);
+Task hello_task(0, TASK_ONCE, &hello, &runner, false);
//task #0 : blink led
extern Task blink_task;
@@ -221,17 +226,12 @@ Task blink_task(0, TASK_FOREVER, &blink, &runner, true); // -> ENABLED, at start
// on 'Note'
void onNoteHandler(Note & n) {
//is it for me?
- if (n.pitch == ID_KEY) {
+ if (n.id == MY_GROUP_ID || n.id == MY_ID) {
//
step_target = n.x1;
step_duration = n.x2;
if (step_duration < 1000) step_duration = 1000;
//
- hello_delay = n.ps;
- if (hello_delay > 0 && hello_task.isEnabled() == false) {
- hello_task.restart();
- }
- //
if (n.onoff == 1) {
stepping_task.restartDelayed(10);
} else if (n.onoff == 0) {
@@ -244,16 +244,37 @@ void onNoteHandler(Note & n) {
// on 'receive'
void onDataReceive(uint8_t * mac, uint8_t *incomingData, uint8_t len) {
+ //
+ //MONITORING_SERIAL.write(incomingData, len);
+
+ //
#if defined(HAVE_CLIENT)
- Serial.write(incomingData, len); // we share it w/ the client.
+ Serial.write(incomingData, len); // we pass it over to the client.
#endif
- // on 'Note'
- if (incomingData[0] == '[' && incomingData[len - 1] == ']' && len == (sizeof(Note) + 2)) {
+ // open => identify => use.
+ if (incomingData[0] == '{' && incomingData[len - 1] == '}' && len == (sizeof(Hello) + 2)) {
+ Hello hello("");
+ memcpy((uint8_t *) &hello, incomingData + 1, sizeof(Hello));
//
+ MONITORING_SERIAL.println(hello.to_string());
+ //
+ }
+
+ // open => identify => use.
+ if (incomingData[0] == '[' && incomingData[len - 1] == ']' && len == (sizeof(Note) + 2)) {
Note note;
memcpy((uint8_t *) ¬e, incomingData + 1, sizeof(Note));
onNoteHandler(note);
+
+ //is it for me?
+ if (note.id == MY_GROUP_ID || note.id == MY_ID) {
+ hello_delay = note.ps;
+ if (hello_delay > 0 && hello_task.isEnabled() == false) {
+ hello_task.restart();
+ }
+ }
+
MONITORING_SERIAL.println(note.to_string());
}
}
@@ -278,26 +299,21 @@ void setup() {
Serial.println();
Serial.println("\"hi, i m your postman.\"");
Serial.println("-");
- Serial.println("- * info >>>");
-#if defined(ID_KEY)
- Serial.println("- identity (key): " + String(ID_KEY));
-#endif
- Serial.println("- mac address: " + WiFi.macAddress());
- Serial.println("- wifi channel: " + String(WIFI_CHANNEL));
- Serial.println("-");
- Serial.println("- * conf >>>");
+ Serial.println("- my id: " + String(MY_ID) + ", gid: " + String(MY_GROUP_ID) + ", call me ==> \"" + String(MY_SIGN) + "\"");
+ Serial.println("- mac address: " + WiFi.macAddress() + ", channel: " + String(WIFI_CHANNEL));
#if defined(HAVE_CLIENT)
- Serial.println("- ======== 'HAVE_CLIENT' ========");
+ Serial.println("- ======== 'HAVE_CLIENT' ========");
#endif
#if defined(SERIAL_SWAP)
- Serial.println("- ======== 'SERIAL_SWAP' ========");
+ Serial.println("- ======== 'SERIAL_SWAP' ========");
#endif
#if defined(DISABLE_AP)
- Serial.println("- ======== 'DISABLE_AP' ========");
+ Serial.println("- ======== 'DISABLE_AP' ========");
+#endif
+#if defined(HAVE_CLIENT_I2C)
+ Serial.println("- ======== 'HAVE_CLIENT_I2C' ========");
#endif
Serial.println("-");
- Serial.println("\".-.-.-. :)\"");
- Serial.println();
//wifi
WiFiMode_t node_type = WIFI_AP_STA;
@@ -316,8 +332,7 @@ void setup() {
esp_now_register_send_cb(onDataSent);
esp_now_register_recv_cb(onDataReceive);
//
- Serial.println("-");
- Serial.println("- we will broadcast everything. ==> add only the 'broadcast peer' (FF:FF:FF:FF:FF:FF).");
+ Serial.println("- ! (esp_now_add_peer) ==> add a 'broadcast peer' (FF:FF:FF:FF:FF:FF).");
uint8_t broadcastmac[6] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
esp_now_add_peer(broadcastmac, ESP_NOW_ROLE_COMBO, 1, NULL, 0);
@@ -353,10 +368,8 @@ void setup() {
#endif
//tasks
- runner.addTask(hello_task);
runner.addTask(stepping_task);
runner.addTask(rest_task);
-
rest_task.restartDelayed(500);
}
diff --git a/taak/src/main.cpp b/taak/src/main.cpp
index 846881b..49db032 100644
--- a/taak/src/main.cpp
+++ b/taak/src/main.cpp
@@ -16,7 +16,17 @@
// always broadcasting. everyone is 'talkative'.
//
-//=====================
+// then, let it save a value in EEPROM (object with memory=mind?)
+
+//========================
+//
+#define MY_GROUP_ID (1000)
+#define MY_ID (MY_GROUP_ID + 1)
+#define MY_SIGN ("TAAK")
+//
+//========================
+
+//=====================
//
// 'HAVE_CLIENT'
// --> i have a client. enable the client task.
@@ -28,29 +38,12 @@
// 'DISABLE_AP'
// --> (questioning)...
//
-//====================
-
-//=====================
+// 'HAVE_CLIENT_I2C'
+// --> i have a client w/ I2C i/f. enable the I2C client task.
//
-// (1) standalone
-#if 1
-// (2) osc client (the ROOT)
-#elif 0
-#define SERIAL_SWAP
-#define HAVE_CLIENT
-// (3) sampler client
-#elif 0
-#define SERIAL_SWAP
-#define HAVE_CLIENT
-#define DISABLE_AP
+//====================
//
-#endif
-//
-//====================
-
-//========================
-#define ID_KEY 151
-//=======================
+// (EMPTY)
//========================
//
@@ -116,9 +109,18 @@ extern Task hello_task;
static int hello_delay = 0;
void hello() {
//
- Hello hello = {
- ID_KEY
- };
+ byte mac[6];
+ WiFi.macAddress(mac);
+ uint32_t mac32 = (((((mac[2] << 8) + mac[3]) << 8) + mac[4]) << 8) + mac[5];
+ //
+ Hello hello(String(MY_SIGN), MY_ID, mac32); // the most basic 'hello'
+ // and you can append some floats
+ static int count = 0;
+ count++;
+ hello.h1 = (count % 1000);
+ // hello.h2 = 0;
+ // hello.h3 = 0;
+ // hello.h4 = 0;
//
uint8_t frm_size = sizeof(Hello) + 2;
uint8_t frm[frm_size];
@@ -126,17 +128,17 @@ void hello() {
memcpy(frm + 1, (uint8_t *) &hello, sizeof(Hello));
frm[frm_size - 1] = '}';
//
- esp_now_send(NULL, frm, frm_size); // just broadcast.
+ esp_now_send(NULL, frm, frm_size); // to all peers in the list.
//
MONITORING_SERIAL.write(frm, frm_size);
- MONITORING_SERIAL.println(" ==(esp_now_send/BROADCAST)==> ");
+ MONITORING_SERIAL.println(" ==(esp_now_send/0)==> ");
//
if (hello_delay > 0) {
if (hello_delay < 100) hello_delay = 100;
hello_task.restartDelayed(hello_delay);
}
}
-Task hello_task(0, TASK_ONCE, &hello);
+Task hello_task(0, TASK_ONCE, &hello, &runner, false);
//task #0 : blink led
extern Task blink_task;
@@ -169,7 +171,7 @@ Task blink_task(0, TASK_FOREVER, &blink, &runner, true); // -> ENABLED, at start
// on 'Note'
void onNoteHandler(Note & n) {
//is it for me?
- if (n.pitch == ID_KEY) {
+ if (n.id == MY_GROUP_ID || n.id == MY_ID) {
//
if (n.velocity < 0) n.velocity = 0;
//taak_on && taak_off
@@ -191,20 +193,38 @@ void onNoteHandler(Note & n) {
// on 'receive'
void onDataReceive(uint8_t * mac, uint8_t *incomingData, uint8_t len) {
+ //
+ //MONITORING_SERIAL.write(incomingData, len);
+
//
#if defined(HAVE_CLIENT)
- Serial.write(incomingData, len); // we share it w/ the client.
+ Serial.write(incomingData, len); // we pass it over to the client.
#endif
- // on 'Note'
+ // open => identify => use.
+ if (incomingData[0] == '{' && incomingData[len - 1] == '}' && len == (sizeof(Hello) + 2)) {
+ Hello hello("");
+ memcpy((uint8_t *) &hello, incomingData + 1, sizeof(Hello));
+ //
+ MONITORING_SERIAL.println(hello.to_string());
+ //
+ }
+
+ // open => identify => use.
if (incomingData[0] == '[' && incomingData[len - 1] == ']' && len == (sizeof(Note) + 2)) {
Note note;
memcpy((uint8_t *) ¬e, incomingData + 1, sizeof(Note));
- //
- MONITORING_SERIAL.println(note.to_string());
- //
onNoteHandler(note);
- //
+
+ //is it for me?
+ if (note.id == MY_GROUP_ID || note.id == MY_ID) {
+ hello_delay = note.ps;
+ if (hello_delay > 0 && hello_task.isEnabled() == false) {
+ hello_task.restart();
+ }
+ }
+
+ MONITORING_SERIAL.println(note.to_string());
}
}
@@ -228,26 +248,21 @@ void setup() {
Serial.println();
Serial.println("\"hi, i m your postman.\"");
Serial.println("-");
- Serial.println("- * info >>>");
-#if defined(ID_KEY)
- Serial.println("- identity (key): " + String(ID_KEY));
-#endif
- Serial.println("- mac address: " + WiFi.macAddress());
- Serial.println("- wifi channel: " + String(WIFI_CHANNEL));
- Serial.println("-");
- Serial.println("- * conf >>>");
+ Serial.println("- my id: " + String(MY_ID) + ", gid: " + String(MY_GROUP_ID) + ", call me ==> \"" + String(MY_SIGN) + "\"");
+ Serial.println("- mac address: " + WiFi.macAddress() + ", channel: " + String(WIFI_CHANNEL));
#if defined(HAVE_CLIENT)
- Serial.println("- ======== 'HAVE_CLIENT' ========");
+ Serial.println("- ======== 'HAVE_CLIENT' ========");
#endif
#if defined(SERIAL_SWAP)
- Serial.println("- ======== 'SERIAL_SWAP' ========");
+ Serial.println("- ======== 'SERIAL_SWAP' ========");
#endif
#if defined(DISABLE_AP)
- Serial.println("- ======== 'DISABLE_AP' ========");
+ Serial.println("- ======== 'DISABLE_AP' ========");
+#endif
+#if defined(HAVE_CLIENT_I2C)
+ Serial.println("- ======== 'HAVE_CLIENT_I2C' ========");
#endif
Serial.println("-");
- Serial.println("\".-.-.-. :)\"");
- Serial.println();
//wifi
WiFiMode_t node_type = WIFI_AP_STA;
@@ -266,8 +281,7 @@ void setup() {
esp_now_register_send_cb(onDataSent);
esp_now_register_recv_cb(onDataReceive);
//
- Serial.println("-");
- Serial.println("- we will broadcast everything. ==> add only the 'broadcast peer' (FF:FF:FF:FF:FF:FF).");
+ Serial.println("- ! (esp_now_add_peer) ==> add a 'broadcast peer' (FF:FF:FF:FF:FF:FF).");
uint8_t broadcastmac[6] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
esp_now_add_peer(broadcastmac, ESP_NOW_ROLE_COMBO, 1, NULL, 0);
@@ -294,7 +308,6 @@ void setup() {
pinMode(D6, OUTPUT);
//tasks
- runner.addTask(hello_task);
runner.addTask(taak_on_task);
runner.addTask(taak_off_task);
}