refactor: rename iot client to stateless gateway

This commit is contained in:
2026-08-03 14:43:39 +08:00
parent 5edca1524f
commit aaede08f88
26 changed files with 92 additions and 111 deletions

View File

@@ -94,7 +94,7 @@ func dispatchIoTOutbox(ctx context.Context) {
}
payload["identity"] = outbox.CommandIdentity
body, _ := json.Marshal(payload)
dispatch, err := http.NewRequestWithContext(ctx, http.MethodPost, config.Spec.IoTAPI.ClientBaseURL+"/v1/device-commands", bytes.NewReader(body))
dispatch, err := http.NewRequestWithContext(ctx, http.MethodPost, config.Spec.IoTAPI.GatewayBaseURL+"/v1/device-commands", bytes.NewReader(body))
if err != nil {
continue
}
@@ -102,7 +102,7 @@ func dispatchIoTOutbox(ctx context.Context) {
dispatch.Header.Set("X-Heqi-Iot-Token", config.Spec.IoTAPI.Token)
dispatchResponse, err := client.Do(dispatch)
if err != nil {
completeIoTOutbox(ctx, client, outbox.Identity, false, 0, "IOT_CLIENT_UNAVAILABLE")
completeIoTOutbox(ctx, client, outbox.Identity, false, 0, "IOT_GATEWAY_UNAVAILABLE")
continue
}
var result struct {
@@ -114,7 +114,7 @@ func dispatchIoTOutbox(ctx context.Context) {
success := (status == http.StatusAccepted || status == http.StatusOK) && decodeErr == nil
errorCode := ""
if !success {
errorCode = "IOT_CLIENT_REJECTED"
errorCode = "IOT_GATEWAY_REJECTED"
}
completeIoTOutbox(ctx, client, outbox.Identity, success, result.PacketNumber, errorCode)
}