添加门磁类型,完善地址过滤
This commit is contained in:
parent
6d538a7bef
commit
6d960f50f8
57
tcpserver.go
57
tcpserver.go
|
@ -96,11 +96,13 @@ func readConn(conn net.Conn, readChan chan<- []byte, stopChan chan<- bool) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
s := strconv.FormatInt(int64(b&0xff), 16)
|
if b!=254{
|
||||||
if len(s) == 1 {
|
s := strconv.FormatInt(int64(b&0xff), 16)
|
||||||
buffer.WriteString("0")
|
if len(s) == 1 {
|
||||||
}
|
buffer.WriteString("0")
|
||||||
buffer.WriteString(s)
|
}
|
||||||
|
buffer.WriteString(s)
|
||||||
|
}
|
||||||
|
|
||||||
// log.Println("========================",data[reqLen-2:reqLen])
|
// log.Println("========================",data[reqLen-2:reqLen])
|
||||||
|
|
||||||
|
@ -111,6 +113,7 @@ func readConn(conn net.Conn, readChan chan<- []byte, stopChan chan<- bool) {
|
||||||
//254为分隔符
|
//254为分隔符
|
||||||
if b==254 && i>3{
|
if b==254 && i>3{
|
||||||
addrs := data[i-4:i]
|
addrs := data[i-4:i]
|
||||||
|
|
||||||
//尿布台数据,地址1位 数据2位
|
//尿布台数据,地址1位 数据2位
|
||||||
dataType := data[i+1]
|
dataType := data[i+1]
|
||||||
values := make([]byte,0)
|
values := make([]byte,0)
|
||||||
|
@ -168,6 +171,39 @@ func readConn(conn net.Conn, readChan chan<- []byte, stopChan chan<- bool) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println("write msg error!", err)
|
log.Println("write msg error!", err)
|
||||||
}
|
}
|
||||||
|
}else if dataType ==3{
|
||||||
|
continueCount = 2
|
||||||
|
end = 3
|
||||||
|
|
||||||
|
if i+3 >reqLen{
|
||||||
|
log.Println("yunhorndeug.push.data.tcp.fq",buffer.String(),addrs,dataType)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
// values = data[i+2:i+3]
|
||||||
|
values := data[i+2]
|
||||||
|
|
||||||
|
//8E 3C 00 00 47 46
|
||||||
|
var green []byte = []byte{0x8E,0x3C,0x00,0x00,0x47,0x46}
|
||||||
|
var red []byte = []byte{0x8E,0x3C,0x00,0x00,0x52,0x46}
|
||||||
|
|
||||||
|
var yellow []byte = []byte{0x8E,0x3C,0x00,0x00,0x59,0x46}
|
||||||
|
var writedata []byte =[]byte{}
|
||||||
|
writedata = green
|
||||||
|
if values == 2{
|
||||||
|
writedata = red
|
||||||
|
}else if values == 1{
|
||||||
|
writedata = green
|
||||||
|
}else if values == 4{
|
||||||
|
writedata = yellow
|
||||||
|
}
|
||||||
|
log.Println("send.msg.conn.RemoteAddr|writedata",connTest.RemoteAddr(),writedata)
|
||||||
|
v, err := connTest.Write(writedata)
|
||||||
|
|
||||||
|
log.Println("send.msg.conn.v",v)
|
||||||
|
if err != nil {
|
||||||
|
log.Println("write msg error!", err)
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -176,7 +212,16 @@ func readConn(conn net.Conn, readChan chan<- []byte, stopChan chan<- bool) {
|
||||||
// log.Println("yunhorndeug.push.data.tcp.type",dataType)
|
// log.Println("yunhorndeug.push.data.tcp.type",dataType)
|
||||||
// log.Println("yunhorndeug.push.data.tcp.values",values)
|
// log.Println("yunhorndeug.push.data.tcp.values",values)
|
||||||
|
|
||||||
buffer = new(bytes.Buffer)
|
_,ok := loraNodeMap.Load(buffer.String())
|
||||||
|
if !ok{
|
||||||
|
log.Println("yunhorndeug.push.data.tcp.dev not exist:",buffer.String())
|
||||||
|
buffer = new(bytes.Buffer)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
buffer = new(bytes.Buffer)
|
||||||
|
|
||||||
|
|
||||||
if(dataType ==1 || dataType ==2 ){
|
if(dataType ==1 || dataType ==2 ){
|
||||||
go dealDatav3(data[i-4:i+end])
|
go dealDatav3(data[i-4:i+end])
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue