subscribe method

Future<void> subscribe(
  1. int nodeId,
  2. SubscriptionCallback callback,
  3. List<ChipAttributePath>? attributePaths,
  4. List<ChipEventPath>? eventPaths,
  5. int minInterval,
  6. int maxInterval,
  7. bool keepSubscriptions,
  8. bool isFabricFiltered,
  9. int imTimeoutMs,
  10. int eventMin, {
  11. Object? connectContext,
})

Implementation

Future<void> subscribe(
  int nodeId,
  SubscriptionCallback callback,
  // int devicePtr,
  List<ChipAttributePath>? attributePaths,
  List<ChipEventPath>? eventPaths,
  // List<DataVersionFilter>? dataVersionFilters,
  int minInterval,
  int maxInterval,
  bool keepSubscriptions,
  bool isFabricFiltered,
  int imTimeoutMs,
  int eventMin,
  {Object? connectContext}
) async {
  String callbackHandle = callback.hashCode.toString();
  _subscriptionCallbacks[callbackHandle] = callback;
  try {
    await _requestPlatform('subscribe', jsonEncode({
      jsonKeyHandle: _platformDeviceControllerHandle,
      'nodeId': nodeId,
      // 'devicePtr': devicePtr,
      'callbackHandle': callbackHandle,
      'attributePaths': attributePaths?.map((e) => e.toJson()).toList(),
      'eventPaths': eventPaths?.map((e) => e.toJson()).toList(),
      // 'dataVersionFilters': dataVersionFilters?.map((e) => e.toJson()).toList(),
      'minInterval': minInterval,
      'maxInterval': maxInterval,
      'keepSubscriptions': keepSubscriptions,
      'isFabricFiltered': isFabricFiltered,
      'imTimeoutMs': imTimeoutMs,
      'eventMin': eventMin,
      'connectContext': connectContext
    }));
  } catch(e, s) {
    print(s);
    _subscriptionCallbacks.remove(callbackHandle);
  }
}