2013年4月28日 星期日

association models

bluetooth的安全驗證機制稱為Secure Simple Pairing。
主要是探討pairing過程的各種驗證機制。
association models是pairing驗證模式的通稱,描述bluetooth連線驗證方面的專有名詞(spec定義的)。
應用範圍為authentication和security



2013年4月24日 星期三

apk

http://tieba.baidu.com/p/1267596506
摘要:
android中的apk檔是一個zip壓縮檔,可以用解壓縮軟體解開。

http://zeaster.blogspot.tw/2007/11/how-to-decompile-dex-file-on-android_28.html
http://www.imobilebbs.com/wordpress/archives/1026
摘要:
class.dex  為 Java編譯成Dalvik 代碼(非Java code)。
.apk 打包後的 所以.xml 文件格式為binary XML 文件格式,可以使用AXMLPrinter2.jar
將二進位XML轉迴文本格式:
java -jar AXMLPrinter2.jar AndroidManifest.xml > AndroidManifest.xml.txt

 http://jinnsblog.blogspot.com/2011/10/how-to-use-sdk-to-install-apk.html
http://givemepass.blogspot.tw/2011/11/adb.html
摘要:
安裝格式:「adb install path/file
預設會安裝在/system/app/ 底下(我的是/factory)

/sdcard/music = 音樂目錄
/sdcard/Download = 下載檔案的預設目錄 

 http://fecbob.pixnet.net/blog/post/35840955-%E5%8F%B2%E4%B8%8A%E6%9C%80%E5%BC%B7android%E5%8F%8D%E7%B7%A8%E8%AD%AF%E5%B7%A5%E5%85%B7%E7%B6%A0%E8%89%B2%E7%89%88v2.0%EF%BC%88%E6%94%B9%E9%80%B2%E7%89%88
 摘要:
android apk反編譯軟體apktool

Android Bluetooth

07.Android之Bluetooth 

http://blog.csdn.net/jjunjoe/article/details/6928913

2013年4月22日 星期一

bluetooth rfcomm

http://www.piaccess.com/trac/wiki/Linux_BlueZ_Bluetooth_Serial_Setup
http://blog.mcuol.com/User/kynot/Article/7049_1.htm
 About rfcomm arugement "channel"
 http://ubuntuforums.org/showthread.php?t=200142

rfcomm  usage:
rfcomm <command> <Bluetooth Device> <BD Address> < Channel>

# rfcomm bind hci0 00:07:A4:D2:03:67 1
#ls -l /dev/rfcomm0
crw------- root root  <time>  rfcomm0
# hcitool cc 00:07:A4:D2:03:67 

2013年4月9日 星期二

2013年4月8日 星期一

extern struct

http://stackoverflow.com/questions/3266580/extern-struct

I'm using extern to fetch variables from another class, and it works fine for int's, float's etc...
But this doesn't work, and I don't know how to do it:

Class1.cpp
struct MyStruct {
 int x;
}

MyStruct theVar;
 
Class2.cpp
extern MyStruct theVar;

void test() {
 int t = theVar.x;
}
 
It doesn't work because Class2 doesn't know what MyStruct is.
How do I fix this? :/
I tried declaring the same struct in Class2.cpp, and it compiled, but the values were wrong.


7 down vote accepted
You put the struct MyStruct type declaration in a .h file and include it in both class1.cpp and class2.cpp.
IOW:
Myst.h
struct MyStruct {
 int x;
};
 
Class1.cpp
#include "Myst.h"

MyStruct theVar;
 
Class2.cpp
#include "Myst.h"

extern struct MyStruct theVar;

void test() {
 int t = theVar.x;
}

gcc -ldl

-ldl 指示连接器连接一个库。这个库里包含了 dlopen, dlsym 等等的函数。也就是说,是支持“在运行时,显示加载使用动态连接库”的函数库。相关的头文件是 dlfcn.h

2013年4月7日 星期日

gcc引用非標準函式庫(gcc -l -L)

gcc引用非標準函式庫要求正確的引用順序
格式:
gcc [source code: .c, .o, .a] [ -l | -L ]
Example:
gcc sin.c -lm -L/usr/lib -I/usr/include
 
 
Try:
gcc $(CFLAGS) -o xxx xxx.o ../../dbus/libdbus.a  = O OK 
gcc $(CFLAGS) -ldbus -L../../dbus -o xxx xxx.o  = X FAIL
gcc $(CFLAGS) -ldbus -L../../dbus -o xxx xxx.o  = X FAIL
gcc $(CFLAGS) -o xxx xxx.o -ldbus -L../../dbus  = O OK 
gcc $(CFLAGS) -o xxx xxx.o -L../../dbus  = X FAIL
gcc $(CFLAGS) -o xxx xxx.o -L../../dbus -ldbus  = O OK  

gcc -I、:=與#include

http://www.rapidtables.com/code/linux/gcc/gcc-i.htm

gcc -I option flag

gcc -I adds include directory of header files.
Syntax
$ gcc -Idir [options] [source files] [object files] [-o output file]
Example
proj/src/myheader.h:

// myfile.h
#define NUM1 5



myfile.c:

// myfile.c
#include
#include "myheader.h"

void main()
{
int num = NUM1;
printf("num=%d\n", num);
}



Build myfile.c without include directory proj/src :

$ gcc myfile.c -o myfile
myfile.c:2:22: fatal error: myheader.h: No such file or directory
compilation terminated.
$



Build myfile.c with include directory proj/src :

$ gcc -Iproj/src myfile.c -o myfile
$ ./myfile
num=5
$


這個方法是可行的,之前的編譯include路徑無效問題出現在
GCC=gcc
LIBFLAGS:=$(CFLAGS) -c
CFLAGS:= -Dxxx -Wall -g -I...
LIBFLAGS使用當下的選項,CFLAGS為空值,從下make指令後可看出。
應該改為:
GCC=gcc
LIBFLAGS=$(CFLAGS) -c
CFLAGS:= -Dxxx -Wall -g -I...

2013年4月3日 星期三

linker input file unused because linking not done

gcc -c

正當我被GCC "undefined reference"搞得死去活來時...

(1)
拜讀了這篇精闢的解說....
http://ticktick.blog.51cto.com/823160/431329
(2)
undefined reference還是除不完
發現undefined reference to android_atomic_release_cas

extern inline int android_atomic_release_cas(int32_t old_value,
int32_t new_value,
volatile int32_t *ptr)
{
android_memory_barrier();
return android_atomic_cas(old_value, new_value, ptr);
}

改用g++編譯。
(3)
g++編譯錯誤, invalid conversion from...
解决方法:CXXFLAGS = -fpermissive

2013年4月2日 星期二

Android Makefile

http://huenlil.pixnet.net/blog/post/23801824-%5B%E8%BD%89%5Dandroid-jni%E5%AF%A6%E4%BE%8B
http://3sec.kilab.tw/?p=244

GCC #error

#error 強迫compiler停止compile,主要是用來除錯用的。與ifdef並用,可以讓程式在某些define
錯誤狀況下中止

語法是
#error 錯誤訊息

當程式遇到#error,錯誤訊息會在console端顯示出來,一般會和其他compiler所定義的訊息
一起顯示出來。

找不到struct ucred

http://linux.die.net/man/7/unix
Ancillary Messages

SCM_CREDENTIALS
Send or receive UNIX credentials. This can be used for authentication. The credentials are passed as a struct ucred ancillary
message. Thus structure is defined in as follows:

struct ucred {
pid_t pid; /* process ID of the sending process */
uid_t uid; /* user ID of the sending process */
gid_t gid; /* group ID of the sending process */
};

Since glibc 2.8, the _GNU_SOURCE feature test macro must be defined (before including any header files) in order to obtain the
definition of this structure.
The credentials which the sender specifies are checked by the kernel. A process with effective user ID 0 is allowed to specify values
that do not match its own. The sender must specify its own process ID (unless it has the capability CAP_SYS_ADMIN), its user
ID, effective user ID, or saved set-user-ID (unless it has CAP_SETUID), and its group ID, effective group ID, or saved
set-group-ID (unless it has CAP_SETGID). To receive a struct ucred message the SO_PASSCRED option must be enabled on the socket.