fix: alarm sms forward data coding issue

This commit is contained in:
2024-09-30 11:38:26 +08:00
parent a6b869966f
commit 0152d4e923
7 changed files with 126 additions and 33 deletions

View File

@@ -150,16 +150,6 @@ type DbConfig struct {
Backup string `yaml:"backup"`
}
//type codingType int
const (
// Short message data coding type
CODING_UCS2 int = iota
CODING_ASCII
CODING_LATIN1
CODING_NODEF
)
type AlarmConfig struct {
SplitEventAlarm bool `yaml:"splitEventAlarm"`
//ForwardAlarm bool `yaml:"forwardAlarm"`
@@ -180,7 +170,7 @@ type AlarmConfig struct {
SystemID string `yaml:"systemID" json:"systemID"`
Password string `yaml:"password" json:"password"`
SystemType string `yaml:"systemType" json:"systemType"`
DataCoding int `yaml:"dataCoding" json:"dataCoding"`
DataCoding byte `yaml:"dataCoding" json:"dataCoding"`
ServiceNumber string `yaml:"serviceNumber" json:"serviceNumber"`
} `yaml:"alarmSMSForward"`
SMS struct {
@@ -399,8 +389,10 @@ func UpdateStructFromMap(s any, updates map[string]any) {
if field.Tag.Get("json") == key {
structField := v.FieldByName(field.Name)
if structField.IsValid() && structField.CanSet() {
if structField.Type() == reflect.TypeOf(value) {
structField.Set(reflect.ValueOf(value))
// Convert value to the appropriate type if necessary
convertedValue := reflect.ValueOf(value).Convert(structField.Type())
if structField.Type() == convertedValue.Type() {
structField.Set(convertedValue)
}
}
break