2013년 12월 31일 화요일

Fix iOS 7 trust device problem on ubuntu 12.04

I think libimobiledevice's developer will give better solution than this guide, soon.
In developer homepage, easy way will be adopted  on 1.1.6.

This guide is just compile and update the newest version of the libimobiledevice and the ifuse.

So, I assume that a reader has a knowledge about using make, cmake, automake, git .. etc which are using widely on developing.

And I also do follow things on my ubuntu 12.04 before update binary.

  1. Install libimobiledeivce-1.1.5 and related libraries.
     http://www.libimobiledevice.org

  2. Disable automount on desktop.
     http://askubuntu.com/questions/89244/how-to-disable-automount-in-nautiluss-preferences
 
Before to do this guide, you must find your original binaries on your system. In my system, it was "/usr", so I add "--prefix=/usr" when configuration. 

Now, lets go.

1. update libimobiledevice
 - git clone https://github.com/libimobiledevice/libimobiledevice
 - cd libimobiledevice
 - autoreconfig
 - automake --add-missing
 - ./configure --prefix=/usr
 - sudo make install

2. update ifuse
 - git clone  http://cgit.sukimashita.com/ifuse.git
 - cd ifuse
 - ./autogen.sh
 - ./configure --prefix=/usr
 - sudo make install

 * I also manually update the libfuse as 2.9.3.

After finished, following command works fine.

- idevicepair pair
  -- success
- idevicepair validate
  -- paried deivce införmation
- ifuse /media/iphone --root
  -- it works fine

Trust message does not bother me after update.

Happy new year.


2013년 12월 21일 토요일

ANT building on android development

If you want to make a script for building, installing and rebooting device, ant build is needed.
Next steps may can help you do make a script or batching.

1. install jdk on your system

2. install ant on your system

3. If you have a custom library or want to just reference jar files, do modify android-sdk/tools/ant/build.xml likes follow. In this example, library added ordered by XXX, YYY, ZZZ.
I remove two lines from original code because do not include jar on my code.

<!-- Compiles this project's .java files into .class files. -->
    <target name="-compile" depends="-pre-build, -build-setup, -code-gen, -pre-compile">
        <do-only-if-manifest-hasCode elseText="hasCode = false. Skipping...">
            <!-- merge the project's own classpath and the tested project's classpath -->
            <path id="project.javac.classpath">
                <path refid="project.all.jars.path" />
                <path refid="tested.project.classpath" />
                <path path="${java.compiler.classpath}" />
            </path>
            <javac encoding="${java.encoding}"
                    source="${java.source}" target="${java.target}"
                    debug="true" extdirs="" includeantruntime="false"
                    destdir="${out.classes.absolute.dir}"
                    verbose="${verbose}"
                    fork="${need.javac.fork}">
                <src path="${source.absolute.dir}" />
                <src path="${gen.absolute.dir}" />
                <compilerarg line="${java.compilerargs}" />
                <classpath>
                          <fileset dir="/User/kwangjo/ANTBUILD" includes="XXX.jar" />
                          <fileset dir="/User/kwangjo/ANTBUILD" includes="YYY.jar" />
                          <fileset dir="/User/kwangjo/ANTBUILD" includes="ZZZ.jar" />
                </classpath>   
            </javac>


This code is same thing on your eclipse menu as follow.



4. you can make build script like as follows
 android update project --name YOURPROJECT -p ./

5. you can implements keystore file on ant.property, next is just sample. you input your own string matching with your keystore. This step is just optional.

key.store=YOUR keystore path
key.alias=YOUR keystore alias
key.store.password=password

key.alias.password=password

6. build your project, you can also do "ant debug"
ant release

Note for installing emacs on mac

Install GNU emacs on your mac.

1. compile emacs


# ./configure --with-ns
# make
# make install
# install nextstep's Emacs.app to Application folder


2. ecb install

- download latest version of ecb on this site
http://ecb.sourceforge.net
- unarchive the downloaded file to ~/.emacs.d/ecb folder
-add follow script to ~/.emacs file

if you encounter some ecb version error add follow text on .emacs
(custom-set-variables '(ecb-options-version "2.32"))



(add-to-list 'load-path "~/app/ecb-2.32/")
(require 'ecb)
(custom-set-variables
  ;; custom-set-variables was added by Custom.
  ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
  ;; If there is more than one, they won't work right.
 '(ecb-fix-window-size (quote width))
 '(ecb-layout-name "left1")
 '(ecb-layout-window-sizes (quote (("left9" (0.32857142857142857 . 0.9791666666666666)))))
 '(ecb-options-version "2.32")
 '(ecb-windows-width 0.33))
(custom-set-faces
  ;; custom-set-faces was added by Custom.
  ;; If you edit it by hand, you could mess it up, so be careful.
  ;; Your init file should contain only one such instance.
  ;; If there is more than one, they won't work right.
 )

;; customize the keys for ECB
(define-key ecb-mode-map (kbd "M-1") 'ecb-goto-window-directories)
(define-key ecb-mode-map (kbd "M-2") 'ecb-goto-window-sources)
(define-key ecb-mode-map (kbd "M-3") 'ecb-goto-window-methods)
(define-key ecb-mode-map (kbd "M-4") 'ecb-goto-window-history)
(define-key ecb-mode-map (kbd "M-5") 'ecb-goto-window-compilation)
(define-key ecb-mode-map (kbd "M-0") 'ecb-goto-window-edit1)

;; auto ecb mode
(setq ecb-auto-activate 'true)
(put 'scroll-left 'disabled nil)
script form http://poongbek.blogspot.kr/2011/06/emacs_04.html
  • "C-c s s": search symbol
  • "C-c s d", "C-c s g": search symbol defines
  • "C-c s G": move to symbol defines
  • "C-c s c": search function caller
  • "C-c s C": search function callee
  • "C-c s t": search string pattern
  • "C-c s e": search egrep pattern 
  • "C-c s f": search files
  • "C-c s i": search files which include the file
  • "C-c s b": show *cscope* 
  • "C-c s n": search a next symbol
  • "C-c s p": search a previous symbol
  • "C-c s N": search to next file
  • "C-c s P": search to pevious file
  • "C-c s a": set cscope database directory 
  • "C-c s A": resolve cscope database directory


3. Install autocomplete

http://www.emacswiki.org/emacs/AutoComplete

AutoCompleteScreenshot

git clone https://github.com/auto-complete/auto-complete
-git submodule init; git submodule update
- make install
- input directory name as ~/.emacs.d/auto-complete
- move libs folder such as popup, fuzzy and ert from auto-complete's source directory to ~/.emacs.d

add follow script to .emacs

;;auto-complete
(add-to-list 'load-path "/Users/kwangjo/.emacs.d/auto-complete")
(add-to-list 'load-path "/Users/kwangjo/.emacs.d/popup");
(require 'auto-complete-config)
(require 'popup)
(ac-config-default) 


4. Install CSCOPE

 - cscope should be installed using brew or make binary
 - Download source file from http://cscope.sourceforge.net
- you should make cscope.files on project directory
find . -name "*.java" > cscope.files
- emacs command using like below

5. using eTags

 - you can make navigate tags (like ctag with vi) using following command
find /usr/src/linux -name '*.[csSh]' | xargs etags

you can using follow script, navigate like vi.

(fset 'find-next-tag "\C-u\256") ; macro for C-u M-. 
(fset 'find-prev-tag "\C-u-\256") ; macro for C-u - M-. 
(global-set-key "\M-]" 'find-next-tag) (global-set-key "\M-[" 'find-prev-tag)

You can find tag using M-. and navigate using M-[ and M-]


6. customise emacs setting

I do not complete this setting. I write just reference pages as follow.

  you can customise colour and font on emacs
-http://www.emacswiki.org/emacs/ColorTheme

  you can customise font.
-http://www.emacswiki.org/emacs/SetFonts

 you can customise indentation.
- http://www.emacswiki.org/emacs/IndentingJava
-http://www.emacswiki.org/emacs/IndentingC



my .emacs setting file
(set-language-environment "Korean")
(prefer-coding-system 'utf-8)
(set-default-coding-systems 'utf-8)
(set-terminal-coding-system 'utf-8)
(set-keyboard-coding-system 'utf-8)
(set-selection-coding-system 'utf-8)
(setq coding-system-for-read 'utf-8)
(setq-default file-name-coding-system 'utf-8)

(add-hook 'eshell-mode-hook
          'lambda nil
          (let ((bashpath (shell-command-to-string "/bin/bash -l -c 'printenv PATH'")))
            (let ((pathlst (split-string bashpath ":")))
              (setq exec-path pathlst))
            (setq eshell-path-env bashpath)
            (setenv "PATH" bashpath)))


;;auto-complete
(add-to-list 'load-path "/Users/kwangjo/.emacs.d/auto-complete")
(add-to-list 'load-path "/Users/kwangjo/.emacs.d/popup")
(require 'auto-complete-config)
(require 'popup)
(ac-config-default)


;;ECB
(custom-set-variables '(ecb-options-version "2.40"))
(add-to-list 'load-path "/Users/kwangjo/.emacs.d/ecb")
(require 'ecb)

;; customize the keys for ECB
(define-key ecb-mode-map (kbd "M-1") 'ecb-goto-window-directories)
(define-key ecb-mode-map (kbd "M-2") 'ecb-goto-window-sources)
(define-key ecb-mode-map (kbd "M-3") 'ecb-goto-window-methods)
(define-key ecb-mode-map (kbd "M-4") 'ecb-goto-window-history)
(define-key ecb-mode-map (kbd "M-5") 'ecb-goto-window-compilation)
(define-key ecb-mode-map (kbd "M-0") 'ecb-goto-window-edit1)

;; auto ecb mode
(setq ecb-auto-activate 'true)
(put 'scroll-left 'disabled nil)

;;CSCOPE
(add-to-list 'load-path "/Users/kwangjo/.emacs.d/xcscope")
(require 'xcscope)
(add-hook 'java-mode-hook (function cscope:hook))
(add-hook 'html-helper-mode-hook (function cscope:hook))


;;ETAG hook
(fset 'find-next-tag "\C-u\256") ; macro for C-u M-.
(fset 'find-prev-tag "\C-u-\256") ; macro for C-u - M-.
(global-set-key "\M-]" 'find-next-tag)

(global-set-key "\M-[" 'find-prev-tag)

2013년 8월 15일 목요일


In this page, I write an instrument to build bluez 5.8 on raspberry pi board. 
I think bluetooth 4.0 and raspberry pi are very good materials for ad-hoc researchers.
I hope this page for helping to visitors.
In this page, I assume that user account is root mode (sudo su).

1. Install


You can get recent raspberrypi OS based on debian on follow site.
  • http://www.raspberrypi.org/downloads

In that site, you can download Raspbian “wheezy”.

After download, you write img file (it appers, when you unzip the downloaded file) 
to sdcard.

You can write img file using follow command. /dev/disk4 is sdcard mount position.
It can find using "df" command. In mac, unmount partition "diskutil unmount /dev/disk4s1", first.

  • sudo dd bs=1m if=~/Desktop/2013-07-26-wheezy-raspbian.img of=/dev/disk4

In first boot, you can change original password. Default user ID is pi.

2. Setting WIFI


If you install wifi usb device to raspberry pi, you should set some flags for using it.

First, you can check wifi device works properly using "iwlist scan" command or "iwconfig" command.
If it shows nearby wifi devices, it works properly, otherwise you need other other wifi device.

You can set IP as manually change "/etc/network/interfaces" file as follow. 
SSID is your ap's ssid and password is your password. In this example, password type is psk2.

auto lo

iface lo inet loopback
iface eth0 inet dhcp

auto wlan0
allow-hotplug wlan0
iface wlan0 inet static
address 192.168.0.33
netmask 255.255.255.0
gateway 192.168.0.1
dns-nameserver 168.126.63.1
wpa-ssid "SSID"
wpa-psk password

3. Building bluez

I use bluetooth 4.0 usb device using Broadcom chipset. It is recommended using Broadcom chipset device. It works properly for using bluetooth low energy. 

You can download blues tar file in http://www.bluez.org. You can upload tar file using sftp. 
After upload file, you can find the file on /home/pi. 
You can unarchive using follow command, after login ssh shell.
  • tar xvfz bluez-5.8.tar.xz 

You need glib ,dbus, libudev,libical and readline library. Run following commands. 
  • apt-get install libglib2.0
  • apt-get install libdbus-1-dev
  • apt-get install libudev-dev
  • apt-get install libical-dev
  • apt-get install libreadline-dev

You can build using follow command. Default prefix maybe /usr/local.
If you want to install, run "make install" after following command.
  • ./configure --disable-usb --disable-systemd --prefix=/usr
  • make
Next is "make install" log text.


root@raspberrypi:/home/pi/bluez-5.8# make install
make --no-print-directory install-am
 /bin/mkdir -p '/usr/bin'
  /bin/bash ./libtool   --mode=install /usr/bin/install -c client/bluetoothctl monitor/btmon tools/hciattach tools/hciconfig tools/hcitool tools/hcidump tools/rfcomm tools/rctest tools/l2test tools/l2ping tools/sdptool tools/ciptool tools/bccmd '/usr/bin'
libtool: install: /usr/bin/install -c client/bluetoothctl /usr/bin/bluetoothctl
libtool: install: /usr/bin/install -c monitor/btmon /usr/bin/btmon
libtool: install: /usr/bin/install -c tools/hciattach /usr/bin/hciattach
libtool: install: /usr/bin/install -c tools/hciconfig /usr/bin/hciconfig
libtool: install: /usr/bin/install -c tools/hcitool /usr/bin/hcitool
libtool: install: /usr/bin/install -c tools/hcidump /usr/bin/hcidump
libtool: install: /usr/bin/install -c tools/rfcomm /usr/bin/rfcomm
libtool: install: /usr/bin/install -c tools/rctest /usr/bin/rctest
libtool: install: /usr/bin/install -c tools/l2test /usr/bin/l2test
libtool: install: /usr/bin/install -c tools/l2ping /usr/bin/l2ping
libtool: install: /usr/bin/install -c tools/sdptool /usr/bin/sdptool
libtool: install: /usr/bin/install -c tools/ciptool /usr/bin/ciptool
libtool: install: /usr/bin/install -c tools/bccmd /usr/bin/bccmd
 /bin/mkdir -p '/usr/libexec/bluetooth'
  /bin/bash ./libtool   --mode=install /usr/bin/install -c src/bluetoothd obexd/src/obexd '/usr/libexec/bluetooth'
libtool: install: /usr/bin/install -c src/bluetoothd /usr/libexec/bluetooth/bluetoothd
libtool: install: /usr/bin/install -c obexd/src/obexd /usr/libexec/bluetooth/obexd
 /bin/mkdir -p '/usr/lib/cups/backend'
  /bin/bash ./libtool   --mode=install /usr/bin/install -c profiles/cups/bluetooth '/usr/lib/cups/backend'
libtool: install: /usr/bin/install -c profiles/cups/bluetooth /usr/lib/cups/backend/bluetooth
 /bin/mkdir -p '/etc/dbus-1/system.d'
 /usr/bin/install -c -m 644 src/bluetooth.conf '/etc/dbus-1/system.d'
 /bin/mkdir -p '/usr/share/man/man1'
 /usr/bin/install -c -m 644 tools/hciattach.1 tools/hciconfig.1 tools/hcitool.1 tools/hcidump.1 tools/rfcomm.1 tools/rctest.1 tools/l2ping.1 tools/sdptool.1 tools/ciptool.1 tools/bccmd.1 '/usr/share/man/man1'
 /bin/mkdir -p '/usr/share/man/man8'
 /usr/bin/install -c -m 644 src/bluetoothd.8 '/usr/share/man/man8'


Building needs a lot of time. (It takes almost one hour on my board.
Make a tar file after building. It will help to save time when needing to install again. 
Following command is moving to home directory and making tar file.

  • cd ~&& tar cvfz bluez_builded.tar ./bluez-5.8 3. Building bluez

4. Turn on bluez and bluetooth

 After finish "make install", you can run hciconfig command. If your bluetooth device works properly, following similar message will show up.

hci0: Type: BR/EDR  Bus: USB
BD Address: 00:19:0E:11:D6:29  ACL MTU: 1021:8  SCO MTU: 64:1
DOWN 
RX bytes:1520 acl:0 sco:0 events:57 errors:0
TX bytes:1946 acl:0 sco:0 commands:57 errors:0

You can turn on the device using following command.
  • hciconfig hci0 up
You can check your device MAC address using following command.
  • hcitool dev

You also needs dbus demon and obex demon for bluetooth. These demons in "/usr/libexec/" folder.
You can run deamon using following command.

  • /usr/libexec/bluetoothd&
  • /usr/libexec/obexd&

5. Conclusion

Nowadays, bluez has big changes. It seems that bluetooth low energy support. 

Any comments is ok. 

Next, I will post some sensor application on raspberry pi using BLE technology. 
If anyone knows working sensors (degree, humidity, etc) on raspberry pi, 
please recommend it to me.


Thank you visit my blog.

References


[1] http://www.bluez.org/
[2] http://www.raspberrypi.org
[3] http://i-miss-erin.blogspot.kr/2010/12/gatttool-in-bluez-over-bredr.html
[4] http://linux.die.net/man/8/hciconfig
[5] Gareth Halfacree, Eben Upton. "Raspberry Pi User Guide", John Wiley & Sons Ltd, 2012

RPI is not good handling DHT11

Hello? This is failure story about converting c code to python. There is GPIO controlling library on Python such as RPI, wiringPI. But...