Batteries included
Alex_90
Posts: 10
Joined: 17 Nov 2016, 12:23

Sending sms from usb modem that connected android device

Post by Alex_90 » 17 Nov 2016, 12:56

HI everyone. HI administrator Josh!!! I wish you lucky with programming. I want to send sms from usb modem on android device. I cant send "at commands". lsusb gives

Bus 001 Device 003: ID 12d1:1446
Bus 001 Device 001: ID 1d6b:0002
Bus 001 Device 001: ID 1d6b:0003

I use android studio. I think one of this ports for send and receive at commands. Another one to send and receive voice. There are no ttyUSB0 or ttyUSB1 in /dev folder. I dont know what to do. Please help it is need to me!

Josh
Site Admin
Posts: 6570
Joined: 03 Nov 2007, 00:30

Re: Sending sms from usb modem that connected android device

Post by Josh » 17 Nov 2016, 15:54

Well, you are running into the problem that drove me into starting the USB-ModeSwitch project ...

You need to 'mode-switch' most modems first before being able to use the actual modem ports.
See the "USB_ModeSwitch" link on the top navigation bar to reach the documentation you need.

Alex_90
Posts: 10
Joined: 17 Nov 2016, 12:23

Re: Sending sms from usb modem that connected android device

Post by Alex_90 » 18 Nov 2016, 17:51

PPP widget 2 is only for internet; But I need send sms using USB modem.
When I connect USB modem to my phone there are three ports: /dev/ttyUSB0, /dev/ttyUSB1, /dev/ttyUSB2
I can send AT command from terminal like this

#echo AT > /dev/ttyUSB0

and it answers OK

But I can't open /dev/ttyUSB1 and /dev/ttyUSB2
java.io.FILENotFoundException: /dev/ttyUSB2: open failed: EIO (I/O error)

Do you have any idea?

Josh
Site Admin
Posts: 6570
Joined: 03 Nov 2007, 00:30

Re: Sending sms from usb modem that connected android device

Post by Josh » 18 Nov 2016, 19:14

You can't 'legally' open device ports on the kernel level from Android apps. Furthermore, you can never be sure if the ttyUSB ports are created on every device - because there is no guarantee that the kernel driver for serial USB ports is available ...

PPP Widget 2 and 3 do not use the ttyUSB ports directly. They work through the Android USB API - that means they have a sort of "driver" on board, written in Java.

Note that it's not too hard to talk to USB devices that way. You don't need to do any low-level stuff because the basic USB communication is handled by the system. You send write requests to a port (or rather an endpoint) and poll it for replies (annother endpoint).

I started by looking at this implementation:
https://github.com/mik3y/usb-serial-for-android

Alex_90
Posts: 10
Joined: 17 Nov 2016, 12:23

Re: Sending sms from usb modem that connected android device

Post by Alex_90 » 19 Nov 2016, 07:20

Yes. You are right. The ports (/dev/ttyUSB0,/dev/ttyUSB1, /dev/ttyUSB2) were not created automatically. I created them manually by this command:

su
echo "12d1 1001" > /sys/bus/usb-serials/drivers/pl2303/new_id

Thanks for the information. Now I understand why these ports didn't created automatically. I will try the library as you said. Thanks!!!
But USB Modem has three interface.

12d1 1001
1d6b 0002
1d6b 0003

all of them CdcAcmSerialDriver?

Alex_90
Posts: 10
Joined: 17 Nov 2016, 12:23

Re: Sending sms from usb modem that connected android device

Post by Alex_90 » 21 Nov 2016, 12:27

Hello, Mr Josh! I'm sorry for disturbing you. But I need your help.

11-21 13:53:39.680 3457 4065 D UsbHostManager: beginUsbDeviceAdded(/dev/bus/usb/001/001) is blacklisted.
11-21 13:53:39.680 3457 4065 D UsbHostManager: beginUsbDeviceAdded(/dev/bus/usb/002/001) is blacklisted.

How to remove from blacklist. There those ports that i need. One of them for commands another one for voice.

Josh
Site Admin
Posts: 6570
Joined: 03 Nov 2007, 00:30

Re: Sending sms from usb modem that connected android device

Post by Josh » 21 Nov 2016, 13:53

I'm afraid that I can't help there ...

I have encountered such blacklist only on Sony tablets so far. They have explicitely barred most known modem sticks.

This is a thing the manufacturers have to implement. They can do so at various places - if they change the basic system libs, there is likely no work-around.

The question is: does PPP Widget 3 work on that device? It shouldn't either with that blacklisting.

Alex_90
Posts: 10
Joined: 17 Nov 2016, 12:23

Re: Sending sms from usb modem that connected android device

Post by Alex_90 » 21 Nov 2016, 14:23

I will try. But PPP widget2 works perfectly.

Alex_90
Posts: 10
Joined: 17 Nov 2016, 12:23

Re: Sending sms from usb modem that connected android device

Post by Alex_90 » 21 Nov 2016, 14:26

PPP widget 3 runs perfectly! Both of them run perfectly! At first time connected to the internet.

Mr Josh one question, how do you connect to the internet on PPP widget. I think procedure is the same. I saw PPP widget 2 log. It also send at commands and receive OK. then configures internet. I think there also two interface, one is for command another one is for internet data. Is not it?

Josh
Site Admin
Posts: 6570
Joined: 03 Nov 2007, 00:30

Re: Sending sms from usb modem that connected android device

Post by Josh » 21 Nov 2016, 22:43

If PPP Widget 2/3 works, the actual USB ports of the modem are not blocked. I think the blacklist notification may refer to a hub or something.

PPP Widget 2 can use only serial ports, and it uses just one - the connection is usually made through the interface that has an "interrupt endpoint" in addition to the IN and OUT endpoints.

PPP Internet connections are a relic from those old times where you just had a plain phone line to work with. Everything is done over one port - AT commands to configure the modem, then a PPP negotiation to set up the connection, then the actual network traffic exchange.

That's what PPP Widget 2 does, after picking the right port.

Now, with USB 3G modems, there may be more than one port which takes AT commands. However, instead of testing which port to use, you could just pick the one with the IRQ endpoint - it is useable in any case.

You need to pick the device, iterate over all interfaces and check their endpoint layout and interface class (look for 0x0a and 0xff) until you find the port you're looking for.

Alex_90
Posts: 10
Joined: 17 Nov 2016, 12:23

Re: Sending sms from usb modem that connected android device

Post by Alex_90 » 22 Nov 2016, 05:20

OK. Thanks a lot!!! Information that you gave me is very important. Because now I'm sure that ports are not blocked. I'll try this ports. Thanks!!!

Alex_90
Posts: 10
Joined: 17 Nov 2016, 12:23

Re: Sending sms from usb modem that connected android device

Post by Alex_90 » 22 Nov 2016, 12:51

HI, Mr Josh. What do you think about this?
This is logcat that when I connected my usb modem to the android phone.

11-22 15:04:39.841 3466 4065 D UsbHostManager: usb:UsbHostManager.beginUsbDeviceAdded(/dev/bus/usb/001/001)
11-22 15:04:39.841 3466 4065 D UsbHostManager: usb: nm:/dev/bus/usb/001/001 vnd:7531 prd:2 cls:9 sub:0 proto:1
11-22 15:04:39.841 3466 4065 D UsbHostManager: + device :: /dev/bus/usb/001/001 [1d6bh:0002h] [09h,00h,01h] Hub(Hi-speed hub with single TT ) (Linux 3.10.61-8007686 xhci-hcd/xHCI Host Controller/512/xhci-hcd.2.auto)
11-22 15:04:39.841 3466 4065 D UsbHostManager: beginUsbDeviceAdded(/dev/bus/usb/001/001) is blacklisted.
11-22 15:04:39.841 3466 4065 D UsbHostManager: usb:UsbHostManager.beginUsbDeviceAdded(/dev/bus/usb/002/001)
11-22 15:04:39.841 3466 4065 D UsbHostManager: usb: nm:/dev/bus/usb/002/001 vnd:7531 prd:3 cls:9 sub:0 proto:3
11-22 15:04:39.841 3466 4065 D UsbHostManager: + device :: /dev/bus/usb/002/001 [1d6bh:0003h] [09h,00h,03h] Unknown device (Linux 3.10.61-8007686 xhci-hcd/xHCI Host Controller/768/xhci-hcd.2.auto)
11-22 15:04:39.841 3466 4065 D UsbHostManager: beginUsbDeviceAdded(/dev/bus/usb/002/001) is blacklisted.
11-22 15:04:39.841 3466 4473 I ActivityManager: Process com.sec.android.app.popupuireceiver (pid 26554)(adj 9) has died(47,996)
11-22 15:04:39.841 3466 4473 D ActivityManager: isAutoRunBlockedApp:: com.sec.android.app.popupuireceiver, Auto Run ON
11-22 15:04:39.841 3466 4473 W ContextImpl: Calling a method in the system process without a qualified user: android.app.ContextImpl.sendBroadcast:830 com.android.server.am.ActivityManagerService.updateOomAdjLocked:26633 com.android.server.am.ActivityManagerService.appDiedLocked:7562 com.android.server.am.ActivityManagerService$AppDeathRecipient.binderDied:1917 android.os.BinderProxy.sendDeathNotice:558
11-22 15:04:41.361 4105 4289 D

Josh
Site Admin
Posts: 6570
Joined: 03 Nov 2007, 00:30

Re: Sending sms from usb modem that connected android device

Post by Josh » 22 Nov 2016, 21:31

I have no idea.

Is your app running already? Note that if you use PPP Widget 2/3 for the mode-switching process, you have to 'snatch' the USB device ID that the modem has afterwards.

De-install PPP Widget, install it again, connect your modem, confirm the first device request, wait a moment, deny the second device request and make that permanent.

Then you need your own "device filter" xml.

Did you read the USB Host API tutorial?

Alex_90
Posts: 10
Joined: 17 Nov 2016, 12:23

Re: Sending sms from usb modem that connected android device

Post by Alex_90 » 23 Nov 2016, 06:12

Hello, Mr Josh!
I'm sorry for disturbing you with many questions...
But I don't know anyone else. You are the only one who wrote app for usb modem. I did it on my PC with OS Win7. There are three ports. COM5, COM6, COM7. COM5 is for internet. COM7 is for at commands. It always sends information. COM6 is for voice data. It activated when you call someone.
I know how USB modems are work. Not all modems supported voice call. For internet modem works on /dev/ttyUSB0 that is called command line port of modem. This port answers for only asked questions. But another command line port is /dev/ttyUSB2 that always send information. For example if someone calls you it sends calling information etc.
I need call through usb modem that connected android device. If you help with this I'll pay for it.
Please help me.

Alex_90
Posts: 10
Joined: 17 Nov 2016, 12:23

Re: Sending sms from usb modem that connected android device

Post by Alex_90 » 23 Nov 2016, 08:51

Good morning Mr Josh if you are in Germany! :)
In linux system /dev/ttyUSB1 is for voice data and /dev/ttyUSB2 for at commands(Application interface);
/dev/ttyUSB0 is for internet. I have tested. But android doesn't let me to open /dev/ttyUSB2

Post Reply