extern void HeartRateHandleAccessWrite(GATT_ACCESS_IND_T *p_ind) { uint8 *p_value = p_ind->value; gatt_client_config client_config; sys_status rc = sys_status_success; switch(p_ind->handle) { /* Heart Rate measurement characteristic client configuration is being * written */ case HANDLE_HEART_RATE_MEASUREMENT_C_CFG: { client_config = BufReadUint16(&p_value); /* Client Configuration is bit field value so ideally bitwise * comparison should be used but since the application supports only * notifications, direct comparison is being used. */ if((client_config == gatt_client_config_notification) || (client_config == gatt_client_config_none)) { /* Store the new client configuration */ g_hr_serv_data.hr_meas_client_config = client_config; /* Write Heart Rate Measurement Client configuration to NVM if * the device is bonded. */ if(AppIsDeviceBonded()) { Nvm_Write((uint16*)&client_config, sizeof(client_config), g_hr_serv_data.nvm_offset + HR_NVM_HR_MEAS_CLIENT_CONFIG_OFFSET); } /* Start sending the HR measurement notifications if they are * not being sent currently. */ StartSendingHRMeasurements(); } else { /* INDICATION or RESERVED */ /* Return Error as only Notifications are supported */ rc = gatt_status_desc_improper_config; } break; } /* Heart Rate Control point is being written */ case HANDLE_HEART_RATE_CONTROL_POINT: { /* Extract the written value */ uint8 cntl_point_val = BufReadUint8(&p_value); /* Check if the HR client has reset the expended energy. */ if(cntl_point_val == hr_control_point_reset_energy) { /* Yes, it has. Make a note of it. */ g_hr_serv_data.energy_expended = 0; g_hr_serv_data.reset_energy_expended_received = TRUE; } else /* Reserved Value */ { rc = gatt_status_desc_improper_config; } break; } default: { /* Write is not permitted on any other characteristic/attribute */ rc = gatt_status_write_not_permitted; break; } } /* Send ACCESS RESPONSE */ GattAccessRsp(p_ind->cid, p_ind->handle, rc, 0, NULL); }
extern void HeartRateHandleAccessWrite(GATT_ACCESS_IND_T *p_ind) { uint8 *p_value = p_ind->value; gatt_client_config client_config; sys_status rc = sys_status_success; switch(p_ind->handle) { /* Heart Rate measurement characteristic client configuration is being * written */ case HANDLE_EEG_MEASUREMENT_C_CFG: { client_config = BufReadUint16(&p_value); /* Client Configuration is bit field value so ideally bitwise * comparison should be used but since the application supports only * notifications, direct comparison is being used. */ if((client_config == gatt_client_config_notification) || (client_config == gatt_client_config_none)) { /* Store the new client configuration */ g_eeg_serv_data.hr_meas_client_config = client_config; /* Write Heart Rate Measurement Client configuration to NVM if * the device is bonded. */ if(AppIsDeviceBonded()) { Nvm_Write((uint16*)&client_config, sizeof(client_config), g_eeg_serv_data.nvm_offset + HR_NVM_HR_MEAS_CLIENT_CONFIG_OFFSET); } /* Start sending the HR measurement notifications if they are * not being sent currently. */ StartSendingHRMeasurements(); } else { /* INDICATION or RESERVED */ /* Return Error as only Notifications are supported */ rc = gatt_status_desc_improper_config; } break; } /* EEG channels Control point is being written */ case HANDLE_EEG_CHANNELS: { /* Extract the written value */ g_eeg_serv_data.channel_map = BufReadUint16(&p_value); DebugWriteString("\n\rChannel map updated"); break; } case HANDLE_EEG_ACQUISITION_RATE: { g_eeg_serv_data.acquisition_rate = BufReadUint16(&p_value); TimerDelete(g_eeg_serv_data.acq_tmr); g_eeg_serv_data.acq_tmr = TimerCreate((uint32) (1000000/g_eeg_serv_data.acquisition_rate), TRUE, acquireData); DebugWriteString("\n\rAcq Rate changed"); break; } default: { /* Write is not permitted on any other characteristic/attribute */ rc = gatt_status_write_not_permitted; break; } } /* Send ACCESS RESPONSE */ GattAccessRsp(p_ind->cid, p_ind->handle, rc, 0, NULL); }