develoven 1 anno fa
parent
commit
84c781ff3c
4 ha cambiato i file con 21 aggiunte e 0 eliminazioni
  1. 18 0
      api/gateway.go
  2. 1 0
      config/application.yaml
  3. 1 0
      config/config.go
  4. 1 0
      initialize/router.go

+ 18 - 0
api/gateway.go

@@ -289,3 +289,21 @@ func StopCollect(c *gin.Context) {
 	response.Success("停止采集", "", c)
 	return
 }
+
+// Disconnect
+// PingExample confrontation-training
+// @Summary 断开连接
+// @Schemes
+// @Description 断开连接
+// @Tags 设备管理
+// @Accept json
+// @Produce json
+// @Success 200 {string} string "ok"
+// @Router /v1/device/:mac/disconnect [delete]
+func Disconnect(c *gin.Context) {
+	mac := c.Param("mac")
+	disconnectUrl := global.Config.Gateway.BaseUrl + global.Config.Gateway.DisconnectUrl
+	disconnectUrl = strings.Replace(disconnectUrl, "MAC", mac, -1)
+	response.Success("断开连接", mac, c)
+	return
+}

+ 1 - 0
config/application.yaml

@@ -30,6 +30,7 @@ gateway:
   notifyUrl: /gatt/nodes?event=1
   writeDataUrl: /gatt/nodes/MAC/handle/32/value/DATA
   openChannel: /gatt/nodes/MAC/handle/36/value/0100
+  disconnectUrl: /gap/nodes/MAC/connection
   scanSecond: 1000 #蓝牙数据推送时间间隔
 
 

+ 1 - 0
config/config.go

@@ -9,6 +9,7 @@ type Gateway struct {
 	WriteDataUrl    string `mapstructure:"writeDataUrl"`
 	StartCollectUrl string `mapstructure:"startCollectUrl"`
 	OpenChannel     string `mapstructure:"openChannel"`
+	DisconnectUrl   string `mapstructure:"disconnectUrl"`
 }
 
 type Config struct {

+ 1 - 0
initialize/router.go

@@ -45,6 +45,7 @@ func Router() {
 	device.GET("/open/notify/", api.OpenNotify)
 	device.GET("/:mac/stop/trans/", api.StopTrans)
 	device.GET("/:mac/stop/collect/", api.StopCollect)
+	device.GET("/:mac/disconnect/", api.Disconnect)
 	//
 	//record := v1.Group("/record")
 	//record.POST("/create", api.GetRecord().SaveRecord)