2024-05-29 11:48:04 +08:00
|
|
|
package btm_vobc
|
|
|
|
|
|
|
|
import (
|
|
|
|
"bytes"
|
|
|
|
"encoding/hex"
|
2024-06-06 17:57:30 +08:00
|
|
|
"encoding/json"
|
2024-05-29 11:48:04 +08:00
|
|
|
"fmt"
|
2024-06-06 17:57:30 +08:00
|
|
|
"joylink.club/bj-rtsts-server/third_party/message"
|
2024-05-29 11:48:04 +08:00
|
|
|
"sync/atomic"
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
|
|
|
code1 = "fffef890149e75e15511000006230000000000d4da14ebfffd"
|
|
|
|
code2 = "fffee601804f004d00800600002a004984ec6f4e902ef6912284000000000000000000000000000000067e000000000000411b0000f5bbee397698fffd"
|
|
|
|
)
|
|
|
|
|
|
|
|
var message_id atomic.Uint32
|
|
|
|
|
|
|
|
func TestDecode(t *testing.T) {
|
|
|
|
fmt.Println(code1[:4])
|
|
|
|
d, _ := hex.DecodeString(code1)
|
|
|
|
fmt.Println(d[:2])
|
|
|
|
dd := d[2 : len(d)-2]
|
|
|
|
fmt.Println(hex.EncodeToString(dd))
|
|
|
|
fmt.Println(bytes.Equal(d[:2], []byte{0xff, 0xfe}))
|
|
|
|
fmt.Println(message_id.Load())
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestMsg(t *testing.T) {
|
|
|
|
|
|
|
|
index := 1
|
|
|
|
for i := 22; i <= 125; i++ {
|
|
|
|
fmt.Println(index)
|
|
|
|
index++
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestBytes(t *testing.T) {
|
2024-06-06 17:57:30 +08:00
|
|
|
dd := make([]byte, 0)
|
|
|
|
dd = append(dd, 0)
|
|
|
|
dd = append(dd, 1)
|
|
|
|
dd = append(dd, 2)
|
|
|
|
dd = append(dd, 3)
|
|
|
|
dd = append(dd, 4)
|
|
|
|
fmt.Println(dd[1:])
|
|
|
|
}
|
|
|
|
func TestArr(t *testing.T) {
|
|
|
|
data := make([]byte, 0)
|
|
|
|
data = append(data, 1)
|
|
|
|
dd := &message.BtmVobcMsgFree{BtmStatus: message.BTM_STSTUS_NORMAL, WorkTemperature: 10, Fun1: uint16(0), Fun2: uint16(0), Fun3: uint16(0), Fun4: uint16(0),
|
|
|
|
FreeMsg: data, RespTime: byte(3), VobcLifeNum: 2, BaseBtmVobc: message.BaseBtmVobc{AutoIdFrame: 1}}
|
|
|
|
s, _ := json.Marshal(dd)
|
|
|
|
fmt.Println(string(s))
|
|
|
|
dd2 := &message.BtmVobcMsgFree{}
|
|
|
|
json.Unmarshal(s, dd2)
|
|
|
|
fmt.Println(dd2)
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestRes(t *testing.T) {
|
|
|
|
ss := "fffee601804f004d00e40321002a004fd6c86f3c2bcde891220700000000000000000000000000002103e20000000000000000000052bed1a5e9edfffd"
|
|
|
|
ss = "fffee601804f004d006a1521002a00f3329169ec2f9c9991229e000000000000000000000000000021156800000000000000000000bff47aff004e24fffd"
|
|
|
|
ss = "fffee601804f004d00cd1921002a005ea577ff00db4b628891220600000000000000000000000000002119cb0000000000000000000077ba3334d06ffffd"
|
|
|
|
ss = "fffee601804f004d006c1d21002a00e2c732ff00f86276339122a80000000000000000000000000000211d6a0000000000000000000049c46daebcf6fffd"
|
|
|
|
ss = "fffee601804f004d00871d21002a00ee97d0fb1c4b2a849122c30000000000000000000000000000211d8500000000000000000000c4e2343e4117fffd"
|
|
|
|
ss = "fffee601804f004d00444a1c002a00473bbfa11d4b3b029122a800000000000000000000000000001c4a42000000000000000000008970492fff00d0fffd"
|
|
|
|
//ss = "fffee601804f004d00921d21002a00ea014fef63995bff009122ce0000000000000000000000000000211d90000000000000000000007b07310379cefffd"
|
|
|
|
cfs, _ := hex.DecodeString(ss)
|
|
|
|
frameType, dataText, _ := message.BtmVobcDecode(cfs)
|
|
|
|
if frameType == message.COMMAND_TYPE {
|
|
|
|
fmt.Println("1111111111111111")
|
|
|
|
} else if frameType == message.REQUEST_TYPE {
|
|
|
|
|
|
|
|
req := &message.BtmVobcReq{}
|
|
|
|
req.Decode(dataText)
|
|
|
|
fmt.Println("22222222222222222222")
|
|
|
|
} else {
|
|
|
|
fmt.Println("zzzzzzzzzzzzzzzzzzzzz")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestRes3(t *testing.T) {
|
|
|
|
ss := "fffef890141175e15511001c4a3b0000000000fd5956a5fffd"
|
|
|
|
arr, _ := hex.DecodeString(ss)
|
|
|
|
_, dataText, err := message.BtmVobcDecode(arr)
|
|
|
|
if err != nil {
|
|
|
|
fmt.Println(err.Error())
|
|
|
|
}
|
|
|
|
|
|
|
|
req := &message.BtmVobcIdCommand{}
|
|
|
|
req.Decode(dataText)
|
2024-05-29 11:48:04 +08:00
|
|
|
}
|