deprovision method

Will try to deprovision the specified ProvisionedMeshNode by sending ConfigNodeReset message via the unicast address.

Returns a ConfigNodeResetStatus or null if timeout after 5sec.

Throws a method channel error "NOT FOUND" if not found in the currently loaded mesh n/w or an UnsupportedError if the current OS is not supported.

Implementation

Future<ConfigNodeResetStatus> deprovision(ProvisionedMeshNode meshNode) async {
  if (Platform.isIOS || Platform.isAndroid) {
    final unicastAddress = await meshNode.unicastAddress;
    final status = _onConfigNodeResetStatusController.stream
        .where((element) => element.source == unicastAddress)
        .timeout(const Duration(seconds: 3),
            onTimeout: (sink) => sink.add(
                  const ConfigNodeResetStatus(-1, -1, false),
                ))
        .first;
    await _methodChannel.invokeMethod('deprovision', {'unicastAddress': unicastAddress});
    return status;
  } else {
    throw UnsupportedError('Platform ${Platform.operatingSystem} is not supported');
  }
}