Bluetooth Embedded System Lab. II
Bluetooth Bluetooth 10 Harald Blaatand Project Ericsson Mobile Communication,1994 Embedded System Lab. II 2
Bluetooth Bluetooth SIG (Special Interest Group) Members Promoters : Ericsson, Nokia, IBM, Toshiba, Intel, Microsoft, Motorola, 3Com, Lucent Technologies Associate Adopter Website : www.bluetooth.com, www.bluetooth.org Embedded System Lab. II 3
Bluetooth Concept PDA PDA 10~100m PC LAN Bluetooth PC Embedded System Lab. II 4
Bluetooth Concept Data/Voice Access Points Cable Replacement Personal Ad-hoc Networks Embedded System Lab. II 5
Bluetooth,, Low Cost : $5 per Chip Low Power : 0.3~30mA ( ) Short Range : 10m~100m, (PAN),, 2.4GHz ISM (Industrial Scientific Medical) Band 79 Channel,1MHz/CH : 10~100m : 1Mbps Embedded System Lab. II 6
Bluetooth, PDA, SIG (Special Interest Group),. :,, // :,, Embedded System Lab. II 7
Bluetooth 2400~2483.5Mhz : 2Mhz / : 2Mhz 3.5Mhz BT = 0.5 GFSK, : 1Mbps, : 0.28~0.35 -FH ( 1,600, 1 time slot = 625usec - 79 (1MHz ), 23-1 : 100 mw, - 2 : 0.25~25 mw, 8~2 db - 3 : 1 mw 70 dbm (), BER = 10 TDD ( Time Division Duplex) :, : -, : 432.6 kbps -, : 721 kbps - 1/3 : 3-2/3 : (15,10) (Shortened /hamming) - ARQ (Automatic Repeat Request) Bluetooth 1.0b Embedded System Lab. II 8
Bluetooth :, PC ( PC), PC, PDA,, AV,,,, LAN () :, LAN (), Embedded System Lab. II 9
Bluetooth (Piconet) Bluetooth 1 Master 10m 7 Slave (Scatternet) 100m 100 Embedded System Lab. II 10
Embedded System Lab. II 11
Pxa255 Pro Bluetooth Module Product Name : BlueSEM-CII Bluetooth V1.1 Module New Product ID : BTxZ50x2xx (Old ID :BTM1C2NR50, BTMZ5012x0 &BTMZ5012x1) Product ID Definition Digit 1~2 : Product's Abbreviation (BT: Bluetooth) Digit 3 : Interface/Application (A: USB Interface) (B: RFCOMM Interface) (E: UART Interface, 115.2k) (x: Undecided Code) Digit 4~6 : Module Size ( Z50 : 0.5cc ) Digit 7 : Hardware Revision (Starting from 0 ; x: Undecided Code) Digit 8 : Power Class ( 2 : Class2 ) Digit 9 : Customer Code (x: Undecided Code) Digit 10 : Firmware Revision (x: Undecided Code) Embedded System Lab. II 12
Bluetooth Block Diagram Embedded System Lab. II 13
Bluetooth Physical Dimension Embedded System Lab. II 14
Bluetooth Pin Description Embedded System Lab. II 15
Bluetooth Pin Description Embedded System Lab. II 16
Bluetooth Test Application PXA-255 Bluetooth : 7 On Bluetooth ttys1 Ramdisk ttys2 Embedded System Lab. II 17
Bluetooth Test Application #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <termios.h> // tcgetattr(), tcsetattr() #include <stdio.h> #include <strings.h> #include <signal.h> #define BAUDRATE B115200 // #define MODEMDEVICE "/dev/ttys1" //ttys! #define _POSIX_SOURCE 1 #define FALSE 0 volatile int STOP=FALSE; Embedded System Lab. II 18
Bluetooth Test Application int main() { int test = 0; int c, res; struct termios oldtio,newtio; pid_t pid; int fdttys1; char my_nick[9]; char other_nick[9]; char sendtemp[255]; char sendbuf[255]; char receivebuf[255]; char ch; int nicksize,sendsize,i; //termids Embedded System Lab. II 19
Bluetooth Test Application fdttys1 = open(modemdevice, O_RDWR O_NOCTTY );//, if (fdttys1 <0) {perror(modemdevice); exit(-1); } tcgetattr(fdttys1,&oldtio); //guswo wkdclfmf djesmsek, termios, bzero(&newtio, sizeof(newtio));// clear newtio.c_cflag = BAUDRATE CS8 CLOCAL CREAD; //,, 8bit, local connetction( ), newtio.c_iflag = IGNPAR ICRNL; /* IGNPAR : Parity. ICRNL : CR NL. ( CR.) otherwise make device raw (no other input processing) */ newtio.c_oflag = 0; newtio.c_lflag = ICANON; /* ICANON : canonical. disable all echo functionality, and don't send signals to calling program */ Embedded System Lab. II 20
Bluetooth Test Application newtio.c_cc[vintr] = 0; //ctrl-c newtio.c_cc[vquit] = 0; //ctrl-/ newtio.c_cc[verase] = 0; //del newtio.c_cc[vkill] = 0; //@ newtio.c_cc[veof] = 4; //ctrl-d newtio.c_cc[vtime] = 0; //time -> inter-character timer unused newtio.c_cc[vmin] = 1; //read, blocking read until 1 character arrives newtio.c_cc[vswtc] = 0; //'\0' newtio.c_cc[vstart] = 0; //ctrl-q newtio.c_cc[vstop] = 0; //ctrl-s newtio.c_cc[vsusp] = 0; //ctrl-z newtio.c_cc[veol] = 0; //'\0' newtio.c_cc[vreprint] = 0; //ctrl-r newtio.c_cc[vdiscard] = 0; //ctrl-u newtio.c_cc[vwerase] = 0; //ctrl-w newtio.c_cc[vlnext] = 0; //ctrl-v newtio.c_cc[veol2] = 0; //'\0' /* modem. */ tcflush(fdttys1, TCIFLUSH); tcsetattr(fdttys1,tcsanow,&newtio); Embedded System Lab. II 21
Bluetooth Test Application printf("input your nickname(length<=8):"); scanf("%8s",&my_nick); nicksize=strlen(my_nick); for(i=0;i<nicksize;i++) sendbuf[i]=my_nick[i]; // my_nick sendbuf[nicksize++]='`'; // sendbuf[nicksize++]='s'; sendbuf[nicksize++]='a'; sendbuf[nicksize++]='y'; sendbuf[nicksize++]=':'; sendsize=0; char recv_id[9]; char allo_id[9]; //broadcast bluetooth nickname printf("input nickname to communicate(length<=8):"); scanf("%8s",&allo_id); printf("input 'q' to quit\n"); Embedded System Lab. II 22
Bluetooth Test Application if((pid=fork())<0){//child process printf("error!!"); return -1; } if(pid>0){//parent process //terminal data read while(ch!='q'){ res = read(fdttys1,receivebuf,255);//ttys1. for(i = 0; i < 9; i++){ if(receivebuf[i]!= '`') recv_id[i] = receivebuf[i]; else break; } if(!strcmp(allo_id, recv_id)){// nickname if(res>0) printf("%s\n",receivebuf); ch=receivebuf[nicksize]; } } kill(pid, SIGQUIT); } Embedded System Lab. II 23
Bluetooth Test Application } else{//child process // data terminal write gets(sendtemp); while(ch!='q'){ printf("=>"); gets(sendtemp); sendsize=strlen(sendtemp); if(sendsize>0){ for(i=nicksize;i<nicksize+sendsize;i++) sendbuf[i]=sendtemp[i-nicksize]; sendbuf[sendsize+nicksize]='\0'; sendbuf[sendsize+nicksize+1]='\n'; test = write(fdttys1,sendbuf,nicksize+2+sendsize); if(test == 0) printf("write error\n"); printf("%s\n",sendbuf); ch=sendtemp[0]; } } kill(pid, SIGQUIT); } tcsetattr(fdttys1,tcsanow,&oldtio); return 0; Embedded System Lab. II 24
Bluetooth Embedded System Lab. II 25