martes, 12 de febrero de 2013

Arduino Mega ADK - Fundamentals


Requirements

Hardware
     1. Arduino Mega ADK
     2. Wifi-shield
     3. Mega Sensor shield
     4. Wifi Module

Tinker-kit also comes with several micro mechanical sensors such as accelerometer, photo-resistor, among others. Each sensor can be connected to the Mega sensor shield in order to sense environmental data.

Software

HTerm (for configuring Arduino WiFi)
Eclipse ( IDE for Android application development)

Assemble the follow structure (from top to bottom)
Wifi-Module -> Wifi-shield -> Micro controller


Configure Wifi Module and Establish Android Communication

/*
* author Huber Flores
*/
### Getting Arduino ready for HTerm
# 1- Set your Wifi Shield to USB (It’s a small switch on you WiFi Shield).
# 2- Upload BareMinimum sketch to your Arduino ((File->Examples->Basic->BareMinimum).
# 3- Open HTerm.
### Connect with following settings
# Port = Port, that you arduino is connected to
# Baud = 9600
# Data = 8
# Stop = 1
# Parity = None
# CTS Flow control = unchecked
### Set up new Baud rate, by typing in the following into Input control box
$ $$$ (Send or enter = None)
$ set u b 115200 (Send or enter = CF-LF from now on)
$ save
$ reboot
###Connecting Arduino to WiFi
# Connect as you did before, only set Baud to 115200
# Enter command mode(type $$$ (send on enter = None))
$ Set “Send or enter” to CF-LF
# Type “scan” (you should now see a list of WiFi networks available)
$ set wlan ssid <your wifi name>
$ set wlan pass <your wifi password>
$ save
$ reboot
# if configuration is successful then, Wifi Shield and led from Wifi module must be blinking
### Set up Arduino to communicate with Android
# Enter command mode
$ set ip remote 2000
$ set ip proto 1
$ comm times 1000
$ get ip
$ set ip host <your android ip address>
$ save
$ reboot
view raw arduino.as hosted with ❤ by GitHub


Once you established communication with Android, then you are ready to start developing Arduino sketches and your Android app.

Here some code to try

martes, 5 de febrero de 2013

Building Isolated Dalvik Machine

/*
* author Huber Flores
*/
#We also can provide you with Amazon image (AMI) public with Android x86
#Please contact to huber AT UT DOT ee for granting access
# CyanogendMod/Android environment must be set up first
# refer to CM7Guide (https://gist.github.com/huberflores/4687766)
$ cd ./android/system/
$ . build/envsetup.sh
$ lunch
.
.
103. cyanogen_espresso-eng
104. cyanogen_fascinatemtd-eng
105. cyanogen_galaxys2-eng (This one)
106. cyanogen_galaxys2att-eng
.
.
Which would you like? [full-eng] 105
============================================
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=2.3.7
TARGET_PRODUCT=cyanogen_galaxys2
TARGET_BUILD_VARIANT=eng
TARGET_SIMULATOR=false
TARGET_BUILD_TYPE=release
TARGET_BUILD_APPS=
TARGET_ARCH=arm
TARGET_ARCH_VARIANT=armv7-a-neon
HOST_ARCH=x86
HOST_OS=linux
HOST_BUILD_TYPE=release
BUILD_ID=GINGERBREAD
============================================
# After environment is configured
$ make -j10 libdvm
or
$ make dalvikvm dalvik
============================================
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=2.3.7
TARGET_PRODUCT=cyanogen_galaxys2
TARGET_BUILD_VARIANT=eng
TARGET_SIMULATOR=false
TARGET_BUILD_TYPE=release
TARGET_BUILD_APPS=
TARGET_ARCH=arm
TARGET_ARCH_VARIANT=armv7-a-neon
HOST_ARCH=x86
HOST_OS=linux
HOST_BUILD_TYPE=release
BUILD_ID=GINGERBREAD
============================================
.
.
.
Install: out/host/linux-x86/bin/apriori
Install: out/host/linux-x86/bin/soslim
Copy: out/host/linux-x86/usr/icu/icudt44l.dat
Copy: out/host/linux-x86/etc/security/cacerts.bks
Install: out/host/linux-x86/lib/libcrypto.so
Install: out/target/product/galaxys2/system/lib/libdl.so
Install: out/target/product/galaxys2/system/lib/libc.so
Install: out/target/product/galaxys2/system/lib/libstdc++.so
Install: out/target/product/galaxys2/system/lib/libm.so
Install: out/target/product/galaxys2/system/lib/liblog.so
Install: out/target/product/galaxys2/system/lib/libz.so
Install: out/target/product/galaxys2/system/lib/libicuuc.so
Install: out/target/product/galaxys2/system/lib/libexpat.so
Install: out/target/product/galaxys2/system/lib/libcutils.so
Install: out/target/product/galaxys2/system/lib/libcrypto.so
Install: out/target/product/galaxys2/system/lib/libicui18n.so
Install: out/target/product/galaxys2/system/lib/libssl.so
Install: out/target/product/galaxys2/system/lib/libutils.so
Install: out/host/linux-x86/lib/libssl.so
Install: out/target/product/galaxys2/system/lib/libsqlite.so
Install: out/target/product/galaxys2/system/lib/libnativehelper.so
Install: out/target/product/galaxys2/system/lib/libdvm.so ###Dalvik engine for Galaxy S2 i9100###
Install: out/host/linux-x86/lib/libicuuc.so
Install: out/host/linux-x86/lib/libicui18n.so
Install: out/host/linux-x86/lib/libdvm.so ###Dalvik engine for x_86###
<
(optional)
# Android x86
$ ./out/host/linux-x86/bin/dalvikvm
# Launch script for the Dalvik Virtual Machine in x86
# Here you actually could wrap .class files into .dex files and execute them within your computer :)
>
# Replace libdvm.so in your phone
# Plug galaxys2 (in my case :P) phone to your computer
$ adb root
adbd is already running as root
$ adb remount
remount succeeded
$ adb push ./android/system/out/target/product/galaxys2/system/lib/libdvm.so /system/lib/liddvm.so
3990 KB/s (671576 bytes in 0.164s)
$ adb reboot
Your phone will restart with the new Dalvik engine
view raw dalvik.as hosted with ❤ by GitHub