summaryrefslogtreecommitdiff
path: root/libs/ihealth-sdk/doc/pt3sbt.md
diff options
context:
space:
mode:
Diffstat (limited to 'libs/ihealth-sdk/doc/pt3sbt.md')
-rw-r--r--libs/ihealth-sdk/doc/pt3sbt.md142
1 files changed, 142 insertions, 0 deletions
diff --git a/libs/ihealth-sdk/doc/pt3sbt.md b/libs/ihealth-sdk/doc/pt3sbt.md
new file mode 100644
index 0000000..97f2296
--- /dev/null
+++ b/libs/ihealth-sdk/doc/pt3sbt.md
@@ -0,0 +1,142 @@
1# PT3SBT Workflow
2
3## Import PT3SBT Module
4
5```js
6import {
7 PT3SBTModule,
8 PT3SBTProfileModule
9} from '@ihealth/ihealthlibrary-react-native';
10```
11
12## APIs
13
14### Add and remove listener
15
16```js
17// add
18notifyListener = DeviceEventEmitter.addListener(PT3SBTModule.Event_Notify, (event) => {
19 console.log(event);
20});
21
22// remove
23notifyListener.remove();
24```
25
26### set time
27
28```js
29PT3SBTModule.setTime(mac);
30
31// response
32// {status: "success", type: "PT3SBT", mac: "004D320C41BE", action: "action_set_time"}
33notifyListener = DeviceEventEmitter.addListener(PT3SBTModule.Event_Notify, (event) => {
34 if (event.action === PT3SBTProfileModule.ACTION_SET_TIME) {
35 console.log(event[NT13BProfileModule.STATUS]);
36 }
37});
38```
39
40### get battery
41
42```js
43PT3SBTModule.getBattery(mac);
44
45// response
46// { battery: 70, type: "PT3SBT", mac: "004D320C41BE", action: "action_get_battery"}
47notifyListener = DeviceEventEmitter.addListener(PT3SBTModule.Event_Notify, (event) => {
48 if (event.action === PT3SBTProfileModule.ACTION_GET_BATTERY) {
49 console.log(event[PT3SBTProfileModule.BATTERY]);
50 }
51});
52```
53
54### set unit
55
56```js
57// 1: centigrade, 2: fahrenheit
58PT3SBTModule.setUnit(mac, unit);
59
60// response
61// {status: "success", type: "PT3SBT", mac: "004D320C41BE", action: "action_set_unit"}
62notifyListener = DeviceEventEmitter.addListener(PT3SBTModule.Event_Notify, (event) => {
63 if (event.action === PT3SBTProfileModule.ACTION_SET_UNIT) {
64 console.log(event[PT3SBTProfileModule.STATUS]);
65 }
66});
67```
68
69### get unit
70
71```js
72PT3SBTModule.getUnit(mac);
73
74// response
75// {unit: 2, type: "PT3SBT", mac: "004D320C41BE", action: "action_get_unit"}
76notifyListener = DeviceEventEmitter.addListener(PT3SBTModule.Event_Notify, (event) => {
77 if (event.action === PT3SBTProfileModule.ACTION_GET_UNIT) {
78 console.log(event[PT3SBTProfileModule.UNIT]);
79 }
80});
81```
82
83### get history data count
84
85```js
86PT3SBTModule.getHistoryCount(mac);
87
88// response
89// {count: 37, type: "PT3SBT", mac: "004D320C41BE", action: "action_get_history_count"}
90notifyListener = DeviceEventEmitter.addListener(PT3SBTModule.Event_Notify, (event) => {
91 if (event.action === PT3SBTProfileModule.ACTION_GET_HISTORY_COUNT) {
92 console.log(event[PT3SBTProfileModule.COUNT]);
93 }
94});
95```
96
97### get history data
98
99**Note: After call get history data, must to delele history data. If don't, the PT3SBT will keep on offline mode.**
100
101```js
102PT3SBTModule.getHistoryData(mac);
103
104// response
105// {history: Array, type: "PT3SBT", mac: "004D320C41BE", action: "action_get_history_data"}
106notifyListener = DeviceEventEmitter.addListener(PT3SBTModule.Event_Notify, (event) => {
107 if (event.action === PT3SBTProfileModule.ACTION_GET_HISTORY_DATA) {
108 const arr = event[PT3SBTProfileModule.HISTORY];
109 arr.foreach(item => {
110 console.log(item[PT3SBTProfileModule.TEMPERATURE]);
111 console.log(item[PT3SBTProfileModule.TS]);
112 })
113 }
114});
115```
116
117### delete history data
118
119```js
120PT3SBTModule.deleteHistoryData(mac);
121
122// response
123// {status: "success", type: "PT3SBT", mac: "004D320C41BE", action: "action_delete_history_data"}
124notifyListener = DeviceEventEmitter.addListener(PT3SBTModule.Event_Notify, (event) => {
125 if (event.action === PT3SBTProfileModule.ACTION_DELETE_HISTORY_DATA) {
126 console.log(event[PT3SBTProfileModule.STATUS]);
127 }
128});
129```
130
131### online measurement
132
133```js
134// response
135// {Tbody: 3845", type: "PT3SBT", mac: "004D320C41BE", action: "action_temperature_measurement"}
136// the real temperature is Tbody / 100, this is centigrade
137notifyListener = DeviceEventEmitter.addListener(PT3SBTModule.Event_Notify, (event) => {
138 if (event.action === PT3SBTProfileModule.ACTION_TEMPERATURE_MEASUREMENT) {
139 console.log(event[PT3SBTProfileModule.TEMPERATURE]);
140 }
141});
142```