senseh_sdk 0.0.2 copy "senseh_sdk: ^0.0.2" to clipboard
senseh_sdk: ^0.0.2 copied to clipboard

The Sense SDK is a powerful toolkit that allows developers to seamlessly connect and interact with Sense devices within their Flutter applications.

example/lib/main.dart

// ignore_for_file: use_build_context_synchronously

import 'package:example/snack_bar.dart';
import 'package:flutter/material.dart';
import 'package:senseh_sdk/senseh_sdk.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'SENSE SDK',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      debugShowCheckedModeBanner: false,
      home: const MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key, required this.title});

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  SenseH senseH = SenseH();

  instance() async {
    final obj = await senseH.instance(
        apiKey: "ZNFZTXY-93JMZVK-GSR1AV4-C6QSC8H",
        name: "karthik M",
        patientId: "1234abcd",
        dob: "1998-10-30",
        gender: "Male");
    print("instance $obj");
  }

//disconnect to Sense device
  disconnectSenseH() async {
    senseH.disconnectSenseH().then((response) {
      print(response);
    });
  }

  // takeTest() async {
  //   await senseH.takeTest();
  // }

  dataSync() async {
    await senseH.dataSync();
    senseH.dataSyncPercentageController.stream.listen((event) {
      print("In TPA $event");
    });
  }

  fetchBP() async {
    final data = await senseH.fetchBP(
        patientId: "1234abcd", period: 'month', pageIndex: '0', limit: '5');
    print(data);
  }

  fetchSpo2() async {
    final data = await senseH.fetchSP02(
        patientId: "1234abcd", period: 'month', pageIndex: '0', limit: '5');
    print(data);
  }

  fetchEcg1() async {
    final data = await senseH.fetchECG1(
        patientId: "1234abcd", period: 'month', pageIndex: '0', limit: '5');
    print(data);
  }

  fetchEcg6() async {
    final data = await senseH.fetchECG6(
        patientId: "1234abcd", period: 'month', pageIndex: '0', limit: '5');
    print(data);
  }

  fetchEcg12() async {
    final data = await senseH.fetchBP(
        patientId: "1234abcd", period: 'month', pageIndex: '0', limit: '5');
    print(data);
  }

  fetchReport() async {
    final data = await senseH.fetchReport(patientId: "1234abcd");
    print(data);
  }

  checkOtaUpdates() async {
    final data = await senseH.checkForFirmwareUpdate();
  }

  @override
  void initState() {
    super.initState();
  }

  @override
  void dispose() {
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          title: const Text("SENSE SDK TEST"),
        ),
        body: Center(
            child: Column(
          children: [
            Center(
              child: ElevatedButton(
                onPressed: () {
                  instance();
                },
                child: const Text("Instance"),
              ),
            ),
            Center(
              child: ElevatedButton(
                onPressed: () async {
                  final status = await senseH.findAndConnectSenseH();
                  print("Connection Status :  $status");
                  Snack.pop(context, status.toString());
                },
                child: const Text("Find and Connect"),
              ),
            ),
            Center(
              child: ElevatedButton(
                onPressed: () {
                  disconnectSenseH();
                },
                child: const Text("Disconnect"),
              ),
            ),
            Center(
              child: ElevatedButton(
                onPressed: () async {
                  await senseH.dataSync();
                  senseH.dataSyncPercentageController.stream.listen(
                    (event) {
                      Snack.pop(context, event.toString());
                    },
                    onDone: () => dispose(),
                  );
                },
                child: const Text("Sync data"),
              ),
            ),
            Row(
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: [
                Center(
                  child: ElevatedButton(
                    onPressed: () async {
                      await fetchBP();
                    },
                    child: const Text("Fetch BP"),
                  ),
                ),
                Center(
                  child: ElevatedButton(
                    onPressed: () async {
                      await fetchSpo2();
                    },
                    child: const Text("Fetch Spo2"),
                  ),
                ),
                Center(
                  child: ElevatedButton(
                    onPressed: () async {
                      await fetchEcg1();
                    },
                    child: const Text("Fetch ECG1"),
                  ),
                ),
              ],
            ),
            Row(
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: [
                Center(
                  child: ElevatedButton(
                    onPressed: () async {
                      await fetchEcg6();
                    },
                    child: const Text("Fetch ECG6"),
                  ),
                ),
                Center(
                  child: ElevatedButton(
                    onPressed: () async {
                      await fetchEcg12();
                    },
                    child: const Text("Fetch ECG12"),
                  ),
                ),
                Flexible(
                  child: Center(
                    child: ElevatedButton(
                      onPressed: () async {
                        await fetchReport();
                      },
                      child: const Text("Generate Report"),
                    ),
                  ),
                ),
              ],
            ),
            Row(
              children: [
                Flexible(
                  child: Center(
                    child: ElevatedButton(
                      onPressed: () async {
                        await checkOtaUpdates();
                      },
                      child: const Text("Check Updates"),
                    ),
                  ),
                ),
                Center(
                  child: ElevatedButton(
                    onPressed: () async {
                      await checkOtaUpdates();
                    },
                    child: const Text("Update firmware"),
                  ),
                ),
              ],
            ),
          ],
        )));
  }
}
0
likes
120
points
45
downloads

Publisher

unverified uploader

Weekly Downloads

The Sense SDK is a powerful toolkit that allows developers to seamlessly connect and interact with Sense devices within their Flutter applications.

Homepage
Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (license)

Dependencies

connectivity_plus, dio, flutter, flutter_blue_plus, intl, logger, permission_handler, shared_preferences, wifi_iot

More

Packages that depend on senseh_sdk