Example #1
0
/*
 ****************************************************************************************
 * @brief Handles ble by calling corresponding procedure.
 *
 * @param[in] blemsg	Pointer to received message.
 *
 * @return void.
 ****************************************************************************************
*/
void HandleBleMsg(ble_msg *blemsg)
{

	if (blemsg->bDstid != TASK_APP && blemsg->bDstid != TASK_GTL)
		return;
	
	switch (blemsg->bType)
	{
 		case GAPM_CMP_EVT:  
 			HadleGapmCmpEvt(blemsg->bType, (struct gapm_cmp_evt *)blemsg->bData, blemsg->bDstid, blemsg->bSrcid);
			break; 
		case GAPC_CMP_EVT:  
 			HadleGapcCmpEvt(blemsg->bType, (struct gapc_cmp_evt *)blemsg->bData, blemsg->bDstid, blemsg->bSrcid);
			break; 
		case GAPM_DEVICE_READY_IND: 
 			gap_ready_evt_handler(blemsg->bType, (struct gap_ready_evt *)blemsg->bData, blemsg->bDstid, blemsg->bSrcid);
			break;
		case GAPM_GET_DEV_INFO_CMD:
			gap_dev_inq_req_cmp_evt_handler(blemsg->bType, (struct gap_dev_inq_req_cmp_evt *) blemsg->bData, blemsg->bDstid, blemsg->bSrcid);
			break;
		case GAPM_ADV_REPORT_IND:
			gap_dev_inq_result_handler(blemsg->bType, (struct gapm_adv_report_ind *) blemsg->bData, blemsg->bDstid, blemsg->bSrcid);
			break;
		case GAPC_CONNECTION_REQ_IND:
			gap_le_create_conn_req_ind_handler(blemsg->bType, (struct gapc_connection_req_ind *) blemsg->bData, blemsg->bDstid, blemsg->bSrcid);
			break;
		case GAPC_DISCONNECT_IND:
			gap_discon_cmp_evt_handler(blemsg->bType,  (struct gapc_disconnect_ind *) blemsg->bData, blemsg->bDstid, blemsg->bSrcid);
			break;
    case GAPC_CON_RSSI_IND:
			gap_read_rssi_cmp_evt_handler(blemsg->bType, (struct gapc_con_rssi_ind *) blemsg->bData, blemsg->bDstid, blemsg->bSrcid);
			break;
   	case GAPC_BOND_IND:
      gap_bond_ind_handler(blemsg->bType,  (struct gapc_bond_ind *) blemsg->bData, blemsg->bDstid, blemsg->bSrcid);
      break;
		case GAPC_BOND_REQ_IND:
			gap_bond_req_ind_handler(blemsg->bType, (struct gapc_bond_req_ind *) blemsg->bData, blemsg->bDstid, blemsg->bSrcid);
			break;
		case GAPC_ENCRYPT_REQ_IND:
			gapc_encrypt_req_ind_handler(blemsg->bType, (struct gapc_encrypt_req_ind *) blemsg->bData, blemsg->bDstid, blemsg->bSrcid);
			break;
		case GAPC_ENCRYPT_IND:
			gapc_encrypt_ind_handler(blemsg->bType, (struct gapc_encrypt_ind *) blemsg->bData, blemsg->bDstid, blemsg->bSrcid);
			break;
    		case PROXR_CREATE_DB_CFM:
  			app_create_db_cfm_handler(blemsg->bDstid);
 			break;
		case PROXR_ALERT_IND:
			app_proxr_alert_ind(blemsg->bDstid, (struct proxr_alert_ind *) blemsg->bData, blemsg->bDstid, blemsg->bSrcid);
 			break;
		case PROXR_DISABLE_IND:
 			break;
		case LLC_RD_TX_PW_LVL_CMP_EVT:
 			llc_rd_tx_pw_lvl_cmp_evt_handler(LLC_RD_TX_PW_LVL_CMP_EVT,
                                      (struct llc_rd_tx_pw_lvl_cmd_complete *) blemsg->bData, 
									  blemsg->bDstid, blemsg->bSrcid);
			break;
        default:
	//		 printf("Rcved UNKNOWN Msg 0x%x\n", blemsg->bType);
			break;
	}

}
/*
 ****************************************************************************************
 * @brief Handles ble by calling corresponding procedure.
 *
 * @param[in] blemsg    Pointer to received message.
 *
 * @return void.
 ****************************************************************************************
*/
void HandleBleMsg(ble_msg *blemsg)
{
    if (blemsg->bDstid != TASK_APP && blemsg->bDstid != TASK_GTL)
        return;

    switch (blemsg->bType)
    {
        //
        // GAPM events
        //

        // Command Complete event
        case GAPM_CMP_EVT:  
            HadleGapmCmpEvt(blemsg->bType, (struct gapm_cmp_evt *)blemsg->bData, blemsg->bDstid, blemsg->bSrcid);
            break; 

        // Event triggered to inform that lower layers are ready
        case GAPM_DEVICE_READY_IND: 
            gapm_device_ready_ind_handler(blemsg->bType, (struct gap_ready_evt *)blemsg->bData, blemsg->bDstid, blemsg->bSrcid);
            break;

        // Local device name indication event
        case GAPM_DEV_NAME_IND:
            break;

        // Local device appearance indication event
        case GAPM_APPEARANCE_IND:
            break;

        // Local device version indication event
        case GAPM_DEV_VERSION_IND:
            break;

        // Local device BD Address indication event
        case GAPM_DEV_BDADDR_IND:
            break;

        // White List Size indication event
        case GAPM_WHITE_LIST_SIZE_IND:
            break;

        // Advertising or scanning report information event
        case GAPM_ADV_REPORT_IND:
            gapm_adv_report_ind_handler(blemsg->bType, (struct gapm_adv_report_ind *) blemsg->bData, blemsg->bDstid, blemsg->bSrcid);
            break;

        // Name of peer device indication
        case GAPM_PEER_NAME_IND:
            break;

        // Privacy flag value has been updated
        case GAPM_UPDATED_PRIVACY_IND:
            break;

        // Reconnection address has been updated
        case GAPM_UPDATED_RECON_ADDR_IND:
            break;

        // Indicate that resolvable random address has been solved
        case GAPM_ADDR_SOLVED_IND:
            break;

        //  AES-128 block result indication
        case GAPM_USE_ENC_BLOCK_IND:
            break;

        // Random Number Indication
        case GAPM_GEN_RAND_NB_IND:
            break;

        // Indication containing information about memory usage.
        case GAPM_DBG_MEM_INFO_IND:
            break;

        // Advertising channel Tx power level
        case GAPM_DEV_ADV_TX_POWER_IND:
            break;

        // Limited discoverable timeout indication
        case GAPM_LIM_DISC_TO_IND:
            break;

        // Scan timeout indication
        case GAPM_SCAN_TO_IND:
            break;

        // Address renewal timeout indication
        case GAPM_ADDR_RENEW_TO_IND:
            break;

        //
        // GAPC events
        //

        // Command Complete event
        case GAPC_CMP_EVT:  
            HadleGapcCmpEvt(blemsg->bType, (struct gapc_cmp_evt *)blemsg->bData, blemsg->bDstid, blemsg->bSrcid);
            break; 

        // Indicate that a connection has been established
        case GAPC_CONNECTION_REQ_IND:
            gapc_connection_req_ind_handler(blemsg->bType, (struct gapc_connection_req_ind *) blemsg->bData, blemsg->bDstid, blemsg->bSrcid);
            break;

        // Indicate that a link has been disconnected
        case GAPC_DISCONNECT_IND:
            gapc_disconnect_ind_handler(blemsg->bType,  (struct gapc_disconnect_ind *) blemsg->bData, blemsg->bDstid, blemsg->bSrcid);
            break;

        // Name of peer device indication
        case GAPC_PEER_NAME_IND:
            break;

        // Indication of peer version info
        case GAPC_PEER_VERSION_IND:
            break;

        // Indication of peer features info
        case GAPC_PEER_FEATURES_IND:
            break;

        // Indication of ongoing connection RSSI
        case GAPC_CON_RSSI_IND:
            gapc_con_rssi_ind_handler(blemsg->bType, (struct gapc_con_rssi_ind *) blemsg->bData, blemsg->bDstid, blemsg->bSrcid);
            break;

        // Indication of peer privacy info
        case GAPC_PRIVACY_IND:
            break;

        // Indication of peer reconnection address info
        case GAPC_RECON_ADDR_IND:
            break;

        // Request of updating connection parameters indication
        case GAPC_PARAM_UPDATE_REQ_IND:
            break;

        // Connection parameters updated indication
        case GAPC_PARAM_UPDATED_IND:
            break;

        // Bonding requested by peer device indication message.
        case GAPC_BOND_REQ_IND:
            gapc_bond_req_ind_handler(blemsg->bType, (struct gapc_bond_req_ind *) blemsg->bData, blemsg->bDstid, blemsg->bSrcid);
            break;

        // Bonding information indication message
        case GAPC_BOND_IND:
             gapc_bond_ind_handler(blemsg->bType,  (struct gapc_bond_ind *) blemsg->bData, blemsg->bDstid, blemsg->bSrcid);
            break;

        // Encryption requested by peer device indication message.
        case GAPC_ENCRYPT_REQ_IND:
            gapc_encrypt_req_ind_handler(blemsg->bType, (struct gapc_encrypt_req_ind *) blemsg->bData, blemsg->bDstid, blemsg->bSrcid);
            break;

        // Encryption information indication message
        case GAPC_ENCRYPT_IND:
            gapc_encrypt_ind_handler(blemsg->bType, (struct gapc_encrypt_ind *) blemsg->bData, blemsg->bDstid, blemsg->bSrcid);
            break;

        // Security requested by peer device indication message
        case GAPC_SECURITY_IND:
            break;

        // Indicate the current sign counters to the application
        case GAPC_SIGN_COUNTER_IND:
            break;

        // Indication of ongoing connection Channel Map
        case GAPC_CON_CHANNEL_MAP_IND:
            break;

        // Parameter update procedure timeout indication
        case GAPC_PARAM_UPDATE_TO_IND:
            break;

        //
        // PROXR events
        //
        case PROXR_CREATE_DB_CFM:
            proxr_create_db_cfm_handler(blemsg->bDstid);
            break;
        case PROXR_ALERT_IND:
            proxr_alert_ind_handler(blemsg->bDstid, (struct proxr_alert_ind *) blemsg->bData, blemsg->bDstid, blemsg->bSrcid);
            break;
        case PROXR_DISABLE_IND:
            break;

        //
        // DISS events
        //
        case DISS_CREATE_DB_CFM:
            diss_create_db_cfm_handler(blemsg->bType, (struct diss_create_db_cfm *) blemsg->bData, blemsg->bDstid, blemsg->bSrcid);
            break;
        case DISS_DISABLE_IND:
            break;
        case DISS_ERROR_IND:
            printf("Rcved DISS_ERROR_IND Msg\n");
            break;

        case LLC_RD_TX_PW_LVL_CMP_EVT:
            llc_rd_tx_pw_lvl_cmp_evt_handler(LLC_RD_TX_PW_LVL_CMP_EVT,
                                      (struct llc_rd_tx_pw_lvl_cmd_complete *) blemsg->bData, 
                                      blemsg->bDstid, blemsg->bSrcid);
            break;

		//
		// SPOTAR events
		//
		case SPOTAR_CREATE_DB_CFM:
			spotar_create_db_cfm_handler(blemsg->bDstid, (struct spotar_create_db_cfm *) blemsg->bData);
			break;
		case SPOTAR_DISABLE_IND:
			app_close_image_file(spota_state.upgrade_file);
			break;
		case SPOTAR_PATCH_MEM_DEV_IND:
			spotar_patch_mem_dev_ind_handler(blemsg->bDstid, (struct spotar_patch_mem_dev_ind *) blemsg->bData);
			break;
		case SPOTAR_GPIO_MAP_IND:
			break;
		case SPOTAR_PATCH_LEN_IND:
			spotar_patch_len_ind_handler(blemsg->bDstid, (struct spotar_patch_len_ind *) blemsg->bData);
			break;
		case SPOTAR_PATCH_DATA_IND:
			spotar_patch_data_ind_handler(blemsg->bDstid, (struct spotar_patch_data_ind *) blemsg->bData);
			break;
        default:
            printf("Rcved UNKNOWN Msg 0x%x\n", blemsg->bType);
            break;
    }
}