moyoung_ble_plugin 0.0.3 copy "moyoung_ble_plugin: ^0.0.3" to clipboard
moyoung_ble_plugin: ^0.0.3 copied to clipboard

A Flutter plugin for communicating with the watch. Includes the following features: Scan BLE device,Connect,Time,Firmware,Battery,User Info,Weather,Steps,Sleep,Unit system,Quick view, Goal steps,Watch [...]

MoYoung Ble Plugin #

Welcome to use this plugin. This is a Flutter plugin for communicating with the watch.

Platform Support #

Android iOS
✔️ ✔️

Usage #

To use this plugin, add moyoung_ble_plugin as a dependency in your pubspec.yaml file.

moyoung_ble_plugin: ^latestVersion

#

Project configuration #

  • Android

Perform the following configuration when generating apk for code obfuscation. Please add the following configuration to your proguard-rules.pro file.

-keep class com.crrepa.ble.** { *; }
-keep class com.moyoung.moyoung_ble_plugin.** { *; }
  • IOS

1.You need to add it to the info.plist .

<key>NSAppTransportSecurity</key>
<dict>
    <key>NSAllowsArbitraryLoads</key>
    <true/>
</dict>
<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string>Use the location to sync weather from your phone to your watch.</string>
<key>NSBluetoothAlwaysUsageDescription</key>
<string>Use the Bluetooth to connect to your Nokia Watch</string>
<key>NSCalendarsUsageDescription</key>
<string>Use the calendar to sync events from your phone to your watch.</string>
<key>NSCameraUsageDescription</key>
<string>Use the camera to scan the QR code on your watch screen.</string>
<key>NSContactsUsageDescription</key>
<string>The selected contacts will be added to your Watch contacts.</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>Use the Photo to change your watch face.</string>
<key>UIApplicationSupportsIndirectInputEvents</key>
<true/>
<key>UIBackgroundModes</key>
<array>
<string>bluetooth-central</string>
</array>

2.Use terminal, in your path for project,use pod install to import the library.

Example #

  • First setp

    Import package.

    import 'package:moyoung_ble_plugin/moyoung_ble.dart';
    
  • Second step

    Apply for some permissions: [location, storage].

    Tips: You can use the example in the Example project to apply for permissions.

  • Third step

    Use in pages.

    class _MyAppState extends State<MyApp> {
      final _streamSubscriptions = <StreamSubscription<dynamic>>[];
      final MoYoungBle _blePlugin = MoYoungBle();
      final List<BleScanBean> _deviceList = [];
      
      @override
      void initState() {
        super.initState();
        subscriptStream();
      }
      
      void subscriptStream() {
        _streamSubscriptions.add(
          _blePlugin.bleScanEveStm.listen(
            (BleScanBean event) async {
              setState(() {
                if (event.isCompleted) {
                  //Scan completed, do something
                } else {
                  _deviceList.add(event);
                }
              });
            },
          ),
        );
      }
      
      @override
      void dispose() {
        super.dispose();
        for (final subscription in _streamSubscriptions) {
          subscription.cancel();
        }
      }
      
      // Scanning bluetooth devices
      void startScan() {
        if (!mounted) return;
        _blePlugin.startScan(10*1000).then((value) => {
          setState(() {
            // Do something.
            print(value ? "Scanning" : "Have not started");
          })
        }).onError((error, stackTrace) => {
          //Usually some permissions are not requested
          print(error.toString())
        });
      }
    }
    

Detailed usage document #

Please click to Wiki.

GNU GENERAL PUBLIC LICENSE License #

Please click to License.

4
likes
0
pub points
71%
popularity

Publisher

verified publishermoyoung.com

A Flutter plugin for communicating with the watch. Includes the following features: Scan BLE device,Connect,Time,Firmware,Battery,User Info,Weather,Steps,Sleep,Unit system,Quick view, Goal steps,Watchface,Alarm, Language,Notification, Sedentary reminder,Find the watch,Heart rate, Blood pressure,Blood oxygen,Take a photo,Mobile phone related operations,RSSI,Shut down,Do not disturb, Breathing light,ECG,Physiological cycle,Find phone ……. more than 50 functional modules

Homepage
Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

flutter, logger

More

Packages that depend on moyoung_ble_plugin