n9m/certificate.go
Alexander Lazarenko 16da4affa8
Refactor and enhance handling of payloads and data structures
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.
2025-02-22 19:23:16 +03:00

99 lines
2.3 KiB
Go

package n9m
type NetConnectionType uint
const (
NetConnectionWired NetConnectionType = iota
NetConnectionWireless
)
type TimeShiftSupportFlag uint8
const (
TimeShiftNotSupported TimeShiftSupportFlag = iota
TimeShiftSupported
)
type FileSystemVersionNumber uint8
const (
FileSystemVersion4 FileSystemVersionNumber = iota
FileSystemVersion5
)
type CertificateConnectRequest struct {
Net NetConnectionType `json:"NET"`
SerialNumber string `json:"DSNO"`
DeviceName string `json:"DEVNAME"`
ChannelsNumber uint `json:"CHANNEL"`
LicensePlate string `json:"CARNUM"`
DeviceNumber string `json:"AUTONO"`
VehicleNumber string `json:"AUTOCAR"`
TimeShiftSupport TimeShiftSupportFlag `json:"TSE"`
FileSystemVersion FileSystemVersionNumber `json:"FSV"`
ICCID string `json:"ICCID"`
EvidenceSupport string `json:"EV"`
}
type CertificateConnectResponse struct {
ErrorCode uint `json:"ERRORCODE"`
ErrorCause string `json:"ERRORCAUSE"`
CommandMask uint `json:"MASKCMD"`
}
type CommandMaskParameters uint
const (
CommandMaskAlarm = 1 << iota
CommandMaskScanningGun
CommandMaskPassengerFlow
CommandMaskFaceContrast
CommandMaskCard
CommandMaskShutdownReport
CommandMaskGPSReport
CommandMaskAll = 0b1111111
)
/*
func (e *Package) RequestConnect(session string, serial string, numOfCams int) {
e.Payload = map[string]any{
"MODULE": "CERTIFICATE",
"OPERATION": "CONNECT",
"PARAMETER": map[string]any{
"DSNO": serial,
"CHANNEL": numOfCams,
},
"SESSION": session,
}
}
// video server util
func (e *Package) ResponseConnect(Sid string, streamName string) {
e.Payload = map[string]any{
"MODULE": "CERTIFICATE",
"OPERATION": "CREATESTREAM",
"RESPONSE": map[string]any{
"ERRORCODE": 0,
"STREAMNAME": streamName,
},
"SESSION": Sid,
}
}
// main server util
func (e *Package) ResponseCertificateConnect(Sid string) {
e.Payload = map[string]any{
"MODULE": "CERTIFICATE",
"OPERATION": "CONNECT",
"RESPONSE": map[string]any{
"ERRORCAUSE": "",
"ERRORCODE": 0,
"MASKCMD": 5,
"PRO": "1.0.5",
},
"SESSION": Sid,
}
}
*/