Bluetooth / Change the RFCOMM server channel number
Hi,
When I create a RFCOMM server the channel is automatically set by the system. I'd like to choose it myself, but for now I can't manage to do it !
I have this exception raised :
[COLOR="Blue"]Bluetooth Server Running Error: javax.bluetooth.ServiceRegistrationException: wrong protocol description list attribue[/COLOR]
Here is a block of code I have used to try changing the channel :
ServiceRecord sr = localDevice.getRecord(notifier);
DataElement protocolDescriptorList = sr.getAttributeValue(0x0004);
Enumeration protocolDescriptorListElems = (Enumeration)protocolDescriptorList.getValue();
DataElement newProtocolDescriptorList = new DataElement (DataElement.DATSEQ);
DataElement newRFCOMM = new DataElement (DataElement.DATSEQ);
DataElement deL2CAP = (DataElement)protocolDescriptorListElems.nextElement();
newProtocolDescriptorList.addElement(deL2CAP);
DataElement deRFCOMM = (DataElement)protocolDescriptorListElems.nextElement();
Enumeration deRFCOMMElems = (Enumeration)deRFCOMM.getValue();
DataElement deRFCOMMUUID = (DataElement)deRFCOMMElems.nextElement();
DataElement deRFCOMMChannel = (DataElement)deRFCOMMElems.nextElement();
DataElement deRFCOMMChannelNew = new DataElement(DataElement.U_INT_1, 14); [COLOR="red"]// I try to change to channel 14[/COLOR]
newRFCOMM.addElement(deRFCOMMUUID);
[U]newRFCOMM.addElement(deRFCOMMChannelNew);[/U]
[COLOR="Red"][B]// here if I do newRFCOMM.addElement(deRFCOMMChannel); everything works fine[/B][/COLOR]
newProtocolDescriptorList.addElement(newRFCOMM);
sr.setAttributeValue(0x0004, newProtocolDescriptorList);
Thanks a lot to anybody would have an idea !!!
Oli
Re: Bluetooth / Change the RFCOMM server channel number
Hi!
were you able to set the server rfcomm channel as you required?
I have the same problem and I don't know how to solve it.
Thanks,
Dario