isLuaInReplState method
Checks if Lua is in the REPL/break by sending a simple print command and expecting a response. If Lua is in the REPL/break state, it will respond with the printed output and we return true. If a Lua main loop is running, it will not respond to the print command within the short timeout, and we return false.
Implementation
Future<bool> isLuaInReplState({Duration timeout = const Duration(milliseconds: 200)}) async{
try {
final response = await sendString("print(1)", awaitResponse: true, log: false);
return response != null && response == "1";
} on BrilliantBluetoothException catch (e) {
if (e.msg == "Timeout waiting for string response") {
return false;
}
else {
rethrow;
}
}
}