rtl_ir_control 0.0.1-dev.2 copy "rtl_ir_control: ^0.0.1-dev.2" to clipboard
rtl_ir_control: ^0.0.1-dev.2 copied to clipboard

Remotec IR Control package

rtl_ir_control #

A Flutter package for controlling infrared (IR) devices via Bluetooth. This package leverages esp_blufi and flutter_blue_plus to set up and manage Bluetooth Low Energy (BLE) connections and download ir code from remotec cloud database to device.

Features #

  • Device scanning and connection management using BLE.
  • Blufi setup for Roomate devices.
  • Downloading IR codesets for device control.

Dependencies #

This package relies on the following external packages:

  • esp_blufi: For BLE communication with ESP-based devices.
  • flutter_blue_plus: For Bluetooth Low Energy operations on Android and iOS.

Platform Support #

  • Android: Requires Bluetooth permissions.
  • iOS: Requires Bluetooth permissions and proper configuration in Info.plist.

Note: This package does not support web or desktop platforms due to Bluetooth limitations.

Getting Started #

Add Bluetooth Permissions #

To use this package, you must configure Bluetooth permissions for your Flutter app. Below are the steps for Android and iOS.

Android #

Add the following permissions to your AndroidManifest.xml (located at android/app/src/main/AndroidManifest.xml):

<!-- Tell Google Play Store that your app uses Bluetooth LE
     Set android:required="true" if bluetooth is necessary -->
<uses-feature android:name="android.hardware.bluetooth_le" android:required="false" />

<!-- New Bluetooth permissions in Android 12
https://developer.android.com/about/versions/12/features/bluetooth-permissions -->
<uses-permission android:name="android.permission.BLUETOOTH_SCAN"/>
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

<!-- legacy for Android 11 or lower -->
<uses-permission android:name="android.permission.BLUETOOTH" android:maxSdkVersion="30" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" android:maxSdkVersion="30" />

<!-- legacy for Android 9 or lower -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" android:maxSdkVersion="28" />

iOS #

Add permissions for iOS In the ios/Runner/Info.plist let’s add:

<dict>
    <key>NSBluetoothAlwaysUsageDescription</key>
    <string>This app needs Bluetooth to function</string>
</dict>

To us ble in app background, add the following to your Info.plist

<dict>
<key>UIBackgroundModes</key>
<array>
    <string>bluetooth-central</string>
</array>
</dict>

Usage #

1. Scan Devices #

Scan for Roomate devices using a name prefix filter.

import 'package:rtl_ir_control/rtl_ir_control.dart';

void scanDevices() {
  _rtlIrControlPlugin.startScan(namePrefix: ['Roomate']);
}

2. Setup Device #

Connect to a device, scan for Wi-Fi networks, and configure Wi-Fi credentials.

import 'package:rtl_ir_control/rtl_ir_control.dart';

Future<void> setupDevice(String id) async {
  final blufi = RTLBlufiSetupUtils();

  // Set the device ID (MAC address)
  await blufi.setCurrentId(id);

  // Connect to the device
  await blufi.connect();

  // Get available Wi-Fi networks
  var list = await blufi.scanWifiList();

  // Example: Select a Wi-Fi network (implement your own UI/logic)
  var ssid = await selectWifi(list); // Custom method to pick from list

  // Example: Get password from user input (implement your own UI/logic)
  var password = await inputPassword(ssid); // Custom method to get password

  // Configure Wi-Fi credentials
  await blufi.configProvision(ssid: ssid, password: password);
}

// Placeholder functions (implement these based on your UI)
Future<String> selectWifi(List<String> wifiList) async {
  return wifiList.first;
}

Future<String> inputPassword(String ssid) async {
  return "your_password";
}

3. Download IR Codes #

import 'package:rtl_ir_control/rtl_ir_control.dart';

Future<void> downloadCodes(String id, String apiJson) async {
  // Parse IR codeset from API response
  RTLIrCodeset codeset = RTLIrCodeset.fromApiJson(apiJson);

  // Get the device instance
  var device = RtlIrControl().getDevice(id);

  // Connect to the device
  await device.connect();

  // Create Roomate device handler
  RoomateDeviceHandler roomateDeviceHandler = RoomateDeviceHandler(device);

  // Download codeset and listen to progress
  roomateDeviceHandler
      .downloadCodeFromCodeset(1, "1", codeset)
      .listen((progress) {
        print("Download progress: $progress%");
      });
}
0
likes
0
points
54
downloads

Publisher

unverified uploader

Weekly Downloads

Remotec IR Control package

Homepage

License

unknown (license)

Dependencies

async, esp_blufi, flutter, flutter_blue_plus, permission_handler, plugin_platform_interface

More

Packages that depend on rtl_ir_control