/** * Enables indications on a specified Client Characteristic Configuration attribute * Writing the value 0x0002 (little-endian) enables indications. * Writing the value 0x0001 (little-endian) enables notifications. * @param connection_handle Handle for open connection to use (always "0" in this demo) * @param client_configuration_handle 16-bit attribute handle of CCC attribute, used for subscribing to indications */ void enable_indications(uint8 connection_handle, uint16 client_configuration_handle) { ble_cmd_sm_encrypt_start(connection_handle, 1); // encrpyt connection (not strictly required) uint8 configuration[] = {0x01, 0x00}; // {0x01, 0x00} = notify, {0x02, 0x00} indicate ble_cmd_attclient_attribute_write(connection_handle, drone_handle_configuration, 2, &configuration); }
/** * "attclient_find_information_found" event handler * Occurs whenever an information search has returned a new entry (e.g. attribute) * (see "attclient_find_information" in API reference guide) * * @param msg Event packet data payload */ void ble_evt_attclient_find_information_found(const struct ble_msg_attclient_find_information_found_evt_t *msg) { //TODO: add different rule for 16 if (msg->uuid.len == 2 || msg->uuid.len == 16) { uint32 uuid = (msg->uuid.data[1] << 8) | msg->uuid.data[0]; if (uuid == DRONE_DATA_CONFIG_UUID) { drone_handle_configuration = msg->chrhandle; } else if (uuid == DRONE_DATA_UUID) { drone_handle_measurement = msg->chrhandle; } else if (uuid == DRONE_BROADCAST_UUID) { drone_handle_broadcast = msg->chrhandle; // Handle for Drone Data configuration already known if (action == action_broadcast_connect) { unsigned char var[] = {1}; printf("Request sent: %d\n", var[0]); ble_cmd_attclient_attribute_write(msg->connection, drone_handle_broadcast, 1, &var); } } } }
void enable_indications(uint8 connection_handle, uint16 client_configuration_handle) { uint8 configuration[] = {0x02, 0x00}; // enable indications ble_cmd_attclient_attribute_write(connection_handle, thermometer_handle_configuration, 2, &configuration); }