mirror of https://github.com/ARMmbed/mbed-os.git
				
				
				
			route ble events to gap
							parent
							
								
									c452d8ff0e
								
							
						
					
					
						commit
						108d6908be
					
				| 
						 | 
				
			
			@ -48,7 +48,7 @@ struct Gap {
 | 
			
		|||
         * @copydoc Gap::EventHandler::onAttMtuChanged
 | 
			
		||||
         */
 | 
			
		||||
        virtual void on_att_mtu_changed(
 | 
			
		||||
            Handle_t connection_handle,
 | 
			
		||||
            connection_handle_t connection_handle,
 | 
			
		||||
            uint16_t att_mtu_size
 | 
			
		||||
        ) = 0;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -56,7 +56,7 @@ struct Gap {
 | 
			
		|||
         * @copydoc Gap::EventHandler::onPacketPaylodSizeChanged
 | 
			
		||||
         */
 | 
			
		||||
        virtual void on_packet_paylod_size_changed(
 | 
			
		||||
            Handle_t connection_handle,
 | 
			
		||||
            connection_handle_t connection_handle,
 | 
			
		||||
            uint16_t tx_size,
 | 
			
		||||
            uint16_t rx_size
 | 
			
		||||
        ) = 0;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -865,7 +865,9 @@ void GenericGap::on_att_mtu_changed(
 | 
			
		|||
    uint16_t att_mtu_size
 | 
			
		||||
)
 | 
			
		||||
{
 | 
			
		||||
    onAttMtuChanged(connectionHandle, attMtuSize);
 | 
			
		||||
    if (_eventHandler) {
 | 
			
		||||
        _eventHandler->onAttMtuChanged(connection_handle, att_mtu_size);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void GenericGap::on_packet_paylod_size_changed(
 | 
			
		||||
| 
						 | 
				
			
			@ -874,7 +876,9 @@ void GenericGap::on_packet_paylod_size_changed(
 | 
			
		|||
    uint16_t rx_size
 | 
			
		||||
)
 | 
			
		||||
{
 | 
			
		||||
    onPacketPaylodSizeChanged(connectionHandle, txSize, rxSize);
 | 
			
		||||
    if (_eventHandler) {
 | 
			
		||||
        _eventHandler->onPacketPaylodSizeChanged(connection_handle, tx_size, rx_size);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void GenericGap::on_phy_update_complete(
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -22,6 +22,8 @@
 | 
			
		|||
#include "ble/pal/SimpleAttServerMessage.h"
 | 
			
		||||
#include "att_api.h"
 | 
			
		||||
#include "att_defs.h"
 | 
			
		||||
#include "ble/pal/PalGap.h"
 | 
			
		||||
#include "CordioPalGap.h"
 | 
			
		||||
 | 
			
		||||
namespace ble {
 | 
			
		||||
namespace pal {
 | 
			
		||||
| 
						 | 
				
			
			@ -318,11 +320,20 @@ public:
 | 
			
		|||
     */
 | 
			
		||||
    static void att_client_handler(const attEvt_t* event)
 | 
			
		||||
    {
 | 
			
		||||
        if (event->hdr.status == ATT_SUCCESS && event->hdr.event == ATT_MTU_UPDATE_IND) {
 | 
			
		||||
            ble::pal::Gap::EventHandler *handler;
 | 
			
		||||
            handler = ble::pal::vendor::cordio::Gap::get_gap().get_event_handler();
 | 
			
		||||
            if (handler) {
 | 
			
		||||
                handler->on_att_mtu_changed(event->hdr.param, event->mtu);
 | 
			
		||||
            }
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // all handlers are stored in a static array
 | 
			
		||||
        static const event_handler_t handlers[] = {
 | 
			
		||||
            &timeout_event_handler,
 | 
			
		||||
            &event_handler<ErrorResponseConverter>,
 | 
			
		||||
            &event_handler<ExchangeMtuResponseConverter>,
 | 
			
		||||
            //&event_handler<ExchangeMtuResponseConverter>,
 | 
			
		||||
            &event_handler<FindInformationResponseConverter>,
 | 
			
		||||
            &event_handler<FindByTypeValueResponseConverter>,
 | 
			
		||||
            &event_handler<ReadByTypeResponseConverter>,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -286,6 +286,20 @@ void BLE::processEvents()
 | 
			
		|||
 | 
			
		||||
void BLE::device_manager_cb(dmEvt_t* dm_event)
 | 
			
		||||
{
 | 
			
		||||
    if (dm_event->hdr.status == HCI_SUCCESS && dm_event->hdr.event == DM_CONN_DATA_LEN_CHANGE_IND) {
 | 
			
		||||
        // this event can only happen after a connection has been established therefore gap is present
 | 
			
		||||
        ble::pal::Gap::EventHandler *handler;
 | 
			
		||||
        handler = ble::pal::vendor::cordio::Gap::get_gap().get_event_handler();
 | 
			
		||||
        if (handler) {
 | 
			
		||||
            handler->on_packet_paylod_size_changed(
 | 
			
		||||
                dm_event->hdr.param,
 | 
			
		||||
                dm_event->dataLenChange.maxTxOctets,
 | 
			
		||||
                dm_event->dataLenChange.maxRxOctets
 | 
			
		||||
            );
 | 
			
		||||
        }
 | 
			
		||||
        return;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    BLE::deviceInstance().stack_handler(0, &dm_event->hdr);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue