Java Code Examples for javax.bluetooth.DataElement#addElement()

The following examples show how to use javax.bluetooth.DataElement#addElement() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
public static synchronized byte[] serialize(ServiceRecord record) {
    DataElement seq = new DataElement(DataElement.DATSEQ);
    int[] attrIDs = record.getAttributeIDs();
    for (int i = 0; i < attrIDs.length; i++) {
        DataElement attrID = new DataElement(DataElement.U_INT_2,
                attrIDs[i]);
        DataElement attrValue = record.getAttributeValue(attrIDs[i]);
        if (attrValue != null) {
            seq.addElement(attrID);
            seq.addElement(attrValue);
        }
    }
    try {
        return des.serialize(seq);
    } catch (IOException e) {
        return null;
    }
}
 
Example 2
public ClientServiceSearchAttributeTransaction(JavaSDPClient client, int transactionID,
        SDPResponseListener listener, int[] attrSet,
        UUID[] uuidSet) {
    super(client, SDPClientTransaction.SDP_SERVICE_SEARCH_ATTRIBUTE_REQUEST, transactionID,
            listener);
    attrData = new DataElement(DataElement.DATSEQ);
    uuidData = new DataElement(DataElement.DATSEQ);
    for (int i = 0; i < attrSet.length; i++) {
        attrData.addElement(new DataElement(DataElement.U_INT_2,
                attrSet[i]));
    }
    for (int i = 0; i < uuidSet.length; i++) {
        uuidData.addElement(new DataElement(DataElement.UUID,
                uuidSet[i]));
    }
    parameterLength = super.client.getConnection().getReaderWriter().getDataSize(attrData) +
            super.client.getConnection().getReaderWriter().getDataSize(uuidData) + 2;
}
 
Example 3
private DataElement dataElementCopy(DataElement original) {
    if ((original.getDataType() == DataElement.DATSEQ)
            || (original.getDataType() == DataElement.DATALT)) {
        DataElement copy = new DataElement(original.getDataType());
        Enumeration elements = (Enumeration) original.getValue();

        while (elements.hasMoreElements()) {
            copy.addElement(dataElementCopy((DataElement)
                    elements.nextElement()));
        }
        return copy;
    } else {
        return original;
    }
}
 
Example 4
public ClientServiceSearchTransaction(JavaSDPClient client, int transactionID,
        SDPResponseListener listener, UUID[] uuidSet) {
    super(client, SDPClientTransaction.SDP_SERVICE_SEARCH_REQUEST, transactionID, listener);
    serviceSearchPattern = new DataElement(DataElement.DATSEQ);
    for (int i = 0; i < uuidSet.length; i++) {
        serviceSearchPattern.addElement(new DataElement(
                DataElement.UUID, uuidSet[i]));
    }
    parameterLength = super.des.getDataSize(serviceSearchPattern) + 2;
}
 
Example 5
ClientServiceAttributeTransaction(JavaSDPClient client, int transactionID,
        SDPResponseListener listener, int recordHandle,
        int[] attrSet) {
    super(client, SDPClientTransaction.SDP_SERVICE_ATTRIBUTE_REQUEST, transactionID, listener);
    serviceRecordHandle = recordHandle;
    attributeIDList = new DataElement(DataElement.DATSEQ);
    for (int i = 0; i < attrSet.length; i++) {
        attributeIDList.addElement(new DataElement(
                DataElement.U_INT_2, attrSet[i]));
    }
    parameterLength = super.client.getConnection().getReaderWriter().getDataSize(attributeIDList) + 6;
}