Documentation
¶
Index ¶
- func BinarySerialToString(bserial []byte) (string, error)
- func StringSerialToBinary(sserial string) error
- type ConnectedMiao
- func (lcm *ConnectedMiao) AcceptNewSensor() error
- func (lcm *ConnectedMiao) MiaoLibreStatus() (MiaoDeviceState, error)
- func (lcm *ConnectedMiao) MiaoResponse() (*MiaoResponsePacket, error)
- func (lcm *ConnectedMiao) PollResponse() (*MiaoResponsePacket, error)
- func (lcm *ConnectedMiao) ReadSensor() (*MiaoMiaoPacket, error)
- func (lcm *ConnectedMiao) ReadingEmitter(accept bool) chan MiaoMiaoPacket
- func (lcm *ConnectedMiao) Subscribe() error
- type LibrePacket
- type LibreReading
- type LibreResponsePacket
- type MiaoBluetoothState
- type MiaoDeviceState
- type MiaoMiaoPacket
- type MiaoResponsePacket
- type SensorStatus
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BinarySerialToString ¶
func StringSerialToBinary ¶
Types ¶
type ConnectedMiao ¶
type ConnectedMiao struct {
BtState MiaoBluetoothState
DevState MiaoDeviceState
LastEmit time.Time
NextEmit time.Time
// contains filtered or unexported fields
}
ConnectedMiao represents a BLE connection to a miaomiao
func AttachBTLE ¶
func AttachBTLE(blec ble.Client) (*ConnectedMiao, error)
AttachBTLE creates a connection descriptor for a miaomiao based on input of a legitimate BLE-layer connected device. It will fail if you give it a BT mouse or whatever
func (*ConnectedMiao) AcceptNewSensor ¶
func (lcm *ConnectedMiao) AcceptNewSensor() error
AcceptNewSensor notifies the device to start reading the attached sensor, which has not yet been read by this device (it's like pairing) note: does not work
func (*ConnectedMiao) MiaoLibreStatus ¶
func (lcm *ConnectedMiao) MiaoLibreStatus() (MiaoDeviceState, error)
MiaoLibreStatus is a helper function to return just the miaomiao's state i.e. new sensor, no sensor, or readings-ready
func (*ConnectedMiao) MiaoResponse ¶
func (lcm *ConnectedMiao) MiaoResponse() (*MiaoResponsePacket, error)
MiaoResponse reads an active BTLE datastream to a packet structure that only represents the thin layer of the device itself, and must be sent to other functions
func (*ConnectedMiao) PollResponse ¶
func (lcm *ConnectedMiao) PollResponse() (*MiaoResponsePacket, error)
PollResponse assures that a subscription is active and returns one reading
func (*ConnectedMiao) ReadSensor ¶
func (lcm *ConnectedMiao) ReadSensor() (*MiaoMiaoPacket, error)
ReadSensor will read a sensor packet and only a sensor packet
func (*ConnectedMiao) ReadingEmitter ¶
func (lcm *ConnectedMiao) ReadingEmitter(accept bool) chan MiaoMiaoPacket
ReadingEmitter returns a channel that is hooked into a goroutine that blocks on BLE information transfer, and returns deserialized miaomiao packets
func (*ConnectedMiao) Subscribe ¶
func (lcm *ConnectedMiao) Subscribe() error
Subscribe negotiates the data wakeup interval with the device itself. currently only allows for 5-minute interval signaling
type LibrePacket ¶
type LibrePacket struct {
Data [344]byte `json:"raw_data"`
SerialNumber string `json:"serial"`
XmitCrcs [3]uint16 `json:"crcs"`
Minutes uint16 `json:"minutes"`
TrendIndex int `json:"trend_i"`
Trend [16]LibreReading `json:"trends"`
HistoryIndex int `json:"history_i"`
History [32]LibreReading `json:"history"`
TimeStarted time.Time `json:"started"`
SensorAge time.Duration `json:"age"`
CaptureTime time.Time `json:"time"`
}
func CreateLibrePacket ¶
func CreateLibrePacket(data [344]byte, serialNumber string, captureTime time.Time) LibrePacket
func CreateLibrePacketNow ¶
func CreateLibrePacketNow(data [344]byte, serialNumber string) LibrePacket
func (*LibrePacket) Print ¶
func (lpkt *LibrePacket) Print()
func (*LibrePacket) ToJSON ¶
func (lpkt *LibrePacket) ToJSON() ([]byte, error)
type LibreReading ¶
type LibreReading struct {
Data [6]byte `json:"data"`
}
type LibreResponsePacket ¶
type LibreResponsePacket struct {
Data []byte
}
LibreResponsePacket is the data from the device itself
type MiaoBluetoothState ¶
type MiaoBluetoothState int
MiaoBluetoothState represents the percieved BLE state of the device
const ( MSDeclared MiaoBluetoothState = 0 MSConnected MiaoBluetoothState = 1 MSSubscribed MiaoBluetoothState = 2 MSBeingNotified MiaoBluetoothState = 3 )
BLE states
type MiaoDeviceState ¶
type MiaoDeviceState byte
MiaoDeviceState represents the percieved application state of the device
const ( MPDeclared MiaoDeviceState = 0x00 MPLibre MiaoDeviceState = 0x28 MPNewSensor MiaoDeviceState = 0x32 MPNoSensor MiaoDeviceState = 0x34 )
Application states
type MiaoMiaoPacket ¶
type MiaoMiaoPacket struct {
Data [363]byte `json:"raw_data"`
PktLength uint16 `json:"length"`
SerialNumber string `json:"serial"`
FimrwareVersion uint16 `json:"fwver"`
HardwareVersion uint16 `json:"hwver"`
BatteryPercentage uint8 `json:"batpct"`
StartTime time.Time `json:"start"`
EndTime time.Time `json:"end"`
LibrePacket *LibrePacket `json:"libre"`
}
MiaoMiaoPacket is a deserialized device reading inclusive of a LibrePacket
func CreateMiaoMiaoPacket ¶
func CreateMiaoMiaoPacket(mmr *MiaoResponsePacket) MiaoMiaoPacket
CreateMiaoMiaoPacket makes an application response packet out of a raw datastream packet provided
func (MiaoMiaoPacket) Print ¶
func (mmp MiaoMiaoPacket) Print()
Print just gives you the deets of a miaomiao packet reading
type MiaoResponsePacket ¶
type MiaoResponsePacket struct {
Type MiaoDeviceState
Data [363]byte
SensorPacket *LibreResponsePacket
StartTime time.Time
EndTime time.Time
}
MiaoResponsePacket is a captured sensor read attempt
type SensorStatus ¶
type SensorStatus byte
SensorStatus represents the sensor
const ( // SSUnknown represents no known state SSUnknown SensorStatus = 0x00 // SSNotStarted means the sensor is powered on SSNotStarted SensorStatus = 0x01 // SSStarting means the sensor is in 0-12h warmup SSStarting SensorStatus = 0x02 // SSReady is the normal on-duty state 12h-15d SSReady SensorStatus = 0x03 // SSExpired is 15d-15d12h last reading repreated SSExpired SensorStatus = 0x04 // SSShutdown is at 15d12h+ it's dead SSShutdown SensorStatus = 0x05 // SSFailed is any time it's otherwise broken SSFailed SensorStatus = 0x06 )
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
m2g-accept
command
|
|
|
m2g-decode
command
|
|
|
m2g-influx
command
|
|
|
m2g-mqp
command
|
|
|
m2g-mqs
command
|
|
|
m2g-mqs-influx
command
|
|
|
m2g-scan
command
|