bitalino 1.1.0 copy "bitalino: ^1.1.0" to clipboard
bitalino: ^1.1.0 copied to clipboard

outdated

A Flutter plugin that integrates the communication with BITalino devices.

BITalino #

Open source Flutter plugin that integrates the communication with BITalino devices. Made by Afonso Raposo.

See the an example app here.

Tested with BITalino Core BT (MCU+BT+PWR) and BITalino Core BLE/BT.

Currently supporting: #

This plugin uses the available native APIs available at https://bitalino.com/en/development/apis.

Plaftorm Supported Native Repository Date
Android revolution-android-api Jul 16, 2020
IOS BITalinoBLE-iOS Jun 22, 2016

Installation #

Add this plugin to the pubspec.yaml file:

dependencies:
  flutter:
    sdk: flutter
  bitalino: ^1.1.0 // add bitalino plugin

Android #

Nothing specific required.

IOS #

On IOS, you have to add the following lines to the bottom of the /ios/Runner/Info.plist file:

<key>NSBluetoothAlwaysUsageDescription</key>
<string>This application needs access to bluetooth to communicate with BITalino device</string>

<key>NSBluetoothPeripheralUsageDescription</key>
<string>This application needs access to BLE to communicate with BITalino device</string>

Examples #

Initialize controller #

onDataAvailable is called everytime the application receives data during recording.

Android #

On Android, the user must provide the device MAC address and can choose between BTH or BLE for communication protocols. If available, BTH is advised.

BITalinoController bitalinoController = BITalinoController();
try {
  await bitalinoController.initialize(
    "20:16:07:18:17:02",
    CommunicationType.BTH,
    onDataAvailable: (BITalinoFrame frame) {
      print(frame.identifier);  // [String]
      print(frame.sequence);    // [int]
      print(frame.analog);      // [List<int>]
      print(frame.digital);     // [List<int>]
    },
  );
} on PlatformException catch (Exception) {
  print("Initialization failed: ${Exception.message}");
}

IOS #

On IOS, the user must provide the device UUID and can only use BLE regarding communication protocol.

The UUID can be found with this application: Bluetooth Smart Scanner .

On IOS, there is no frame identifier.

BITalinoController bitalinoController = BITalinoController();
try {
  await bitalinoController.initialize(
    "03A1C0AB-018F-5B39-9567-471DDE5B0322",
    CommunicationType.BLE,
    onDataAvailable: (BITalinoFrame frame) {
      print(frame.sequence);    // [int]
      print(frame.analog);      // [List<int>]
      print(frame.digital);     // [List<int>]
    },
  );
} on PlatformException catch (Exception) {
  print("Initialization failed: ${Exception.message}");
}

Connect to device #

Connect to a device by providing its address.

await bitalinoController.connect(
  onConnectionLost: () {
    print("Connection lost");
  },
)

Start acquisition #

Start acquiring analog channels: A0, A2, A4, and A5, with a Sampling Rate of 10Hz.

bool success = await bitalinoController.start(
  [0, 2, 4, 5],
  Frequency.HZ10),
);

During acquisiton, the onDataAvailable callback is called.

Stop acquisition #

bool success = await bitalinoController.stop();

Get the device state #

Android #

BITalinoState state = await bitalinoController.state();
print(state.identifier);        // [String]
print(state.battery);           // [int]
print(state.batteryThreshold);  // [int]
print(state.analog);            // [List<int>]
print(state.digital);           // [List<int>]

IOS #

This method is not available for IOS.

Disconnect from device #

bool success = await bitalinoController.disconnect();

Dispose controller #

When you're done using the controller, dispose it.

bool success = await bitalinoController.dispose();

More #

You can find all the information regarding this plugin on the API reference page.



Future #

If you have any suggestion or problem, let me know and I'll try to improve or fix it. Also, feel free to contribute to this project! :)

Versioning #

  • v1.0.1 - 14 August 2020
  • v1.0.0 - 14 August 2020
  • v0.0.6 - 19 July 2020
  • v0.0.5 - 19 July 2020
  • v0.0.4 - 19 July 2020
  • v0.0.3 - 18 July 2020
  • v0.0.2 - 18 July 2020
  • v0.0.1 - 18 July 2020

License #

GNU General Public License v3.0, see the LICENSE.md file for details.

3
likes
0
pub points
0%
popularity

Publisher

verified publisherscientisst.com

A Flutter plugin that integrates the communication with BITalino devices.

Homepage
Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter

More

Packages that depend on bitalino