Ejemplo n.º 1
0
/** 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-signaling 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] ACLChannel  Bluetooth ACL data channel information structure for the packet's destination channel
 */
void Bluetooth_PacketReceived(void* Data, uint16_t DataLen, Bluetooth_Channel_t* const ACLChannel)
{
    /* Run the correct packet handler based on the received packet's PSM, which indicates the service being carried */
    switch (ACLChannel->PSM)
    {
    case CHANNEL_PSM_SDP:
        /* Service Discovery Protocol packet */
        SDP_ProcessPacket(Data, ACLChannel);
        break;
    case CHANNEL_PSM_RFCOMM:
        /* RFCOMM (Serial Port) Protocol packet */
        RFCOMM_ProcessPacket(Data, ACLChannel);
        break;
    }
}
Ejemplo n.º 2
0
void EVENT_Bluetooth_DataReceived(BT_StackConfig_t* const StackState,
                                  BT_L2CAP_Channel_t* const Channel,
                                  uint16_t Length,
                                  uint8_t* Data)
{
	/* Dispatch packets with a known protocol to the integrated services - for unknown packets, display a message to the LCD */
	switch (Channel->PSM)
	{
		case CHANNEL_PSM_SDP:
		case CHANNEL_PSM_HIDCTL:
		case CHANNEL_PSM_HIDINT:
		case CHANNEL_PSM_RFCOMM:
			SDP_ProcessPacket(StackState, Channel, Length, Data);
			HID_ProcessPacket(StackState, Channel, Length, Data);
			RFCOMM_ProcessPacket(StackState, Channel, Length, Data);
			break;		
		default:
			LCD_WriteFormattedString_P(PSTR("\fL2CAP Recv:%04X\n"
			                                  "PSM:%04X C:%04X"),
			                           Length, Channel->PSM, Channel->LocalNumber);
			break;
	}
}