企业版4.4.20 JT808

企业版4.4.20 中实现的JT808网关的协议版本是多少?

使用JT808-2013模拟终端时报错日志,请问是哪里有问题?


2023-09-15T13:10:03.449400+08:00 [error] Generic server <0.8968.0> terminating. Reason: unexpected_frame. Last message: {inet_async,#Port<0.682>,0,{ok,<<126,2,0,0,38,1,35,69,103,137,18,0,147,0,0,0,0,0,0,0,3,2,97,19,97,6,240,18,77,0,88,2,148,0,0,35,9,21,5,16,4,1,4,0,0,4,206,2,2,0,0,184,126>>}}. State: {state,esockd_transport,#Port<0.682>,{{61,169,57,116},6839},{not_detect_heading_0x7e,8192},{pstate,#{conn_mod => emqx_jt808_connection,peercert => nossl,peername => {{61,169,57,116},6839},sendfun => {fun emqx_jt808_connection:send/3,[esockd_transport,#Port<0.682>]},sockname => {{172,26,223,161},8090},socktype => tcp},#{clientid => undefined,is_bridge => false,is_superuser => false,mountpoint => undefined,peerhost => {61,169,57,116},protocol => jt808,sockport => 8090,username => undefined,zone => undefined},undefined,undefined,undefined,{fun emqx_jt808_connection:send/3,[esockd_transport,#Port<0.682>]},undefined,0,<<"jt808/%c/dn">>,<<"jt808/%c/up">>,{auth,undefined,undefined,true},[0,<<0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,...>>],{inflight,128,{0,nil}},undefined,undefined},undefined,undefined,8192,true,30000}.
2023-09-15T13:10:03.449887+08:00 [error] crasher: initial call: emqx_jt808_connection:init/1, pid: <0.8968.0>, registered_name: [], exit: {unexpected_frame,[{gen_server,handle_common_reply,8,[{file,"gen_server.erl"},{line,811}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,226}]}]}, ancestors: [<0.3650.0>,<0.3649.0>,esockd_sup,<0.2340.0>], message_queue_len: 1, messages: [{inet_async,#Port<0.682>,1,{error,closed}}], links: [<0.3650.0>], dictionary: [], trap_exit: false, status: running, heap_size: 10958, stack_size: 29, reductions: 20003; neighbours:
2023-09-15T13:10:05.344725+08:00 [error] [JT808 Proto] Unexpected frame #{<<"body">> => #{<<"alarm">> => 0,<<"altitude">> => 88,<<"direction">> => 0,<<"extra">> => #{<<"fuel_meter">> => 0,<<"mileage">> => 1230},<<"latitude">> => 39916385,<<"longitude">> => 116396621,<<"speed">> => 660,<<"status">> => 3,<<"time">> => <<"230915051005">>},<<"header">> => #{<<"encrypt">> => 0,<<"len">> => 38,<<"msg_id">> => 512,<<"msg_sn">> => 148,<<"phone">> => <<"012345678912">>}}
2023-09-15T13:10:05.345084+08:00 [error] Generic server <0.8970.0> terminating. Reason: unexpected_frame. Last message: {inet_async,#Port<0.683>,0,{ok,<<126,2,0,0,38,1,35,69,103,137,18,0,148,0,0,0,0,0,0,0,3,2,97,19,97,6,240,18,77,0,88,2,148,0,0,35,9,21,5,16,5,1,4,0,0,4,206,2,2,0,0,190,126>>}}. State: {state,esockd_transport,#Port<0.683>,{{61,169,57,116},6872},{not_detect_heading_0x7e,8192},{pstate,#{conn_mod => emqx_jt808_connection,peercert => nossl,peername => {{61,169,57,116},6872},sendfun => {fun emqx_jt808_connection:send/3,[esockd_transport,#Port<0.683>]},sockname => {{172,26,223,161},8090},socktype => tcp},#{clientid => undefined,is_bridge => false,is_superuser => false,mountpoint => undefined,peerhost => {61,169,57,116},protocol => jt808,sockport => 8090,username => undefined,zone => undefined},undefined,undefined,undefined,{fun emqx_jt808_connection:send/3,[esockd_transport,#Port<0.683>]},undefined,0,<<"jt808/%c/dn">>,<<"jt808/%c/up">>,{auth,undefined,undefined,true},[0,<<0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,...>>],{inflight,128,{0,nil}},undefined,undefined},undefined,undefined,8192,true,30000}.
2023-09-15T13:10:05.345439+08:00 [error] crasher: initial call: emqx_jt808_connection:init/1, pid: <0.8970.0>, registered_name: [], exit: {unexpected_frame,[{gen_server,handle_common_reply,8,[{file,"gen_server.erl"},{line,811}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,226}]}]}, ancestors: [<0.3650.0>,<0.3649.0>,esockd_sup,<0.2340.0>], message_queue_len: 1, messages: [{inet_async,#Port<0.683>,1,{error,closed}}], links: [<0.3650.0>], dictionary: [], trap_exit: false, status: running, heap_size: 10958, stack_size: 29, reductions: 20003; neighbours:
2023-09-15T13:10:06.993760+08:00 [error] [JT808 Proto] Unexpected frame #{<<"body">> => #{<<"alarm">> => 0,<<"altitude">> => 88,<<"direction">> => 0,<<"extra">> => #{<<"fuel_meter">> => 0,<<"mileage">> => 1230},<<"latitude">> => 39916385,<<"longitude">> => 116396621,<<"speed">> => 660,<<"status">> => 3,<<"time">> => <<"230915051007">>},<<"header">> => #{<<"encrypt">> => 0,<<"len">> => 38,<<"msg_id">> => 512,<<"msg_sn">> => 149,<<"phone">> => <<"012345678912">>}}
2023-09-15T13:10:06.994194+08:00 [error] Generic server <0.8972.0> terminating. Reason: unexpected_frame. Last message: {inet_async,#Port<0.684>,0,{ok,<<126,2,0,0,38,1,35,69,103,137,18,0,149,0,0,0,0,0,0,0,3,2,97,19,97,6,240,18,77,0,88,2,148,0,0,35,9,21,5,16,7,1,4,0,0,4,206,2,2,0,0,189,126>>}}. State: {state,esockd_transport,#Port<0.684>,{{61,169,57,116},6907},{not_detect_heading_0x7e,8192},{pstate,#{conn_mod => emqx_jt808_connection,peercert => nossl,peername => {{61,169,57,116},6907},sendfun => {fun emqx_jt808_connection:send/3,[esockd_transport,#Port<0.684>]},sockname => {{172,26,223,161},8090},socktype => tcp},#{clientid => undefined,is_bridge => false,is_superuser => false,mountpoint => undefined,peerhost => {61,169,57,116},protocol => jt808,sockport => 8090,username => undefined,zone => undefined},undefined,undefined,undefined,{fun emqx_jt808_connection:send/3,[esockd_transport,#Port<0.684>]},undefined,0,<<"jt808/%c/dn">>,<<"jt808/%c/up">>,{auth,undefined,undefined,true},[0,<<0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,...>>],{inflight,128,{0,nil}},undefined,undefined},undefined,undefined,8192,true,30000}.
2023-09-15T13:10:06.994506+08:00 [error] crasher: initial call: emqx_jt808_connection:init/1, pid: <0.8972.0>, registered_name: [], exit: {unexpected_frame,[{gen_server,handle_common_reply,8,[{file,"gen_server.erl"},{line,811}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,226}]}]}, ancestors: [<0.3650.0>,<0.3649.0>,esockd_sup,<0.2340.0>], message_queue_len: 1, messages: [{inet_async,#Port<0.684>,1,{error,closed}}], links: [<0.3650.0>], dictionary: [], trap_exit: false, status: running, heap_size: 10958, stack_size: 29, reductions: 20003; neighbours:

协议版本:JT/T 808 2013 协议
这个错是解析协议出错了。
你先开 debug 日志

可能是客户端没有注册 connected 状态不对

同个模拟终端,连接到其他平台是没有问题的呢,不知道是不是实现的方式和EMQX有什么区别,麻烦看看啦

2023-09-15T14:25:03.356084+08:00 [debug] [JT808 Conn] RECV <<126,2,0,0,38,1,35,69,103,137,18,0,11,0,0,0,0,0,0,0,3,2,97,19,97,6,240,18,77,0,88,2,148,0,0,35,9,21,6,37,3,1,4,0,0,4,206,2,2,0,0,17,126>>
2023-09-15T14:25:03.356358+08:00 [error] [JT808 Proto] Unexpected frame #{<<"body">> => #{<<"alarm">> => 0,<<"altitude">> => 88,<<"direction">> => 0,<<"extra">> => #{<<"fuel_meter">> => 0,<<"mileage">> => 1230},<<"latitude">> => 39916385,<<"longitude">> => 116396621,<<"speed">> => 660,<<"status">> => 3,<<"time">> => <<"230915062503">>},<<"header">> => #{<<"encrypt">> => 0,<<"len">> => 38,<<"msg_id">> => 512,<<"msg_sn">> => 11,<<"phone">> => <<"012345678912">>}}
2023-09-15T14:25:03.356546+08:00 [debug] [JT808 Conn] Terminated for unexpected_frame
2023-09-15T14:25:03.356715+08:00 [error] Generic server <0.11708.0> terminating. Reason: unexpected_frame. Last message: {inet_async,#Port<0.746>,0,{ok,<<126,2,0,0,38,1,35,69,103,137,18,0,11,0,0,0,0,0,0,0,3,2,97,19,97,6,240,18,77,0,88,2,148,0,0,35,9,21,6,37,3,1,4,0,0,4,206,2,2,0,0,17,126>>}}. State: {state,esockd_transport,#Port<0.746>,{{61,169,57,116},11317},{not_detect_heading_0x7e,8192},{pstate,#{conn_mod => emqx_jt808_connection,peercert => nossl,peername => {{61,169,57,116},11317},sendfun => {fun emqx_jt808_connection:send/3,[esockd_transport,#Port<0.746>]},sockname => {{172,26,223,161},8090},socktype => tcp},#{clientid => undefined,is_bridge => false,is_superuser => false,mountpoint => undefined,peerhost => {61,169,57,116},protocol => jt808,sockport => 8090,username => undefined,zone => undefined},undefined,undefined,undefined,{fun emqx_jt808_connection:send/3,[esockd_transport,#Port<0.746>]},undefined,0,<<"jt808/%c/dn">>,<<"jt808/%c/up">>,{auth,undefined,undefined,true},[0,<<0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,...>>],{inflight,128,{0,nil}},undefined,undefined},undefined,undefined,8192,true,30000}.
2023-09-15T14:25:03.357083+08:00 [error] crasher: initial call: emqx_jt808_connection:init/1, pid: <0.11708.0>, registered_name: [], exit: {unexpected_frame,[{gen_server,handle_common_reply,8,[{file,"gen_server.erl"},{line,811}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,226}]}]}, ancestors: [<0.9386.0>,<0.9385.0>,esockd_sup,<0.2340.0>], message_queue_len: 1, messages: [{inet_async,#Port<0.746>,1,{error,closed}}], links: [<0.9386.0>], dictionary: [], trap_exit: false, status: running, heap_size: 17731, stack_size: 29, reductions: 30423; neighbours:

虽然已设置了匿名登录,但是还是需要发 AUTH包的:16#0102,这样才能把phone设置为 clientid

所以在你发512包(MC_LOCATION_REPORT)包之前,先发auth包,关联一下phone和clientid应该就可以再发MC_LOCATION_REPORT了。

正常的流程应该是先 register -》auth -》 location_report 这样。