feat(cwmp): get parameter attributes
This commit is contained in:
parent
d7a265049b
commit
03a4cec08f
|
|
@ -59,6 +59,7 @@ func (a *Api) StartApi() {
|
||||||
iot.HandleFunc("/auth", a.deviceAuth).Methods("GET", "POST", "DELETE")
|
iot.HandleFunc("/auth", a.deviceAuth).Methods("GET", "POST", "DELETE")
|
||||||
iot.HandleFunc("/cwmp/{sn}/getParameterNames", a.cwmpGetParameterNamesMsg).Methods("PUT")
|
iot.HandleFunc("/cwmp/{sn}/getParameterNames", a.cwmpGetParameterNamesMsg).Methods("PUT")
|
||||||
iot.HandleFunc("/cwmp/{sn}/getParameterValues", a.cwmpGetParameterValuesMsg).Methods("PUT")
|
iot.HandleFunc("/cwmp/{sn}/getParameterValues", a.cwmpGetParameterValuesMsg).Methods("PUT")
|
||||||
|
iot.HandleFunc("/cwmp/{sn}/getParameterAttributes", a.cwmpGetParameterAttributesMsg).Methods("PUT")
|
||||||
iot.HandleFunc("/cwmp/{sn}/setParameterValues", a.cwmpSetParameterValuesMsg).Methods("PUT")
|
iot.HandleFunc("/cwmp/{sn}/setParameterValues", a.cwmpSetParameterValuesMsg).Methods("PUT")
|
||||||
iot.HandleFunc("", a.retrieveDevices).Methods("GET")
|
iot.HandleFunc("", a.retrieveDevices).Methods("GET")
|
||||||
iot.HandleFunc("/{id}", a.retrieveDevices).Methods("GET")
|
iot.HandleFunc("/{id}", a.retrieveDevices).Methods("GET")
|
||||||
|
|
@ -71,7 +72,7 @@ func (a *Api) StartApi() {
|
||||||
iot.HandleFunc("/{sn}/{mtp}/instances", a.deviceGetParameterInstances).Methods("PUT")
|
iot.HandleFunc("/{sn}/{mtp}/instances", a.deviceGetParameterInstances).Methods("PUT")
|
||||||
iot.HandleFunc("/{sn}/{mtp}/operate", a.deviceOperateMsg).Methods("PUT")
|
iot.HandleFunc("/{sn}/{mtp}/operate", a.deviceOperateMsg).Methods("PUT")
|
||||||
iot.HandleFunc("/{sn}/{mtp}/fw_update", a.deviceFwUpdate).Methods("PUT")
|
iot.HandleFunc("/{sn}/{mtp}/fw_update", a.deviceFwUpdate).Methods("PUT")
|
||||||
// iot.HandleFunc("/{sn}/{mtp}/wifi", a.deviceWifi).Methods("PUT", "GET")
|
iot.HandleFunc("/{sn}/wifi", a.deviceWifi).Methods("PUT", "GET")
|
||||||
// mtp := r.PathPrefix("/api/mtp").Subrouter()
|
// mtp := r.PathPrefix("/api/mtp").Subrouter()
|
||||||
// mtp.HandleFunc("", a.mtpInfo).Methods("GET")
|
// mtp.HandleFunc("", a.mtpInfo).Methods("GET")
|
||||||
dash := r.PathPrefix("/api/info").Subrouter()
|
dash := r.PathPrefix("/api/info").Subrouter()
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,41 @@ func (a *Api) cwmpGetParameterNamesMsg(w http.ResponseWriter, r *http.Request) {
|
||||||
w.Write(data)
|
w.Write(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (a *Api) cwmpGetParameterAttributesMsg(w http.ResponseWriter, r *http.Request) {
|
||||||
|
sn := getSerialNumberFromRequest(r)
|
||||||
|
|
||||||
|
payload, err := io.ReadAll(r.Body)
|
||||||
|
if err != nil {
|
||||||
|
w.WriteHeader(http.StatusBadRequest)
|
||||||
|
w.Write(utils.Marshall(err.Error()))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
data, err := bridge.NatsCwmpInteraction(
|
||||||
|
nats.NATS_CWMP_ADAPTER_SUBJECT_PREFIX+sn+".api",
|
||||||
|
payload,
|
||||||
|
w,
|
||||||
|
a.nc,
|
||||||
|
)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
var response cwmp.GetParameterAttributesResponse
|
||||||
|
err = xml.Unmarshal(data, &response)
|
||||||
|
if err != nil {
|
||||||
|
err = json.Unmarshal(data, &response)
|
||||||
|
if err != nil {
|
||||||
|
w.WriteHeader(http.StatusBadRequest)
|
||||||
|
w.Write(utils.Marshall(err))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
w.Write(data)
|
||||||
|
}
|
||||||
|
|
||||||
func (a *Api) cwmpGetParameterValuesMsg(w http.ResponseWriter, r *http.Request) {
|
func (a *Api) cwmpGetParameterValuesMsg(w http.ResponseWriter, r *http.Request) {
|
||||||
sn := getSerialNumberFromRequest(r)
|
sn := getSerialNumberFromRequest(r)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user