android bluetooth implementation basics -
can in simple words explain me need of uuid in android bluetooth example. have read articles still not getting clear exact need of uuid. , let me explain scenario of want develop: want develop android application transfer data example "file .xyz extension" phone other phone on bluetooth. not @ necessary receiving phone should have application using. want transfer data application other phone , thats it. don't care receiver data. want connect device within range , transfer file using application how should this? the role of uuid come here? have read uuid application , , both server , receiver should aware of uuid form connection . if receiver not have application? surely not know applications uuid ? how data transfer possible? want use bluetooth without concerning specific application. in here, application should doing? should creating server socket / client socket or what? , why.
an explanation in simple words appreciated(some articles if possible). dont want regular answers having bluetoothchat suggestions. if don't understand question please let me know, try more specific , elaborate you. basic goal of question clarify use of uuid , transfer data between 2 devices (and not application) using bluetooth application running on 1 android phone.
even bluetooth can create client-server application.. there bluetoothsocket
read here http://developer.android.com/reference/android/bluetooth/bluetoothsocket.html
now, lets have 2 devices:
- device
- device b
and assume device sending data device b, didn't if device b sending data device a, i'll describe first scenario when send b.
so in case, since data stored in device , want send device b, more reasonable create device bluetoothserver , device b bluetoothclient listening server.
but.. if want both of devices exchange data.. can make 1 of them server , each 1 of them create 2 threads:
- thread sends data
- thread listening data
so both of them can exchange data..
another thing.. if ever programmed regular client server noticed accept()
method blocking until there client connected server.. same bluetooth client-server application.
summarize:
one device act server - you'll need write server project , install
on first devicesecond device act client - you'll need write client project , install on second device
don't forget add bluetooth permission in manifest file both
projects.both of projects need same uuid mentioned in question. in simple words both of sides need uuid each know they're communicate think it's more port in regular client-server.. read somewhere used rfc communication.. know there are
protocols bluetooth rfc,sdp , etc..
edit: in of phones there pairing process when want send data through bluethooth. if don't want use client-server version, think can this:
- your application search devices connect to. (pairing process)
- after pairing connected other device , send data
edit 2: want send data b right? i'll explain more clearly..
you're right when said client should know server , need insert port , ip of server correct , works in way.
now, look..
the server listen connection clients, when connection established communication begins.
- client ask data
the server processing client request , send him related data
so data like: files, databases should stored on server side..
now in case, files want send located in device , not in device b, if device server listen connections.. when device b connects server (device a) communication begins.. device b can request files device a.. also, since device server, can broadcast message.. means send same message clients connected him.
but you're want send file if device b didn't ask it, right? don't understand if want device b send file device a, lets divide it
scenarios:just device send b: in case, since files located in device a, means device have data, device server , device b client. when connection established can send b.
both devices exchange data: in case, both devices should listen each other, 1 of should act server , other client. means need install serverapp on 1 of them , clientapp on other. each of them can send , listen other. each of need create thread handle sending data , thread handles receiving data
Comments
Post a Comment