68 lines
1.3 KiB
Go
68 lines
1.3 KiB
Go
package api
|
|
|
|
import (
|
|
"sync"
|
|
"time"
|
|
|
|
"gitea.unprism.ru/KRBL/mpu/mpu"
|
|
"gitea.unprism.ru/KRBL/sim-modem/api/modem/gps"
|
|
)
|
|
|
|
// Some supplement types and constants
|
|
|
|
// This struct contains status of the system that will be on the display
|
|
type status struct {
|
|
mutex sync.Mutex
|
|
|
|
// Status data
|
|
time time.Time
|
|
gpsData gps.Data
|
|
mpuData mpu.Data
|
|
|
|
rssi int // Received signal strength indicator (check gitea.unprism.ru/KRBL/sim-modem/api/modem/utils/signal.go)
|
|
service string // Internet service name, could be: "NO SERVICE", "GSM", "WCDMA", "LTE", "TDS"
|
|
}
|
|
|
|
type StatusUpdater interface {
|
|
UpdateTime(newTime time.Time)
|
|
UpdateGps(newData gps.Data)
|
|
UpdateMpu(newData mpu.Data)
|
|
UpdateRssi(newData int)
|
|
UpdateService(newData string)
|
|
}
|
|
|
|
func (st *status) UpdateTime(newTime time.Time) {
|
|
st.mutex.Lock()
|
|
defer st.mutex.Unlock()
|
|
|
|
st.time = newTime
|
|
}
|
|
|
|
func (st *status) UpdateGps(newData gps.Data) {
|
|
st.mutex.Lock()
|
|
defer st.mutex.Unlock()
|
|
|
|
st.gpsData = newData
|
|
}
|
|
|
|
func (st *status) UpdateMpu(newData mpu.Data) {
|
|
st.mutex.Lock()
|
|
defer st.mutex.Unlock()
|
|
|
|
st.mpuData = newData
|
|
}
|
|
|
|
func (st *status) UpdateRssi(newData int) {
|
|
st.mutex.Lock()
|
|
defer st.mutex.Unlock()
|
|
|
|
st.rssi = newData
|
|
}
|
|
|
|
func (st *status) UpdateService(newData string) {
|
|
st.mutex.Lock()
|
|
defer st.mutex.Unlock()
|
|
|
|
st.service = newData
|
|
}
|