X-Git-Url: http://git.linex4red.de/pub/lufa.git/blobdiff_plain/a20a9086f76c142bb77293f5de3fe42295d27847..2eff731ecfbcfec4f3152992e5ae5602a3694424:/Demos/Host/Incomplete/BluetoothHost/BluetoothHost.c diff --git a/Demos/Host/Incomplete/BluetoothHost/BluetoothHost.c b/Demos/Host/Incomplete/BluetoothHost/BluetoothHost.c index b9b5ec14b..66ed417d5 100644 --- a/Demos/Host/Incomplete/BluetoothHost/BluetoothHost.c +++ b/Demos/Host/Incomplete/BluetoothHost/BluetoothHost.c @@ -36,7 +36,7 @@ #include "BluetoothHost.h" -/** Bluetooth configuration structure. This structure configures the bluetooth stack's user alterable settings. */ +/** Bluetooth configuration structure. This structure configures the Bluetooth stack's user alterable settings. */ Bluetooth_Device_t Bluetooth_DeviceConfiguration = { Class: (DEVICE_CLASS_SERVICE_CAPTURING | DEVICE_CLASS_MAJOR_COMPUTER | DEVICE_CLASS_MINOR_COMPUTER_PALM), @@ -213,6 +213,10 @@ void Bluetooth_StackInitialized(void) printf_P(PSTR("Stack initialized with local address %02X:%02X:%02X:%02X:%02X:%02X.\r\n"), Bluetooth_State.LocalBDADDR[5], Bluetooth_State.LocalBDADDR[4], Bluetooth_State.LocalBDADDR[3], Bluetooth_State.LocalBDADDR[2], Bluetooth_State.LocalBDADDR[1], Bluetooth_State.LocalBDADDR[0]); + + /* Reinitialize the services placed on top of the Bluetooth stack ready for new connections */ + SDP_Initialize(); + RFCOMM_Initialize(); } /** Bluetooth stack callback event for a Bluetooth connection request. When this callback fires, the @@ -241,6 +245,8 @@ void Bluetooth_ConnectionComplete(void) Bluetooth_Connection.RemoteAddress[5], Bluetooth_Connection.RemoteAddress[4], Bluetooth_Connection.RemoteAddress[3], Bluetooth_Connection.RemoteAddress[2], Bluetooth_Connection.RemoteAddress[1], Bluetooth_Connection.RemoteAddress[0]); + + LEDs_SetAllLEDs(LEDMASK_USB_BUSY); } /** Bluetooth stack callback event for a completed Bluetooth disconnection. When this callback is made, @@ -254,13 +260,15 @@ void Bluetooth_DisconnectionComplete(void) Bluetooth_Connection.RemoteAddress[5], Bluetooth_Connection.RemoteAddress[4], Bluetooth_Connection.RemoteAddress[3], Bluetooth_Connection.RemoteAddress[2], Bluetooth_Connection.RemoteAddress[1], Bluetooth_Connection.RemoteAddress[0]); + + LEDs_SetAllLEDs(LEDMASK_USB_READY); } /** Bluetooth stack callback event for a Bluetooth ACL Channel connection request. When is callback fires, * the user application must indicate if the channel connection should be rejected or not, based on the * protocol (PSM) value of the requested channel. * - * \param PSM Protocol PSM value for the requested channel + * \param[in] PSM Protocol PSM value for the requested channel * * \return Boolean true to accept the channel connection request, false to reject it */ @@ -273,9 +281,9 @@ bool Bluetooth_ChannelConnectionRequest(const uint16_t PSM) /** Bluetooth stack callback event for a non-signal ACL packet reception. This callback fires once a connection * to a remote Bluetooth device has been made, and the remote device has sent a non-signalling ACL packet. * - * \param[in] Data Pointer to a buffer where the received data is stored - * \param[in] DataLen Length of the packet data, in bytes - * \param[in] Channel Bluetooth ACL data channel information structure for the packet's destination channel + * \param[in] Data Pointer to a buffer where the received data is stored + * \param[in] DataLen Length of the packet data, in bytes + * \param[in] Channel Bluetooth ACL data channel information structure for the packet's destination channel */ void Bluetooth_PacketReceived(void* Data, uint16_t DataLen, Bluetooth_Channel_t* const Channel) { @@ -285,13 +293,14 @@ void Bluetooth_PacketReceived(void* Data, uint16_t DataLen, Bluetooth_Channel_t* /* Service Discovery Protocol packet */ SDP_ProcessPacket(Data, Channel); break; + case CHANNEL_PSM_RFCOMM: + /* RFCOMM (Serial Port) Protocol packet */ + RFCOMM_ProcessPacket(Data, Channel); + break; default: /* Unknown Protocol packet */ - printf_P(PSTR("Packet Received (Channel 0x%04X, PSM: 0x%02x):\r\n"), Channel->LocalNumber, Channel->PSM); - for (uint16_t Byte = 0; Byte < DataLen; Byte++) - printf_P(PSTR("0x%02X "), ((uint8_t*)Data)[Byte]); - puts_P(PSTR("\r\n")); - + printf_P(PSTR("Unknown Packet Received (Channel 0x%04X, PSM: 0x%02X, Len: 0x%04X):\r\n"), + Channel->LocalNumber, Channel->PSM, DataLen); break; } }