Guest User

/lib/netifd/proto/3g.sh OpenWRT 15.05.1 Huwaei 4G/LTE e3372s

a guest
Jun 5th, 2017
136
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/sh
  2. INCLUDE_ONLY=1
  3.  
  4. . ../netifd-proto.sh
  5. . ./ppp.sh
  6. init_proto "$@"
  7.  
  8. proto_3g_init_config() {
  9. no_device=1
  10. available=1
  11. ppp_generic_init_config
  12. proto_config_add_string "device:device"
  13. proto_config_add_string "apn"
  14. proto_config_add_string "service"
  15. proto_config_add_string "pincode"
  16. proto_config_add_string "dialnumber"
  17. }
  18.  
  19. proto_3g_setup() {
  20. local interface="$1"
  21. local chat
  22.  
  23. json_get_var device device
  24. json_get_var apn apn
  25. json_get_var service service
  26. json_get_var pincode pincode
  27. json_get_var dialnumber dialnumber
  28.  
  29. [ -e "$device" ] || {
  30. proto_set_available "$interface" 0
  31. return 1
  32. }
  33.  
  34. case "$service" in
  35. cdma|evdo)
  36. chat="/etc/chatscripts/evdo.chat"
  37. ;;
  38. *)
  39. chat="/etc/chatscripts/3g.chat"
  40. # cardinfo=$(gcom -d "$device" -s /etc/gcom/getcardinfo.gcom)
  41. cardinfo="huawei"
  42. if echo "$cardinfo" | grep -q Novatel; then
  43. case "$service" in
  44. umts_only) CODE=2;;
  45. gprs_only) CODE=1;;
  46. *) CODE=0;;
  47. esac
  48. export MODE="AT\$NWRAT=${CODE},2"
  49. elif echo "$cardinfo" | grep -q Option; then
  50. case "$service" in
  51. umts_only) CODE=1;;
  52. gprs_only) CODE=0;;
  53. *) CODE=3;;
  54. esac
  55. export MODE="AT_OPSYS=${CODE}"
  56. elif echo "$cardinfo" | grep -q "Sierra Wireless"; then
  57. SIERRA=1
  58. elif echo "$cardinfo" | grep -qi huawei; then
  59. case "$service" in
  60. umts_only) CODE="14,2";;
  61. gprs_only) CODE="13,1";;
  62. *) CODE="0302";;
  63. esac
  64. # export MODE="AT^SYSCFGEX=${CODE},3FFFFFFF,2,4"
  65. export MODE='AT^SYSCFGEX="0302",3FFFFFFF,2,4,7FFFFFFFFFFFFFFF,,'
  66. fi
  67.  
  68. # if [ -n "$pincode" ]; then
  69. # PINCODE="$pincode" gcom -d "$device" -s /etc/gcom/setpin.gcom || {
  70. # proto_notify_error "$interface" PIN_FAILED
  71. # proto_block_restart "$interface"
  72. # return 1
  73. # }
  74. # fi
  75. [ -n "$MODE" ] && gcom -d "$device" -s /etc/gcom/setmode.gcom
  76.  
  77. # wait for carrier to avoid firmware stability bugs
  78. # [ -n "$SIERRA" ] && {
  79. # gcom -d "$device" -s /etc/gcom/getcarrier.gcom || return 1
  80. # }
  81.  
  82. if [ -z "$dialnumber" ]; then
  83. dialnumber="*99***1#"
  84. fi
  85.  
  86. ;;
  87. esac
  88.  
  89. connect="${apn:+USE_APN=$apn }DIALNUMBER=$dialnumber /usr/sbin/chat -t5 -v -E -f $chat"
  90. ppp_generic_setup "$interface" \
  91. noaccomp \
  92. nopcomp \
  93. novj \
  94. nobsdcomp \
  95. noauth \
  96. lock \
  97. crtscts \
  98. 115200 "$device"
  99. return 0
  100. }
  101.  
  102. proto_3g_teardown() {
  103. proto_kill_command "$interface"
  104. }
  105.  
  106. add_protocol 3g
RAW Paste Data