adding debug tools

This commit is contained in:
YamiDoesDev 2022-12-17 22:40:36 +01:00
parent 1cd4a74979
commit 7ffe408d44
1 changed files with 15 additions and 0 deletions

View File

@ -41,6 +41,7 @@ class _BluetoothScreen extends State<BluetoothScreen> {
bool isDisconnecting = false; bool isDisconnecting = false;
bool isConnected = false; bool isConnected = false;
String textInput = "0123456789 abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ"; String textInput = "0123456789 abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ";
String textOuput = "";
ButtonStyle buttonStyle = ElevatedButton.styleFrom( ButtonStyle buttonStyle = ElevatedButton.styleFrom(
foregroundColor: Colors.black, foregroundColor: Colors.black,
@ -115,6 +116,9 @@ class _BluetoothScreen extends State<BluetoothScreen> {
void _connectionOnListen(Uint8List data) { void _connectionOnListen(Uint8List data) {
debugPrint("received: $data"); debugPrint("received: $data");
debugPrint("received decoded: ${const Utf8Decoder().convert(data)}"); debugPrint("received decoded: ${const Utf8Decoder().convert(data)}");
setState(() {
textOuput += const Utf8Decoder().convert(data);
});
// Allocate buffer for parsed data // Allocate buffer for parsed data
int backspacesCounter = 0; int backspacesCounter = 0;
for (var byte in data) { for (var byte in data) {
@ -250,6 +254,7 @@ class _BluetoothScreen extends State<BluetoothScreen> {
], ],
), ),
const Divider(), const Divider(),
Text(textOuput),
TextFormField( TextFormField(
decoration: const InputDecoration( decoration: const InputDecoration(
labelText: "BluetoothText" labelText: "BluetoothText"
@ -273,6 +278,16 @@ class _BluetoothScreen extends State<BluetoothScreen> {
}, },
style: buttonStyle, style: buttonStyle,
child: const Text("Request Permissions"), child: const Text("Request Permissions"),
),
ElevatedButton(
onPressed: () async {
setState(() {
textOuput = "";
});
},
style: buttonStyle,
child: const Text("Clear Output"),
), ),
ElevatedButton( ElevatedButton(
onPressed: () async { onPressed: () async {