Esempio n. 1
0
void HCI_Event_CB(void *pckt)
{
  hci_uart_pckt *hci_pckt = pckt;
  hci_event_pckt *event_pckt = (hci_event_pckt*)hci_pckt->data;

  if (hci_pckt->type != HCI_EVENT_PKT)
    return;

  switch(event_pckt->evt)
  {
  case EVT_DISCONN_COMPLETE:
    //evt_disconn_complete *evt = (void *)event_pckt->data;
    GAP_DisconnectionComplete_CB();
    break;

  case EVT_LE_META_EVENT:
  {
    evt_le_meta_event *evt = (void *)event_pckt->data;
    switch(evt->subevent)
    {
    case EVT_LE_CONN_COMPLETE:
    {
      evt_le_connection_complete *cc = (void *)evt->data;
      GAP_ConnectionComplete_CB(cc->peer_bdaddr,cc->handle);
      break;
    }
    }
    break;
  }

  case EVT_VENDOR:
  {
    evt_blue_aci *blue_evt = (void*)event_pckt->data;
    switch(blue_evt->ecode)
    {
    case EVT_BLUE_GATT_READ_PERMIT_REQ:
    {
      evt_gatt_read_permit_req *pr = (void*)blue_evt->data;
      Read_Request_CB(pr->attr_handle);
      break;
#ifdef ST_OTA_BTL
    case EVT_BLUE_GATT_ATTRIBUTE_MODIFIED:
      evt_gatt_attr_modified *am = (void*)blue_evt->data;
      //PRINTF("-> modified attribute 0x%04X \r\n",am->attr_handle);
      OTA_Write_Request_CB(am);
      break;
#endif
    }
    }
    break;
  }
  }
}
void HCI_Event_CB(void *pckt)
{
    hci_uart_pckt *hci_pckt = pckt;
    hci_event_pckt *event_pckt = (hci_event_pckt*)hci_pckt->data;
    
    if(hci_pckt->type != HCI_EVENT_PKT)
        return;
    
    switch(event_pckt->evt){
        
    case EVT_DISCONN_COMPLETE:
        {
            GAP_DisconnectionComplete_CB();
        }
        break;
        
    case EVT_LE_META_EVENT:
        {
            evt_le_meta_event *evt = (void *)event_pckt->data;
            
            switch(evt->subevent){
            case EVT_LE_CONN_COMPLETE:
                {
                    evt_le_connection_complete *cc = (void *)evt->data;
                    GAP_ConnectionComplete_CB(cc->peer_bdaddr,cc->handle);
                }
                break;
            }
        }
        break;
        
    case EVT_VENDOR:
        {
            evt_blue_aci *blue_evt = (void*)event_pckt->data;
            switch(blue_evt->ecode){
                
#ifdef ST_OTA_BTL
            /* We need to indicate to the stack that the response can be sent to the client */
            case EVT_BLUE_GATT_READ_PERMIT_REQ:
                {
                    //evt_gatt_read_permit_req *pr = (void*)blue_evt->data;                    
                    if(connection_handle !=0)
                        aci_gatt_allow_read(connection_handle);                 
                }
                break;      
#endif
            case EVT_BLUE_GATT_ATTRIBUTE_MODIFIED:
                {  
#ifdef ST_OTA_BTL
                  evt_gatt_attr_modified *am = (void*)blue_evt->data;
                  OTA_Write_Request_CB(am);  
#endif
                }
                break;

            }
        }
        break;
    }
    
}