Connecting Raspberry Pi running Android Things to wifi - android

I've been trying to connect to my Raspberry Pi running Android Things to wifi but to no avail.
I've followed this guide to connect to Wifi. I had connected my Pi via ethernet port to get the IP address and then was able to connect via adb connect Android.Local. But when starting the WifiSetupService via the below command
adb shell am startservice \
-n com.google.wifisetup/.WifiSetupService \
-a WifiSetupService.Connect \
-e ssid <Network_SSID> \
-e passphrase <Network_Passcode>
and then getting the logcat output via adb logcat -d | grep Wifi command, I get the below output:
12-28 17:27:19.761 1133 1133 D WifiSetupService: onStartCommand(Intent { act=WifiSetupService.Connect cmp=com.google.wifisetup/.WifiSetupService (has extras) })
12-28 17:27:19.761 1133 1133 I WifiConfigurator: Connecting to network with SSID "winterfell"
12-28 17:27:19.764 408 1052 D WifiService: setWifiEnabled: true pid=1133, uid=10023
12-28 17:27:19.771 1133 1360 D WifiConfigurator: Updating existing network 0
12-28 17:27:19.845 408 1361 D WifiNetworkHistory: saving network history: "winterfell"WPA_PSK gw: null Network Selection-status: NETWORK_SELECTION_ENABLED ephemeral=false choice:null link:0 status:2 nid:0 hasEverConnected: false
12-28 17:27:19.845 408 1361 V WifiNetworkHistory: writeKnownNetworkHistory write config "winterfell"WPA_PSK
12-28 17:27:19.883 408 1362 D WifiNetworkHistory: saving network history: "winterfell"WPA_PSK gw: null Network Selection-status: NETWORK_SELECTION_ENABLED ephemeral=false choice:null link:0 status:2 nid:0 hasEverConnected: false
12-28 17:27:19.884 408 1362 V WifiNetworkHistory: writeKnownNetworkHistory write config "winterfell"WPA_PSK
12-28 17:27:19.884 408 457 I WifiConnectivityManager: forceConnectivityScan
12-28 17:27:19.886 408 457 E WifiScanner: listener cannot be found
12-28 17:27:49.884 1133 1360 E WifiConfigurator: Wifi failed to connect in 30000 ms
I don't know where I am missing or why Pi is unable to connect to Wifi. I have verified multiple times that I'm sending the correct passphrase to the shell am command.
Any help will be highly appreciated!

the ssid for
-e ssid <Network_SSID> \
is case sensitive :-)
Try Winterfell

I got the same problem but my solution was different, I had an error when I tried to copy the code to the terminal:
adb shell am startservice \
-n com.google.wifisetup/.WifiSetupService \
enter code here
-a WifiSetupService.Connect \
enter code here
-e ssid Network \
-e passphrase Network_Password
It is important to add an space after: Network_Password, I mean an the end like:
adb shell am startservice \
-n com.google.wifisetup/.WifiSetupService \
enter code here
-a WifiSetupService.Connect \
enter code here
-e ssid Network \
enter code here
-e passphrase Network_Password" "
(Without Quotation marks, just a space at the end)

I think I had similar problem. It might be caused by my previous attempts to log to the same network but with wrong SSID/Password (issue with spaces solved here). First I tried to connect to another network, I used hotspot on my Android phone, with WPA2 and simple SSID/Password without any spaces or strange characters just to be sure. It connected without problems but I still couldn't connect to my target access point. What solved my problem was re-flashing the microSD card and trying to connect again but this time with correct SSID/Password for the first time.

Related

Permission denied even with 777

So I'm developing an android app. It uses IR blaster to send signals to TVs and other stuff. It worked fine on CyanogenMod 11(Android 4.4.4) but after updating to CyanogenMod 12(Android 5.0) it stopped working. App is assessing these files: /dev/ttyHSL2 and /sys/devices/platform/ir_remote_control/enable . Normally their permissions are ok, but after updating they are "ok" but not ok :/ :
05-09 23:44:02.980 28282-28340/com.sssemil.ir E/libsonyir﹕ IRpowerOn : Error opaning power node /sys/devices/platform/ir_remote_control/enable error : Permission denied
05-09 23:44:03.981 28282-28340/com.sssemil.ir I/libsonyir﹕ IRserialOpen : CALLED
05-09 23:44:03.991 28282-28340/com.sssemil.ir E/libsonyir﹕ IRserialOpen : Error opaning serial device /dev/ttyHSL2 error : Permission denied
So I've tried to fix them:
su -c "chmod 222 /sys/devices/platform/ir_remote_control/enable"
su -c "chmod 666 /dev/ttyHSL2"
Still same errors. Then I've tried this:
su -c "chmod 777 /sys/devices/platform/ir_remote_control/enable"
su -c "chmod 777 /dev/ttyHSL2"
Still nothing... I've checked permissions and they were ok:
shell#odin:/ $ su -c "ls -l /dev/ttyHSL2"
crwxrwxrwx system system 244, 2 2015-05-09 22:27 ttyHSL2
shell#odin:/ $ ls -l /sys/devices/platform/ir_remote_control/enable
-rwxrwxrwx system system 4096 2015-05-09 22:27 enable
So if there are any ideas please help me. My app is open source so here is source code if you need it https://github.com/sssemil/android_packages_apps_IRRemote .
Thanks.
So, to fix it type: su -c "setenforce 0"

How to prevent calabash-android "App did not start" error?

I work on linux pc,
Ensured that AndroidManifest.xml has permission for INTERNET.
Tried command both with and without proxy, observation is same.
my real device has 4.1.1 android software,
AVD has 4.2.2 android with API level 17, Would that be problem?
I observe that, sample demo app gets launched on device, while I run 'calabash-android run AndroidDemoProject.apk...
but command throws error saying "App did not start" (RunTimeError).
Error details:
Feature: Demo feature
Scenario: I can start my app # features/my_first.feature:3
I wait for "Hello World, AndroidDemoProject" to appear
3707 KB/s (553745 bytes in 0.145s)
3045 KB/s (36301 bytes in 0.011s)
App did not start (RuntimeError)
/usr/lib/ruby/gems/1.8/gems/calabash-android-0.4.9/lib/calabash-android/operations.rb:512:in `start_test_server_in_background'
/usr/lib/ruby/gems/1.8/gems/retriable-1.3.3.1/lib/retriable/retriable.rb:31:in `perform'
/usr/lib/ruby/gems/1.8/gems/retriable-1.3.3.1/lib/retriable/retriable.rb:59:in `retriable'
/usr/lib/ruby/gems/1.8/gems/calabash-android-0.4.9/lib/calabash-android/operations.rb:511:in `start_test_server_in_background'
/usr/lib/ruby/gems/1.8/gems/calabash-android-0.4.9/lib/calabash-android/operations.rb:92:in `start_test_server_in_background'
/home/vijayvk/Downloads/AndroidDemoProject/calabash/features/support/app_life_cycle_hooks.rb:15:in `Before'
Failing Scenarios:
cucumber features/my_first.feature:3 # Scenario: I can start my app
I wait for "Hello World, AndroidDemoProject" to appear
1 scenario (1 failed)
0 steps
0m22.337s
===========================================================================
$calabash-android run ../AndroidDemoProject.apk --verbose, leads to below output
013-09-04 15:42:45 - /usr/bin/ruby1.8 -S cucumber --verbose MAIN_ACTIVITY=sh.calaba.demoproject.AndroidDemoProjectActivity APP_PATH="/home/vijayvk/Downloads/AndroidDemoProject/AndroidDemoProject.apk" TEST_APP_PATH="test_servers/d06f94e698e2dfae7d59f229087ea78f_0.4.9.apk"
Code:
* features/support/env.rb
* features/support/app_installation_hooks.rb
* features/support/app_life_cycle_hooks.rb
* features/support/hooks.rb
* features/step_definitions/calabash_steps.rb
Features:
* features/my_first.feature
Parsing feature files took 0m0.002s
Feature: Demo feature
Scenario: I can start my app # features/my_first.feature:3
I wait for "Hello World, AndroidDemoProject" to appear
2013-09-04 15:42:46 - First scenario in feature - reinstalling apps
2013-09-04 15:42:46 - "/home/vijayvk/Development/adt-bundle-linux-x86-20130219/sdk/platform-tools/adb" -s 00000D6300009613 forward tcp:34777 tcp:7102
2013-09-04 15:42:46 -
2013-09-04 15:42:46 - Uninstalling: sh.calaba.demoproject.test
2013-09-04 15:42:47 - Success
2013-09-04 15:42:47 - Uninstalling: sh.calaba.demoproject
2013-09-04 15:42:49 - Success
2013-09-04 15:42:49 - Installing: test_servers/d06f94e698e2dfae7d59f229087ea78f_0.4.9.apk
3153 KB/s (553745 bytes in 0.171s)
2013-09-04 15:42:54 - pkg: /data/local/tmp/d06f94e698e2dfae7d59f229087ea78f_0.4.9.apk
Success
2013-09-04 15:42:55 - Installing: /home/vijayvk/Downloads/AndroidDemoProject/AndroidDemoProject.apk
4513 KB/s (36306 bytes in 0.007s)
2013-09-04 15:42:56 - pkg: /data/local/tmp/AndroidDemoProject.apk
Success
2013-09-04 15:42:59 - Waking up device using:
2013-09-04 15:42:59 - "/home/vijayvk/Development/adt-bundle-linux-x86-20130219/sdk/platform-tools/adb" -s 00000D6300009613 shell am start -a android.intent.action.MAIN -n sh.calaba.demoproject.test/sh.calaba.instrumentationbackend.WakeUp
Starting: Intent { act=android.intent.action.MAIN cmp=sh.calaba.demoproject.test/sh.calaba.instrumentationbackend.WakeUp }
2013-09-04 15:43:01 - Starting test server using:
2013-09-04 15:43:01 - "/home/vijayvk/Development/adt-bundle-linux-x86-20130219/sdk/platform-tools/adb" -s 00000D6300009613 shell am instrument -e class sh.calaba.instrumentationbackend.InstrumentationBackend -e target_package sh.calaba.demoproject -e test_server_port 7102 -e main_activity sh.calaba.demoproject.AndroidDemoProjectActivity -e debug false sh.calaba.demoproject.test/sh.calaba.instrumentationbackend.CalabashInstrumentationTestRunner
App did not start (RuntimeError)
/usr/lib/ruby/gems/1.8/gems/calabash-android-0.4.9/lib/calabash-android/operations.rb:512:in `start_test_server_in_background'
/usr/lib/ruby/gems/1.8/gems/retriable-1.3.3.1/lib/retriable/retriable.rb:31:in `perform'
/usr/lib/ruby/gems/1.8/gems/retriable-1.3.3.1/lib/retriable/retriable.rb:59:in `retriable'
/usr/lib/ruby/gems/1.8/gems/calabash-android-0.4.9/lib/calabash-android/operations.rb:511:in `start_test_server_in_background'
/usr/lib/ruby/gems/1.8/gems/calabash-android-0.4.9/lib/calabash-android/operations.rb:92:in `start_test_server_in_background'
/home/vijayvk/Downloads/AndroidDemoProject/calabash/features/support/app_life_cycle_hooks.rb:15:in `Before'
Failing Scenarios:
cucumber features/my_first.feature:3 # Scenario: I can start my app
I wait for "Hello World, AndroidDemoProject" to appear
1 scenario (1 failed)
0 steps
0m26.737s
==========================================================================
$ calabash-android console AndroidDemoProject/AndroidDemoProject.apk
No test server found for this combination of app and calabash version. Recreating test server.
Done signing the test server. Moved it to test_servers/d06f94e698e2dfae7d59f229087ea78f_0.4.9.apk
irb(main):004:0> ARGV << "-v"
[
[0] "--readline",
[1] "--prompt-mode",
[2] "simple",
[3] "-v"
]
irb(main):005:0> start_test_server_in_background
2013-09-04 16:29:06 - Starting test server using:
2013-09-04 16:29:06 - "/home/vijayvk/Development/adt-bundle-linux-x86-20130219/sdk//platform-tools/adb" -s 00000D6300009613 shell am instrument -e test_server_port 7102 -e class sh.calaba.instrumentationbackend.InstrumentationBackend -e debug false -e target_package sh.calaba.demoproject -e main_activity sh.calaba.demoproject.AndroidDemoProjectActivity sh.calaba.demoproject.test/sh.calaba.instrumentationbackend.CalabashInstrumentationTestRunner
RuntimeError: App did not start
from /usr/lib/ruby/gems/1.8/gems/calabash-android-0.4.9/lib/calabash-android/operations.rb:512:in `start_test_server_in_background'
from /usr/lib/ruby/gems/1.8/gems/retriable-1.3.3.1/lib/retriable/retriable.rb:31:in `perform'
from /usr/lib/ruby/gems/1.8/gems/retriable-1.3.3.1/lib/retriable/retriable.rb:59:in `retriable'
from /usr/lib/ruby/gems/1.8/gems/calabash-android-0.4.9/lib/calabash-android/operations.rb:511:in `start_test_server_in_background'
from /usr/lib/ruby/gems/1.8/gems/calabash-android-0.4.9/lib/calabash-android/operations.rb:92:in `start_test_server_in_background'
from (irb):5
Please let me know if there is any work around for this problem...
I could resolve this when I had come across this error, by doing this:
1) Close the AVD and restart
2) If (1) doesnt fix the issue, uninstall the app, and execute reinstall_apps for your app again
3) if (2) doesnt fix the issue, delete the test servers folder and execute start_test_server_in_background again.
Adding the following solves the problem as well.
<uses-permission android:name="android.permission.INTERNET" />
Reference:
http://www.luisdelarosa.com/2013/04/18/how-to-fix-problem-when-app-wont-start-when-testing-with-calabash-android/
Also you can try this way.
Inside your ruby folder find file operations.rb. Path is like this "C:\Ruby23-x64\lib\ruby\gems\2.3.0\gems\calabash-android-0.7.3\lib\calabash-android". Open the file and find the block of code:
Retriable.retriable :tries => 100, :interval => 0.1 do
raise "App did not start" unless app_running?
Change "tries" parameter value on 300 instead of 100. It will help your app run in case of insufficiently productive device.
We've tested 6 different devices with default settings, but only 2 flagship smartphones (Samsung galaxy S6) could run app with "tries" parameter value => 100.
Now all our devices can run apps great!

How to get the PID from PS command output in Android shell

Can anyone tell how can I get the PID from the output of PS command in Android shell.
For example from the output:
u0_a51 20240 38 132944 22300 ffffffff 40037ebc S com.example.poc_service
pid value 20240 is to be got. I tried
ps -ef | grep com.example.poc_service
but to no avail. Also pgrep is not being recognized.
If you have shell access in Android you can also use pidof:
# pidof com.example.poc_service
20240
However, be careful as there may be multiple processes matching...
Its pretty nasty but it works:
for pid in `ls /proc`; do
cmd=`cat $pid/cmdline 2> /dev/null`;
if [ "X$cmd" == "Xcom.example.poc_service" ]; then
echo $pid;
fi
done
or as one line:
for pid in `ls /proc`; do cmd=`cat $pid/cmdline 2> /dev/null`; if [ "X$cmd" == "X/system/bin/mm-qcamera-daemon" ]; then echo $pid; fi done
Neither grep, egrep, fgrep, rgrep is available in Android.
If you are working on Unix, Linux, Mac or Cygwin, you can pipe the output of adb shell command to get the result you want.
$ adb shell ps |grep settings
system 23846 71 111996 22676 ffffffff 00000000 S com.android.settings
$ adb shell ps |grep settings |awk '{print $2}'
23846

Android/adb redirect console app output

I am trying to get the output of a WLAN driver control interface via adb shell on a motorola droid 2. The command is called wlan_cu. To run the command,I am using:
% wlan_cu -itiwlan0 -s /data/jay/stat.sh
Connection established with supplicant .../Connection> Bssid_list,
Connect, Disassociate, Status, Full_bssid_list, wPs/
Status : DISCONNECT MAC : f8.7b.7a.7b.b7.9b SSID : <empty>
BSSID : 00.00.00.00.00.00
Channel : <empty>
Driver/, Connection/, Management/, Show/, Privacy/, scAn/, roaminG/, qOs/, poWer/, eVents/, Bt coexsistance/, Report/, dEbug/, biT/, aboUt, Quit
[1] Segmentation fault wlan_cu -itiwlan0 -s /data/jay/stat.sh
The -s option is to read wlan_cu commands from a script.
% cat /data/jay/stat.sh
c s
/
q
If I try to redirect the output i.e.
% wlan_cu -itiwlan0 -s /data/jay/stat.sh &> out.txt
out.txt is created, but empty and the output still goes to screen. Anyone have an idea? been stuck on this for quite a while.
you can try to redirect both stdout and stderr to the out.txt. Try this,
# wlan_cu -itiwlan0 -s /data/jay/stat.sh > out.txt 2>&1

GSM module with Android on BeagleBoard

I'm using http://www.sparkfun.com/products/9427 as GSM module. I've built for FTDI and generic usb-serial driver. Everytime I try to pppd call GPRS I'll get pppd: connect script failed.
The commands executed were:
1. pppd /dev/ttyUSB0
2. netcfg ppp0 up
3. pppd call gprs
gprs script:
/dev/ttyUSB0
460800
crtscts
modem
noauth
debug
nodetach
usepeerdns
noipdefault
defaultroute
user ""
0.0.0.0:0.0.0.0
connect '/system/bin/chat -s -v -f /system/etc/ppp/gprs-connect-chat' `
gprs-connect-chat script:
TIMEOUT 15
ABORT "DELAYED"
ABORT "BUSY"
ABORT "ERROR"
ABORT "NO DIALTONE"
ABORT "NO CARRIER"
TIMEOUT 40
'' \rAT
OK ATZ
OK "ATQ0 V1 E0 S0=0 &C1 &D2 +FCLASS=0"
OK AT+CGDCONT=1,"IP","Singtel"
OK ATDT*99#
CONNECT

Categories

Resources