I'm having problems configuring max9867 as a direct output without going through I2C. I perform the settings of the following registers. I'm using zephyr as rtos.
[00:00:01.709,625] <dbg> max9867: codec_read_reg: RD | REG: 0x00 VAL: 0x00 - 00000000
[00:00:01.730,651] <dbg> max9867: codec_read_reg: RD | REG: 0x01 VAL: 0x20 - 00100000
[00:00:01.751,586] <dbg> max9867: codec_read_reg: RD | REG: 0x02 VAL: 0x00 - 00000000
[00:00:01.772,491] <dbg> max9867: codec_read_reg: RD | REG: 0x03 VAL: 0x00 - 00000000
[00:00:01.793,518] <dbg> max9867: codec_read_reg: RD | REG: 0x04 VAL: 0xe6 - 11100110
[00:00:01.814,361] <dbg> max9867: codec_read_reg: RD | REG: 0x05 VAL: 0x10 - 00010000
[00:00:01.835,601] <dbg> max9867: codec_read_reg: RD | REG: 0x06 VAL: 0x10 - 00010000
[00:00:01.856,689] <dbg> max9867: codec_read_reg: RD | REG: 0x07 VAL: 0x01 - 00000001
[00:00:01.877,685] <dbg> max9867: codec_read_reg: RD | REG: 0x08 VAL: 0x00 - 00000000
[00:00:01.898,834] <dbg> max9867: codec_read_reg: RD | REG: 0x09 VAL: 0x00 - 00000000
[00:00:01.919,708] <dbg> max9867: codec_read_reg: RD | REG: 0x0a VAL: 0x11 - 00010001
[00:00:01.940,979] <dbg> max9867: codec_read_reg: RD | REG: 0x0b VAL: 0xc0 - 11000000
[00:00:01.962,188] <dbg> max9867: codec_read_reg: RD | REG: 0x0c VAL: 0x00 - 00000000
[00:00:01.983,123] <dbg> max9867: codec_read_reg: RD | REG: 0x0d VAL: 0x33 - 00110011
[00:00:02.004,180] <dbg> max9867: codec_read_reg: RD | REG: 0x0e VAL: 0x00 - 00000000
[00:00:02.025,329] <dbg> max9867: codec_read_reg: RD | REG: 0x0f VAL: 0x00 - 00000000
[00:00:02.046,264] <dbg> max9867: codec_read_reg: RD | REG: 0x10 VAL: 0x04 - 00000100
[00:00:02.067,230] <dbg> max9867: codec_read_reg: RD | REG: 0x11 VAL: 0x09 - 00001001
[00:00:02.088,165] <dbg> max9867: codec_read_reg: RD | REG: 0x12 VAL: 0x34 - 00110100
[00:00:02.109,130] <dbg> max9867: codec_read_reg: RD | REG: 0x13 VAL: 0x34 - 00110100
[00:00:02.130,035] <dbg> max9867: codec_read_reg: RD | REG: 0x14 VAL: 0x40 - 01000000
[00:00:02.150,909] <dbg> max9867: codec_read_reg: RD | REG: 0x15 VAL: 0x00 - 00000000
[00:00:02.172,027] <dbg> max9867: codec_read_reg: RD | REG: 0x16 VAL: 0x03 - 00000011
[00:00:02.193,023] <dbg> max9867: codec_read_reg: RD | REG: 0x17 VAL: 0x00 - 00000000
The image below follows the shape of the flow I'm trying to configure.
Functional Diagram
But there is no signal coming out of the LOUTP. Do you have any guidance for me, am I doing something wrong?
Related
I'm currently working on USB headset using stm32 microcontroller. I used example code from X-CUBE-USB-AUDIO package to stream audio to\from PC. Everything seems to work fine. Now I want to modify the code to allow USB device to notify the host of volume/mute changes. According to USB audio specification 1.0 p.30, an optional Status Interrupt Endpoint can be used for this purpose. So I modified device descriptor to include that optional endpoint. Here is the original descriptor:
Information for device STM32 AUDIO Streaming in FS Mode (VID=0x0483 PID=0x5730):
Connection Information:
------------------------------
Device current bus speed: FullSpeed
Device supports USB 1.1 specification
Device supports USB 2.0 specification
Device address: 0x004B
Current configuration value: 0x01
Number of open pipes: 0
Device Descriptor:
------------------------------
0x12 bLength
0x01 bDescriptorType
0x0200 bcdUSB
0x00 bDeviceClass
0x00 bDeviceSubClass
0x00 bDeviceProtocol
0x40 bMaxPacketSize0 (64 bytes)
0x0483 idVendor
0x5730 idProduct
0x0200 bcdDevice
0x01 iManufacturer "STMicroelectronics"
0x02 iProduct "STM32 AUDIO Streaming in FS Mode"
0x03 iSerialNumber "368932633438"
0x01 bNumConfigurations
Configuration Descriptor:
------------------------------
0x09 bLength
0x02 bDescriptorType
0x00CB wTotalLength (203 bytes)
0x03 bNumInterfaces
0x01 bConfigurationValue
0x00 iConfiguration
0xC0 bmAttributes (Self-powered Device)
0x32 bMaxPower (100 mA)
Interface Descriptor:
------------------------------
0x09 bLength
0x04 bDescriptorType
0x00 bInterfaceNumber
0x00 bAlternateSetting
0x00 bNumEndPoints
0x01 bInterfaceClass (Audio Device Class)
0x01 bInterfaceSubClass (Audio Control Interface)
0x00 bInterfaceProtocol (Audio Protocol undefined)
0x00 iInterface
AC Interface Header Descriptor:
------------------------------
0x0A bLength
0x24 bDescriptorType
0x01 bDescriptorSubtype
0x0100 bcdADC
0x0048 wTotalLength (72 bytes)
0x02 bInCollection
0x01 baInterfaceNr(1)
0x02 baInterfaceNr(2)
AC Input Terminal Descriptor:
------------------------------
0x0C bLength
0x24 bDescriptorType
0x02 bDescriptorSubtype
0x12 bTerminalID
0x0101 wTerminalType (USB Streaming)
0x00 bAssocTerminal
0x02 bNrChannels (2 channels)
0x0003 wChannelConfig
0x00 iChannelNames
0x00 iTerminal
AC Feature Unit Descriptor:
------------------------------
0x0A bLength
0x24 bDescriptorType
0x06 bDescriptorSubtype
0x16 bUnitID
0x12 bSourceID
0x01 bControlSize
bmaControls:
0x03 Channel(0) - Mute / Volume
0x00 Channel(1)
0x00 Channel(2)
0x00 iFeature
AC Output Terminal Descriptor:
------------------------------
0x09 bLength
0x24 bDescriptorType
0x03 bDescriptorSubtype
0x14 bTerminalID
0x0301 wTerminalType (Speaker)
0x00 bAssocTerminal
0x16 bSourceID
0x00 iTerminal
AC Input Terminal Descriptor:
------------------------------
0x0C bLength
0x24 bDescriptorType
0x02 bDescriptorSubtype
0x11 bTerminalID
0x0201 wTerminalType (Microphone)
0x00 bAssocTerminal
0x02 bNrChannels (2 channels)
0x0003 wChannelConfig
0x00 iChannelNames
0x00 iTerminal
AC Feature Unit Descriptor:
------------------------------
0x0A bLength
0x24 bDescriptorType
0x06 bDescriptorSubtype
0x15 bUnitID
0x11 bSourceID
0x01 bControlSize
bmaControls:
0x03 Channel(0) - Mute / Volume
0x00 Channel(1)
0x00 Channel(2)
0x00 iFeature
AC Output Terminal Descriptor:
------------------------------
0x09 bLength
0x24 bDescriptorType
0x03 bDescriptorSubtype
0x13 bTerminalID
0x0101 wTerminalType (USB Streaming)
0x00 bAssocTerminal
0x15 bSourceID
0x00 iTerminal
Interface Descriptor:
------------------------------
0x09 bLength
0x04 bDescriptorType
0x01 bInterfaceNumber
0x00 bAlternateSetting
0x00 bNumEndPoints
0x01 bInterfaceClass (Audio Device Class)
0x02 bInterfaceSubClass (Audio Streaming Interface)
0x00 bInterfaceProtocol (Audio Protocol undefined)
0x00 iInterface
Interface Descriptor:
------------------------------
0x09 bLength
0x04 bDescriptorType
0x01 bInterfaceNumber
0x01 bAlternateSetting
0x02 bNumEndPoints
0x01 bInterfaceClass (Audio Device Class)
0x02 bInterfaceSubClass (Audio Streaming Interface)
0x00 bInterfaceProtocol (Audio Protocol undefined)
0x00 iInterface
AS Interface Descriptor:
------------------------------
0x07 bLength
0x24 bDescriptorType
0x01 bDescriptorSubtype
0x12 bTerminalLink
0x01 bDelay
0x0001 wFormatTag (PCM)
AS Format Type 1 Descriptor:
------------------------------
0x0B bLength
0x24 bDescriptorType
0x02 bDescriptorSubtype
0x01 bFormatType (FORMAT_TYPE_1)
0x02 bNrChannels (2 channels)
0x02 bSubframeSize
0x10 bBitResolution (16 bits per sample)
0x01 bSamFreqType (Discrete sampling frequencies)
0x00BB80 tSamFreq(1) (48000 Hz)
Endpoint Descriptor (Audio/MIDI 1.0):
------------------------------
0x09 bLength
0x05 bDescriptorType
0x01 bEndpointAddress (OUT endpoint 1)
0x05 bmAttributes (Transfer: Isochronous / Synch: Asynchronous / Usage: Data)
0x00C4 wMaxPacketSize (1 x 196 bytes)
0x01 bInterval (1 frames)
0x00 bRefresh
0x81 bSynchAddress
AS Isochronous Data Endpoint Descriptor:
------------------------------
0x07 bLength
0x25 bDescriptorType
0x01 bDescriptorSubtype
0x00 bmAttributes
0x00 bLockDelayUnits (undefined)
0x0000 wLockDelay
Endpoint Descriptor (Audio/MIDI 1.0):
------------------------------
0x09 bLength
0x05 bDescriptorType
0x81 bEndpointAddress (IN endpoint 1)
0x01 bmAttributes (Transfer: Isochronous / Synch: None / Usage: Data)
0x0003 wMaxPacketSize (1 x 3 bytes)
0x01 bInterval (1 frames)
0x07 bRefresh
0x00 bSynchAddress
Interface Descriptor:
------------------------------
0x09 bLength
0x04 bDescriptorType
0x02 bInterfaceNumber
0x00 bAlternateSetting
0x00 bNumEndPoints
0x01 bInterfaceClass (Audio Device Class)
0x02 bInterfaceSubClass (Audio Streaming Interface)
0x00 bInterfaceProtocol (Audio Protocol undefined)
0x00 iInterface
Interface Descriptor:
------------------------------
0x09 bLength
0x04 bDescriptorType
0x02 bInterfaceNumber
0x01 bAlternateSetting
0x01 bNumEndPoints
0x01 bInterfaceClass (Audio Device Class)
0x02 bInterfaceSubClass (Audio Streaming Interface)
0x00 bInterfaceProtocol (Audio Protocol undefined)
0x00 iInterface
AS Interface Descriptor:
------------------------------
0x07 bLength
0x24 bDescriptorType
0x01 bDescriptorSubtype
0x13 bTerminalLink
0x01 bDelay
0x0001 wFormatTag (PCM)
AS Format Type 1 Descriptor:
------------------------------
0x0B bLength
0x24 bDescriptorType
0x02 bDescriptorSubtype
0x01 bFormatType (FORMAT_TYPE_1)
0x02 bNrChannels (2 channels)
0x02 bSubframeSize
0x10 bBitResolution (16 bits per sample)
0x01 bSamFreqType (Discrete sampling frequencies)
0x00BB80 tSamFreq(1) (48000 Hz)
Endpoint Descriptor (Audio/MIDI 1.0):
------------------------------
0x09 bLength
0x05 bDescriptorType
0x82 bEndpointAddress (IN endpoint 2)
0x01 bmAttributes (Transfer: Isochronous / Synch: None / Usage: Data)
0x00C0 wMaxPacketSize (1 x 192 bytes)
0x01 bInterval (1 frames)
0x00 bRefresh
0x00 bSynchAddress
AS Isochronous Data Endpoint Descriptor:
------------------------------
0x07 bLength
0x25 bDescriptorType
0x01 bDescriptorSubtype
0x00 bmAttributes
0x00 bLockDelayUnits (undefined)
0x0000 wLockDelay
Microsoft OS Descriptor is not available. Error code: 0x0000001F
String Descriptor Table
--------------------------------
Index LANGID String
0x00 0x0000 0x0409
0x01 0x0409 "STMicroelectronics"
0x02 0x0409 "STM32 AUDIO Streaming in FS Mode"
0x03 0x0409 "368932633438"
------------------------------
Connection path for device:
USB xHCI Compliant Host Controller
Root Hub
STM32 AUDIO Streaming in FS Mode (VID=0x0483 PID=0x5730) Port: 5
Running on: Windows 10 or greater (Build Version 19043)
Brought to you by TDD v2.15.0, Jun 8 2020, 17:18:07
And here is the modified descriptor:
Information for device STM32 AUDIO Streaming in FS Mode (VID=0x0483 PID=0x5730):
Connection Information:
------------------------------
Device current bus speed: FullSpeed
Device supports USB 1.1 specification
Device supports USB 2.0 specification
Device address: 0x001B
Current configuration value: 0x01
Number of open pipes: 1
Device Descriptor:
------------------------------
0x12 bLength
0x01 bDescriptorType
0x0200 bcdUSB
0x00 bDeviceClass
0x00 bDeviceSubClass
0x00 bDeviceProtocol
0x40 bMaxPacketSize0 (64 bytes)
0x0483 idVendor
0x5730 idProduct
0x0200 bcdDevice
0x01 iManufacturer "STMicroelectronics"
0x02 iProduct "STM32 AUDIO Streaming in FS Mode"
0x03 iSerialNumber "368932633438"
0x01 bNumConfigurations
Configuration Descriptor:
------------------------------
0x09 bLength
0x02 bDescriptorType
0x00D4 wTotalLength (212 bytes)
0x03 bNumInterfaces
0x01 bConfigurationValue
0x00 iConfiguration
0xC0 bmAttributes (Self-powered Device)
0x32 bMaxPower (100 mA)
Interface Descriptor:
------------------------------
0x09 bLength
0x04 bDescriptorType
0x00 bInterfaceNumber
0x00 bAlternateSetting
0x01 bNumEndPoints
0x01 bInterfaceClass (Audio Device Class)
0x01 bInterfaceSubClass (Audio Control Interface)
0x00 bInterfaceProtocol (Audio Protocol undefined)
0x00 iInterface
AC Interface Header Descriptor:
------------------------------
0x0A bLength
0x24 bDescriptorType
0x01 bDescriptorSubtype
0x0100 bcdADC
0x0048 wTotalLength (72 bytes)
0x02 bInCollection
0x01 baInterfaceNr(1)
0x02 baInterfaceNr(2)
AC Input Terminal Descriptor:
------------------------------
0x0C bLength
0x24 bDescriptorType
0x02 bDescriptorSubtype
0x12 bTerminalID
0x0101 wTerminalType (USB Streaming)
0x00 bAssocTerminal
0x02 bNrChannels (2 channels)
0x0003 wChannelConfig
0x00 iChannelNames
0x00 iTerminal
AC Feature Unit Descriptor:
------------------------------
0x0A bLength
0x24 bDescriptorType
0x06 bDescriptorSubtype
0x16 bUnitID
0x12 bSourceID
0x01 bControlSize
bmaControls:
0x03 Channel(0) - Mute / Volume
0x00 Channel(1)
0x00 Channel(2)
0x00 iFeature
AC Output Terminal Descriptor:
------------------------------
0x09 bLength
0x24 bDescriptorType
0x03 bDescriptorSubtype
0x14 bTerminalID
0x0301 wTerminalType (Speaker)
0x00 bAssocTerminal
0x16 bSourceID
0x00 iTerminal
AC Input Terminal Descriptor:
------------------------------
0x0C bLength
0x24 bDescriptorType
0x02 bDescriptorSubtype
0x11 bTerminalID
0x0201 wTerminalType (Microphone)
0x00 bAssocTerminal
0x02 bNrChannels (2 channels)
0x0003 wChannelConfig
0x00 iChannelNames
0x00 iTerminal
AC Feature Unit Descriptor:
------------------------------
0x0A bLength
0x24 bDescriptorType
0x06 bDescriptorSubtype
0x15 bUnitID
0x11 bSourceID
0x01 bControlSize
bmaControls:
0x03 Channel(0) - Mute / Volume
0x00 Channel(1)
0x00 Channel(2)
0x00 iFeature
AC Output Terminal Descriptor:
------------------------------
0x09 bLength
0x24 bDescriptorType
0x03 bDescriptorSubtype
0x13 bTerminalID
0x0101 wTerminalType (USB Streaming)
0x00 bAssocTerminal
0x15 bSourceID
0x00 iTerminal
Endpoint Descriptor (Audio/MIDI 1.0):
------------------------------
0x09 bLength
0x05 bDescriptorType
0x83 bEndpointAddress (IN endpoint 3)
0x03 bmAttributes (Transfer: Interrupt / Synch: None / Usage: Data)
0x0002 wMaxPacketSize (1 x 2 bytes)
0x0A bInterval (10 frames)
0x00 bRefresh
0x00 bSynchAddress
Interface Descriptor:
------------------------------
0x09 bLength
0x04 bDescriptorType
0x01 bInterfaceNumber
0x00 bAlternateSetting
0x00 bNumEndPoints
0x01 bInterfaceClass (Audio Device Class)
0x02 bInterfaceSubClass (Audio Streaming Interface)
0x00 bInterfaceProtocol (Audio Protocol undefined)
0x00 iInterface
Interface Descriptor:
------------------------------
0x09 bLength
0x04 bDescriptorType
0x01 bInterfaceNumber
0x01 bAlternateSetting
0x02 bNumEndPoints
0x01 bInterfaceClass (Audio Device Class)
0x02 bInterfaceSubClass (Audio Streaming Interface)
0x00 bInterfaceProtocol (Audio Protocol undefined)
0x00 iInterface
AS Interface Descriptor:
------------------------------
0x07 bLength
0x24 bDescriptorType
0x01 bDescriptorSubtype
0x12 bTerminalLink
0x01 bDelay
0x0001 wFormatTag (PCM)
AS Format Type 1 Descriptor:
------------------------------
0x0B bLength
0x24 bDescriptorType
0x02 bDescriptorSubtype
0x01 bFormatType (FORMAT_TYPE_1)
0x02 bNrChannels (2 channels)
0x02 bSubframeSize
0x10 bBitResolution (16 bits per sample)
0x01 bSamFreqType (Discrete sampling frequencies)
0x00BB80 tSamFreq(1) (48000 Hz)
Endpoint Descriptor (Audio/MIDI 1.0):
------------------------------
0x09 bLength
0x05 bDescriptorType
0x01 bEndpointAddress (OUT endpoint 1)
0x05 bmAttributes (Transfer: Isochronous / Synch: Asynchronous / Usage: Data)
0x00C4 wMaxPacketSize (1 x 196 bytes)
0x01 bInterval (1 frames)
0x00 bRefresh
0x81 bSynchAddress
AS Isochronous Data Endpoint Descriptor:
------------------------------
0x07 bLength
0x25 bDescriptorType
0x01 bDescriptorSubtype
0x00 bmAttributes
0x00 bLockDelayUnits (undefined)
0x0000 wLockDelay
Endpoint Descriptor (Audio/MIDI 1.0):
------------------------------
0x09 bLength
0x05 bDescriptorType
0x81 bEndpointAddress (IN endpoint 1)
0x01 bmAttributes (Transfer: Isochronous / Synch: None / Usage: Data)
0x0003 wMaxPacketSize (1 x 3 bytes)
0x01 bInterval (1 frames)
0x07 bRefresh
0x00 bSynchAddress
Interface Descriptor:
------------------------------
0x09 bLength
0x04 bDescriptorType
0x02 bInterfaceNumber
0x00 bAlternateSetting
0x00 bNumEndPoints
0x01 bInterfaceClass (Audio Device Class)
0x02 bInterfaceSubClass (Audio Streaming Interface)
0x00 bInterfaceProtocol (Audio Protocol undefined)
0x00 iInterface
Interface Descriptor:
------------------------------
0x09 bLength
0x04 bDescriptorType
0x02 bInterfaceNumber
0x01 bAlternateSetting
0x01 bNumEndPoints
0x01 bInterfaceClass (Audio Device Class)
0x02 bInterfaceSubClass (Audio Streaming Interface)
0x00 bInterfaceProtocol (Audio Protocol undefined)
0x00 iInterface
AS Interface Descriptor:
------------------------------
0x07 bLength
0x24 bDescriptorType
0x01 bDescriptorSubtype
0x13 bTerminalLink
0x01 bDelay
0x0001 wFormatTag (PCM)
AS Format Type 1 Descriptor:
------------------------------
0x0B bLength
0x24 bDescriptorType
0x02 bDescriptorSubtype
0x01 bFormatType (FORMAT_TYPE_1)
0x02 bNrChannels (2 channels)
0x02 bSubframeSize
0x10 bBitResolution (16 bits per sample)
0x01 bSamFreqType (Discrete sampling frequencies)
0x00BB80 tSamFreq(1) (48000 Hz)
Endpoint Descriptor (Audio/MIDI 1.0):
------------------------------
0x09 bLength
0x05 bDescriptorType
0x82 bEndpointAddress (IN endpoint 2)
0x01 bmAttributes (Transfer: Isochronous / Synch: None / Usage: Data)
0x00C0 wMaxPacketSize (1 x 192 bytes)
0x01 bInterval (1 frames)
0x00 bRefresh
0x00 bSynchAddress
AS Isochronous Data Endpoint Descriptor:
------------------------------
0x07 bLength
0x25 bDescriptorType
0x01 bDescriptorSubtype
0x00 bmAttributes
0x00 bLockDelayUnits (undefined)
0x0000 wLockDelay
Microsoft OS Descriptor is not available. Error code: 0x0000001F
String Descriptor Table
--------------------------------
Index LANGID String
0x00 0x0000 0x0409
0x01 0x0409 "STMicroelectronics"
0x02 0x0409 "STM32 AUDIO Streaming in FS Mode"
0x03 0x0409 "368932633438"
------------------------------
Connection path for device:
USB xHCI Compliant Host Controller
Root Hub
STM32 AUDIO Streaming in FS Mode (VID=0x0483 PID=0x5730) Port: 5
Running on: Windows 10 or greater (Build Version 19043)
Brought to you by TDD v2.15.0, Jun 8 2020, 17:18:07
The changes I've made are:
Add AC Interrupt endpoint descriptor.
Change wTotalLength in Configuration Descriptor.
Change bNumEndPoints in AC Interface descriptor from 0 to 1.
USB device seems to enumerate fine and there is audio, however when looking at the output of Beagle USB logic analyzer, I don't see any data being requested by the host from the interrupt endpoint. So my question is, is there something wrong with the way I modified the descriptors or is it something else? Has anyone managed to get the Status Interrupt Endpoint working properly for USB audio devices?
Running on: Windows 10 or greater (Build Version 19043)
Windows doesn't handle this interrupt in my experience. Try it on Linux or MacOS.
I have a string returned in this format:
\n\bbcn_test\u0012\u00041.14\u001a\u0004escc\"\u0004vscc*(\u0012\f\u0012\n\b\u0001\u0012\u0002\b\u0000\u0012\u0002\b\u0001\u001a\u000b\u0012\t\n\u0007Org1MSP\u001a\u000b\u0012\t\n\u0007Org2MSP2D\n \ufffd\ufffda\ufffd\ufffd\ufffd3RU4\ufffd\ufffdR\ufffd\ufffd\ufffd\ufffd#\ufffd\ufffds\b\ufffd\u0014\ufffd\ufffd.\ufffd!\ufffd\u0012 s\ufffd\ufffdc\ufffd6\ufffd\ufffd#\ufffd\u001eF\ufffdƳ\ufffdi\ufffd$\ufffd\ufffd4\ufffdgP\ufffd:\ufffdt\u000e: 6ђ\ufffd\ufffd3\u007fJ\ufffdHt\u0004\ufffd\ufffd\ufffd\ufffd^{\\\ufffd\u001d\ufffd\ufffd\ufffd\ufffd\ufffd3\ufffdb?#\ufffdB,\u0012\f\u0012\n\b\u0001\u0012\u0002\b\u0000\u0012\u0002\b\u0001\u001a\r\u0012\u000b\n\u0007Org1MSP\u0010\u0001\u001a\r\u0012\u000b\n\u0007Org2MSP\u0010\u0001
\n\u0004mycc\u0012\u00031.0\u001a\u0004escc\"\u0004vscc*,\u0012\f\u0012\n\b\u0002\u0012\u0002\b\u0000\u0012\u0002\b\u0001\u001a\r\u0012\u000b\n\u0007Org1MSP\u0010\u0003\u001a\r\u0012\u000b\n\u0007Org2MSP\u0010\u00032D\n \ufffd\u0011}\ufffdT\ufffdV \u0010l\ufffdNT\ufffd\ufffdz\ufffd\ufffd\ufffdv+\ufffd˹5;\ufffd#q\ufffd\ufffd\u000e\u0012 \u0007\u001f\u0014)\u001e\u0015+\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffdt\ufffd\u0013ak\ufffd\u0015J\ufffd\ufffd\ufffd\ufffdZ\u0017_c&: y\ufffd\ufffdw\ufffdnN\ufffd<\ufffd3^v\ufffdbIB`M\ufffd\ufffd\ufffd)&\u0007x\ufffd;(u\ufffdLB,\u0012\f\u0012\n\b\u0001\u0012\u0002\b\u0000\u0012\u0002\b\u0001\u001a\r\u0012\u000b\n\u0007Org1MSP\u0010\u0001\u001a\r\u0012\u000b\n\u0007Org2MSP\u0010\u0001
I am trying to decode it in order to obtain a valid string but I don't understand which format it's written in and what is a good decoder for it.
How can I determine what the format is and how to decode it?
What you have is binary data that has been stringified into a human readable format.
So, you need to first parse the string converting its characters into bytes.
Substrings that are encoded in an escape sequence format (preceded by the '\' character followed by 1-4 characters) are decoded to specific bytes like this:
\b -> 0x08
\t -> 0x09
\n -> 0x0A
\f -> 0x0C
\r -> 0x0D
\" -> 0x22
\' -> 0x27
\\ -> 0x5C
\u00## + \uff## -> 0x## (the ff is due to sign-extension for bytes >= 0x80)
Any un-escaped characters in the string are to be converted as-is (ie, simply cast from 16-bit Char to 8-bit Byte ignoring the high 8 bits).
Let's look at the first string you provided:
\n\bbcn_test\u0012\u00041.14\u001a\u0004escc\"\u0004vscc*(\u0012\f\u0012\n\b\u0001\u0012\u0002\b\u0000\u0012\u0002\b\u0001\u001a\u000b\u0012\t\n\u0007Org1MSP\u001a\u000b\u0012\t\n\u0007Org2MSP2D\n \ufffd\ufffda\ufffd\ufffd\ufffd3RU4\ufffd\ufffdR\ufffd\ufffd\ufffd\ufffd#\ufffd\ufffds\b\ufffd\u0014\ufffd\ufffd.\ufffd!\ufffd\u0012 s\ufffd\ufffdc\ufffd6\ufffd\ufffd#\ufffd\u001eF\ufffdƳ\ufffdi\ufffd$\ufffd\ufffd4\ufffdgP\ufffd:\ufffdt\u000e: 6ђ\ufffd\ufffd3\u007fJ\ufffdHt\u0004\ufffd\ufffd\ufffd\ufffd^{\\ufffd\u001d\ufffd\ufffd\ufffd\ufffd\ufffd3\ufffdb?#\ufffdB,\u0012\f\u0012\n\b\u0001\u0012\u0002\b\u0000\u0012\u0002\b\u0001\u001a\r\u0012\u000b\n\u0007Org1MSP\u0010\u0001\u001a\r\u0012\u000b\n\u0007Org2MSP\u0010\u0001
Break up the individual sequences for decoding:
\n \b b c n _ t e s t \u0012 \u0004 1 . 1 4 \u001a \u0004 e s c c \" \u0004 v s c c * ( \u0012 \f \u0012 \n \b \u0001 \u0012 \u0002 \b \u0000 \u0012 \u0002 \b \u0001 \u001a \u000b \u0012 \t \n \u0007 O r g 1 M S P \u001a \u000b \u0012 \t \n \u0007 O r g 2 M S P 2 D \n \ufffd \ufffd a \ufffd \ufffd \ufffd 3 R U 4 \ufffd \ufffd R \ufffd \ufffd \ufffd \ufffd # \ufffd \ufffd s \b \ufffd \u0014 \ufffd \ufffd . \ufffd ! \ufffd \u0012 s \ufffd \ufffd c \ufffd 6 \ufffd \ufffd # \ufffd \u001e F \ufffd Ƴ \ufffd i \ufffd $ \ufffd \ufffd 4 \ufffd g P \ufffd : \ufffd t \u000e : 6 ђ1 \ufffd \ufffd 3 \u007f J \ufffd H t \u0004 \ufffd \ufffd \ufffd \ufffd ^ { \\ \ufffd \u001d \ufffd \ufffd \ufffd \ufffd \ufffd 3 \ufffd b ? # \ufffd B , \u0012 \f \u0012 \n \b \u0001 \u0012 \u0002 \b \u0000 \u0012 \u0002 \b \u0001 \u001a \r \u0012 \u000b \n \u0007 O r g 1 M S P \u0010 \u0001 \u001a \r \u0012 \u000b \n \u0007 O r g 2 M S P \u0010 \u0001
And convert them to bytes:
0x0A 0x08 0x62 0x63 0x6E 0x5F 0x74 0x65 0x73 0x74 0x12 0x04 0x31 0x2E 0x31 0x34 0x1A 0x04 0x65 0x73 0x63 0x63 0x22 0x04 0x76 0x73 0x63 0x63 0x2A 0x28 0x12 0x0C 0x12 0x0A 0x08 0x01 0x12 0x02 0x08 0x00 0x12 0x02 0x08 0x01 0x1A 0x0B 0x12 0x09 0x0A 0x07 0x4F 0x72 0x67 0x31 0x4D 0x53 0x50 0x1A 0x0B 0x12 0x09 0x0A 0x07 0x4F 0x72 0x67 0x32 0x4D 0x53 0x50 0x32 0x44 0x0A 0x20 0xFD 0xFD 0x61 0xFD 0xFD 0xFD 0x33 0x52 0x55 0x34 0xFD 0xFD 0x52 0xFD 0xFD 0xFD 0xFD 0x40 0xFD 0xFD 0x73 0x08 0xFD 0x14 0xFD 0xFD 0x2E 0xFD 0x21 0xFD 0x12 0x20 0x73 0xFD 0xFD 0x63 0xFD 0x36 0xFD 0xFD 0x40 0xFD 0x1E 0x46 0xFD 0x59 0xFD 0x69 0xFD 0x24 0xFD 0xFD 0x34 0xFD 0x67 0x50 0xFD 0x3A 0xFD 0x74 0x0E 0x3A 0x20 0x36 ђ1 0xFD 0xFD 0x33 0x7F 0x4A 0xFD 0x48 0x74 0x04 0xFD 0xFD 0xFD 0xFD 0x5E 0x7B 0x5C 0xFD 0x1D 0xFD 0xFD 0xFD 0xFD 0xFD 0x33 0xFD 0x62 0x3F 0x40 0xFD 0x42 0x2C 0x12 0x0C 0x12 0x0A 0x08 0x01 0x12 0x02 0x08 0x00 0x12 0x02 0x08 0x01 0x1A 0x0D 0x12 0x0b 0x0A 0x07 0x4F 0x72 0x67 0x31 0x4D 0x53 0x50 0x10 0x01 0x1A 0x0D 0x12 0x0B 0x0A 0x07 0x4F 0x72 0x67 0x32 0x4D 0x53 0x50 0x10 0x01
Once you have decoded the bytes, you can interpret binary data as needed. It appears to be in a kind of Type-Length-Value format, like #RobNapier suggested in a comment to your question:
BTW, this looks exactly like a TLV (Type-Length-Value) format. The first byte is a type 0x0a, followed by a length 0x08, followed by eight bytes of data ("bcn_test"), followed by a type (0x12), followed by a length (0x04), followed by 4 bytes of data ("1.14"), etc.
0x0A (Type 10), 0x08 (Len 8)
0x62 0x63 0x6E 0x5F 0x74 0x65 0x73 0x74 (bcn_test)
0x12 (Type 18) 0x04 (Len 4)
0x31 0x2E 0x31 0x34 (1.14)
0x1A (Type 26) 0x04 (Len 4)
0x65 0x73 0x63 0x63 (escc)
0x22 (Type 34) 0x04 (Len 4)
0x76 0x73 0x63 0x63 (vscc)
and so on ...
1: however, I'm not sure how to correctly decode the ђ in the original string. It is Unicode codepoint U+0452 CYRILLIC SMALL LETTER DJE, which in a Java Char is bytes 0x04 0x52. Truncated to 0x04 or 0x52, or interpreted in a Cyrillic charset like Windows-1251 where it would be byte 0x90, it doesn't match up with the rest of the TLV format.
I understand that new interface addition can be detected using RTE_NEWLINK message type in NETLINK. Netlink sends a message with which we can get index and name of the interface using (if_indextoname & if_nametoindex).
My question is , if we add a VLAN interface, it sends a message with interface name (example: eth1.10). Does this vlan number only be available in interface name
or is it available anywhere inside NL_MSG structure. I dont want to parse
interface name and get VLAN number
I executed the below code and added a vlan sub interface, but couldn't find vlan information from attribute structures. It didnt print anything even though RTM_NEWLINK detected the new interface. Please correct me if i am looking for VLAN information at a wrong place in code.
if(nl_msg_hdr->nlmsg_type == RTM_NEWLINK)
{
struct ifinfomsg *ifi;
struct rtattr *rt_attr;
int rtattrlen;
ifi = (struct ifinfomsg *) NLMSG_DATA(nl_msg_hdr);
printf("RTM_NEWLINK");
for (;RTA_OK(rt_attr, rtattrlen); rt_attr = RTA_NEXT(rt_attr, rtattrlen)) {
if (rt_attr->rta_type == IFLA_LINKINFO)
printf(" IFLA_LINKINFO \n");
if (rt_attr->rta_type == IFLA_LINK)
printf(" IFLA_LINK \n");
if (rt_attr->rta_type == IFLA_INFO_DATA)
printf(" IFLA_INFO_DATA\n");
if (rt_attr->rta_type == IFLA_VLAN_ID)
printf(" IFLA_VLAN_ID\n");
}
}
x/200bx nl_msg_hdr - 200 bytes hex-dump (VLAN ID is 33 in my case)
0x7fffffffd250: 0xa4 0x04 0x00 0x00 0x10 0x00 0x00 0x00
0x7fffffffd258: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x7fffffffd260: 0x00 0x00 0x01 0x00 0x27 0x00 0x00 0x00
0x7fffffffd268: 0x02 0x10 0x00 0x00 0xff 0xff 0xff 0xff
0x7fffffffd270: 0x0d 0x00 0x03 0x00 0x76 0x65 0x74 0x68
0x7fffffffd278: 0x31 0x2e 0x33 0x33 0x00 0x00 0x00 0x00
0x7fffffffd280: 0x08 0x00 0x0d 0x00 0x00 0x00 0x00 0x00
0x7fffffffd288: 0x05 0x00 0x10 0x00 0x02 0x00 0x00 0x00
0x7fffffffd290: 0x05 0x00 0x11 0x00 0x00 0x00 0x00 0x00
0x7fffffffd298: 0x08 0x00 0x04 0x00 0xdc 0x05 0x00 0x00
0x7fffffffd2a0: 0x08 0x00 0x1b 0x00 0x00 0x00 0x00 0x00
0x7fffffffd2a8: 0x08 0x00 0x1e 0x00 0x00 0x00 0x00 0x00
0x7fffffffd2b0: 0x08 0x00 0x1f 0x00 0x01 0x00 0x00 0x00
0x7fffffffd2b8: 0x08 0x00 0x20 0x00 0x01 0x00 0x00 0x00
0x7fffffffd2c0: 0x08 0x00 0x05 0x00 0x0a 0x00 0x00 0x00
0x7fffffffd2c8: 0x05 0x00 0x21 0x00 0x01 0x00 0x00 0x00
0x7fffffffd2d0: 0x09 0x00 0x06 0x00 0x6e 0x6f 0x6f 0x70
0x7fffffffd2d8: 0x00 0x00 0x00 0x00 0x24 0x00 0x0e 0x00
0x7fffffffd2e0: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x7fffffffd2e8: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x7fffffffd2f0: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x7fffffffd2f8: 0x00 0x00 0x00 0x00 0x00 0x88 0xff 0xff
0x7fffffffd300: 0x0a 0x00 0x01 0x00 0x66 0x0f 0x70 0x37
0x7fffffffd308: 0x0b 0x27 0x00 0x00 0x0a 0x00 0x02 0x00
0x7fffffffd310: 0xff 0xff 0xff 0xff 0xff 0xff 0x00 0x00
The vlan info is available in RTM_NEWLINK messages: IFLA_LINKINFO / IFLA_INFO_DATA / IFLA_VLAN_ID:
# the message structure:
[ nlmsg fields ]
[ ifinfmsg fields ]
nla chain:
[ IFLA_IFNAME ]
[ IFLA_… ]
[ IFLA_LINKINFO ]
nla chain:
[ IFLA_INFO_KIND ]
...
[ IFLA_INFO_DATA ]
nla chain:
[ IFLA_VLAN_ID ]
and the corresponding code (python sample with pyroute2):
from pyroute2 import IPRoute
ip = IPRoute()
# assume `ifindex` contains VLAN interface index
nlmsg = ip.get_links(ifindex)[0]
vid = nlmsg.get_attr('IFLA_LINKINFO').\
get_attr('IFLA_INFO_DATA').\
get_attr('IFLA_VLAN_ID')
print(vid)
Checked on kernels from 2.6.32 (RHEL6.5) to 4.1.0-rc6 (F22).
And yes, you're right — one should not rely on the interface name as the source of VLAN id. The interface name can be literally any.
I'm trying to send/receive audio over USB from my embedded linux device to/from a Windows host.
I understand there are 2 protocols to send audio over USB - USB Audio Class 1 and 2 (UAC1 & UAC2). I found them explained here: http://www.thewelltemperedcomputer.com/HW/USB_Audio.htm.
I have currently used the existing UAC1 device driver in Linux to get audio from the host PC. It works for me. I am now trying to change the device driver to also be capable of sending audio to the host PC.
I see that there's a UAC2 driver (in the latest Linux kernel) that both sends and receives audio from the host. But I'd like to have a UAC1 driver that does that, so that I don't have to install any extra drivers on the Windows host (especially ones I have to buy: http://www.thesycon.de/eng/usb_audiodriver.shtml).
I've modified the linux device driver at linux/drivers/usb/gadget/f_audio.c (I'm using an older kernel). I've changed the USB header descriptor to include the extra endpoint for sending audio to host.
static struct usb_descriptor_header *hs_audio_desc[] = {
(struct usb_descriptor_header *)&std_ac_if_desc,
(struct usb_descriptor_header *)&ac_hdr_desc,
(struct usb_descriptor_header *)&usb_it_desc,
(struct usb_descriptor_header *)&usb_ot_desc,
(struct usb_descriptor_header *)&std_as_out_if0_desc,
(struct usb_descriptor_header *)&std_as_out_if1_desc,
(struct usb_descriptor_header *)&as_out_hdr_desc,
(struct usb_descriptor_header *)&as_out_fmt1_desc,
(struct usb_descriptor_header *)&hs_epout_desc,
(struct usb_descriptor_header *)&as_iso_out_desc,
(struct usb_descriptor_header *)&std_as_in_if0_desc,
(struct usb_descriptor_header *)&std_as_in_if1_desc,
(struct usb_descriptor_header *)&as_in_hdr_desc,
(struct usb_descriptor_header *)&as_in_fmt1_desc,
(struct usb_descriptor_header *)&hs_epin_desc,
(struct usb_descriptor_header *)&as_iso_in_desc,
NULL,
};
The OUT endpoint is defined as:
struct usb_endpoint_descriptor hs_epout_desc = {
.bLength = USB_DT_ENDPOINT_SIZE,
.bDescriptorType = USB_DT_ENDPOINT,
.bmAttributes = USB_ENDPOINT_XFER_ISOC | USB_ENDPOINT_SYNC_ASYNC,
.wMaxPacketSize = __constant_cpu_to_le16(OUT_EP_MAX_PACKET_SIZE),
.bInterval = 4,
};
The IN endpoint is defined as:
struct usb_endpoint_descriptor hs_epin_desc = {
.bLength = USB_DT_ENDPOINT_SIZE,
.bDescriptorType = USB_DT_ENDPOINT,
.bEndpointAddress = USB_DIR_IN,
.bmAttributes = USB_ENDPOINT_XFER_ISOC | USB_ENDPOINT_SYNC_ASYNC,
.wMaxPacketSize = __constant_cpu_to_le16(OUT_EP_MAX_PACKET_SIZE),
.bInterval = 4,
};
In epautoconf.c, the bEndpointAddress field is usually OR'ed with the endpoint number. I see in my case that this is happening.
The 'bEndpointAddress' field for my OUT endpoint is 0x01 and for my IN endpoint is 0x81 when I print it in epautoconf.c.
I'm however not able to see it on the host side. On my Windows PC, I use USB View tool to see the descriptors and I see that the values are 0x00 and 0x80.
What could have possibly changed the value of bEndpointAdress?
These are the USB descriptors I see in Windows using USB View tool:
Device Descriptor:
bcdUSB: 0x0200
bDeviceClass: 0x00
bDeviceSubClass: 0x00
bDeviceProtocol: 0x00
bMaxPacketSize0: 0x40 (64)
idVendor: 0x1D6B
idProduct: 0x0101
bcdDevice: 0x0316
iManufacturer: 0x01
0x0409: "Linux 3.2.0 with musb-hdrc"
iProduct: 0x02
0x0409: "Linux USB Audio Gadget"
iSerialNumber: 0x00
bNumConfigurations: 0x01
ConnectionStatus: DeviceConnected
Current Config Value: 0x01
Device Bus Speed: High
Device Address: 0x13
Open Pipes: 0
Configuration Descriptor:
wTotalLength: 0x0095
bNumInterfaces: 0x03
bConfigurationValue: 0x01
iConfiguration: 0x00
bmAttributes: 0xC0 (Bus Powered Self Powered )
MaxPower: 0x01 (2 Ma)
Interface Descriptor:
bInterfaceNumber: 0x00
bAlternateSetting: 0x00
bNumEndpoints: 0x00
bInterfaceClass: 0x01 (Audio)
bInterfaceSubClass: 0x01 (Audio Control)
bInterfaceProtocol: 0x00
iInterface: 0x04
0x0409: "Topology Control"
Audio Control Interface Header Descriptor:
bLength: 0x0A
bDescriptorType: 0x24
bDescriptorSubtype: 0x01
bcdADC: 0x0100
wTotalLength: 0x001F
bInCollection: 0x02
baInterfaceNr[1]: 0x01
baInterfaceNr[2]: 0x02
Audio Control Input Terminal Descriptor:
bLength: 0x0C
bDescriptorType: 0x24
bDescriptorSubtype: 0x02
bTerminalID: 0x02
wTerminalType: 0x0201 (Microphone)
bAssocTerminal: 0x00
bNrChannels: 0x02
wChannelConfig: 0x0003
iChannelNames: 0x00
iTerminal: 0x07
Audio Control Output Terminal Descriptor:
bLength: 0x09
bDescriptorType: 0x24
bDescriptorSubtype: 0x03
bTerminalID: 0x01
wTerminalType: 0x0301 (Speaker)
bAssocTerminal: 0x00
bSoruceID: 0x00
iTerminal: 0x09
Interface Descriptor:
bInterfaceNumber: 0x01
bAlternateSetting: 0x00
bNumEndpoints: 0x00
bInterfaceClass: 0x01 (Audio)
bInterfaceSubClass: 0x02 (Audio Streaming)
bInterfaceProtocol: 0x00
iInterface: 0x0B
0x0409: "Playback Inactive"
Interface Descriptor:
bInterfaceNumber: 0x01
bAlternateSetting: 0x01
bNumEndpoints: 0x01
bInterfaceClass: 0x01 (Audio)
bInterfaceSubClass: 0x02 (Audio Streaming)
bInterfaceProtocol: 0x00
iInterface: 0x0C
0x0409: "Playback Active"
Audio Streaming Class Specific Interface Descriptor:
bLength: 0x07
bDescriptorType: 0x24
bDescriptorSubtype: 0x01
bTerminalLink: 0x01
bDelay: 0x01
wFormatTag: 0x0001 (PCM)
Audio Streaming Format Type Descriptor:
bLength: 0x0B
bDescriptorType: 0x24
bDescriptorSubtype: 0x02
bFormatType: 0x01
bNrChannels: 0x00
bSubframeSize: 0x02
bBitResolution: 0x10
bSamFreqType: 0x01
tSamFreq[1]: 0x00BB80 (48000 Hz)
Endpoint Descriptor:
bEndpointAddress: 0x00 OUT
Transfer Type: Isochronous
wMaxPacketSize: 0x00C8 (200)
bInterval: 0x04
Audio Streaming Class Specific Audio Data Endpoint Descriptor:
bLength: 0x07
bDescriptorType: 0x25
bDescriptorSubtype: 0x01
bmAttributes: 0x00
bLockDelayUnits: 0x00
wLockDelay: 0x0000
Interface Descriptor:
bInterfaceNumber: 0x02
bAlternateSetting: 0x00
bNumEndpoints: 0x00
bInterfaceClass: 0x01 (Audio)
bInterfaceSubClass: 0x02 (Audio Streaming)
bInterfaceProtocol: 0x00
iInterface: 0x0D
0x0409: "Capture Inactive"
Interface Descriptor:
bInterfaceNumber: 0x02
bAlternateSetting: 0x01
bNumEndpoints: 0x01
bInterfaceClass: 0x01 (Audio)
bInterfaceSubClass: 0x02 (Audio Streaming)
bInterfaceProtocol: 0x00
iInterface: 0x0E
0x0409: "Capture Active"
Audio Streaming Class Specific Interface Descriptor:
bLength: 0x07
bDescriptorType: 0x24
bDescriptorSubtype: 0x01
bTerminalLink: 0x02
bDelay: 0x01
wFormatTag: 0x0001 (PCM)
Audio Streaming Format Type Descriptor:
bLength: 0x0B
bDescriptorType: 0x24
bDescriptorSubtype: 0x02
bFormatType: 0x01
bNrChannels: 0x00
bSubframeSize: 0x02
bBitResolution: 0x10
bSamFreqType: 0x01
tSamFreq[1]: 0x00BB80 (48000 Hz)
Endpoint Descriptor:
bEndpointAddress: 0x80 IN
Transfer Type: Isochronous
wMaxPacketSize: 0x00C8 (200)
bInterval: 0x04
Audio Streaming Class Specific Audio Data Endpoint Descriptor:
bLength: 0x07
bDescriptorType: 0x25
bDescriptorSubtype: 0x01
bmAttributes: 0x00
bLockDelayUnits: 0x00
wLockDelay: 0x0000
Why won't Windows install the UAC1 driver?
For my first question, I got an answer from the linux-usb mailing list. It turns out that 'epautoconf.c' does not change 'bEndpointAdress'. So I changed the value in the definition of 'bEndpointAdress' and it is correctly conveyed to the host now.
Windows installs the UAC1 driver correctly when I use this configuration:
ConnectionStatus: DeviceConnected
Current Config Value: 0x01
Device Bus Speed: High
Device Address: 0x11
Open Pipes: 0
Configuration Descriptor:
wTotalLength: 0x00E7
bNumInterfaces: 0x03
bConfigurationValue: 0x01
iConfiguration: 0x00
bmAttributes: 0xC0 (Bus Powered Self Powered )
MaxPower: 0x01 (2 Ma)
Interface Descriptor:
bInterfaceNumber: 0x00
bAlternateSetting: 0x00
bNumEndpoints: 0x00
bInterfaceClass: 0x01 (Audio)
bInterfaceSubClass: 0x01 (Audio Control)
bInterfaceProtocol: 0x00
iInterface: 0x00
Audio Control Interface Header Descriptor:
bLength: 0x0A
bDescriptorType: 0x24
bDescriptorSubtype: 0x01
bcdADC: 0x0100
wTotalLength: 0x0065
bInCollection: 0x02
baInterfaceNr[1]: 0x01
baInterfaceNr[2]: 0x02
Audio Control Input Terminal Descriptor:
bLength: 0x0C
bDescriptorType: 0x24
bDescriptorSubtype: 0x02
bTerminalID: 0x01
wTerminalType: 0x0201 (Microphone)
bAssocTerminal: 0x00
bNrChannels: 0x02
wChannelConfig: 0x0003
iChannelNames: 0x00
iTerminal: 0x00
Audio Control Feature Unit Descriptor:
bLength: 0x0A
bDescriptorType: 0x24
bDescriptorSubtype: 0x06
bUnitID: 0x02
bSourceID: 0x01
bControlSize: 0x01
bmaControls[0]:
03
bmaControls[1]:
00
bmaControls[2]:
00
iFeature: 0x00
Audio Control Input Terminal Descriptor:
bLength: 0x0C
bDescriptorType: 0x24
bDescriptorSubtype: 0x02
bTerminalID: 0x03
wTerminalType: 0x0402 (Headset)
bAssocTerminal: 0x09
bNrChannels: 0x02
wChannelConfig: 0x0003
iChannelNames: 0x00
iTerminal: 0x00
Audio Control Feature Unit Descriptor:
bLength: 0x0A
bDescriptorType: 0x24
bDescriptorSubtype: 0x06
bUnitID: 0x04
bSourceID: 0x03
bControlSize: 0x01
bmaControls[0]:
03
bmaControls[1]:
00
bmaControls[2]:
00
iFeature: 0x00
Audio Control Selector Unit Descriptor:
bLength: 0x06
bDescriptorType: 0x24
bDescriptorSubtype: 0x05
bUnitID: 0x05
bNrInPins: 0x01
baSourceID[1]: 0x04
iSelector: 0x09
Audio Control Output Terminal Descriptor:
bLength: 0x09
bDescriptorType: 0x24
bDescriptorSubtype: 0x03
bTerminalID: 0x06
wTerminalType: 0x0101 (USB streaming)
bAssocTerminal: 0x00
bSoruceID: 0x05
iTerminal: 0x00
Audio Control Input Terminal Descriptor:
bLength: 0x0C
bDescriptorType: 0x24
bDescriptorSubtype: 0x02
bTerminalID: 0x07
wTerminalType: 0x0101 (USB streaming)
bAssocTerminal: 0x00
bNrChannels: 0x02
wChannelConfig: 0x0003
iChannelNames: 0x00
iTerminal: 0x00
Audio Control Feature Unit Descriptor:
bLength: 0x0A
bDescriptorType: 0x24
bDescriptorSubtype: 0x06
bUnitID: 0x08
bSourceID: 0x0A
bControlSize: 0x01
bmaControls[0]:
01
bmaControls[1]:
02
bmaControls[2]:
02
iFeature: 0x00
Audio Control Output Terminal Descriptor:
bLength: 0x09
bDescriptorType: 0x24
bDescriptorSubtype: 0x03
bTerminalID: 0x09
wTerminalType: 0x0402 (Headset)
bAssocTerminal: 0x03
bSoruceID: 0x08
iTerminal: 0x00
Audio Control Mixer Unit Descriptor:
bLength: 0x0D
bDescriptorType: 0x24
bDescriptorSubtype: 0x04
bUnitID: 0x0A
bNrInPins: 0x02
baSourceID[1]: 0x07
baSourceID[2]: 0x02
bNrChannels: 0x02
wChannelConfig: 0x0003
iChannelNames: 0x00
bmControls:
00
iMixer: 0x00
Interface Descriptor:
bInterfaceNumber: 0x01
bAlternateSetting: 0x00
bNumEndpoints: 0x00
bInterfaceClass: 0x01 (Audio)
bInterfaceSubClass: 0x02 (Audio Streaming)
bInterfaceProtocol: 0x00
iInterface: 0x00
Interface Descriptor:
bInterfaceNumber: 0x01
bAlternateSetting: 0x01
bNumEndpoints: 0x01
bInterfaceClass: 0x01 (Audio)
bInterfaceSubClass: 0x02 (Audio Streaming)
bInterfaceProtocol: 0x00
iInterface: 0x00
Audio Streaming Class Specific Interface Descriptor:
bLength: 0x07
bDescriptorType: 0x24
bDescriptorSubtype: 0x01
bTerminalLink: 0x06
bDelay: 0x01
wFormatTag: 0x0001 (PCM)
Audio Streaming Format Type Descriptor:
bLength: 0x0B
bDescriptorType: 0x24
bDescriptorSubtype: 0x02
bFormatType: 0x01
bNrChannels: 0x02
bSubframeSize: 0x02
bBitResolution: 0x10
bSamFreqType: 0x01
tSamFreq[1]: 0x00BB80 (48000 Hz)
Endpoint Descriptor:
bEndpointAddress: 0x01 OUT
Transfer Type: Isochronous
wMaxPacketSize: 0x00C8 (200)
bInterval: 0x04
Audio Streaming Class Specific Audio Data Endpoint Descriptor:
bLength: 0x07
bDescriptorType: 0x25
bDescriptorSubtype: 0x01
bmAttributes: 0x01
bLockDelayUnits: 0x00
wLockDelay: 0x0000
Interface Descriptor:
bInterfaceNumber: 0x02
bAlternateSetting: 0x00
bNumEndpoints: 0x00
bInterfaceClass: 0x01 (Audio)
bInterfaceSubClass: 0x02 (Audio Streaming)
bInterfaceProtocol: 0x00
iInterface: 0x00
Interface Descriptor:
bInterfaceNumber: 0x02
bAlternateSetting: 0x01
bNumEndpoints: 0x01
bInterfaceClass: 0x01 (Audio)
bInterfaceSubClass: 0x02 (Audio Streaming)
bInterfaceProtocol: 0x00
iInterface: 0x00
Audio Streaming Class Specific Interface Descriptor:
bLength: 0x07
bDescriptorType: 0x24
bDescriptorSubtype: 0x01
bTerminalLink: 0x07
bDelay: 0x01
wFormatTag: 0x0001 (PCM)
Audio Streaming Format Type Descriptor:
bLength: 0x0B
bDescriptorType: 0x24
bDescriptorSubtype: 0x02
bFormatType: 0x01
bNrChannels: 0x02
bSubframeSize: 0x02
bBitResolution: 0x10
bSamFreqType: 0x01
tSamFreq[1]: 0x00BB80 (48000 Hz)
Endpoint Descriptor:
bEndpointAddress: 0x81 IN
Transfer Type: Isochronous
wMaxPacketSize: 0x00C8 (200)
bInterval: 0x04
Audio Streaming Class Specific Audio Data Endpoint Descriptor:
bLength: 0x07
bDescriptorType: 0x25
bDescriptorSubtype: 0x01
bmAttributes: 0x01
bLockDelayUnits: 0x01
wLockDelay: 0x0004
I am trying to implement Bluetooth on an existing embedded device. The controller I’m using is the LS Research TiWi-uB2, which uses the Ti CC2564 dual mode IC. The host is a LPC2378 microcontroller. The device needs to be discoverable by other devices (Android devices & PCs for the moment). There is no ready made BT stack for this device which suits me needs (cost, static memory allocation, memory size) so I’m writing my own stack.
Going through Volume 2 Part E of the specification I eventually got meaningful communication on the HCI, but the device does not ever appear to be ‘discoverable’ by anything else. At this point I’m only using the BR/EDR features rather than the LE features.
Here is a debug dump of the HCI interface (including the UART packet types):
BT_Reset
Tx: 0x01 0x03 0x0C 0x00
Rx: 0x04 0x0E 0x04 0x01 0x03 0x0C 0x00
Device info
Tx: 0x01 0x01 0x10 0x00
Rx: 0x04 0x0E 0x0C 0x01 0x01 0x10 0x00 0x06 0x00 0x00 0x06 0x0D 0x00 0x0F 0x1B
Local supported commands
Tx: 0x01 0x02 0x10 0x00
Rx: 0x04 0x0E 0x44 0x01 0x02 0x10 0x00 0xFF 0xFF 0xFF 0x03 0xCE 0xFF 0xFF 0xFF 0xFF
Local supported features
Tx: 0x01 0x03 0x10 0x00
Rx: 0x04 0x0E 0x0C 0x01 0x03 0x10 0x00 0xFF 0xFE 0x2D 0xFE 0xDB 0xFF 0x7B 0x87
Get device address
Tx: 0x01 0x09 0x10 0x00
Rx: 0x04 0x0E 0x0A 0x01 0x09 0x10 0x00 0x81 0xA6 0xD3 0x2F 0x18 0x00
Address: 00 18 2F D3 A6 81
Read buffer size
Tx: 0x01 0x05 0x10 0x00
Rx: 0x04 0x0E 0x0B 0x01 0x05 0x10 0x00 0xFD 0x03 0xB4 0x04 0x00 0x04 0x00
ACL len = 1021
Write buffer size
Tx: 0x01 0x33 0x0C 0x07 0xFC 0x00 0x00 0x00 0x00 0x00 0x00
Rx: 0x04 0x0E 0x04 0x01 0x33 0x0C 0x00
Write local name
Tx: 0x01 0x13 0x0C 0x08 0x42 0x54 0x5F 0x54 0x65 0x73 0x74 0x00
Rx: 0x04 0x0E 0x04 0x01 0x13 0x0C 0x00
Read class of device
Tx: 0x01 0x23 0x0C 0x00
Rx: 0x04 0x0E 0x07 0x01 0x23 0x0C 0x00 0x14 0x01 0x08
Write class of device
Tx: 0x01 0x24 0x0C 0x03 0x14 0x01 0x08
Rx: 0x04 0x0E 0x04 0x01 0x24 0x0C 0x00
Write scan enabled
Tx: 0x01 0x1A 0x0C 0x01 0x03
Rx: 0x04 0x0E 0x04 0x01 0x1A 0x0C 0x00
Finished
I can also do link inquiry:
Tx: 0x01 0x01 0x04 0x05 0x33 0x8B 0x9E 0x0A 0x0A
Rx: 0x04 0x0F 0x04 0x00 0x01 0x01 0x04
…
Rx: 0x04 0x01 0x01 0x00
But it does not find any devices.
I’m sure I’m missing something fairly obvious out, but can’t see what it might be. I can't see that the CC2564 needs to be specially treated to run in BR/EDR mode, and all the defaults seem reasonable.
Update
The module needs an initialization script (aka 'service pack'). See https://code.google.com/p/btstack/wiki/MSP430GettingStarted under 'Init Scripts'. The good news is that with the script the module is now discoverable. The bad news is that according to LS Research my own stack would not be Bluetooth SIG complaint - I would have to use the Bluetopia stack. It seems that everything is geared heavily to using the Ti processor.
At this point I'll have to wait until the BR/EDR/BLE modules with a higher level interface come on line.
Bluetooth compliance is only needed, when you are using public profiles (SPP for example), or when you expose your device in a connectable manner for other devices in public (like headsets or keyboards). Shortly, qualification is only needed if you are selling your device on global market as a "Bluetooth" device (so you can use the logo)...at least in my understanding...
And the service pack does not contain any part of the stack, so its completely royalty free.
And there are no Bluetooth specific operations (even discovery) permitted before loading the service pack according to this document:
cc256x guide