Topic: connect_flag doesn't re-establish itself
In my sketch I am monitoring the connect_flag and drive a physical LED either green or red if connected (depending on a zone control in my RemoteXY app), and blue if not connected. That all woks OK, the LED turns blue if I put the iPad app into the background. Serial comms to the Bluetooth module stops, as expected, and the "paired" led on the BT module stays solid.
However, when I bring the RemoteXY app to the foreground again, serial comms restarts, indicating that it is communicating with the iPad app again, but the connect_flag remains 0, meaning I have to Stop the project and restart it manually. You can see from the code excerpt that I have put some debugging outputs for my oscilloscope, and can clearly see scope1 toggling on and off, but not scope2
Has anyone else seen this behaviour, and more importantly know a way round it ?
void loop() {
digitalWrite(scope1, HIGH);
RemoteXY_Handler ();
digitalWrite(scope1, LOW);
if (RemoteXY.connect_flag == 0) {
// not connected
LED_Blue();
// delay(5);
}
else {
// connected
digitalWrite(scope2, HIGH);
switch (RemoteXY.ZONE) {
// ZONE = 0, so Zone 1
case 0:
LED_Green();
RemoteXY.led_1_g = 150;
RemoteXY.led_1_r = 0;
digitalWrite(IR2_Gate, LOW);
digitalWrite(IR1_Gate, HIGH);
break;
case 1:
// ZONE = 1, so Zone 2
LED_Red();
RemoteXY.led_1_r = 150;
RemoteXY.led_1_g = 0;
digitalWrite(IR1_Gate, LOW);
digitalWrite(IR2_Gate, HIGH);
break;
}
digitalWrite(scope2, LOW);
}