I downloaded a sample bluetooth s/w and try to study that.
As far as I understand, when we have found the bluetooth enabled devices, we search the devices with the service we want.
For that we use UUID.
In that sample s/w, in the deviceDiscovered(RemoteDevice btDevice, DeviceClass cod) method , it writes like that
so by giving the second parameter of searchServices() method, we have specified the sevice we need.Code:public void deviceDiscovered(RemoteDevice btDevice, DeviceClass cod) UUID uuidSet[] = new UUID[1]; uuidSet[0] = RFCOMM_UUID; int searchID = m_DscrAgent.searchServices(null,uuidSet,btDevice,this); //////////When we will use the id that return from the searchServices() ////method?
But in the servicesDiscovered(int transID, ServiceRecord[] records) method, he test again like that
Why we need to test whether the url starts with btspp?Code:public void servicesDiscovered(int transID, ServiceRecord[] records) { for (int i = 0; i < records.length; i++) { m_strUrl = records[i].getConnectionURL(ServiceRecord.AUTHENTICATE_ENCRYPT, false); System.out.println(m_strUrl); if(m_strUrl.startsWith("btspp")) //we have found our service protocol { m_bServerFound = true; m_bInitClient=true; break; } } }
Is it necessary?
We have specified the servies we need in the bluetooth devices we found by setting the second parameter of searchServices() method?
is it not enough?
What is the service record????

Reply With Quote


