extern void ScanParamHandleAccessRead(GATT_ACCESS_IND_T *p_ind) { uint16 length = 0; uint8 val[2], *p_value = NULL; sys_status rc = sys_status_success; switch(p_ind->handle) { case HANDLE_SCAN_REFRESH_C_CFG: { p_value = val; length = 2; /* Two Octets */ BufWriteUint16(&p_value, scan_param_data.refresh_client_config); /* BufWriteUint16 will have incremented p_value. Revert it back * to point to val. */ p_value -= length; } break; default: { rc = gatt_status_read_not_permitted; } break; } GattAccessRsp(p_ind->cid, p_ind->handle, rc, length, p_value); }
extern void BatteryHandleAccessRead(GATT_ACCESS_IND_T *p_ind) { uint16 length = 0; uint8 value[2]; uint8 *p_val = NULL; sys_status rc = sys_status_success; switch(p_ind->handle) { /* Battery level is being read */ case HANDLE_BATT_LEVEL: { /* Reading battery level */ length = 1; /* One Octet */ g_batt_data.level = readBatteryLevel(); value[0] = g_batt_data.level; } break; /* Client Characteristic Configuration for the Battery Level * Characteristic is being read */ case HANDLE_BATT_LEVEL_C_CFG: { length = 2; /* Two Octets */ p_val = value; BufWriteUint16((uint8 **)&p_val, g_batt_data.level_client_config); } break; default: /* No more IRQ characteristics */ rc = gatt_status_read_not_permitted; break; } /* Send Access response */ GattAccessRsp(p_ind->cid, p_ind->handle, rc, length, value); }
/*----------------------------------------------------------------------------* * NAME * BatteryHandleAccessRead * * DESCRIPTION * This function handles read operations on Battery Service attributes * maintained by the application and responds with the GATT_ACCESS_RSP * message. * * PARAMETERS * p_ind [in] Data received in GATT_ACCESS_IND message. * * RETURNS * Nothing *----------------------------------------------------------------------------*/ extern void BatteryHandleAccessRead(GATT_ACCESS_IND_T *p_ind) { uint16 length = 0; /* Length of attribute data, octets */ uint8 value[2]; /* Attribute value */ uint8 *p_val = NULL; /* Pointer to attribute value */ sys_status rc = sys_status_success; /* Function status */ switch(p_ind->handle) { case HANDLE_BATT_LEVEL: { /* Read the battery level */ length = 1; /* One Octet */ g_batt_data.level = readBatteryLevel(); value[0] = g_batt_data.level; } break; case HANDLE_BATT_LEVEL_C_CFG: { /* Read the client configuration descriptor for the battery level * characteristic. */ length = 2; /* Two Octets */ p_val = value; BufWriteUint16((uint8 **)&p_val, g_batt_data.level_client_config); } break; default: /* No more IRQ characteristics */ rc = gatt_status_read_not_permitted; break; } /* Send ACCESS RESPONSE */ GattAccessRsp(p_ind->cid, p_ind->handle, rc, length, value); }
extern void GattHandleAccessRead(GATT_ACCESS_IND_T *p_ind) { uint16 data_length = 0; uint8 value[2]; uint8 *p_value = NULL; sys_status rc = gatt_status_read_not_permitted; uint8 dev_index = AppGetConnectedDeviceIndex(); if(p_ind->handle == HANDLE_SERVICE_CHANGED_CLIENT_CONFIG) { /* Service changed client characteristic configuration descriptor read * has been requested */ data_length = 2; p_value = value; BufWriteUint16((uint8 **)&p_value, g_gatt_data.serv_changed_config[dev_index]); rc = sys_status_success; } /* Send Access Response */ GattAccessRsp(p_ind->cid, p_ind->handle, rc, data_length, p_value); }
extern void HeartRateHandleAccessRead(GATT_ACCESS_IND_T *p_ind) { /* Initialise to 2 octets for Client Configuration */ uint16 length = 2; uint8 value[2]; uint8 *p_val = NULL; sys_status rc = sys_status_success; switch(p_ind->handle) { /* Client configuration of the Heart Rate Measurement Characteristic is * being read. */ case HANDLE_HEART_RATE_MEASUREMENT_C_CFG: { p_val = value; /* copy the client configuration value in response buffer */ BufWriteUint16(&p_val, g_hr_serv_data.hr_meas_client_config); } break; default: { /* Let the firmware handle.the request */ rc = gatt_status_irq_proceed; } break; } /* Send GATT Response for the received request */ GattAccessRsp(p_ind->cid, p_ind->handle, rc, length, value); }
extern void HidHandleAccessRead(GATT_ACCESS_IND_T *p_ind) { uint16 length = 0; uint8 *p_value = NULL; uint8 val[2]; sys_status rc = sys_status_success; switch(p_ind->handle) { case HANDLE_HID_INPUT_RPT_CLIENT_CONFIG: { p_value = val; BufWriteUint16(&p_value, hid_data.input_client_config); /* CCCD value of a characteristic is 2 bytes in length. */ length = 2; /* BufWriteUint16 will have incremented p_value. Revert it back * to point to val. */ p_value -= length; } break; case HANDLE_HID_BOOT_INPUT_RPT_CLIENT_CONFIG: { p_value = val; BufWriteUint16(&p_value, hid_data.input_boot_client_config); /* CCCD value of a characteristic is 2 bytes in length. */ length = 2; /* BufWriteUint16 will have incremented p_value. Revert it back * to point to val. */ p_value -= length; } break; case HANDLE_HID_INPUT_REPORT: { /* The input report array is maintained by mouse_hw.c. Get a * reference to it. */ p_value = GetMouseReport(HID_INPUT_REPORT_ID); length = ATTR_LEN_HID_INPUT_REPORT; } break; case HANDLE_HID_BOOT_INPUT_REPORT: { /* The input report array is maintained by mouse_hw.c. Get a * reference to it. */ p_value = GetMouseReport(HID_INPUT_REPORT_ID); length = ATTR_LEN_HID_BOOT_INPUT_REPORT; } break; case HANDLE_HID_PROTOCOL_MODE: { p_value = val; /* Get the current protocol mode. */ p_value[0] = hid_data.report_mode; length = ATTR_LEN_HID_PROTOCOL_MODE; } break; case HANDLE_HID_FEATURE_REPORT: { p_value = val; val[0] = GetSensorResolution(); /* Feature report value is 1 byte in length */ length = ATTR_LEN_HID_FEATURE_REPORT; } break; default: { /* Let firmware handle the request */ rc = gatt_status_irq_proceed; } break; } GattAccessRsp(p_ind->cid, p_ind->handle, rc, length, p_value); }