-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathcgmpage.go
53 lines (45 loc) · 1.28 KB
/
cgmpage.go
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
package medtronic
const (
// MaxGlucosePages is the maximum number of glucose history pages.
MaxGlucosePages = 32
)
// GlucosePage downloads the given glucose page.
func (pump *Pump) GlucosePage(page int) []byte {
return pump.Download(glucosePage, page)
}
// ISIGPage downloads the given ISIG page.
func (pump *Pump) ISIGPage(page int) []byte {
return pump.Download(isigPage, page)
}
// VcntrPage downloads the given vcntr page.
func (pump *Pump) VcntrPage(page int) []byte {
return pump.Download(vcntrPage, page)
}
// CalibrationFactor returns the CGM calibration factor.
func (pump *Pump) CalibrationFactor() int {
data := pump.Execute(calibrationFactor)
if pump.Error() != nil {
return 0
}
if len(data) < 3 || data[0] != 2 {
pump.BadResponse(calibrationFactor, data)
return 0
}
return int(twoByteUint(data[1:3]))
}
// CGMCurrentGlucosePage returns the current CGM glucose page number.
func (pump *Pump) CGMCurrentGlucosePage() int {
data := pump.Execute(cgmPageCount)
if pump.Error() != nil {
return 0
}
if len(data) < 13 || data[0] != 12 {
pump.BadResponse(cgmPageCount, data)
return 0
}
return int(fourByteUint(data[1:5]))
}
// CGMWriteTimestamp writes a new sensor timestamp to the CGM history.
func (pump *Pump) CGMWriteTimestamp() {
pump.Execute(cgmWriteTimestamp)
}