Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable PUT method for deviceshifu OPCUA and MQTT to write data #1004

Merged
merged 1 commit into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkg/deviceshifu/deviceshifumqtt/deviceshifumqtt.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ func (handler DeviceCommandHandlerMQTT) commandHandleFunc() http.HandlerFunc {
logger.Errorf("Cannot Encode message to json")
return
}
} else if reqType == http.MethodPost {
} else if reqType == http.MethodPost || reqType == http.MethodPut {
mqttTopic := handler.HandlerMetaData.properties.MQTTTopic
logger.Infof("the controlMsgs is %v", controlMsgs)
if mutexBlocking {
Expand Down
7 changes: 6 additions & 1 deletion pkg/deviceshifu/deviceshifumqtt/deviceshifumqtt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,12 @@ func TestCommandHandleMQTTFunc(t *testing.T) {
assert.Nil(t, r.Error()) // not blocked

// test put method
r = dc.Put().Do(context.TODO())
MutexProcess("test/test1", "device_finish_moving")
r = dc.Put().Body([]byte(requestBody)).Do(context.TODO())
assert.Nil(t, r.Error()) // not blocked

// test delete method
r = dc.Delete().Do(context.TODO())
assert.Equal(t, "the server rejected our request for an unknown reason", r.Error().Error())

// test Cannot Encode message to json
Expand Down
2 changes: 2 additions & 0 deletions pkg/deviceshifu/deviceshifuopcua/deviceshifuopcua.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,8 @@
switch r.Method {
case http.MethodGet:
handler.read(w, r)
case http.MethodPut:
fallthrough

Check warning on line 194 in pkg/deviceshifu/deviceshifuopcua/deviceshifuopcua.go

View check run for this annotation

Codecov / codecov/patch

pkg/deviceshifu/deviceshifuopcua/deviceshifuopcua.go#L193-L194

Added lines #L193 - L194 were not covered by tests
case http.MethodPost:
handler.write(w, r)
default:
Expand Down
Loading