@@ -12,8 +12,8 @@ char ssid[] = "yourNetwork"; // your network SSID (name)
12
12
char pass[] = " secretPassword" ; // your network password (use for WPA, or use as key for WEP)
13
13
int keyIndex = 0 ; // your network key Index number (needed only for WEP)
14
14
15
-
16
15
unsigned long t0 = millis();
16
+ bool isConnected = false ;
17
17
18
18
APPLEMIDI_CREATE_INSTANCE (WiFiUDP, AppleMIDI); // see definition in AppleMidi_Defs.h
19
19
@@ -86,7 +86,7 @@ void loop()
86
86
87
87
// send a note every second
88
88
// (dont cáll delay(1000) as it will stall the pipeline)
89
- if ((millis () - t0) > 1000 )
89
+ if (isConnected && (millis () - t0) > 1000 )
90
90
{
91
91
t0 = millis ();
92
92
// Serial.print(".");
@@ -108,6 +108,7 @@ void loop()
108
108
// rtpMIDI session. Device connected
109
109
// -----------------------------------------------------------------------------
110
110
void OnAppleMidiConnected (char * name) {
111
+ isConnected = true ;
111
112
// Serial.print("Connected to session ");
112
113
// Serial.println(name);
113
114
}
@@ -116,6 +117,7 @@ void OnAppleMidiConnected(char* name) {
116
117
// rtpMIDI session. Device disconnected
117
118
// -----------------------------------------------------------------------------
118
119
void OnAppleMidiDisconnected () {
120
+ isConnected = false ;
119
121
// Serial.println("Disconnected");
120
122
}
121
123
@@ -143,4 +145,4 @@ void OnAppleMidiNoteOff(byte channel, byte note, byte velocity) {
143
145
Serial.print (" velocity:" );
144
146
Serial.print (velocity);
145
147
Serial.println ();
146
- }
148
+ }
0 commit comments