コード例 #1
0
        protected override void Decode(IChannelHandlerContext context, IByteBuffer input, List <object> output)
        {
            var msg = new byte[input.ReadableBytes];

            input.ReadBytes(msg);
            var hex    = BytesUtil.HexInsertSpace(BytesUtil.BytesToHex(msg));
            var srcMac = hex.Substring(50, 18).Replace(" ", "");

            Console.WriteLine($"Time: {DateTime.Now} Mac: {srcMac} => 收到服务器消息:{hex}");
        }
コード例 #2
0
        private byte[] GetSettleDeviceMsg()
        {
            var srcUnmarkHeight = 3000;
            var srcHeight       = 10050.32f;
            var unmarkHeight    = srcUnmarkHeight + index * 12;
            var height          = srcHeight + index * 1.2f * (new Random().Next(10));
            var core            = MessageBuilder.BuildSettleData(unmarkHeight, -3, height);
            var sensorMsg       = MessageBuilder.BuildSensorMsg(mac, 1, SensorType.THSTC, core);
            var msg             = MessageBuilder.BuildMessage(0, TransportType.GRPS, FunType.GatewayCacheDataBPublish, mac,
                                                              sensorMsg);
            var hex = BytesUtil.HexInsertSpace(BytesUtil.BytesToHex(msg));

            Console.WriteLine($"Time: {DateTime.Now} Index : {index} Mac: {mac} => 发送消息:{hex}");
            index++;
            return(msg);
        }