Make bluetooth SDP code correctly unpack the search UUIDs and parameters.
authorDean Camera <dean@fourwalledcubicle.com>
Mon, 19 Apr 2010 10:53:14 +0000 (10:53 +0000)
committerDean Camera <dean@fourwalledcubicle.com>
Mon, 19 Apr 2010 10:53:14 +0000 (10:53 +0000)
Minor documentation improvements.

Demos/Device/ClassDriver/Keyboard/Keyboard.c
Demos/Device/ClassDriver/KeyboardMouse/KeyboardMouse.c
Demos/Device/LowLevel/Keyboard/Keyboard.c
Demos/Host/Incomplete/BluetoothHost/BluetoothHost.c
Demos/Host/Incomplete/BluetoothHost/Lib/BluetoothACLPackets.c
Demos/Host/Incomplete/BluetoothHost/Lib/ServiceDiscoveryProtocol.c
Demos/Host/Incomplete/BluetoothHost/Lib/ServiceDiscoveryProtocol.h
LUFA/ManPages/LUFAPoweredProjects.txt
LUFA/ManPages/LibraryApps.txt
LUFA/ManPages/SoftwareBootloaderJump.txt

index db30ac5..ea4fbf8 100644 (file)
@@ -7,8 +7,7 @@
 */\r
 \r
 /*\r
 */\r
 \r
 /*\r
-  Copyright 2010  Denver Gingerich (denver [at] ossguy [dot] com)\r
-      Based on code by Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+  Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
 \r
   Permission to use, copy, modify, distribute, and sell this \r
   software and its documentation for any purpose is hereby granted\r
 \r
   Permission to use, copy, modify, distribute, and sell this \r
   software and its documentation for any purpose is hereby granted\r
index 1c01730..1f87a7a 100644 (file)
@@ -8,7 +8,6 @@
 \r
 /*\r
   Copyright 2010  Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
 \r
 /*\r
   Copyright 2010  Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
-  Copyright 2010  Denver Gingerich (denver [at] ossguy [dot] com)\r
          \r
   Permission to use, copy, modify, distribute, and sell this \r
   software and its documentation for any purpose is hereby granted\r
          \r
   Permission to use, copy, modify, distribute, and sell this \r
   software and its documentation for any purpose is hereby granted\r
index 9ce4eb9..fd7e63e 100644 (file)
@@ -7,8 +7,8 @@
 */\r
 \r
 /*\r
 */\r
 \r
 /*\r
+  Copyright 2010  Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
   Copyright 2010  Denver Gingerich (denver [at] ossguy [dot] com)\r
   Copyright 2010  Denver Gingerich (denver [at] ossguy [dot] com)\r
-      Based on code by Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
 \r
   Permission to use, copy, modify, distribute, and sell this \r
   software and its documentation for any purpose is hereby granted\r
 \r
   Permission to use, copy, modify, distribute, and sell this \r
   software and its documentation for any purpose is hereby granted\r
index 1107bc0..99c0987 100644 (file)
@@ -206,8 +206,7 @@ void Bluetooth_Host_Task(void)
 bool Bluetooth_ConnectionRequest(const uint8_t* RemoteAddress)\r
 {\r
        printf_P(PSTR("Connection Request from Device %02X:%02X:%02X:%02X:%02X:%02X\r\n"),\r
 bool Bluetooth_ConnectionRequest(const uint8_t* RemoteAddress)\r
 {\r
        printf_P(PSTR("Connection Request from Device %02X:%02X:%02X:%02X:%02X:%02X\r\n"),\r
-                RemoteAddress[5], RemoteAddress[4],\r
-                RemoteAddress[3], RemoteAddress[2],\r
+                RemoteAddress[5], RemoteAddress[4], RemoteAddress[3], RemoteAddress[2],\r
                 RemoteAddress[1], RemoteAddress[0]);\r
 \r
        /* Always accept connections from remote devices */\r
                 RemoteAddress[1], RemoteAddress[0]);\r
 \r
        /* Always accept connections from remote devices */\r
index 9f1ec36..87ef652 100644 (file)
@@ -493,17 +493,17 @@ static inline void Bluetooth_Signal_ConfigurationReq(const BT_Signal_Header_t* c
                while (OptionPos < OptionsLen)\r
                {\r
                        BT_Config_Option_Header_t* OptionHeader = (BT_Config_Option_Header_t*)&Options[OptionPos];\r
                while (OptionPos < OptionsLen)\r
                {\r
                        BT_Config_Option_Header_t* OptionHeader = (BT_Config_Option_Header_t*)&Options[OptionPos];\r
-                       void*                      OptionData   = &Options[OptionPos + sizeof(*OptionHeader)];\r
+                       void*                      OptionData   = &Options[OptionPos + sizeof(BT_Config_Option_Header_t)];\r
 \r
                        BT_ACL_DEBUG(2, "-- Option Type: 0x%04X", OptionHeader->Type);\r
 \r
                        BT_ACL_DEBUG(2, "-- Option Type: 0x%04X", OptionHeader->Type);\r
-                       BT_ACL_DEBUG(2, "-- Option Length: 0x%04X", (sizeof(*OptionHeader) + OptionHeader->Length));\r
+                       BT_ACL_DEBUG(2, "-- Option Length: 0x%04X", (sizeof(BT_Config_Option_Header_t) + OptionHeader->Length));\r
                        \r
                        /* Store the remote MTU option's value if present */\r
                        if (OptionHeader->Type == BT_CONFIG_OPTION_MTU)\r
                          ChannelData->RemoteMTU = *((uint16_t*)OptionData);\r
 \r
                        /* Progress to the next option in the packet */\r
                        \r
                        /* Store the remote MTU option's value if present */\r
                        if (OptionHeader->Type == BT_CONFIG_OPTION_MTU)\r
                          ChannelData->RemoteMTU = *((uint16_t*)OptionData);\r
 \r
                        /* Progress to the next option in the packet */\r
-                       OptionPos += (sizeof(*OptionHeader) + OptionHeader->Length);\r
+                       OptionPos += (sizeof(BT_Config_Option_Header_t) + OptionHeader->Length);\r
                }\r
        }\r
        \r
                }\r
        }\r
        \r
index 3937a97..0d96542 100644 (file)
@@ -40,6 +40,11 @@ void ServiceDiscovery_ProcessPacket(void* Data, Bluetooth_Channel_t* Channel)
        BT_SDP_DEBUG(2, "-- PDU ID: 0x%02X", SDPHeader->PDU);\r
        BT_SDP_DEBUG(2, "-- Param Length: 0x%04X", SDPHeader->ParameterLength);\r
        \r
        BT_SDP_DEBUG(2, "-- PDU ID: 0x%02X", SDPHeader->PDU);\r
        BT_SDP_DEBUG(2, "-- Param Length: 0x%04X", SDPHeader->ParameterLength);\r
        \r
+       printf("\r\n");\r
+       for (uint8_t i = 0; i < SDPHeader->ParameterLength; i++)\r
+         printf("0x%02X ", *((uint8_t*)Data + sizeof(SDP_PDUHeader_t) + i));\r
+       printf("\r\n");\r
+\r
        switch (SDPHeader->PDU)\r
        {\r
                case SDP_PDU_SERVICESEARCHREQUEST:\r
        switch (SDPHeader->PDU)\r
        {\r
                case SDP_PDU_SERVICESEARCHREQUEST:\r
@@ -66,60 +71,92 @@ static void ServiceDiscovery_ProcessServiceAttribute(SDP_PDUHeader_t* SDPHeader)
 \r
 static void ServiceDiscovery_ProcessServiceSearchAttribute(SDP_PDUHeader_t* SDPHeader)\r
 {\r
 \r
 static void ServiceDiscovery_ProcessServiceSearchAttribute(SDP_PDUHeader_t* SDPHeader)\r
 {\r
-       uint8_t* CurrentParameter = ((uint8_t*)SDPHeader + sizeof(SDP_PDUHeader_t));\r
+       void* CurrentParameter = ((void*)SDPHeader + sizeof(SDP_PDUHeader_t));\r
        \r
        BT_SDP_DEBUG(1, "<< Service Search Attribute", NULL);\r
        \r
        BT_SDP_DEBUG(1, "<< Service Search Attribute", NULL);\r
+       \r
+       uint8_t ElementHeaderSize;\r
 \r
 \r
-       uint8_t ServicePatternLength = ServiceDiscovery_GetDataElementSize(CurrentParameter);\r
+       uint16_t ServicePatternLength = ServiceDiscovery_GetDataElementSize(&CurrentParameter, &ElementHeaderSize);\r
+       BT_SDP_DEBUG(2, "-- Total UUID Length: 0x%04X", ServicePatternLength);\r
        while (ServicePatternLength)\r
        {\r
        while (ServicePatternLength)\r
        {\r
-               uint8_t UUIDLength = ServiceDiscovery_GetDataElementSize(CurrentParameter);\r
+               uint8_t UUIDLength = ServiceDiscovery_GetDataElementSize(&CurrentParameter, &ElementHeaderSize);\r
                uint8_t UUID[16];\r
                \r
                memset(UUID, 0x00, sizeof(UUID));\r
                uint8_t UUID[16];\r
                \r
                memset(UUID, 0x00, sizeof(UUID));\r
-               memcpy(&UUID[sizeof(UUID) - UUIDLength], CurrentParameter, UUIDLength);\r
+               memcpy(UUID, CurrentParameter, UUIDLength);\r
+               CurrentParameter += UUIDLength;\r
                \r
                \r
-               BT_SDP_DEBUG(2, "-- UUID: 0x%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X",\r
-                               UUID[0], UUID[1], UUID[2],  UUID[3],  UUID[4],  UUID[5],  UUID[6],  UUID[7],\r
-                                               UUID[8], UUID[9], UUID[10], UUID[11], UUID[12], UUID[13], UUID[14], UUID[15]);\r
+               BT_SDP_DEBUG(2, "-- UUID (%d): 0x%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X",\r
+                                               UUIDLength,\r
+                               UUID[15], UUID[14], UUID[13], UUID[12], UUID[11], UUID[10], UUID[9], UUID[8],\r
+                                               UUID[7],  UUID[6],  UUID[5],  UUID[4],  UUID[3],  UUID[2],  UUID[1], UUID[0]);\r
        \r
        \r
-               ServicePatternLength -= UUIDLength;\r
+               ServicePatternLength -= (UUIDLength + ElementHeaderSize);\r
        }\r
        \r
        }\r
        \r
-       uint16_t MaxAttributeSize = ServiceDiscovery_Read16BitParameter(CurrentParameter);\r
+       uint16_t MaxAttributeSize = ServiceDiscovery_Read16BitParameter(&CurrentParameter);\r
+       BT_SDP_DEBUG(2, "-- Max Return Attribute Bytes: 0x%04X", MaxAttributeSize);\r
 \r
 \r
-       uint8_t AttributeIDListLength = ServiceDiscovery_GetDataElementSize(CurrentParameter);\r
+       uint16_t AttributeIDListLength = ServiceDiscovery_GetDataElementSize(&CurrentParameter, &ElementHeaderSize);\r
+       BT_SDP_DEBUG(2, "-- Total Attribute Length: 0x%04X", AttributeIDListLength);\r
        while (AttributeIDListLength)\r
        {\r
        while (AttributeIDListLength)\r
        {\r
-               uint8_t AttributeLength = ServiceDiscovery_GetDataElementSize(CurrentParameter);\r
+               uint8_t  AttributeLength = ServiceDiscovery_GetDataElementSize(&CurrentParameter, &ElementHeaderSize);\r
+               uint32_t Attribute = 0;\r
                \r
                \r
-               BT_SDP_DEBUG(2, "-- Attribute Length: 0x%04X", AttributeLength);\r
+               memcpy(&Attribute, CurrentParameter, AttributeLength);\r
+               CurrentParameter += AttributeLength;\r
+               \r
+               BT_SDP_DEBUG(2, "-- Attribute(%d): 0x%08lX", AttributeLength, Attribute);\r
        \r
        \r
-               AttributeIDListLength -= AttributeLength;\r
+               AttributeIDListLength -= (AttributeLength + ElementHeaderSize);\r
        }\r
 }\r
 \r
        }\r
 }\r
 \r
-static uint32_t ServiceDiscovery_GetDataElementSize(void* DataElementHeader)\r
+static uint32_t ServiceDiscovery_GetDataElementSize(void** DataElementHeader, uint8_t* ElementHeaderSize)\r
 {\r
 {\r
-       uint8_t SizeIndex = (*((uint8_t*)DataElementHeader++) & 0x07);\r
-\r
+       uint8_t SizeIndex = (*((uint8_t*)*DataElementHeader) & 0x07);\r
+       *DataElementHeader += sizeof(uint8_t);\r
+       \r
+       *ElementHeaderSize = 1;\r
+       \r
+       uint32_t ElementValue;\r
+       \r
        switch (SizeIndex)\r
        {\r
                case 0:\r
        switch (SizeIndex)\r
        {\r
                case 0:\r
-                       return 1;\r
+                       ElementValue = 1;\r
+                       break;\r
                case 1:\r
                case 1:\r
-                       return 2;\r
+                       ElementValue = 2;\r
+                       break;\r
                case 2:\r
                case 2:\r
-                       return 4;\r
+                       ElementValue = 4;\r
+                       break;\r
                case 3:\r
                case 3:\r
-                       return 8;\r
+                       ElementValue = 8;\r
+                       break;\r
                case 4:\r
                case 4:\r
-                       return 16;\r
+                       ElementValue = 16;\r
+                       break;\r
                case 5:\r
                case 5:\r
-                       return *((uint8_t*)DataElementHeader++);\r
+                       ElementValue = *((uint8_t*)*DataElementHeader);\r
+                       *DataElementHeader += sizeof(uint8_t);\r
+                       *ElementHeaderSize  = (1 + sizeof(uint8_t));\r
+                       break;\r
                case 6:\r
                case 6:\r
-                       return *((uint16_t*)DataElementHeader++);\r
+                       ElementValue = *((uint16_t*)*DataElementHeader);\r
+                       *DataElementHeader += sizeof(uint16_t);\r
+                       *ElementHeaderSize  = (1 + sizeof(uint16_t));\r
+                       break;\r
                default:\r
                default:\r
-                       return *((uint32_t*)DataElementHeader++);\r
+                       ElementValue = *((uint32_t*)*DataElementHeader);\r
+                       *DataElementHeader += sizeof(uint32_t);\r
+                       *ElementHeaderSize  = (1 + sizeof(uint32_t));\r
+                       break;\r
        }\r
        }\r
+       \r
+       return ElementValue;\r
 }\r
 }\r
index b17cc2b..39c97af 100644 (file)
                        static void ServiceDiscovery_ProcessServiceAttribute(SDP_PDUHeader_t* SDPHeader);\r
                        static void ServiceDiscovery_ProcessServiceSearchAttribute(SDP_PDUHeader_t* SDPHeader);\r
                        \r
                        static void ServiceDiscovery_ProcessServiceAttribute(SDP_PDUHeader_t* SDPHeader);\r
                        static void ServiceDiscovery_ProcessServiceSearchAttribute(SDP_PDUHeader_t* SDPHeader);\r
                        \r
-                       static inline uint16_t ServiceDiscovery_Read16BitParameter(void* AttributeHeader)\r
+                       static inline uint16_t ServiceDiscovery_Read16BitParameter(void** AttributeHeader)\r
                        {\r
                        {\r
-                               return *((uint16_t*)AttributeHeader++);\r
+                               uint16_t ParamValue = *((uint16_t*)*AttributeHeader);\r
+                               *AttributeHeader += sizeof(uint16_t);\r
+                               return ParamValue;\r
                        }\r
 \r
                        }\r
 \r
-                       static uint32_t ServiceDiscovery_GetDataElementSize(void* AttributeHeader);\r
+                       static uint32_t ServiceDiscovery_GetDataElementSize(void** AttributeHeader, uint8_t* ElementHeaderSize);\r
                #endif\r
 \r
 #endif\r
                #endif\r
 \r
 #endif\r
index a606031..75c2d6a 100644 (file)
  *  - "Fingerlicking Wingdinger" (WARNING: Bad Language if no Javascript), a MIDI controller: http://noisybox.net/electronics/wingdinger/\r
  *  - Garmin GPS USB to NMEA standard serial sentence translator: http://github.com/nall/garmin-transmogrifier/tree/master\r
  *  - Generic HID Device Creator: http://generichid.sourceforge.net/\r
  *  - "Fingerlicking Wingdinger" (WARNING: Bad Language if no Javascript), a MIDI controller: http://noisybox.net/electronics/wingdinger/\r
  *  - Garmin GPS USB to NMEA standard serial sentence translator: http://github.com/nall/garmin-transmogrifier/tree/master\r
  *  - Generic HID Device Creator: http://generichid.sourceforge.net/\r
- *  - NES Controller USB modification: http://projects.peterpolidoro.net/video/NESUSB.htm\r
+ *  - IR Remote to Keyboard decoder: http://netzhansa.blogspot.com/2010/04/our-living-room-hi-fi-setup-needs-mp3.html\r
+ *  - LED Panel controller: http://projects.peterpolidoro.net/caltech/panelscontroller/panelscontroller.htm\r
  *  - Linux Secure Storage Dongle: http://github.com/TomMD/teensy\r
  *  - MakeTV Episode Dispenser: http://www.youtube.com/watch?v=BkWUi18hl3g\r
  *  - Linux Secure Storage Dongle: http://github.com/TomMD/teensy\r
  *  - MakeTV Episode Dispenser: http://www.youtube.com/watch?v=BkWUi18hl3g\r
- *  - Midimonster, a USB-to-MIDI gateway board: http://www.dorkbotpdx.org/wiki/midimonster\r
+ *  - MidiMonster, a USB-to-MIDI gateway board: http://www.dorkbotpdx.org/wiki/midimonster\r
+ *  - NES Controller USB modification: http://projects.peterpolidoro.net/video/NESUSB.htm\r
  *  - Opendous-JTAG, an open source JTAG device: http://code.google.com/p/opendous-jtag/\r
  *  - Openkubus, an open source hardware-based authentication dongle: http://code.google.com/p/openkubus/\r
  *  - Orbee, a USB connected RGB Orb for notifications: http://www.franksworkshop.com.au/Electronics/Orbee/Orbee.htm\r
  *  - Programmable XBOX controller: http://richard-burke.dyndns.org/wordpress/pan-galactic-gargantuan-gargle-brain-aka-xbox-360-usb-controller/\r
  *  - Reprap with LUFA, a LUFA powered 3D printer: http://code.google.com/p/at90usb1287-code-for-arduino-and-eclipse/\r
  *  - Opendous-JTAG, an open source JTAG device: http://code.google.com/p/opendous-jtag/\r
  *  - Openkubus, an open source hardware-based authentication dongle: http://code.google.com/p/openkubus/\r
  *  - Orbee, a USB connected RGB Orb for notifications: http://www.franksworkshop.com.au/Electronics/Orbee/Orbee.htm\r
  *  - Programmable XBOX controller: http://richard-burke.dyndns.org/wordpress/pan-galactic-gargantuan-gargle-brain-aka-xbox-360-usb-controller/\r
  *  - Reprap with LUFA, a LUFA powered 3D printer: http://code.google.com/p/at90usb1287-code-for-arduino-and-eclipse/\r
+ *  - SD Card reader: http://elasticsheep.com/2010/04/teensy2-usb-mass-storage-with-an-sd-card/\r
  *  - SEGA Megadrive/Genesis Development Cartridge: http://www.makestuff.eu/wordpress/?page_id=398\r
  *  - Stripe Snoop, a Magnetic Card reader: http://www.ossguy.com/ss_usb/\r
  *  - USB Interface for Playstation Portable Devices: http://forums.ps2dev.org/viewtopic.php?t=11001\r
  *  - SEGA Megadrive/Genesis Development Cartridge: http://www.makestuff.eu/wordpress/?page_id=398\r
  *  - Stripe Snoop, a Magnetic Card reader: http://www.ossguy.com/ss_usb/\r
  *  - USB Interface for Playstation Portable Devices: http://forums.ps2dev.org/viewtopic.php?t=11001\r
index 5f52263..2217740 100644 (file)
  *    - <b>LEDNotifier</b> - USB LED Notification project\r
  *    - <b>Magstripe</b> - Magnetic Stripe Card Reader project\r
  *    - <b>MissileLaucher</b> - Toy Missile Launcher Host project\r
  *    - <b>LEDNotifier</b> - USB LED Notification project\r
  *    - <b>Magstripe</b> - Magnetic Stripe Card Reader project\r
  *    - <b>MissileLaucher</b> - Toy Missile Launcher Host project\r
+ *    - <b>RelayBoard</b> - Relay board controller, controllable via the "sismpctl" Linux application\r
  *    - <b>TemperatureDataLogger</b> - Temperature Datalogging project, using the FatFS library\r
  *    - <b>USBtoSerial</b> - USB to USART Serial Converter project\r
  *    - <b>Webserver</b> - RNDIS Host Webserver with DHCP client, powered by uIP TCP/IP stack project and FatFS library\r
  *    - <b>TemperatureDataLogger</b> - Temperature Datalogging project, using the FatFS library\r
  *    - <b>USBtoSerial</b> - USB to USART Serial Converter project\r
  *    - <b>Webserver</b> - RNDIS Host Webserver with DHCP client, powered by uIP TCP/IP stack project and FatFS library\r
index 82fce4a..3f6e305 100644 (file)
@@ -34,8 +34,8 @@
  *  void Bootloader_Jump_Check(void) ATTR_INIT_SECTION(3);\r
  *  void Bootloader_Jump_Check(void)\r
  *  {\r
  *  void Bootloader_Jump_Check(void) ATTR_INIT_SECTION(3);\r
  *  void Bootloader_Jump_Check(void)\r
  *  {\r
- *      // If the bootloader key is correct, clear it and jump to the bootloader\r
- *      if (Boot_Key == MAGIC_BOOT_KEY)\r
+ *      // If the reset source was the bootloader and the key is correct, clear it and jump to the bootloader\r
+ *      if ((MCUSR & (1<<WDRF)) && (Boot_Key == MAGIC_BOOT_KEY))\r
  *      {\r
  *          Boot_Key = 0;\r
  *          ((void (*)(void))BOOTLOADER_START_ADDRESS)(); \r
  *      {\r
  *          Boot_Key = 0;\r
  *          ((void (*)(void))BOOTLOADER_START_ADDRESS)(); \r