Example #1
0
void ble_sc_ctrlpt_on_ble_evt(ble_sc_ctrlpt_t * p_sc_ctrlpt, ble_evt_t const * p_ble_evt)
{
    if (p_sc_ctrlpt == NULL || p_ble_evt == NULL)
    {
        return;
    }

    switch (p_ble_evt->header.evt_id)
    {
        case BLE_GAP_EVT_CONNECTED:
            on_connect(p_sc_ctrlpt, p_ble_evt);
            break;

        case BLE_GAP_EVT_DISCONNECTED:
            on_disconnect(p_sc_ctrlpt, p_ble_evt);
            break;

        case BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST:
            on_rw_authorize_request(p_sc_ctrlpt, &p_ble_evt->evt.gatts_evt);
            break;

        case BLE_GATTS_EVT_HVC:
            on_sc_hvc_confirm(p_sc_ctrlpt, p_ble_evt);
            break;

        case BLE_GATTS_EVT_HVN_TX_COMPLETE:
            on_tx_complete(p_sc_ctrlpt);
            break;

        default:
            break;
    }
}
Example #2
0
void nrf_ble_cgms_on_ble_evt(nrf_ble_cgms_t * p_cgms, ble_evt_t * p_ble_evt)
{

    switch (p_ble_evt->header.evt_id)
    {
        case BLE_GAP_EVT_CONNECTED:
            p_cgms->conn_handle    = p_ble_evt->evt.gap_evt.conn_handle;
            p_cgms->cgms_com_state = STATE_NO_COMM;
            break;

        case BLE_GAP_EVT_DISCONNECTED:
            p_cgms->conn_handle = BLE_CONN_HANDLE_INVALID;
            break;

        case BLE_GATTS_EVT_WRITE:
            on_write(p_cgms, p_ble_evt);
            break;

        case BLE_EVT_TX_COMPLETE:
            on_tx_complete(p_cgms, p_ble_evt);
            break;

        case BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST:
            on_rw_authorize_request(p_cgms, &p_ble_evt->evt.gatts_evt);
            break;

        case BLE_GATTS_EVT_HVC:
            on_hvc(p_cgms, p_ble_evt);
            break;

        default:
            // No implementation needed.
            break;
    }
}
void ble_achs_on_ble_evt(ble_achs_t * p_achs, ble_evt_t * p_ble_evt)
{
    switch (p_ble_evt->header.evt_id)
    {
        case BLE_GAP_EVT_CONNECTED:
            p_achs->conn_handle = p_ble_evt->evt.gap_evt.conn_handle;

            // If we are connected start reporting, push a fake reporting mode on command
            m_last_received_command.command = REPORTING_MODE_ON;
            m_last_received_command.master_id = EVERY_MASTER_ID;
            m_last_received_command.group_number = NO_GROUPS;
            m_last_received_command.shared_address = EVERY_DEVICE_ADDRESS;

            asc_event_set(&m_event_flags, EVENT_ASC_COMMAND_RECEIVED);
            break;

        case BLE_GAP_EVT_DISCONNECTED:
            p_achs->conn_handle = BLE_CONN_HANDLE_INVALID;
            break;

        case BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST:
            on_rw_authorize_request(p_achs, &p_ble_evt->evt.gatts_evt);
            break;

        default:
            // No implementation needed.
            break;
    }
}
Example #4
0
void ble_iqo_on_ble_evt(ble_iqo_t * p_iqo, ble_evt_t * p_ble_evt)
{
    switch (p_ble_evt->header.evt_id)
    {
        case BLE_GAP_EVT_CONNECTED:
            on_connect(p_iqo, p_ble_evt);
            break;

        case BLE_GAP_EVT_DISCONNECTED:
            on_disconnect(p_iqo, p_ble_evt);
            break;

        case BLE_GATTS_EVT_WRITE:
            on_write(p_iqo, p_ble_evt);
            break;

        case BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST:
        	on_rw_authorize_request(p_iqo, p_ble_evt);
        	break;

        default:
            // No implementation needed.
            break;
    }
}
/**@brief Function for handling BLE events.
 *
 * @param[in]   p_dfu__nordic_       DFU (Nordic) Service structure.
 * @param[in]   p_ble_evt   Event received from the BLE stack.
 */
void ble_dfu__nordic__on_ble_evt(ble_dfu__nordic__t * p_dfu__nordic_, ble_evt_t * p_ble_evt)
{
    switch (p_ble_evt->header.evt_id)
    {
        case BLE_GAP_EVT_CONNECTED:
            on_connect(p_dfu__nordic_, p_ble_evt);
            break;
        case BLE_GAP_EVT_DISCONNECTED:
            on_disconnect(p_dfu__nordic_, p_ble_evt);
            break;
        case BLE_GATTS_EVT_WRITE:
            on_write(p_dfu__nordic_, &p_ble_evt->evt.gatts_evt.params.write);
            break;
         case BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST:
            on_rw_authorize_request(p_dfu__nordic_, &p_ble_evt->evt.gatts_evt);
            break;
        default:
            //No implementation needed.
            break;
    }
}
/**@brief Function for handling BLE events.
 *
 * @param[in]   p_agsensor       AgSensor Service structure.
 * @param[in]   p_ble_evt   Event received from the BLE stack.
 */
void ble_agsensor_on_ble_evt(ble_agsensor_t * p_agsensor, ble_evt_t * p_ble_evt)
{
    switch (p_ble_evt->header.evt_id)
    {
        case BLE_GAP_EVT_CONNECTED:
            on_connect(p_agsensor, p_ble_evt);
            break;
        case BLE_GAP_EVT_DISCONNECTED:
            on_disconnect(p_agsensor, p_ble_evt);
            break;
        case BLE_GATTS_EVT_WRITE:
            on_write(p_agsensor, &p_ble_evt->evt.gatts_evt.params.write);
            break;
         case BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST:
            on_rw_authorize_request(p_agsensor, &p_ble_evt->evt.gatts_evt);
            break;
         case BLE_GATTS_EVT_HVC:
     		APPL_LOG("ble_agsensor_on_ble_evt BLE_GATTS_EVT_HVC\r\n");
        	 // if the response msg pending then need to copy that to sending hvx buffer and len and return
        	 if (response_msg_pending == true) {
        			memcpy(&hvx_encoded_buffer, &temp_response_hvx_encoded_buffer, temp_response_hvx_p_config_len);
        			hvx_p_config_len = temp_response_hvx_p_config_len;
        			response_msg_pending = false;
        	        isConfigSendWaiting = true;
        			return;
        	 }

        	 if (isMeasuringSensor && sentek_is_measurement_ready_toSend(0)) {
        		 ble_agsensor_create_sensor_read_data_msg();
        		 sentek_reset_measurement_ready_toSend(0);
        		 isConfigSendWaiting = true;
        		 return;
        	 }

        	 if (airNormalizationInProgress == true && sentek_normalization_done()) {

        		 hvx_p_config_len = 0;
        		 (hvx_p_config_len) += uint16_encode(BLE_AGSENSOR_CONFIGURATION_OPCODE_AIR_NORMALIZE, &hvx_encoded_buffer[hvx_p_config_len]);

        		 // Add the sensor count in the sending msg
        		 uint8_t indice = sentek_measurement_get_Indice_toSend();
        		 hvx_encoded_buffer[hvx_p_config_len] = indice;
        		 hvx_p_config_len ++;

        		 airNormalizationInProgress = false;
        		 isConfigSendWaiting = true;
        		 return;
        	 }

        	 if (waterNormalizationInProgress == true && sentek_normalization_done()) {

        		 hvx_p_config_len = 0;
        		 (hvx_p_config_len) += uint16_encode(BLE_AGSENSOR_CONFIGURATION_OPCODE_WATER_NORMALIZE, &hvx_encoded_buffer[hvx_p_config_len]);

        		 // Add the sensor count in the sending msg
        		 uint8_t indice = sentek_measurement_get_Indice_toSend();
        		 hvx_encoded_buffer[hvx_p_config_len] = indice;
        		 hvx_p_config_len ++;

        		 waterNormalizationInProgress = false;
        		 isConfigSendWaiting = true;
        		 return;
        	 }


        	 //last indication complete
        	 if (opcode_inRead != BLE_AGSENSOR_CONFIGURATION_OPCODE_DATETIME && hvx_encoded_buffer[2] == 0) {
        		 opcode_inRead = BLE_AGSENSOR_CONFIGURATION_OPCODE_DATETIME;
        	 }
             ble_agsensor_process_request(0, NULL, opcode_inRead, false, false, false);
            break;

        default:
            //No implementation needed.
            break;
    }
}