Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

huawei-ussd patch to support zte modems (raw at+cusd)

By: a guest on Oct 24th, 2013  |  syntax: Diff  |  size: 1.29 KB  |  views: 118  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. --- huawei-ussd 2012-01-04 23:13:14.000000000 +0400
  2. +++ huawei-ussd 2013-10-24 14:09:31.317551040 +0400
  3. @@ -24,23 +24,31 @@
  4.    -n        Do not send any data to port. Useful with -v.
  5.    -h        Print this help.
  6.    -v        Be verbose.
  7. -  -i           Use iconv [from utf16be to utf8] to reply
  8. +  -i        Use iconv [from utf16be to utf8] to reply
  9.    -w        reply workaround (try it if script can not decode reply)
  10. +  -z        Do not encode request to 7bit PDU
  11.  __EOU
  12.  
  13.  sub HELP_MESSAGE {print "$USAGE\n"; exit;}
  14.  sub VERSION_MESSAGE {};
  15. -getopts ('r:s:hnvwi');
  16. +getopts ('r:s:hnvwiz');
  17.  HELP_MESSAGE() and exit if (! $ARGV[0]) or defined($opt_h);
  18. -
  19. +my $ussd_req ='';
  20.  print "USSD MSG: $ARGV[0]\n" if $opt_v;
  21. -my $ussd_req = Device::Gsm::Pdu::encode_text7($ARGV[0]);
  22. -$ussd_req =~ s/^..//;
  23. +if (! $opt_z) {
  24. +       $ussd_req = Device::Gsm::Pdu::encode_text7($ARGV[0]);
  25. +       $ussd_req =~ s/^..//;
  26. +}
  27. +else {
  28. +       $ussd_req = ($ARGV[0]);
  29. +}
  30. +
  31.  print "PDU ENCODED: $ussd_req\n" if $opt_v;
  32.  
  33.  my $ussd_reply;
  34.  if (! $opt_n) {
  35.      open (SENDPORT, '+<', $opt_s) or die "Can't open '$opt_s': $!\n";
  36. +    print 'Sending AT+CUSD=1,',$ussd_req,",15\r\n" if $opt_v;
  37.      print SENDPORT 'AT+CUSD=1,',$ussd_req,",15\r\n";
  38.      close SENDPORT;
  39.      open (RCVPORT, $opt_r) or die "Can't open '$opt_r': $!\n";