Add packet reception and send routines to the ACL layer of the incomplete Bluetooth...
[pub/USBasp.git] / Demos / Host / Incomplete / BluetoothHost / BluetoothHost.c
index a3ca0aa..5ed120a 100644 (file)
@@ -196,6 +196,13 @@ void Bluetooth_Host_Task(void)
        }\r
 }\r
 \r
+/** Bluetooth stack callback event for a Bluetooth connection request. When this callback fires, the\r
+ *  user application must indicate if the connection is to be allowed or rejected.\r
+ *\r
+ *  \param RemoteAddress  Bluetooth address of the remote device attempting the connection\r
+ *\r
+ *  \return Boolean true to accept the connection, false to reject it\r
+ */\r
 bool Bluetooth_ConnectionRequest(uint8_t* RemoteAddress)\r
 {\r
        printf_P(PSTR("Connection Request from Device %02X:%02X:%02X:%02X:%02X:%02X\r\n"),\r
@@ -207,6 +214,9 @@ bool Bluetooth_ConnectionRequest(uint8_t* RemoteAddress)
        return true;\r
 }\r
 \r
+/** Bluetooth stack callback event for a completed Bluetooth connection. When this callback is made,\r
+ *  the connection information can be accessed through the global \ref Bluetooth_Connection structure.\r
+ */\r
 void Bluetooth_ConnectionComplete(void)\r
 {\r
        printf_P(PSTR("Connection Complete to Device %02X:%02X:%02X:%02X:%02X:%02X\r\n"), \r
@@ -215,6 +225,11 @@ void Bluetooth_ConnectionComplete(void)
                 Bluetooth_Connection.RemoteAddress[1], Bluetooth_Connection.RemoteAddress[0]);\r
 }\r
 \r
+/** Bluetooth stack callback event for a completed Bluetooth disconnection. When this callback is made,\r
+ *  the connection information in the global \ref Bluetooth_Connection structure is invalidated with the\r
+ *  exception of the RemoteAddress element, which can be used to determine the address of the device that\r
+ *  was disconnected.\r
+ */\r
 void Bluetooth_DisconnectionComplete(void)\r
 {\r
        printf_P(PSTR("Disconnection Complete to Device %02X:%02X:%02X:%02X:%02X:%02X\r\n"), \r
@@ -222,3 +237,21 @@ void Bluetooth_DisconnectionComplete(void)
                 Bluetooth_Connection.RemoteAddress[3], Bluetooth_Connection.RemoteAddress[2],\r
                 Bluetooth_Connection.RemoteAddress[1], Bluetooth_Connection.RemoteAddress[0]);\r
 }\r
+\r
+/** Bluetooth stack callback event for a non-signal ACL packet reception. This callback fires once a connection\r
+ *  to a remote Bluetooth device has been made, and the remote device has sent a non-signalling ACL packet.\r
+ *\r
+ *  \param PacketLength  Length of the packet data, in bytes - this must be decremented as data is read\r
+ *  \param Channel       Bluetooth ACL data channel information structure for the packet's destination channel\r
+ */\r
+void Bluetooth_PacketReceived(uint16_t* PacketLength, Bluetooth_Channel_t* Channel)\r
+{\r
+       uint8_t DataPayload[*PacketLength];\r
+       Pipe_Read_Stream_LE(&DataPayload, *PacketLength);\r
+       *PacketLength = 0;\r
+\r
+       BT_ACL_DEBUG("-- Data Payload: ", NULL);\r
+       for (uint16_t B = 0; B < sizeof(DataPayload); B++)\r
+         printf("0x%02X ", DataPayload[B]);\r
+       printf("\r\n"); \r
+}\r