forked from Elara6331/itd
Fix find and replace error
This commit is contained in:
parent
b4992cb393
commit
adb297c6dd
18
socket.go
18
socket.go
@ -149,14 +149,14 @@ func handleConnection(conn net.Conn, dev *infinitime.Device) {
|
|||||||
case ReqTypeNotify:
|
case ReqTypeNotify:
|
||||||
// If no data, return error
|
// If no data, return error
|
||||||
if req.Data == nil {
|
if req.Data == nil {
|
||||||
connErr(conn, nil, "Data required for notify types.Request")
|
connErr(conn, nil, "Data required for notify request")
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
var reqData types.ReqDataNotify
|
var reqData types.ReqDataNotify
|
||||||
// Decode data map to notify types.Request data
|
// Decode data map to notify request data
|
||||||
err = mapstructure.Decode(req.Data, &reqData)
|
err = mapstructure.Decode(req.Data, &reqData)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
connErr(conn, err, "Error decoding types.Request data")
|
connErr(conn, err, "Error decoding request data")
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
// Send notification to watch
|
// Send notification to watch
|
||||||
@ -170,13 +170,13 @@ func handleConnection(conn net.Conn, dev *infinitime.Device) {
|
|||||||
case ReqTypeSetTime:
|
case ReqTypeSetTime:
|
||||||
// If no data, return error
|
// If no data, return error
|
||||||
if req.Data == nil {
|
if req.Data == nil {
|
||||||
connErr(conn, nil, "Data required for settime types.Request")
|
connErr(conn, nil, "Data required for settime request")
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
// Get string from data or return error
|
// Get string from data or return error
|
||||||
reqTimeStr, ok := req.Data.(string)
|
reqTimeStr, ok := req.Data.(string)
|
||||||
if !ok {
|
if !ok {
|
||||||
connErr(conn, nil, "Data for settime types.Request must be RFC3339 formatted time string")
|
connErr(conn, nil, "Data for settime request must be RFC3339 formatted time string")
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -184,7 +184,7 @@ func handleConnection(conn net.Conn, dev *infinitime.Device) {
|
|||||||
if reqTimeStr == "now" {
|
if reqTimeStr == "now" {
|
||||||
reqTime = time.Now()
|
reqTime = time.Now()
|
||||||
} else {
|
} else {
|
||||||
// Parse time as RFC3339/ISO9601
|
// Parse time as RFC3339/ISO8601
|
||||||
reqTime, err = time.Parse(time.RFC3339, reqTimeStr)
|
reqTime, err = time.Parse(time.RFC3339, reqTimeStr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
connErr(conn, err, "Invalid time format. Time string must be formatted as ISO8601 or the word `now`")
|
connErr(conn, err, "Invalid time format. Time string must be formatted as ISO8601 or the word `now`")
|
||||||
@ -202,14 +202,14 @@ func handleConnection(conn net.Conn, dev *infinitime.Device) {
|
|||||||
case ReqTypeFwUpgrade:
|
case ReqTypeFwUpgrade:
|
||||||
// If no data, return error
|
// If no data, return error
|
||||||
if req.Data == nil {
|
if req.Data == nil {
|
||||||
connErr(conn, nil, "Data required for firmware upgrade types.Request")
|
connErr(conn, nil, "Data required for firmware upgrade request")
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
var reqData types.ReqDataFwUpgrade
|
var reqData types.ReqDataFwUpgrade
|
||||||
// Decode data map to firmware upgrade types.Request data
|
// Decode data map to firmware upgrade request data
|
||||||
err = mapstructure.Decode(req.Data, &reqData)
|
err = mapstructure.Decode(req.Data, &reqData)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
connErr(conn, err, "Error decoding types.Request data")
|
connErr(conn, err, "Error decoding request data")
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
switch reqData.Type {
|
switch reqData.Type {
|
||||||
|
Loading…
Reference in New Issue
Block a user