Skip to content

Commit b8aecac

Browse files
committed
Added comments for "SDP_ServiceSearchAttributeResponse"
1 parent aae52f8 commit b8aecac

File tree

1 file changed

+88
-75
lines changed

1 file changed

+88
-75
lines changed

SPPServer.cpp

Lines changed: 88 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -504,15 +504,15 @@ void SPPServer::serviceNotSupported(uint8_t transactionIDHigh, uint8_t transacti
504504
l2capoutbuf[0] = SDP_SERVICE_SEARCH_ATTRIBUTE_RESPONSE_PDU;
505505
l2capoutbuf[1] = transactionIDHigh;
506506
l2capoutbuf[2] = transactionIDLow;
507-
l2capoutbuf[3] = 0x00; // Parameter Length
508-
l2capoutbuf[4] = 0x05; // Parameter Length
509-
l2capoutbuf[5] = 0x00; // AttributeListsByteCount
510-
l2capoutbuf[6] = 0x02; // AttributeListsByteCount
507+
l2capoutbuf[3] = 0x00; // MSB Parameter Length
508+
l2capoutbuf[4] = 0x05; // LSB Parameter Length = 5
509+
l2capoutbuf[5] = 0x00; // MSB AttributeListsByteCount
510+
l2capoutbuf[6] = 0x02; // LSB AttributeListsByteCount = 2
511511

512512
/* Attribute ID/Value Sequence: */
513-
l2capoutbuf[7] = 0x35;
514-
l2capoutbuf[8] = 0x00;
515-
l2capoutbuf[9] = 0x00;
513+
l2capoutbuf[7] = 0x35; // Data element sequence - length in next byte
514+
l2capoutbuf[8] = 0x00; // Length = 0
515+
l2capoutbuf[9] = 0x00; // No continuation state
516516

517517
SDP_Command(l2capoutbuf, 10);
518518
}
@@ -521,56 +521,60 @@ void SPPServer::serialPortResponse1(uint8_t transactionIDHigh, uint8_t transacti
521521
l2capoutbuf[0] = SDP_SERVICE_SEARCH_ATTRIBUTE_RESPONSE_PDU;
522522
l2capoutbuf[1] = transactionIDHigh;
523523
l2capoutbuf[2] = transactionIDLow;
524-
l2capoutbuf[3] = 0x00; // Parameter Length
525-
l2capoutbuf[4] = 0x2B; // Parameter Length
526-
l2capoutbuf[5] = 0x00; // AttributeListsByteCount
527-
l2capoutbuf[6] = 0x26; // AttributeListsByteCount
524+
l2capoutbuf[3] = 0x00; // MSB Parameter Length
525+
l2capoutbuf[4] = 0x2B; // LSB Parameter Length = 43
526+
l2capoutbuf[5] = 0x00; // MSB AttributeListsByteCount
527+
l2capoutbuf[6] = 0x26; // LSB AttributeListsByteCount = 38
528528

529529
/* Attribute ID/Value Sequence: */
530-
l2capoutbuf[7] = 0x36;
531-
l2capoutbuf[8] = 0x00;
532-
l2capoutbuf[9] = 0x3C;
533-
l2capoutbuf[10] = 0x36;
534-
l2capoutbuf[11] = 0x00;
535-
536-
l2capoutbuf[12] = 0x39;
537-
l2capoutbuf[13] = 0x09;
538-
l2capoutbuf[14] = 0x00;
539-
l2capoutbuf[15] = 0x00;
540-
l2capoutbuf[16] = 0x0A;
541-
l2capoutbuf[17] = 0x00;
530+
l2capoutbuf[7] = 0x36; // Data element sequence - length in next two bytes
531+
l2capoutbuf[8] = 0x00; // MSB Length
532+
l2capoutbuf[9] = 0x3C; // LSB Length = 60
533+
534+
l2capoutbuf[10] = 0x36; // Data element sequence - length in next two bytes
535+
l2capoutbuf[11] = 0x00; // MSB Length
536+
l2capoutbuf[12] = 0x39; // LSB Length = 57
537+
538+
l2capoutbuf[13] = 0x09; // Unsigned Integer - length 2 bytes
539+
l2capoutbuf[14] = 0x00; // MSB ServiceRecordHandle
540+
l2capoutbuf[15] = 0x00; // LSB ServiceRecordHandle
541+
l2capoutbuf[16] = 0x0A; // Unsigned int - length 4 bytes
542+
l2capoutbuf[17] = 0x00; // ServiceRecordHandle value - TODO: Is this related to HCI_Handle?
542543
l2capoutbuf[18] = 0x01;
543544
l2capoutbuf[19] = 0x00;
544545
l2capoutbuf[20] = 0x06;
545-
l2capoutbuf[21] = 0x09;
546-
l2capoutbuf[22] = 0x00;
547-
l2capoutbuf[23] = 0x01;
548-
l2capoutbuf[24] = 0x35;
549-
l2capoutbuf[25] = 0x03;
550-
l2capoutbuf[26] = 0x19;
551-
l2capoutbuf[27] = 0x11;
552-
553-
l2capoutbuf[28] = 0x01;
554-
l2capoutbuf[29] = 0x09;
555-
l2capoutbuf[30] = 0x00;
556-
l2capoutbuf[31] = 0x04;
557-
l2capoutbuf[32] = 0x35;
558-
l2capoutbuf[33] = 0x0C;
559-
l2capoutbuf[34] = 0x35;
560-
l2capoutbuf[35] = 0x03;
561-
l2capoutbuf[36] = 0x19;
562-
l2capoutbuf[37] = 0x01;
563-
l2capoutbuf[38] = 0x00;
564-
l2capoutbuf[39] = 0x35;
565-
l2capoutbuf[40] = 0x05;
566-
l2capoutbuf[41] = 0x19;
567-
l2capoutbuf[42] = 0x00;
568-
l2capoutbuf[43] = 0x03;
569-
570-
l2capoutbuf[44] = 0x08;
571-
l2capoutbuf[45] = 0x02; // Two extra bytes
572-
l2capoutbuf[46] = 0x00; // 25 (0x19) more bytes to come
573-
l2capoutbuf[47] = 0x19;
546+
547+
l2capoutbuf[21] = 0x09; // Unsigned Integer - length 2 bytes
548+
l2capoutbuf[22] = 0x00; // MSB ServiceClassIDList
549+
l2capoutbuf[23] = 0x01; // LSB ServiceClassIDList
550+
l2capoutbuf[24] = 0x35; // Data element sequence - length in next byte
551+
l2capoutbuf[25] = 0x03; // Length = 3
552+
l2capoutbuf[26] = 0x19; // UUID (universally unique identifier) - length = 2 bytes
553+
l2capoutbuf[27] = 0x11; // MSB SerialPort
554+
l2capoutbuf[28] = 0x01; // LSB SerialPort
555+
556+
l2capoutbuf[29] = 0x09; // Unsigned Integer - length 2 bytes
557+
l2capoutbuf[30] = 0x00; // MSB ProtocolDescriptorList
558+
l2capoutbuf[31] = 0x04; // LSB ProtocolDescriptorList
559+
l2capoutbuf[32] = 0x35; // Data element sequence - length in next byte
560+
l2capoutbuf[33] = 0x0C; // Length = 12
561+
562+
l2capoutbuf[34] = 0x35; // Data element sequence - length in next byte
563+
l2capoutbuf[35] = 0x03; // Length = 3
564+
l2capoutbuf[36] = 0x19; // UUID (universally unique identifier) - length = 2 bytes
565+
l2capoutbuf[37] = 0x01; // MSB L2CAP
566+
l2capoutbuf[38] = 0x00; // LSB L2CAP
567+
568+
l2capoutbuf[39] = 0x35; // Data element sequence - length in next byte
569+
l2capoutbuf[40] = 0x05; // Length = 5
570+
l2capoutbuf[41] = 0x19; // UUID (universally unique identifier) - length = 2 bytes
571+
l2capoutbuf[42] = 0x00; // MSB RFCOMM
572+
l2capoutbuf[43] = 0x03; // LSB RFCOMM
573+
l2capoutbuf[44] = 0x08; // Unsigned Integer - length 1 byte
574+
575+
l2capoutbuf[45] = 0x02; // ContinuationState - Two more bytes
576+
l2capoutbuf[46] = 0x00; // MSB length
577+
l2capoutbuf[47] = 0x19; // LSB length = 25 more bytes to come
574578

575579
SDP_Command(l2capoutbuf, 48);
576580
}
@@ -579,40 +583,49 @@ void SPPServer::serialPortResponse2(uint8_t transactionIDHigh, uint8_t transacti
579583
l2capoutbuf[0] = SDP_SERVICE_SEARCH_ATTRIBUTE_RESPONSE_PDU;
580584
l2capoutbuf[1] = transactionIDHigh;
581585
l2capoutbuf[2] = transactionIDLow;
582-
l2capoutbuf[3] = 0x00; // Parameter Length
583-
l2capoutbuf[4] = 0x1C; // Parameter Length
584-
l2capoutbuf[5] = 0x00; // AttributeListsByteCount
585-
l2capoutbuf[6] = 0x19; // AttributeListsByteCount
586+
l2capoutbuf[3] = 0x00; // MSB Parameter Length
587+
l2capoutbuf[4] = 0x1C; // LSB Parameter Length = 28
588+
l2capoutbuf[5] = 0x00; // MSB AttributeListsByteCount
589+
l2capoutbuf[6] = 0x19; // LSB AttributeListsByteCount = 25
586590

587591
/* Attribute ID/Value Sequence: */
588-
l2capoutbuf[7] = 0x01;
589-
l2capoutbuf[8] = 0x09;
590-
l2capoutbuf[9] = 0x00;
591-
l2capoutbuf[10] = 0x06;
592-
l2capoutbuf[11] = 0x35;
593-
594-
l2capoutbuf[12] = 0x09;
595-
l2capoutbuf[13] = 0x09;
596-
l2capoutbuf[14] = 0x65;
597-
l2capoutbuf[15] = 0x6E;
598-
l2capoutbuf[16] = 0x09;
599-
l2capoutbuf[17] = 0x00;
600-
l2capoutbuf[18] = 0x6A;
601-
l2capoutbuf[19] = 0x09;
592+
l2capoutbuf[7] = 0x01; // Channel 1 - TODO: Try different values, so multiple servers can be used at once
593+
594+
l2capoutbuf[8] = 0x09; // Unsigned Integer - length 2 bytes
595+
l2capoutbuf[9] = 0x00; // MSB LanguageBaseAttributeIDList
596+
l2capoutbuf[10] = 0x06; // LSB LanguageBaseAttributeIDList
597+
l2capoutbuf[11] = 0x35; // Data element sequence - length in next byte
598+
l2capoutbuf[12] = 0x09; // Length = 9
599+
600+
// Identifier representing the natural language = en = English - see: "ISO 639:1988"
601+
l2capoutbuf[13] = 0x09; // Unsigned Integer - length 2 bytes
602+
l2capoutbuf[14] = 0x65; // 'e'
603+
l2capoutbuf[15] = 0x6E; // 'n'
604+
605+
// "The second element of each triplet contains an identifier that specifies a character encoding used for the language"
606+
// Encoding is set to 106 (UTF-8) - see: http://www.iana.org/assignments/character-sets/character-sets.xhtml
607+
l2capoutbuf[16] = 0x09; // Unsigned Integer - length 2 bytes
608+
l2capoutbuf[17] = 0x00; // MSB of character encoding
609+
l2capoutbuf[18] = 0x6A; // LSB of character encoding (106)
610+
611+
// Attribute ID that serves as the base attribute ID for the natural language in the service record
612+
// "To facilitate the retrieval of human-readable universal attributes in a principal language, the base attribute ID value for the primary language supported by a service record shall be 0x0100"
613+
l2capoutbuf[19] = 0x09; // Unsigned Integer - length 2 bytes
602614
l2capoutbuf[20] = 0x01;
603615
l2capoutbuf[21] = 0x00;
604-
l2capoutbuf[22] = 0x09;
605-
l2capoutbuf[23] = 0x01;
606-
l2capoutbuf[24] = 0x00;
607-
l2capoutbuf[25] = 0x25;
608616

617+
l2capoutbuf[22] = 0x09; // Unsigned Integer - length 2 bytes
618+
l2capoutbuf[23] = 0x01; // MSB ServiceDescription
619+
l2capoutbuf[24] = 0x00; // LSB ServiceDescription
620+
621+
l2capoutbuf[25] = 0x25; // Text string - length in next byte
609622
l2capoutbuf[26] = 0x05; // Name length
610623
l2capoutbuf[27] = 'T';
611624
l2capoutbuf[28] = 'K';
612625
l2capoutbuf[29] = 'J';
613626
l2capoutbuf[30] = 'S';
614627
l2capoutbuf[31] = 'P';
615-
l2capoutbuf[32] = 0x00; // No more data
628+
l2capoutbuf[32] = 0x00; // No continuation state
616629

617630
SDP_Command(l2capoutbuf, 33);
618631
}

0 commit comments

Comments
 (0)