2010年4月7日 星期三

acer 5560 sawed

Pic Ref:
沒想到筆電的CMOS電池會沒電.真是有點扯..... 只好來把它肢解一下.... 好在現在又可以work了... PS: 不知道拿給acer修理要多少錢阿.... 看來自己修理應該是最省的

Bluetooth Player ...

Pic Ref: Bluetooth Player...

Tools

  • tool language : java
  • library : JSR82 (blue tooth lib)
  • : AVIDemo (jpeg 2 avi)
  • external tool : FFmpeg (media converter)

Ref: WebCam http://funningboy.blogspot.com/2010/04/remote-webcam-player.html Ref : image 2 vedio stream http://changyy.pixnet.net/blog/post/25435171 Ref: stream 2 flv/3gp http://www.unix-center.net/bbs/viewthread.phptid=16031 http://apocryph.org/2007/10/27/transcoding_avi_flv_ffmpeg/ http://goinggnu.wordpress.com/2007/02/13/convert-avi-to-3gp-using-ffmpeg/

Ref: Bluetooth http://funningboy.blogspot.com/2010/04/bluetooth-sample-code.html http://funningboy.blogspot.com/2010/04/bluetooth-case-study.html Ref : java call external .exe http://www.javaworld.com.tw/jute/post/view?bid=29&id=31477&sty=3

Target: we use our cell phone to display our media from our Webcam emulator. what's the WebCam emulator? you can ref our previous posted "Remote Player" http://funningboy.blogspot.com/2010/04/remote-web-player-pt1.html PS: "Webcam emulator" is a sample way to emulate the Webcam captured for each frame and stored it in "jpg" format. Design flow : the left hand side is our Webcam emulator and the right hand side is our image converted. both of them are independent, so we use the synchronous queues to our interface, that can commute the multi triggers by each time. Webcam emulator : always captured our frames in 1frame/100ms, and stored in jpg. Converter : always convert from jpgs 2 our media Bluetooth : communucation between our host and client. PS: the java api not support media stream for real time, so you use the media storage for a while time, if it finish and put it to our clint. Result : sample code download : http://sites.google.com/site/funningboy/java-1/jpg2avi_bluetooth.rar?attredirects=0&d=1

Bluetooth sample code

在Bluetooth 的傳輸的Protocl上.包括 RFCOMM 和 Object Exchange (OBEX) 兩種方式.底下就protocl 部分做個簡單的介紹 Ref: http://funningboy.blogspot.com/2010/04/bluetooth-case-study.html 藍芽通訊協定stack
  • HCI 主機控制器介面(Host Controller Interface). 主機(電腦)和控制器(藍芽設備)之間的介面.
  • L2CAP 邏輯連結控制器適配協定(Logical Link Controller Adaptation Protocol),這一層充當其他所有層的資料多工器.
  • BNEP 即藍芽網路封裝協定(Bluetooth Network Encapsulation Protocol) , 可以在藍芽上執行其他網路協定, 例如 IP、TCP 和 UDP.
  • RFCOMM 稱作虛擬串流通訊協定(virtual serial port protocol),因為它允許藍芽設備類比串流的功能
  • OBEX 通訊協定層是在 RFCOMM 層上面實作, 把資料以物件 "檔" (data) 的形式傳輸
  • SDP 是服務發現協定(Service Discovery Protocol)層,用於在遠端藍芽設備上尋找服務
  • AVCTP 和 AVDTP,用於藍芽上音頻和視頻的控制.

底下用 jsr82 來實現 RFCOMM.

Server.java

import java.io.*;
import javax.microedition.io.*;
import javax.bluetooth.*;

public class RFCOMMServer {

    public static void main( String args[] ) {
        try {
            String url = "btspp://localhost:" +
                new UUID( 0x1101 ).toString() +
                ";name=SampleServer";
            StreamConnectionNotifier service =
                (StreamConnectionNotifier) Connector.open( url );

            StreamConnection con =
                (StreamConnection) service.acceptAndOpen();
            OutputStream os = con.openOutputStream();
            InputStream is = con.openInputStream();

            String greeting = "JSR-82 RFCOMM server says hello";
            os.write( greeting.getBytes() );

            byte buffer[] = new byte[80];
            int bytes_read = is.read( buffer );
            String received = new String(buffer, 0, bytes_read);
            System.out.println("received: " + received);
         
            con.close();
        } catch ( IOException e ) {
            System.err.print(e.toString());
        }
    }
}

Client.java

import java.io.*;
import javax.microedition.io.*;
import javax.bluetooth.*;

public class RFCOMMClient {

    public static void main( String args[] ) {
        try {
            String url = "btspp://0123456789AB:3";

            StreamConnection con =
                (StreamConnection) Connector.open(url);

            OutputStream os = con.openOutputStream();
            InputStream is = con.openInputStream();

            String greeting = "JSR-82 RFCOMM client says hello";
            os.write( greeting.getBytes() );

            byte buffer[] = new byte[80];
            int bytes_read = is.read( buffer );
            String received = new String(buffer, 0, bytes_read);
            System.out.println("received: " + received);
         
            con.close();
        } catch ( IOException e ) {
            System.err.print(e.toString());
        }
    }
}

請注意 "url" 要改成你的 address & port.

如不知道,可用jsr 82所提供的 ServiceSearch.java

Ref: http://www.jsr82.com/

結果: BlueCove version 2.1.0 on winsock wait for device inquiry to complete... Device 001D289E7AFE found name K530i Device 2421AB354DC5 found Device 001E45B4779B found name Z610i Device Inquiry completed! 3 device(s) found BlueCove stack shutdown completed