Added support for handling various payload types, including GPS and alarms, with new structures and constants. Introduced helper methods for JSON marshalling/unmarshalling of GPS data and modularized the handling of certificates, configurations, and alarms. Implemented foundational server code for testing and expanded several package functionalities.
80 lines
1.6 KiB
Go
80 lines
1.6 KiB
Go
package n9m
|
|
|
|
/*
|
|
|
|
// request reqistration parameters (directly to register)
|
|
func (e *Package) RequestParameters(params map[string]any, serial int, session string) {
|
|
e.Payload = map[string]any{
|
|
"MODULE": "CONFIGMODEL",
|
|
"OPERATION": "GET",
|
|
"PARAMETER": map[string]any{
|
|
"MDVR": params["MDVR"],
|
|
"SERIAL": serial,
|
|
},
|
|
"SESSION": session,
|
|
}
|
|
} // end of 'RequestParameters' function
|
|
|
|
// set reigeter parameters (directly to register)
|
|
func (e *Package) SetParameters(params map[string]any, serial int, session string) {
|
|
e.Payload = map[string]any{
|
|
"MODULE": "CONFIGMODEL",
|
|
"OPERATION": "SET",
|
|
"PARAMETER": map[string]any{
|
|
"MDVR": params["MDVR"],
|
|
"SERIAL": serial,
|
|
},
|
|
"SESSION": session,
|
|
}
|
|
// log.Println(e.Payload)
|
|
} // end of 'SetParameters' function
|
|
*/
|
|
|
|
type ConfigModelSetRequest struct {
|
|
MDVR Setting `json:"MDVR"`
|
|
}
|
|
|
|
type ConfigModelGetRequest struct {
|
|
MDVR interface{} `json:"MDVR"`
|
|
}
|
|
|
|
type ConfigModelSetResponse struct {
|
|
MDVR Setting `json:"MDVR"`
|
|
}
|
|
|
|
func (e *Package) InitialConfigModelSetRequest() {
|
|
e.SetParameters(ConfigModelSetRequest{
|
|
MDVR: Setting{
|
|
KEYS: KEYS{
|
|
GV: 1, // GPS version
|
|
},
|
|
PGDSM: PGDSM{
|
|
PGPS: PGPS{
|
|
EN: 1, // Real-time position monitoring
|
|
MODE: 0b10, // Enable timer
|
|
TM: 10, // Time interval
|
|
},
|
|
},
|
|
SUBSTRNET: SUBSTRNET{
|
|
SM: 1,
|
|
},
|
|
},
|
|
})
|
|
}
|
|
|
|
/*
|
|
func (e *Package) ResponseConfigModelSet(Sid string) {
|
|
e.Payload = map[string]any{
|
|
"MODULE": "CONFIGMODUL", // it's not error
|
|
"OPERATION": "SET",
|
|
"RESPONSE": map[string]any{
|
|
"ERRORCODE": 0,
|
|
"ERRORCAUSE": "None",
|
|
"ERRORDESCRIPTION": "None",
|
|
},
|
|
"SESSION": Sid,
|
|
}
|
|
}
|
|
|
|
*/
|