dexcom 1.0.6
dexcom: ^1.0.6 copied to clipboard
dexcom for Dart allows you to use Dexcom Share to get your Dexcom CGM data, or anybody else's, to run your application.
import 'dart:io';
import 'package:dexcom/dexcom.dart';
void main({String username = "", String password = ""}) async {
// If DEXCOM_DEBUG is enabled (set to "true" or is greater than 0), then enable debug logging.
String debug = Platform.environment['DEXCOM_DEBUG'] ?? "false";
// Set up the main [dexcom] object
Dexcom dexcom = Dexcom(
username: username,
password: password,
debug: debug == "true" || (int.tryParse(debug) ?? 0) > 0,
);
// Set up the listener (provider)
DexcomStreamProvider provider = DexcomStreamProvider(
dexcom,
debug: true,
buffer: 10,
);
print("Dexcom: $dexcom");
print("Provider: $provider");
print("Dexcom readings: ${await dexcom.getGlucoseReadings(maxCount: 3)}");
print("Dexcom verify: ${await dexcom.verify()}");
// Listen to the provider
provider.listen(
onData: (data) => print('Stream received: $data'),
onError: (error) => print('Stream errored: $error'),
onTimerChange: (time) => print("Stream timer: $time"),
onRefresh: () => print("Stream refresh"),
onRefreshEnd:
(time) => print("Stream refresh ended after ${time.inMilliseconds}ms"),
);
// Listen for key inputs
stdin.echoMode = false;
stdin.lineMode = false;
stdin.listen((List<int> data) {
for (int byte in data) {
String char = String.fromCharCode(byte);
print("Received character: $char");
switch (char) {
case "r":
provider.refresh();
break;
}
}
});
}