Send AT Commands to Android Phone - android

I want to Send AT Command to Android phone.
I know SDK does not support this.
but there are two solution :
change the code of Kernel and release your new Android (it seems it is so hard!)
LoopBack on USB.(i think Bluetooth is same)
About second solution , when you connect your phone to PC with USB cable , you will see a GSM modem on Device Manager that help you to send AT Command to GSM Modem.
If we find a solution to loop back on mobile phone , we can send AT commands to GSM Modem.
Question is : HOW to loop back and what tty file on kernel will help us?

first you have to root the phone then
in adb shell
su
echo -e "AT\r" > /dev/smd0
if you want to see answer use
cat /dev/smd0
i've test this command in samsung mini,cooper,s+ and it works.
if you use htc (htc rhyme tested) try to adb shell and type this command "radiooptions 13 AT"
if you want to see answer type "logcat -b radio"
try echo to /dev/smd0 for other devices
*you can use this command in sdk java code by using Runtime.exec (require su)

Related

Is it possible to use adb to take a screenshot of a wearable connected via bluetooth?

I have an LG watch which I can connect directly to my developer machine using USB and therefore can use the following command to take screenshots:
adb shell screencap -p /sdcard/screenshot.png
However my Moto 360 watch doesn't have a usb connection and thus I have to connect it using bluetooth going via its paired handset. This means there are always two devices connected to adb. Thus its not possible to use the adb shell command as adb doesn't know which device to apply it to. Some adb commands can have the device specied, but it doesn't look like this is possible with adb shell.
Using the Take wearables screenshot menu option in the Android Wear app isn't doing anything - it says "Screenshot request sent" but then nothing after that.
So how can I grab a screenshot of the watch? (I want to take a screenshot when there is an incoming phone call)
Enable bluetooth debugging on your wearable and setup a debugging session (described here: Debugging over Bluetooth).
You have to run any adb command in the following format:
adb -s localhost:4444 <command>
A simple
adb -s localhost:4444 shell screencap -p /sdcard/screenshot.png
adb -s localhost:4444 pull -p /sdcard/screenshot.png
should do the trick ;)

Device recognized in ADB but not in shell

When I use ADB, my phone is recognized. However, once I enter the shell, the phone mysteriously disappears. This is weird especially because the shell lists "root#nozomi", as "nozomi" is the phone's code name.
And because it is not recognized, I can't, for example, push files:
The adb command is available both on your phone and your host/development machine. However, it is not much useful on your phone from the shell.
adb shell opens a unix command shell on your phone. Commands you enter here are executed on your phone.
When you execute adb devices in the adb shell, you ask your phone if it has any other phones connected to it via the android debugging interface. And clearly your phone tells you, that this is not the case.
Same thing holds for adb push you are asking your phone to push a file to another phone via adb. Since none are connected, you get the error message.
Try exiting the adb shell again and execute commands on the host machine instead.

How to auto boot a rooted android device on charging [code req]

How to auto boot a rooted android phone when it is dead and connected to the charger?
I know many people think its not possible as when the device is OFF and ADB isn't running. But it turns out that it is possible to write an application for rooted device.
There is an application for the same #playstore to do just that.
I just want to make similar app. Any ideas or pointers?
I am researching for the same problem (Android 2.3, htc wildfire s), this are my investigation results:
It works! Unfortunaly it works, if you connect the phone without accumulator and after that insert the accu- now its autoboots. Connecting the phone with inserted accu or insert the accu in the unconnected phone does not work.
Not the result I hoped for but maybe a hint for a pointer.
And I found a script solution: https://android.stackexchange.com/questions/39899/auto-boot-when-charger-connected-for-htc-magic
echo "echo skipping chargemon" > chargemon.script
adb pull /system/bin/chargemon chargemon.backup
adb push chargemon.script /sqlite_stmt_journals
adb shell
$ cd /sqlite_stmt_journals
$ su
# mount -o remount,rw /dev/block/mtdblock0 /system
# cat chargemon.script > /system/bin/chargemon
# chmod 755 /system/bin/chargemon
# reboot -p
You should google a bit
i guess your looking for something
similar to this?
https://android.stackexchange.com/q/39899
Mostly you will have to check the boot-sequence of multiple devices and code accordingly as each device will have different setups
for example the app you posted in your question works only for samsung devices

Sending AT commands from Powershell script to Android phone via adb

I have a little script that I run in adb shell of Android phone (/system/etc directory), which enables to communicate with the modem by sending/receiving a single AT command.
The script itself, if run in adb shell, works OK. That's what it looks like:
cat /dev/pts/7 &
echo -e $1\\r > /dev/pts/7
Here's the output in adb shell:
# ./sendATCommand "at+cops?"
./sendATCommand "at+cops?"
#
+COPS: 0,0,"AT&T",6
OK
/dev/pts/7: invalid length
(need to press ENTER to return control to adb shell)
#
Now I want to invoke this script from a powershell script running on my PC, thus eventually controlling modem via AT commands, but nothing happens.
For example, the below powershell script will send the command at+cops? to check the operator to which mobile is registered to:
$adb = [IO.Path]::Combine([IO.Path]::Combine($Env:ANDROID, "platform-tools"), "adb.exe")
& $adb remount
$atCommand = "at+cops?"
& $adb shell /system/etc/sendATCommand $atCommand
The output may looks sometimes like +ATCMD (any residual [proprietary]AT command sitting in device buffer after bootup), or at+cops?(echo), or nothing at all, but
never +COPS: 0,0,"AT&T",6 which I expect. Could you help me figure out what's going on and how to possibly fix it? Ideally
I want to be able to execute at command, return control to powershell, and have output available for further processing.
I am also open to other solutions to implement same thing.
Would greatly appreciate your help. Thanks!
Not sure to answer your question, my phone is not an Android, but when I connect it via buetooth or USB to my computer a COM port is created. So I build an assembly tool on the top of .NET SerialPort class that allow, for example, to send SMS using the phone Modem.
I think it's usable in your case.

Read android device info from windows

Is it possible to get android device info (e.g. firmware version) from windows, when device is connected with PC by USB cable?
As I understand AT commands are not available. I was trying to use "adb", but I cannot see any usefull options. Maybe there is some text file with device info on the filesystem of the phone, so I could use "adb shell" to read this file?
Regards!
Use for example
adb -e shell getprop ro.build.display.id
to obtain something like
sdk-eng 2.1 ERD79 22607 test-keys
If you have more than one device or emulator, use
adb devices
to identify them and then use -s serialno in adb command line

Categories

Resources