BITalinoController constructor
BITalinoController(
- String address,
- CommunicationType communicationType
Controls a BITalino device.
The device MAC address (Android) or UUID (IOS), and the CommunicationType must be provided.
Throws BITalinoException(BITalinoErrorType.NOT_IMPLEMENTED_IOS) if the CommunicationType.BTH is used on IOS devices. Throws BITalinoException(BITalinoErrorType.ADDRESS_NULL) if the provided address is null. Throws BITalinoException(BITalinoErrorType.INVALID_ADDRESS) if the provided MAC address is invalid. Throws BITalinoException(BITalinoErrorType.TIMEOUT) if the timeout limit is reached.
Implementation
BITalinoController(String address, CommunicationType communicationType) {
if (address.isEmpty)
throw BITalinoException(BITalinoErrorType.ADDRESS_NULL);
if (Platform.isIOS && communicationType == CommunicationType.BTH) {
throw BITalinoException(BITalinoErrorType.NOT_IMPLEMENTED_IOS);
}
if (Platform.isAndroid) {
RegExp regExp = new RegExp(r"^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$");
if (!regExp.hasMatch(address))
throw BITalinoException(BITalinoErrorType.INVALID_ADDRESS);
}
_channel.setMethodCallHandler(this._didReceiveTranscript);
this.communicationType = communicationType;
this.address = address;
}