K2InformaticsGmbH / smpp_parser

A parser for SMPP protocol PDUs
Apache License 2.0
3 stars 1 forks source link

missing rec_infos : network_type, service, time_unit, number #103

Closed c-bik closed 6 years ago

c-bik commented 6 years ago
> PDU = "00 00 00 C4 00 00 01 11 00 00 00 00 00 00 00 01 57 41 50 00 00 09 31 36 38 2E 30 2E 30 2E 31 00 74 68 69 73 5F 63 6F 75 6C 64 5F 62 65 5F 61 5F 6D 65 73 73 61 67 65 5F 69 64 00 01 39 39 30 38 32 33 31 36 35 33 34 33 30 30 30 52 00 39 39 30 33 31 30 30 30 30 30 30 30 30 30 30 52 00 00 7F FF 06 06 00 23 02 6D 79 5F 62 72 6F 61 64 63 61 73 74 5F 61 72 65 61 5F 69 64 65 6E 74 69 66 69 65 72 5F 30 30 30 30 31 06 01 00 03 03 00 13 06 04 00 02 00 00 06 05 00 03 0E 00 09 06 02 00 24 6D 79 5F 62 72 6F 61 64 63 61 73 74 5F 63 6F 6E 74 65 6E 74 5F 74 79 70 65 5F 69 6E 66 6F 5F 30 30 30 30 34"

> Bin = list_to_binary([binary_to_integer(B, 16) || B <- re:split(PDU, " ")]).
> SMPP1 = lists:foldl(fun smpp:list_to_map/2, #{}, smpp:unpack(Bin)).
smpp:rec_info:177 unknown network_type
smpp:rec_info:177 unknown service
smpp:rec_info:177 unknown time_unit
smpp:rec_info:177 unknown number
#{broadcast_area_identifier =>
      [[{format,2},
        {details,"my_broadcast_area_identifier_00001"}]],
  broadcast_content_type => [#{},#{}],
  broadcast_content_type_info =>
      "my_broadcast_content_type_info_00004",
  broadcast_frequency_interval => [#{},#{}],
  broadcast_rep_num => 0,command_id => 273,
  command_length => 196,command_status => 0,
  data_coding => 127,
  message_id => "this_could_be_a_message_id",
  priority_flag => 1,replace_if_present_flag => 0,
  schedule_delivery_time => "990823165343000R",
  sequence_number => 1,service_type => "WAP",
  sm_default_msg_id => 255,source_addr => "168.0.0.1",
  source_addr_npi => 9,source_addr_ton => 0,
  validity_period => "990310000000000R"}
65> JSON = smpp:internal2json(SMPP1).
** exception error: bad argument
     in function  list_to_binary/1
        called as list_to_binary([[{format,2},
                                   {details,"my_broadcast_area_identifier_00001"}]])
     in call from smpp:internal2json/2 (c:/projects/git/K2InformaticsGmbH/smpp_parser/_build/test/lib/smpp_parser/src/smpp.erl, line 34)
     in call from maps:'-map/2-lc$^0/1-0-'/2 (maps.erl, line 232)
     in call from maps:map/2 (maps.erl, line 232)
shamis commented 6 years ago

@c-bik this has been fixed with https://github.com/K2InformaticsGmbH/smpp_parser/blob/master/src/smpp.erl#L206-L213 i think.

>smpp:decode(PDU).        
{ok,#{broadcast_area_identifier => [#{details => <<"my_broadcast_area_identifier_00001">>,  format => 2}],
      broadcast_content_type => #{network_type => 3,service => 19},
      broadcast_content_type_info =>
          <<"my_broadcast_content_type_info_00004">>,
      broadcast_frequency_interval =>
          #{number => 9,time_unit => 14},
      broadcast_rep_num => 0,command_id => <<"broadcast_sm">>,
      command_length => 196,command_status => <<"ESME_ROK">>,
      data_coding => <<"127">>,
      message_id => <<"this_could_be_a_message_id">>,
      priority_flag => 1,replace_if_present_flag => 0,
      schedule_delivery_time => <<"990823165343000R">>,
      sequence_number => 1,service_type => <<"WAP">>,
      sm_default_msg_id => 255,source_addr => <<"168.0.0.1">>,
      source_addr_npi => <<"Private">>,
      source_addr_ton => <<"Unknown">>,
      validity_period => <<"990310000000000R">>}}
c-bik commented 6 years ago

Fixed as see comment above