open_earable_flutter

Last updated:

0 purchases

open_earable_flutter Image
open_earable_flutter Images
Add to Cart

Description:

open earable flutter

OpenEarable Flutter #




This Dart package provides functionality for interacting with OpenEarable devices. It enables you to communicate with OpenEarable devices, control LED colors, control audio, and access raw sensor data.
  Get OpenEarable device now!  
Show library on pub.dev
Permissions #
For your app to be able to use Flutter reactive BLE in this package, you need to grant the following permissions:
Android #
You need to add the following permissions to your AndroidManifest.xml file:
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" android:usesPermissionFlags="neverForLocation" />
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" android:maxSdkVersion="30" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" android:maxSdkVersion="30" />
copied to clipboard
If you use BLUETOOTH_SCAN to determine location, modify your AndroidManfiest.xml file to include the following entry:
<uses-permission android:name="android.permission.BLUETOOTH_SCAN"
tools:remove="android:usesPermissionFlags"
tools:targetApi="s" />
copied to clipboard
If you use location services in your app, remove android:maxSdkVersion="30" from the location permission tags
Android ProGuard rules #
In case you are using ProGuard add the following snippet to your proguard-rules.pro file:
-keep class com.signify.hue.** { *; }
copied to clipboard
This will prevent issues like #131.
iOS #
For iOS it is required you add the following entries to the Info.plist file of your app. It is not allowed to access Core BLuetooth without this. See our example app on how to implement this. For more indepth details: Blog post on iOS bluetooth permissions
iOS 13 and higher

NSBluetoothAlwaysUsageDescription

iOS 12 and lower

NSBluetoothPeripheralUsageDescription

Getting Started #
To get started with the OpenEarable Flutter package, follow these steps:

Installation: Add the package to your flutter project: \

flutter pub add open_earable_flutter
copied to clipboard
Alternatively, you can follow the instructions on pub.dev

Import the package:

import 'package:open_earable_flutter/open_earable_flutter.dart';
copied to clipboard

Initialize OpenEarable

final openEarable = OpenEarable();
copied to clipboard

Connect to Earable Device

openEarable.bleManager.startScan();

// Listen for discovered devices
openEarable.bleManager.scanStream.listen((device) {
// Handle discovered device
});

// Connect to a device
openEarable.bleManager.connectToDevice(device);

copied to clipboard
Usage #

Read device information after connecting to a device:
String? deviceName = openEarable.deviceName;
String? deviceIdentifier = openEarable.deviceIdentifier;
String? deviceFirmwareVersion = openEarable.deviceFirmwareVersion;
copied to clipboard

Sensors:

Configuration of Sensors:
var config = OpenEarableSensorConfig(sensorId: 0, samplingRate: 30, latency: 0);
openEarable.sensorManager.writeSensorConfig(config);
copied to clipboard
Please refer to open-earable for a documentation on all possible sensor configurations

Subscribing to sensor data with sensor id 0
openEarable.sensorManager.subscribeToSensorData(0).listen((data) {
// Handle sensor data
});
copied to clipboard
Sensor data is returned as a dictionary:
{
"sensorId": 0,
"timestamp": 163538,
"sensorName": "ACC_GYRO_MAG",
"ACC": {
"units": {"X": "g", "Y": "g", "Z": "g"},
"X": 5.255882263183594,
"Y": -2.622856855392456,
"Z": 8.134146690368652
},
"GYRO": {
"units": {"X": "dps", "Y": "dps", "Z": "dps"},
"X": 0.007621999830007553,
"Y": -0.030487999320030212,
"Z": -0.015243999660015106
},
"MAG": {
"units": {"X": "uT", "Y": "uT", "Z": "uT"},
"X": -566.1000366210938,
"Y": -95.70000457763672,
"Z": -117.30000305175781
}
"EULER": {
"units": {"ROLL": "rad", "PITCH": "rad", "YAW": "rad"},
"ROLL": 0.8741,
"PITCH": -0.2417,
"YAW": 1.2913
}
}
copied to clipboard

Battery Level percentage:
Stream batteryLevelStream = openEarable.sensorManager.getBatteryLevelStream();
copied to clipboard

Button State:
Stream buttonStateStream = openEarable.sensorManager.getButtonStateStream();
copied to clipboard

contains the following button states as integers:

0: Idle
1: Pressed
2: Held








Control built-in LED:
openEarable.rgbLed.writeLedColor(r: 0, g: 255, b: 0);
copied to clipboard

Control audio player:

Play WAV files
openEarable.audioPlayer.wavFile("audio.wav");
openEarable.audioPlayer.setState(AudioPlayerState.start);
copied to clipboard

name: filename of audio file stored on earable


Play Frequency:
int waveForm = 1;
double frequency = 500.0;
double loudness = 0.5;
openEarable.audioPlayer.frequency(waveForm, frequency, loudness);
openEarable.audioPlayer.setState(AudioPlayerState.start);
copied to clipboard

state: WavAudioPlayerState

frequency: double
waveForm: int

0: sine
1: triangle
2: square
3: sawtooth


loudness: double between 0.0 and 1.0


Play Jingle:
int jingleId = 1;
openEarable.audioPlayer.jingle(jingleId);
openEarable.audioPlayer.setState(AudioPlayerState.start);
copied to clipboard

jingleId: id of jingle stored on earable
0: 'IDLE'

1: 'NOTIFICATION'
2: 'SUCCESS'
3: 'ERROR'
4: 'ALARM'
5: 'PING'
6: 'OPEN'
7: 'CLOSE'
8: 'CLICK'

License:

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.