summaryrefslogtreecommitdiff
path: root/libs/ihealth-sdk/module/AM5Module.js
blob: ab9f0aef7d8afcea62942369661f81a3f05d4178 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
'use strict';


var {
    NativeModules,
    DeviceEventEmitter
} = require('react-native');

var AM5ProfileModule = require('./AM5ProfileModule.js');

var RCTModule = NativeModules.AM5Module

/**
 * @module AM5Module
 */
module.exports = {

  Event_Notify: RCTModule.Event_Notify,

  /**
   * Binding apps and devices.
   * AM5 devices must be bound one-to-one. If you want to use other devices, you must unbind them first and then bind them to other devices.
   * @param {string} mac Device's mac address
   */
   bindDevice: function (mac) {
      RCTModule.bindDevice(mac)
  },

  /**
   * UnBind apps and devices.
   * @param {string} mac Device's mac address
   */
   unBindDevice: function (mac) {
      RCTModule.unBindDevice(mac)
  },

  /**
   * Get information of the device
   * @param {string} mac Device's mac address
   */
   getBasicInfo: function (mac) {
      RCTModule.getBasicInfo(mac)
   },

//   /**
//    * Set time of the device
//    * @param year   year
//    * @param month  month
//    * @param day    day
//    * @param hour   hour
//    * @param minute minute
//    * @param second second
//    * @param week   What day is today?  Effective Value 1-7
//    */
//    setTime: function (mac, year, month, day, minute, second, week) {
//     RCTModule.setTime(mac, year, month, day, minute, second, week)
//    },

   /**
    * Set current time of the device
    */
    setTime: function (mac) {
        RCTModule.setTime(mac)
    },

    /**
     * Get the live data of the device
     * @param {string} mac Device's mac address
     * @param year   Year of birth
     * @param month  Month of birth
     * @param day    Day of birth
     * @param weight weight
     * @param height height
     * @param gander gender male: 1, female: 2
    */
    setUserInfo: function (mac, year, month, day, weight, height, gander) {
        RCTModule.setUserInfo(mac, year, month, day, weight, height, gander)
    },

    /**
     * Set unit
     * When you never set them, treat them as defaults
     * @param {string} mac Device's mac address
     * @param type 0: Distance unit                 unit: 0 default ; 1 KM ; 2 MI
     * @param type 1: Wight unit                    unit: 0 default ; 1 KG ; 2 LB ; 3 ST
     * @param type 2: Temperature unit              unit: 0 default ; 1 °C ; 2 °F
     * @param type 3: Distance at each step         unit: distance (cm)      (default 0cm)
     * @param type 4: Language                      unit: 0 default ; 1 zh ; 2 en ; 3 fr ; 4 de ; 5 it ; 6 es ; 7 ja ; 8 po ; 9 cz
     * @param type 5: Time Mode                     unit: 0 default ; 1 24 hour system ; 2 12 hour system
     * @param type 6: Distance at each step of run  unit: distance (cm)      (default 0cm)
     * @param type 7: GPS calibration switch        unit: 0 default ; 1 open ; 2 close
    */
    setUnit: function (mac, type, unit) {
        RCTModule.setUnit(mac, type, unit)
    },

    /**
     * Reboot the device
     * @param {string} mac Device's mac address
     */
     reboot: function (mac) {
        RCTModule.reboot(mac)
    },

    /**
     * Set Hand Wear Mode
     * @param {string} mac Device's mac address
     * @param mode 0  left-hand   1 right-hand
     */
     setHandWearMode: function (mac, mode) {
        RCTModule.setHandWearMode(mac, mode)
    },

    /**
     * Get the live data of the device
     * @param {string} mac Device's mac address
     */
     getLiveData: function (mac) {
        RCTModule.getLiveData(mac)
    },

    /**
     * Sync health data from device
     * @param {string} mac Device's mac address
     */
     syncHealthData: function (mac) {
        RCTModule.syncHealthData(mac)
    },

    /**
     * Stop sync health data from device
     * @param {string} mac Device's mac address
     */
     stopSyncHealthData: function (mac) {
        RCTModule.stopSyncHealthData(mac)
    },

    /**
     * Get all connected AM4 device
     *
     * e.g. {"devices":["A4D5783FB00C","A4D5783FFE58"]}
     */
    getAllConnectedDevices: function () {
        RCTModule.getAllConnectedDevices()
    },
    
    disconnect: function (mac) {
       RCTModule.disconnect(mac)
   },
}