Logo Search packages:      
Sourcecode: kdebluetooth version File versions  Download package

bool KBluetooth::SDP::Service::getRfcommChannel ( unsigned int &  n )

Retrieves the Rfcomm channel. This function is provided just for conveniance.

nThe Rfcomm channel. true if an rfcomm channel was found, false otherwise.

Definition at line 182 of file sdpservice.cpp.

    // Get the rfcomm channel
    Attribute protoDescAttr;
    // Get the the protocol descriptor list attribute (0x04)
    if (getAttributeByID(0x04 , protoDescAttr) == false) {
        return false;

    std::vector<SDP::Attribute> protoDescList = protoDescAttr.getSequence();
    std::vector<SDP::Attribute>::iterator it;

      //Search in all subLists of the Protocol Description List.
      for(it = protoDescList.begin(); it != protoDescList.end(); ++it) {
        std::vector<SDP::Attribute> attrList = it->getSequence();
        std::vector<SDP::Attribute>::iterator it;

            //The List must have at least 2 Attributes
            //  UUID16 : 0x0003 - RFCOMM
        //  Channel/Port (Integer) : 0x6

            if(attrList.size() >= 2) {
                it = attrList.begin();

                  // The first Attribute of the list must be an UUID
                  if(it->getType() != Attribute::UUID)
            // The UUID must have the value of "0x0003" that's the RFCOMM UUID
                  SDP::uuid_t rfcommUUID;
                  if(it->getUUID() != rfcommUUID) //RFCOMM UUID
                  //If the UUID is ok we get the rfcomm channel number
            if(it->getType() != Attribute::UINT)
                  n = it->getUInt().lo;
                  return true;
      // If we're here, we haven't found a correct Rfcomm channel, so we return false
    return false;

Generated by  Doxygen 1.6.0   Back to index