@tryvital/vital-devices-react-native 0.3.0 → 0.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.d.ts ADDED
@@ -0,0 +1,25 @@
1
+ import type { DeviceModel } from './model/device_model';
2
+ import { DeviceKind } from './model/device_model';
3
+ import { Brand } from './model/brand';
4
+ export declare const VitalDevicesNativeModule: any;
5
+ export declare const VitalDevicesEvents: {
6
+ scanEvent: string;
7
+ pairEvent: string;
8
+ glucoseMeterReadEvent: string;
9
+ bloodPressureReadEvent: string;
10
+ };
11
+ export declare class VitalDevicesManager {
12
+ scanForDevice(deviceModel: DeviceModel): Promise<any>;
13
+ stopScan(): Promise<any>;
14
+ pairDevice(scannedDeviceId: string): Promise<any>;
15
+ readBloodPressure(scannedDeviceId: string): Promise<any>;
16
+ readGlucoseMeter(scannedDeviceId: string): Promise<any>;
17
+ private checkPermission;
18
+ static brands: Brand[];
19
+ static supportedDevices: {
20
+ id: string;
21
+ name: string;
22
+ brand: Brand;
23
+ kind: DeviceKind;
24
+ }[];
25
+ }
package/lib/index.js ADDED
@@ -0,0 +1,122 @@
1
+ import { DeviceKind } from './model/device_model';
2
+ import { NativeModules, Platform } from 'react-native';
3
+ import { checkMultiple, PERMISSIONS } from 'react-native-permissions';
4
+ import { Brand } from './model/brand';
5
+ const LINKING_ERROR = `The package 'vital-core-react-native' doesn't seem to be linked. Make sure: \n\n` +
6
+ Platform.select({ ios: "- You have run 'pod install'\n", default: '' }) +
7
+ '- You rebuilt the app after installing the package\n' +
8
+ '- You are not using Expo Go\n';
9
+ const VitalDevicesReactNative = NativeModules.VitalDevicesReactNative
10
+ ? NativeModules.VitalDevicesReactNative
11
+ : new Proxy({}, {
12
+ get() {
13
+ throw new Error(LINKING_ERROR);
14
+ },
15
+ });
16
+ export const VitalDevicesNativeModule = VitalDevicesReactNative;
17
+ export const VitalDevicesEvents = {
18
+ scanEvent: 'ScanEvent',
19
+ pairEvent: 'PairEvent',
20
+ glucoseMeterReadEvent: 'GlucoseMeterReadEvent',
21
+ bloodPressureReadEvent: 'BloodPressureReadEvent',
22
+ };
23
+ export class VitalDevicesManager {
24
+ async scanForDevice(deviceModel) {
25
+ await this.checkPermission();
26
+ return NativeModules.VitalDevicesReactNative.startScanForDevice(deviceModel.id, deviceModel.name, deviceModel.brand, deviceModel.kind);
27
+ }
28
+ async stopScan() {
29
+ return NativeModules.VitalDevicesReactNative.stopScanForDevice();
30
+ }
31
+ async pairDevice(scannedDeviceId) {
32
+ await this.checkPermission();
33
+ return NativeModules.VitalDevicesReactNative.pair(scannedDeviceId);
34
+ }
35
+ async readBloodPressure(scannedDeviceId) {
36
+ await this.checkPermission();
37
+ return NativeModules.VitalDevicesReactNative.startReadingBloodPressure(scannedDeviceId);
38
+ }
39
+ async readGlucoseMeter(scannedDeviceId) {
40
+ await this.checkPermission();
41
+ return NativeModules.VitalDevicesReactNative.startReadingGlucoseMeter(scannedDeviceId);
42
+ }
43
+ async checkPermission() {
44
+ if (Platform.OS === 'ios') {
45
+ const result = await checkMultiple([
46
+ PERMISSIONS.IOS.BLUETOOTH_PERIPHERAL,
47
+ ]);
48
+ if (result[PERMISSIONS.IOS.BLUETOOTH_PERIPHERAL] !== 'granted') {
49
+ throw new Error('Bluetooth permission is not granted. Please check your settings.');
50
+ }
51
+ }
52
+ else {
53
+ const result = await checkMultiple([
54
+ PERMISSIONS.ANDROID.BLUETOOTH_SCAN,
55
+ PERMISSIONS.ANDROID.BLUETOOTH_CONNECT,
56
+ ]);
57
+ if (result[PERMISSIONS.ANDROID.BLUETOOTH_SCAN] !== 'granted') {
58
+ throw new Error('Bluetooth scan permission is not granted');
59
+ }
60
+ if (result[PERMISSIONS.ANDROID.BLUETOOTH_CONNECT] !== 'granted') {
61
+ throw new Error('Bluetooth connect permission is not granted');
62
+ }
63
+ }
64
+ }
65
+ static brands = [
66
+ Brand.Omron,
67
+ Brand.AccuChek,
68
+ Brand.Contour,
69
+ Brand.Beurer,
70
+ Brand.Libre,
71
+ ];
72
+ static supportedDevices = [
73
+ {
74
+ id: 'omron_m4',
75
+ name: 'Omron Intelli IT M4',
76
+ brand: Brand.Omron,
77
+ kind: DeviceKind.BloodPressure,
78
+ },
79
+ {
80
+ id: 'omron_m7',
81
+ name: 'Omron Intelli IT M7',
82
+ brand: Brand.Omron,
83
+ kind: DeviceKind.BloodPressure,
84
+ },
85
+ {
86
+ id: 'accuchek_guide',
87
+ name: 'Accu-Chek Guide',
88
+ brand: Brand.AccuChek,
89
+ kind: DeviceKind.GlucoseMeter,
90
+ },
91
+ {
92
+ id: 'accuchek_guide_me',
93
+ name: 'Accu-Chek Guide Me',
94
+ brand: Brand.AccuChek,
95
+ kind: DeviceKind.GlucoseMeter,
96
+ },
97
+ {
98
+ id: 'accuchek_guide_active',
99
+ name: 'Accu-Chek Active',
100
+ brand: Brand.AccuChek,
101
+ kind: DeviceKind.GlucoseMeter,
102
+ },
103
+ {
104
+ id: 'contour_next_one',
105
+ name: 'Contour Next One',
106
+ brand: Brand.Contour,
107
+ kind: DeviceKind.GlucoseMeter,
108
+ },
109
+ {
110
+ id: 'beurer',
111
+ name: 'Beurer Devices',
112
+ brand: Brand.Beurer,
113
+ kind: DeviceKind.BloodPressure,
114
+ },
115
+ {
116
+ id: 'libre1',
117
+ name: 'Freestyle Libre 1',
118
+ brand: Brand.Libre,
119
+ kind: DeviceKind.GlucoseMeter,
120
+ },
121
+ ];
122
+ }
@@ -0,0 +1,7 @@
1
+ export declare enum Brand {
2
+ Omron = "omron",
3
+ AccuChek = "accuChek",
4
+ Contour = "contour",
5
+ Beurer = "beurer",
6
+ Libre = "libre"
7
+ }
@@ -0,0 +1,8 @@
1
+ export var Brand;
2
+ (function (Brand) {
3
+ Brand["Omron"] = "omron";
4
+ Brand["AccuChek"] = "accuChek";
5
+ Brand["Contour"] = "contour";
6
+ Brand["Beurer"] = "beurer";
7
+ Brand["Libre"] = "libre";
8
+ })(Brand || (Brand = {}));
@@ -0,0 +1,11 @@
1
+ import type { Brand } from './brand';
2
+ export declare enum DeviceKind {
3
+ BloodPressure = "bloodPressure",
4
+ GlucoseMeter = "glucoseMeter"
5
+ }
6
+ export interface DeviceModel {
7
+ id: string;
8
+ name: string;
9
+ brand: Brand;
10
+ kind: DeviceKind;
11
+ }
@@ -0,0 +1,5 @@
1
+ export var DeviceKind;
2
+ (function (DeviceKind) {
3
+ DeviceKind["BloodPressure"] = "bloodPressure";
4
+ DeviceKind["GlucoseMeter"] = "glucoseMeter";
5
+ })(DeviceKind || (DeviceKind = {}));
@@ -0,0 +1,6 @@
1
+ import type { DeviceModel } from './device_model';
2
+ export interface ScannedDevice {
3
+ id: string;
4
+ name: string;
5
+ deviceModel: DeviceModel;
6
+ }
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tryvital/vital-devices-react-native",
3
- "version": "0.3.0",
3
+ "version": "0.3.2",
4
4
  "description": "Client to access Vital's Endpoints",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -17,7 +17,7 @@ Pod::Spec.new do |s|
17
17
  s.source_files = "ios/**/*.{h,m,mm,swift}"
18
18
 
19
19
  s.dependency "React-Core"
20
- s.dependency "VitalDevices", "~> 0.7.11"
20
+ s.dependency "VitalDevices", "~> 0.7.13"
21
21
 
22
22
  # Don't install the dependencies when we run `pod install` in the old architecture.
23
23
  if ENV['RCT_NEW_ARCH_ENABLED'] == '1' then