I've got a problem in service with service attribte propagation and service attribute retrieval. I want to implement a service that propagates additional information about the service by using an individual service attribute.
The prppagation of the service attribute should work. I'm using the code below:
try{
//connection string: scheme, target, parameters
//... for servers: btspp://localhost:serviceuuid;name=servicename
//... for clients: btspp://00803dad2AA1:3;authenticate=true
UUID uuid = new UUID(0x0003);
notifier = (StreamConnectionNotifier)Connector.open("btspp://localhost:"+uuid.toString()+";name=Scatternet");
//modify the service record here
LocalDevice ld = LocalDevice.getLocalDevice();
ServiceRecord sr = ld.getRecord(notifier);
analyseServiceRecord(sr);
long seqno = 0;
//Construct a new seqno DataElement
DataElement seqnoDataElement = new DataElement(DataElement.U_INT_4, seqno);
//Write the new seqno DataElement
boolean successful = sr.setAttributeValue(ATTRIBUTE_ID, seqnoDataElement);
System.out.println("ReceiveManager: ServiceRecord modified successfully: " + successful);
analyseServiceRecord(sr);
//Explicitely update the ServiceRecord in the SDDB of the LocalDevice, otherwise no effect will take place.
ld.updateRecord(sr);
//Get the current Attribute of the RemoteDevice from its ServiceRecord
ServiceRecord sr = servRecord[i];
//Read the seqno DataElement
int [] attrIDs = {ATTRIBUTE_ID_ID};
boolean successful = sr.populateRecord(attrIDs);
System.out.println("PiconetManager: Retrieving SeqNo from ServiceRecord successfully: " + successful);
if(successful){
DataElement seqnoDataElement = sr.getAttributeValue(ATTRIBUTE_ID);
long seqno = seqnoDataElement.getLong();
dos.writeLong(seqno);//seqno
} else {
System.out.println("PiconetManager: Could not retrieve SeqNo from ServiceRecord. (Line 103)");
return;
}
} catch (IOException ioe){
ioe.printStackTrace();
}
That produces the following output:
Searching on device No. 1 of 1 for a RFCOMM service with ATTRIBUTE_ID in its attribute set.
Service discovered
Explicitely retrieving Attribute service attribute: false
no, cant tell you whats wrong, infact im having the same problem, I can supposedly set these service record attributes as you say, and its says they are set i.e. no errors been thrown, but when I try it on the Nokia 6600, it just has the original service record attributes only.
I tried seeting for both my own services and those exisiting services and both failed. On the phone itself it also tells me its sets them , but when i try to retrieve the service record from the second phone they are not present (and yes I have them in my attr list)
Anyone could help, it would be good, what about that Graham guy, he seems to know everything about J2ME??
Graham are you there? Whats the solution?
i got it working with a custom service using a long form of UUID in my notifier eg 1020304050D0708093A1B121D1E1F100 on a Nokia 6600, couldnt get it to work with short form of UUID for existing services or short form of UUID using custom services, im pretty new at this so guess i dont know how to do my connections correctly and neither do those idiots who write those Bluetooth books.
Do you mean to publish something like a string about ur server? Try to use attribitute 51. I used it before successfully to publish more date about my server. But actualy I dnt remember why.