This commit is contained in:
fish 2019-03-21 11:52:09 +08:00
parent b10aace99b
commit 1bcc46f458
6 changed files with 443 additions and 444 deletions

View File

@ -4,10 +4,10 @@ import (
"database/sql"
"encoding/json"
_ "github.com/mattn/go-sqlite3"
"os"
"time"
"strconv"
"log"
"os"
"strconv"
"time"
)
type Traffic struct {
@ -64,7 +64,6 @@ var conf Conf
var DEVICEDATAS Devicedatas
var demoDevice Device
var db, _ = sql.Open("sqlite3", "./db/gateway.db")
// 加载配置文件
@ -87,7 +86,6 @@ func init() {
}
DEVICEDATAS.Unlock()
demoDevice.ID = "deb03e28-ddcb-4e5d-aa31-d870a1f0f09b"
demoDevice.VERSION = "yunhorn_kgl_c8_v1"
demoDevice.DATA = make(map[string]interface{})
@ -97,7 +95,6 @@ func init() {
demoDevice.ONLINE = true
log.Println("init demoDevice success:", demoDevice)
dbdata_init()
}

View File

@ -3,8 +3,8 @@ package main
import (
"github.com/robfig/cron"
"log"
"os"
"net"
"os"
)
var err error

View File

@ -11,7 +11,6 @@ import (
// "go-study/socket/config"
)
func handleConn(conn net.Conn) {
defer conn.Close()

View File

@ -4,9 +4,9 @@ import (
"encoding/binary"
"github.com/tarm/serial"
"log"
"math/rand"
"strconv"
"sync"
"math/rand"
)
type Devicedatas struct {
@ -14,7 +14,6 @@ type Devicedatas struct {
DATA map[string]Device
}
type Device struct {
sync.RWMutex
ID string `json:"id"`
@ -34,10 +33,14 @@ func yunhorn_ys_l_v1(data_buf []byte){
// log.Println(binary.BigEndian.Uint16(append([]byte{0x00}, k))
// }
log.Println("ys_l_v1_data:",data_buf)
// log.Println("ys_l_v1_data:",data_buf)
data_int := Bytes2Bits(data_buf[3:4])
data_int0 := Bytes2Bits(data_buf[0:1])
data_int1 := Bytes2Bits(data_buf[1:2])
data_int2 := Bytes2Bits(data_buf[2:3])
log.Println("data_int:", data_int[0])
log.Printf("ADRH:%d,ADRL:%d,dataType:%d,", data_int0[0], data_int1[0], data_int2[0])
var device Device
device.ID = demoDevice.ID
device.VERSION = demoDevice.VERSION