smart_device_core 0.3.7 copy "smart_device_core: ^0.3.7" to clipboard
smart_device_core: ^0.3.7 copied to clipboard

Flutter Plugin SDK named smart_device_core

smart_device_core #

A Flutter Plugin that provides core smart device management capabilities for Android and iOS, including device binding, live video streaming, event library, bird recognition, device settings, and more.

Requirements #

  • Flutter >= 3.3.0
  • Dart SDK >= 3.0.5 < 4.0.0
  • Android: minSdkVersion 21+
  • iOS: 13.0+

Installation #

Add the dependency in your pubspec.yaml:

dependencies:
  smart_device_core:
    git:
      url: https://github.com/SmartIotDeviceSDK/flutter.git

Quick Start #

1. Initialize SDK #

import 'package:smart_device_core/smart_device_core.dart';

final config = InitConfigBuilder()
    .setTenantId('your_tenant_id')
    .setLanguage('en')
    .setIsDebug(true)
    .setLoggerDelegate(LoggerDelegate(
      error: (tag, msg) => print('[$tag] ERROR: $msg'),
      info: (tag, msg) => print('[$tag] INFO: $msg'),
    ))
    .setAccountChangeListener(AccountChangeListener(
      onAccountInfoError: (status) {
        // Handle account errors, e.g. token expiration
      },
    ))
    .build();

SmartDeviceCore.getInstance()?.initSDK(config, Callback(
  onSuccess: (code, msg, data) => print('SDK initialized successfully'),
  onError: (code, msg) => print('SDK initialization failed: $msg'),
));

2. Login #

SmartDeviceCore.getInstance()?.login('your_jwt_token', Callback(
  onSuccess: (code, msg, data) => print('Login successful'),
  onError: (code, msg) => print('Login failed: $msg'),
));

Core Modules #

BindCore - Device Binding #

Supports multiple binding methods: QR code, wired, AP hotspot, and Bluetooth (BLE).

final bindCore = BindCore.getInstance();

// Initialize Bluetooth
bindCore?.bleInit();

// Discover devices via BLE
bindCore?.discoverDeviceByBLE(DiscoverCallBack(
  onDiscover: (device) => print('Device found: $device'),
));

// Bind via Bluetooth
bindCore?.startBindByBLE('WiFi_SSID', 'WiFi_Password', 'device_user_sn',
  StartBindCallback(
    onBindProgress: (step, code) => print('Binding progress: $step'),
    onBindSuccess: (device) => print('Binding successful'),
    onBindFailed: (code, msg) => print('Binding failed: $msg'),
  ),
);

// Bind via QR code
bindCore?.startBindByQRCode('WiFi_SSID', 'WiFi_Password',
  StartBindCallback(...),
);

// Bind via wired connection
bindCore?.startBindByWire('device_user_sn', StartBindCallback(...));

// Get WiFi list scanned by the device
bindCore?.getScanedWifiListOverA4xBle('ble_identifier', 'user_sn', Callback(...));

// Stop binding / release resources
bindCore?.stopBind();
bindCore?.releaseBindResource();

DeviceManageCore - Device Management #

final deviceCore = DeviceManageCore.getInstance();

// Query device list
deviceCore?.queryDeviceList(
  onSuccess: (code, msg, devices) {
    for (var device in devices) {
      print('Device: ${device.serialNumber}');
    }
  },
  onError: (code, msg) => print('Query failed: $msg'),
);

// Query single device info
deviceCore?.querySingleDeviceInfo('serial_number',
  onSuccess: (code, msg, device) => print('Device name: ${device.name}'),
  onError: (code, msg) => print('Query failed: $msg'),
);

DeviceSettingCore - Device Settings #

final settingCore = DeviceSettingCore.getInstance();

// Get device attributes
settingCore?.getAttribute('serial_number',
  onSuccess: (code, msg, attributes) => print('Attributes: $attributes'),
  onError: (code, msg) => print('Failed to get attributes: $msg'),
);

// Set motion tracking
settingCore?.setMotionTrack('serial_number', true,
  onSuccess: (code, msg, data) => print('Setting applied'),
  onError: (code, msg) => print('Setting failed: $msg'),
);

DeviceSleepPlanCore - Sleep Schedule #

DeviceSleepPlanCore.getInstance()?.setSleep('serial_number', true,
  onSuccess: (code, msg, data) => print('Sleep schedule set'),
  onError: (code, msg) => print('Setting failed: $msg'),
);

Live Video #

Use LiveManagerInstance to get a player instance. Supports both WebRTC and IJK playback (automatically selected based on device type).

// Get player
final player = LiveManagerInstance().getPlayer(deviceBean);

// Add rendering view in Widget
SurfaceView(serialNumber: 'device_serial_number')

// Start live streaming
player?.startLive(customParam);

// Audio / Intercom
player?.audioEnable(true);
player?.speakEnable(true);

// Screenshot
player?.screenShot(
  onSuccess: (code, msg, imageBytes) => print('Screenshot captured'),
  onError: (code, msg) => print('Screenshot failed'),
);

// PTZ control
player?.setPtz(x, y,
  onSuccess: (code, msg, data) {},
  onError: (code, msg) {},
);

// Switch resolution
player?.setResolution('HD',
  onSuccess: (code, msg, data) {},
  onError: (code, msg) {},
);

// SD card playback
player?.getSDVideoList(startTime, endTime,
  onSuccess: (code, msg, videoList) {},
  onError: (code, msg) {},
);
player?.startSdcard(startTime);

// Stop live streaming / release resources
player?.stopLive();
player?.destroyLive();

LibraryCore - Event Library #

final libraryCore = LibraryCore.getInstance();

// Query event list
libraryCore?.getEventRecordByFilter(filterEntry,
  onSuccess: (code, msg, eventData) => print('Event count: ${eventData.list?.length}'),
  onError: (code, msg) => print('Query failed: $msg'),
);

// Query event details
libraryCore?.getEventDetail(false, 'video_event_key',
  onSuccess: (code, msg, detail) {},
  onError: (code, msg) {},
);

// Download event resources
libraryCore?.downloadSource(tasks, false,
  onProgress: (progress) => print('Download progress: $progress'),
  onFinish: (path) => print('Download complete: $path'),
);

// Mark as read / bookmark
libraryCore?.setReadStatus(1, 'traceId', onSuccess: ..., onError: ...);
libraryCore?.setMarkStatus(1, 'traceId', onSuccess: ..., onError: ...);

BirdRecognizeCore - Bird Recognition #

BirdRecognizeCore.getInstance()?.getWikiCurrentBirdInfo(birdModel,
  onSuccess: (code, msg, bird) => print('Bird: ${bird.name}'),
  onError: (code, msg) => print('Query failed: $msg'),
);

Project Structure #

lib/
├── smart_device_core.dart       # SDK entry point
├── bind_core.dart               # Device binding module
├── bird_recognize_core.dart     # Bird recognition module
├── device_manage_core.dart      # Device management module
├── device_setting_core.dart     # Device settings module
├── device_sleep_plan_core.dart  # Sleep schedule module
├── library_core.dart            # Event library module
├── common/                      # Base communication layer
│   ├── sdk.dart
│   ├── sdk_method_channel.dart
│   ├── sdk_platform_interface.dart
│   └── callback_queue.dart
├── models/                      # Data models
│   ├── bird/
│   ├── device/
│   ├── library/
│   └── location/
├── video/                       # Video playback module
│   ├── video_player.dart        # Player abstract interface
│   ├── webrtc_player.dart       # WebRTC player
│   ├── ijk_player.dart          # IJK player
│   └── live_manager_instance.dart
└── view/
    └── surface_view.dart        # Native rendering view

Running the Example #

cd example
flutter pub get
flutter run

Changelog #

See CHANGELOG.md.

1
likes
85
points
114
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

Flutter Plugin SDK named smart_device_core

Homepage

License

unknown (license)

Dependencies

flutter, json_annotation, plugin_platform_interface, uuid

More

Packages that depend on smart_device_core

Packages that implement smart_device_core