Modify ↓
Opened 6 years ago
Last modified 4 years ago
#1308 investigate enhancement
Support 3G dongle: Huawei EC156
Reported by: | anonymous | Owned by: | |
---|---|---|---|
Priority: | normal | Milestone: | |
Component: | fon-network-3g | Version: | N/A |
Severity: | unknown | ||
Cc: | Hardware: | both |
Description (last modified by matthijs)
My Huawei E1750 just says "dailing in" in the web gui but no connection. Modem Huawei EC156 INWI from Morocco Modem like Modem Tata photon
root@Fonera:~# cat /proc/bus/usb/devices T: Bus=01 Lev=00 Prnt=00 Port=00 Cnt=00 Dev#= 1 Spd=480 MxCh= 1 B: Alloc= 2/800 us ( 0%), #Int= 2, #Iso= 0 D: Ver= 2.00 Cls=09(hub ) Sub=00 Prot=01 MxPS=64 #Cfgs= 1 P: Vendor=0000 ProdID=0000 Rev= 2.06 S: Manufacturer=Linux 2.6.21.7 dwc_otg_hcd S: Product=DWC OTG Controller S: SerialNumber=lm0 C:* #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr= 0mA I:* If#= 0 Alt= 0 #EPs= 1 Cls=09(hub ) Sub=00 Prot=00 Driver=hub E: Ad=81(I) Atr=03(Int.) MxPS= 4 Ivl=256ms T: Bus=01 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#= 5 Spd=12 MxCh= 0 D: Ver= 1.10 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs= 1 P: Vendor=12d1 ProdID=140c Rev= 0.00 S: Manufacturer=HUAÿWEI TECHNOLOGIES S: Product=HUAWEI Mobile S: SerialNumber=ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ C:* #Ifs= 5 Cfg#= 1 Atr=a0 MxPwr=500mA I:* If#= 0 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=ff Prot=ff Driver=option E: Ad=81(I) Atr=03(Int.) MxPS= 16 Ivl=128ms E: Ad=82(I) Atr=02(Bulk) MxPS= 64 Ivl=0ms E: Ad=02(O) Atr=02(Bulk) MxPS= 64 Ivl=0ms I:* If#= 1 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=ff Prot=ff Driver=option E: Ad=85(I) Atr=03(Int.) MxPS= 16 Ivl=8ms E: Ad=83(I) Atr=02(Bulk) MxPS= 64 Ivl=0ms E: Ad=03(O) Atr=02(Bulk) MxPS= 64 Ivl=0ms I:* If#= 2 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=ff Driver=option E: Ad=84(I) Atr=02(Bulk) MxPS= 64 Ivl=0ms E: Ad=04(O) Atr=02(Bulk) MxPS= 64 Ivl=0ms I:* If#= 3 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=ff Driver=option E: Ad=86(I) Atr=02(Bulk) MxPS= 64 Ivl=0ms E: Ad=06(O) Atr=02(Bulk) MxPS= 64 Ivl=0ms I:* If#= 4 Alt= 0 #EPs= 2 Cls=08(stor.) Sub=06 Prot=50 Driver=usb-storage E: Ad=87(I) Atr=02(Bulk) MxPS= 64 Ivl=0ms E: Ad=08(O) Atr=02(Bulk) MxPS= 64 Ivl=0ms root@Fonera:/Apps# cat umtsd.lua #!/usr/bin/lua -- (c) john@phrozen.org gplv2 -- we have 9 states local ERROR = 1 local INIT = 2 local PIN = 3 local PUK = 4 local PORTS = 5 local IDLE = 6 local REG = 7 local DIAL = 8 local ONLINE = 9 local DISCONN = 10 local states = { "ERROR", "INIT", "PIN", "PUK", "PORTS", "IDLE", "REG", "DIAL", "ONLINE", "DISCONNECT" } local state = ERROR local ATI_error = 0 local uci = require("luci.model.uci").cursor_state() -- some dummy data local model local vendor local data = "/dev/ttyUSB0" local cmd = "/dev/ttyUSB1" local pass = "" local apn = "" local pin = "" local since = 0 local mode local device = uci:get("umtsd", "umtsd", "device") local vidpid = uci:get("umtsd", "umtsd", "vidpid") local huawei local hso local conf_data local conf_cmd if vidpid and device then print(device..vidpid) conf_data = uci:get("umtsd", device..vidpid, "data") conf_cmd = uci:get("umtsd", device..vidpid, "cmd") huawei = uci:get("umtsd", device..vidpid, "huawei") or "0" hso = uci:get("umtsd", device..vidpid, "hso") or "0" model = uci:get("umtsd", device..vidpid, "model") vendor = uci:get("umtsd", device..vidpid, "vendor") print(conf_data) print(conf_cmd) print(huawei) print(hso) print(model) print(vendor) end if conf_data ~= nil and conf_cmd ~= nil then os.execute("logger found "..device..vidpid) data = conf_data cmd = conf_cmd else if device == "hso" then data = "/dev/ttyUSB3" end if device == "usbserial" then data = "/dev/ttyUSB2" cmd = "/dev/ttyUSB0" end end -- the reason why we are in error state local error_reason = "" -- info about the network local signal local provider local seconds local rx local tx -- the pid of the pppd local pppdpid -- we use the umts c binding local umts = require("umts") -- and store our instance here local u -- helper function to parse the signal strength function getsignal() local signal = umts.chat(u, "AT+CSQ\r\n", 1000) if signal ~= nil then local csq = string.find(signal, "+CSQ:") local eol = string.find(signal, "\n", (csq or 1)) if csq == nil or eol == nil then return nil end return string.sub(signal, csq + 6, eol - 1) end return nil end -- helper function for reading user data function get_user_data() pin = uci:get("umtsd", "umtsd", "pin") apn = uci:get("umtsd", "umtsd", "apn") user = uci:get("umtsd", "umtsd", "user") pass = uci:get("umtsd", "umtsd", "pass") mode = uci:get("umtsd", "umtsd", "mode") or "1" end function strip_foo(a) local l = a:find(" ") if l > 1 then return a:sub(1, l - 1) end return a end -- let luci know what we are doing function dump_uci_state() if huawei ~= "1" then if signal then signal = string.sub(signal, 1, string.len(signal) - 1) end local netdata = require("luci.sys").net.getifconfig() local wan = uci:get("network", "wan", "device") if netdata[wan] then tx = strip_foo(netdata[wan]["TX bytes"] or "0") rx = strip_foo(netdata[wan]["RX bytes"] or "0") end seconds = os.time() - since end local uci = require("luci.model.uci").cursor_state() -- Remove the state file before writing to it, to prevent it -- from groing without bounds (by default, uci_state only -- appends to a file). os.execute("rm /var/state/umtsd") uci:load("umtsd") uci:set("umtsd", "umtsdstate", "vendor", vendor or ""); uci:set("umtsd", "umtsdstate", "model", model or ""); uci:set("umtsd", "umtsdstate", "provider", provider or ""); uci:set("umtsd", "umtsdstate", "signal", signal or "") uci:set("umtsd", "umtsdstate", "state", states[state] or "") uci:set("umtsd", "umtsdstate", "tx", tx or 0) uci:set("umtsd", "umtsdstate", "rx", rx or 0) uci:set("umtsd", "umtsdstate", "online", seconds or 0) -- Since we removed the file, rewrite these variables uci:set("umtsd", "umtsd", "attached", "1") uci:set("umtsd", "umtsd", "device", device) uci:set("umtsd", "umtsd", "vidpid", vidpid) uci:save("umtsd") end -- -- each state has its own handler -- -- error state -- we just loop here function handle_state_error() local uci2 = require("luci.model.uci").cursor() local needpin = uci2:get("umtsd", "umtsd", "needpin") local wrongpin = uci2:get("umtsd", "umtsd", "wrongpin") local pinpuk = uci2:get("umtsd", "umtsd", "pinpuk") get_user_data() if apn and apn ~= "" and needpin ~= "1" and wrongpin ~= "1" and pinpuk ~= "1" and ATI_er return INIT end return ERROR end -- init state -- here we check if the modem is ready and check whether it needs a pin function handle_state_init() umts.chat(u, "ATE0\r\n", 1000); if apn ~= "cdma" then if hso == "1" then if mode == "0" then --GPRSONLY umts.chat(u, "at_opsys=0,2\r\n", 30000) elseif mode == "1" then --3GONLY umts.chat(u, "at_opsys=1,2\r\n", 30000) elseif mode == "2" then --GPRSPREF umts.chat(u, "at_opsys=2,2\r\n", 30000) elseif mode == "3" then --3GPREF umts.chat(u, "at_opsys=3,2\r\n", 30000) end elseif device == "usbserial" then print "nothing" elseif huawei == "1" then if mode == "0" then --GPRSONLY umts.chat(u, "AT^SYSCFG=13,1,40000000,2,4\r\n", 30000) elseif mode == "1" then --3GONLY umts.chat(u, "AT^SYSCFG=14,2,40000000,2,4\r\n", 30000) elseif mode == "2" then --GPRSPREF umts.chat(u, "AT^SYSCFG=2,1,40000000,2,4\r\n", 30000) elseif mode == "3" then --3GPREF umts.chat(u, "AT^SYSCFG=2,2,40000000,2,4\r\n", 30000) end end end local answer = umts.chat(u, "AT+CPIN?\r\n", 1000); if answer == nil then return ERROR; elseif string.find(answer, "CME ERROR") ~= nil then return INIT; elseif string.find(answer, "+CPIN: READY") ~= nil then return PORTS; elseif string.find(answer, "+CPIN: SIM PIN") ~= nil then return PIN; elseif string.find(answer, "+CPIN: SIM PUK") ~= nil then return PUK; else umts.log("unhandled PIN return code"..answer) end error_reason = "unhandled pin error" return ERROR; end -- pin state -- here we set the pin. if a pin is needed, but none is given, we throw an error function handle_state_pin() local uci2 = require("luci.model.uci").cursor() if pin == nil or #pin == 0 then uci2:set("umtsd", "umtsd", "needpin", "1") uci2:commit("umtsd") umts.log("oops, no pin but need one") error_reason = "need a pin" return ERROR end local answer = umts.chat(u, "AT+CPIN=\""..pin.."\"\r\n", 1000) if answer ~= nil and string.find(answer, "ERROR") ~= nil then uci2:set("umtsd", "umtsd", "wrongpin", "1") uci2:commit("umtsd") umts.log("oops, wrong pin") error_reason = "wrong pin" return ERROR; end uci2:delete("umtsd", "umtsd", "wrongpin") uci2:delete("umtsd", "umtsd", "failcount") uci2:commit("umtsd") return INIT; end -- puk state -- here we will not do anything but set the error state function handle_state_puk() local uci2 = require("luci.model.uci").cursor() local puk = uci2:get("umtsd", "umtsd", "puk") if puk then local answer = umts.chat(u, "AT+CPIN=\""..puk.."\", \""..pin.."\"\r\n", 1000) uci2:delete("umtsd","umtsd","puk") uci2:commit("umtsd") return INIT end uci2:set("umtsd", "umtsd", "pinpuk", "1") uci2:commit("umtsd") umts.log("oops, we need a puk") error_reason = "need a puk" return ERROR end function handle_state_ports() local uci2 = require("luci.model.uci").cursor() local ati = umts.chat(u, "ATI\r\n", 1000) print(ati) if ati ~= nil then local mfg = string.find(ati, "Manufacturer:") local eol = string.find(ati, "\n", (mfg or 1)) local mod = string.find(ati, "Model:") local eol2 = string.find(ati, "\n", (mod or 1)) if mfg == nil or mod == nil or eol == nil or eol2 == nil then umts.log("ATI failed") error_reason = "ATI failed" return ERROR end if huawei ~= "1" then vendor = string.sub(ati, mfg + 13, eol - 1) local r = string.find(vendor, "\r"); if r then if r then model = string.sub(model, 1, r - 1) end ATI_error = 0 return IDLE end ATI_error = ATI_error + 1 return ERROR end -- idle state -- if we have not doen so, we get info on the device -- then we wait until we are in a umts cell function handle_state_idle() _provider = umts.chat(u, "AT+COPS?\r\n", 1000) provider = nil print(_provider) if _provider then local s1, s2 s1 = string.find(_provider, "\"") if s1 and s1 > 0 then s2 = string.find(_provider, "\"", s1 + 1) if s2 and s2 > 0 then provider = string.sub(_provider, s1 + 1, s2 - 1) end end end print(provider) if provider and provider ~= "Limited Service" then return REG end return IDLE end -- reg state -- here we wait for the signal function handle_state_reg() if getsignal() ~= nil then return DIAL end return REG end -- dial state -- this is where we start pppd function handle_state_dial() local srv = require("luci.fon.service") local service = srv.Service("pppdumts") local params = {data, "460800", "crtscts", "lock", "defaultroute", "mtu", "1500", "mru", "1500", "noauth", "noipdefault", "novj", "usepeerdns", "nodetach", "connect", "/usr/sbin/chat -v -f /tmp/chat_umts", "nodetach", "unit", "0", "linkname", "wan", "ipparam", "wan"} if user and pass then params[#params + 1] = "user" params[#params + 1] = user params[#params + 1] = "password" params[#params + 1] = pass end if device ~= "usbserial" then print(umts.chat(u, "ATH\r\n", 1000)) print(umts.chat(u, "ATZ\r\n", 1000)) -- print(umts.chat(u, "AT+CGDCONT=1,\"IP\",\""..apn.."\",\"0.0.0.0\",0,0\r\n", 1000) end local f = io.open("/tmp/chat_umts", "w") if f then f:write("ABORT \"NO CARRIER\"\n".. "ABORT \"NO DIALTONE\"\n".. "ABORT \"ERROR\"\n".. "ABORT \"NO ANSWER\"\n".. "ABORT \"BUSY\"\n".. "\"\" \"ATZ\"\n".. "OK \"ATH\"\n".. "OK AT+CGDCONT=1,\"IP\",\""..apn.."\"\n".. "OK \"ATD*99***1#\"\n".. "\"CONNECT\" \"\"") f:close() service:start(unpack(params)) if service:status() == true then return ONLINE end end error_reason = "failed to write /tmp/chat_umts" return ERROR end -- online state -- check whether pppd is still running local last_since = 0 local last_since = 0 function handle_state_online() local srv = require("luci.fon.service") local service = srv.Service("pppdumts") if since == 0 then local wan = uci:get("network", "wan", "device") if wan and #wan > 3 then since = os.time() end end if service:status() ~= true then return DISCONN; end local async = umts.async(u, service:getpid()) if async and string.sub(async, 4, 12) == "DSFLOWRPT" then -- huawei delivers a line like this --> -- ^DSFLOWRPT:000000F8,00000000,00000000,000000000001640C,000000 0000048B14,0003E800,0003E800 -- :seconds , TX , RX seconds = tonumber(string.sub(async, 14, 21) or 0, 16) tx = tonumber(string.sub(async, 41, 56) or 0, 16) rx = tonumber(string.sub(async, 58, 73) or 0, 16) end local s = getsignal() if s then signal = s end return ONLINE; end -- disconn state -- here we make sure the umts modem goes offline, before exit function handle_state_disconn() get_user_data() umts.chat(u, "ATH\r\n", 1000) umts.reopen(u) return IDLE end local state_cb = { handle_state_error, handle_state_init, handle_state_pin, handle_state_puk, handle_state_ports, handle_state_idle, handle_state_reg, handle_state_dial, handle_state_online, handle_state_disconn } get_user_data() u = umts.new(data, cmd) local changed = 1 local last_time = os.time() while true do if changed == 1 then print("state --> "..state.."--"..(states[state] or "")) end changed = 1 local t = os.time() if (t - last_time) > 60 then os.execute("logger umtsd - clock skew detected") since = since + (t - last_time) end last_time = t local newstate = state_cb[state]() if newstate == state then umts.sleep() changed = 0 else if state == ONLINE then tx = 0 rx = 0 online = 0 signal = 0 since = 0 end end state = newstate if state == ERROR and error_reason ~= nil then print(error_reason) error_reason = nil end dump_uci_state() end
Attachments (0)
Change History (5)
comment:1 Changed 6 years ago by anonymous
comment:2 Changed 5 years ago by matthijs
- Description modified (diff)
- Hardware changed from 2.0n (FON2300) to both
- Status changed from new to investigate
- Summary changed from Huawei EC156 to Support 3G dongle: Huawei EC156
- Type changed from request to enhancement
- Version changed from 2.3.7.0 (Paco) to N/A
We're currently working on a new firmware version which improves support. When it becomes available, we'll leave a comment here.
comment:3 Changed 4 years ago by anonymous
can someone help me
comment:4 Changed 4 years ago by hichm19956@…
I Upgrede to 2.3.8.0 1 beta
but i have problem, it show me SIM Error but my Modem not use SIM This have EVDO and Hybryde connection
comment:5 Changed 4 years ago by hichm19956@…
how can i configurate port , Data ?
Note: See
TracTickets for help on using
tickets.
if you don't understand problem I'Will tel you in Audre way in first moment i attached my Huawei EC156 but he show me this
i edit in :
root@Fonera:/# cd /etc/usb_modeswitch.d/vi 12d1:1505
root@Fonera:/# vi /etc/usb_modeswitch.conf
http://code.google.com/p/wl500g/source/browse/branches/rt-n/usb_modeswitch/data/usb_modeswitch.d/12d1%3A1505?r=3188
and fonera show this
but the problem how i can enable it "dailing in"
thank you and sorry about my bad english