connect method

Future<void> connect(
  1. String port
)

Connects to the given serial port and adds an entry to devices.

If the connection or handshake fails, a message is logged to the home screen and the device is not added to devices.

Implementation

Future<void> connect(String port) async {
  models.home.setMessage(severity: Severity.info, text: "Connecting to $port...");
  final device = BurtFirmwareSerial(port: port, logger: BurtLogger());
  if (!await device.init()) {
    await device.dispose();
  	models.home.setMessage(severity: Severity.error, text: "Could not connect to $port");
  	return;
  }
  device.messages.listen(models.messages.addMessage);
  models.home.setMessage(severity: Severity.info, text: "Connected to $port");
  devices[port] = device;
  notifyListeners();
}