- if (HCIEventHeader.EventCode == EVENT_COMMAND_STATUS)\r
- {\r
- Bluetooth_HCIEvent_CommandStatus_Header_t CommandStatusHeader;\r
-\r
- Pipe_Read_Stream_LE(&CommandStatusHeader, sizeof(CommandStatusHeader));\r
- HCIEventHeader.ParameterLength -= sizeof(CommandStatusHeader);\r
- \r
- BT_DEBUG("(HCI) >> Command status: 0x%02X", CommandStatusHeader.CommandStatus);\r
- \r
- if (CommandStatusHeader.CommandStatus)\r
- Bluetooth_HCIProcessingState = Bluetooth_Init;\r
- }\r
- else if (HCIEventHeader.EventCode == EVENT_CONNECTION_REQUEST)\r
- {\r
- Bluetooth_HCIEvent_ConnectionRequest_Header_t ConnectionRequestParams;\r
- \r
- Pipe_Read_Stream_LE(&ConnectionRequestParams, sizeof(ConnectionRequestParams));\r
- HCIEventHeader.ParameterLength -= sizeof(ConnectionRequestParams);\r
-\r
- BT_DEBUG("(HCI) >> Connection Request from device %02X:%02X:%02X:%02X:%02X:%02X",\r
- ConnectionRequestParams.RemoteAddress[5], ConnectionRequestParams.RemoteAddress[4], \r
- ConnectionRequestParams.RemoteAddress[3], ConnectionRequestParams.RemoteAddress[2], \r
- ConnectionRequestParams.RemoteAddress[1], ConnectionRequestParams.RemoteAddress[0]);\r
- BT_DEBUG("(HCI) -- Device Class: 0x%02X%04X", ConnectionRequestParams.ClassOfDevice_Service,\r
- ConnectionRequestParams.ClassOfDevice_MajorMinor);\r
- BT_DEBUG("(HCI) -- Link Type: 0x%02x", ConnectionRequestParams.LinkType);\r
- \r
- memcpy(Bluetooth_TempDeviceAddress, ConnectionRequestParams.RemoteAddress,\r
- sizeof(Bluetooth_TempDeviceAddress));\r
-\r
- Bluetooth_HCIProcessingState = (Bluetooth_Connection.IsConnected) ? Bluetooth_Conn_RejectConnection :\r
- Bluetooth_Conn_AcceptConnection;\r
- }\r
- else if (HCIEventHeader.EventCode == EVENT_DISCONNECTION_COMPLETE)\r
- {\r
- BT_DEBUG("(HCI) >> Disconnection from device complete.", NULL);\r
- Bluetooth_HCIProcessingState = Bluetooth_Init;\r
- }\r
- else if (HCIEventHeader.EventCode == EVENT_CONNECTION_COMPLETE)\r
- {\r
- Bluetooth_HCIEvent_ConnectionComplete_Header_t ConnectionCompleteParams;\r
- \r
- Pipe_Read_Stream_LE(&ConnectionCompleteParams, sizeof(ConnectionCompleteParams));\r
- HCIEventHeader.ParameterLength -= sizeof(ConnectionCompleteParams);\r
-\r
- BT_DEBUG("(HCI) >> Connection to device complete.", NULL);\r
- BT_DEBUG("(HCI) -- Status: %d", ConnectionCompleteParams.Status);\r
- BT_DEBUG("(HCI) -- Handle: %d", ConnectionCompleteParams.ConnectionHandle);\r
- \r
- if (ConnectionCompleteParams.Status == 0x00)\r
- {\r
- memcpy(Bluetooth_Connection.DeviceAddress, ConnectionCompleteParams.RemoteAddress,\r
- sizeof(Bluetooth_Connection.DeviceAddress));\r
- Bluetooth_Connection.ConnectionHandle = ConnectionCompleteParams.ConnectionHandle;\r
- Bluetooth_Connection.IsConnected = true;\r
- }\r
- }\r
- else if (HCIEventHeader.EventCode == EVENT_PIN_CODE_REQUEST)\r
- {\r
- Pipe_Read_Stream_LE(&Bluetooth_TempDeviceAddress, sizeof(Bluetooth_TempDeviceAddress));\r
- HCIEventHeader.ParameterLength -= sizeof(Bluetooth_TempDeviceAddress);\r
-\r
- BT_DEBUG("(HCI) >> PIN code Request from device %02X:%02X:%02X:%02X:%02X:%02X", \r
- Bluetooth_TempDeviceAddress[5], Bluetooth_TempDeviceAddress[4], Bluetooth_TempDeviceAddress[3],\r
- Bluetooth_TempDeviceAddress[2], Bluetooth_TempDeviceAddress[1], Bluetooth_TempDeviceAddress[0]);\r
- \r
- Bluetooth_HCIProcessingState = Bluetooth_Conn_SendPINCode;\r
- }\r
- else if (HCIEventHeader.EventCode == EVENT_COMMAND_COMPLETE)\r
- {\r
- BT_DEBUG("(HCI) >> Command Complete", NULL);\r
- }\r
- \r
- BT_DEBUG("(HCI) -- Unread Event Param Length: %d", HCIEventHeader.ParameterLength);\r
-\r
- Bluetooth_DiscardRemainingHCIEventParameters();\r
- }\r
-\r