gatt_client.c (a94d23eaebfede58bf9fb58975795b387dd511df) gatt_client.c (cb5b2b64b641b0c9ea8fec53cab92f9c86ecd94e)
1/*
2 * Copyright (C) 2014 BlueKitchen GmbH
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright

--- 2858 unchanged lines hidden (view full) ---

2867 gatt_client->attribute_length = value_length;
2868 gatt_client->attribute_offset = 0;
2869 gatt_client->attribute_value = value;
2870 gatt_client->state = P_W2_PREPARE_RELIABLE_WRITE;
2871 gatt_client_run();
2872 return ERROR_CODE_SUCCESS;
2873}
2874
1/*
2 * Copyright (C) 2014 BlueKitchen GmbH
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright

--- 2858 unchanged lines hidden (view full) ---

2867 gatt_client->attribute_length = value_length;
2868 gatt_client->attribute_offset = 0;
2869 gatt_client->attribute_value = value;
2870 gatt_client->state = P_W2_PREPARE_RELIABLE_WRITE;
2871 gatt_client_run();
2872 return ERROR_CODE_SUCCESS;
2873}
2874
2875uint8_t gatt_client_write_client_characteristic_configuration(btstack_packet_handler_t callback, hci_con_handle_t con_handle, gatt_client_characteristic_t * characteristic, uint16_t configuration){
2875uint8_t gatt_client_write_client_characteristic_configuration_with_context(btstack_packet_handler_t callback, hci_con_handle_t con_handle,
2876 gatt_client_characteristic_t * characteristic, uint16_t configuration, uint16_t service_id, uint16_t connection_id){
2876 gatt_client_t * gatt_client;
2877 uint8_t status = gatt_client_provide_context_for_request(con_handle, &gatt_client);
2878 if (status != ERROR_CODE_SUCCESS){
2879 return status;
2880 }
2881
2882 if (configuration > 3){
2883 return ERROR_CODE_UNSUPPORTED_FEATURE_OR_PARAMETER_VALUE;

--- 5 unchanged lines hidden (view full) ---

2889 return GATT_CLIENT_CHARACTERISTIC_NOTIFICATION_NOT_SUPPORTED;
2890 } else if ( (configuration & GATT_CLIENT_CHARACTERISTICS_CONFIGURATION_INDICATION) &&
2891 ((characteristic->properties & ATT_PROPERTY_INDICATE) == 0u)){
2892 log_info("gatt_client_write_client_characteristic_configuration: GATT_CLIENT_CHARACTERISTIC_INDICATION_NOT_SUPPORTED");
2893 return GATT_CLIENT_CHARACTERISTIC_INDICATION_NOT_SUPPORTED;
2894 }
2895
2896 gatt_client->callback = callback;
2877 gatt_client_t * gatt_client;
2878 uint8_t status = gatt_client_provide_context_for_request(con_handle, &gatt_client);
2879 if (status != ERROR_CODE_SUCCESS){
2880 return status;
2881 }
2882
2883 if (configuration > 3){
2884 return ERROR_CODE_UNSUPPORTED_FEATURE_OR_PARAMETER_VALUE;

--- 5 unchanged lines hidden (view full) ---

2890 return GATT_CLIENT_CHARACTERISTIC_NOTIFICATION_NOT_SUPPORTED;
2891 } else if ( (configuration & GATT_CLIENT_CHARACTERISTICS_CONFIGURATION_INDICATION) &&
2892 ((characteristic->properties & ATT_PROPERTY_INDICATE) == 0u)){
2893 log_info("gatt_client_write_client_characteristic_configuration: GATT_CLIENT_CHARACTERISTIC_INDICATION_NOT_SUPPORTED");
2894 return GATT_CLIENT_CHARACTERISTIC_INDICATION_NOT_SUPPORTED;
2895 }
2896
2897 gatt_client->callback = callback;
2898 gatt_client->service_id = service_id;
2899 gatt_client->connection_id = connection_id;
2897 gatt_client->start_group_handle = characteristic->value_handle;
2898 gatt_client->end_group_handle = characteristic->end_handle;
2899 little_endian_store_16(gatt_client->client_characteristic_configuration_value, 0, configuration);
2900
2901#ifdef ENABLE_GATT_FIND_INFORMATION_FOR_CCC_DISCOVERY
2902 gatt_client->gatt_client_state = P_W2_SEND_FIND_CLIENT_CHARACTERISTIC_CONFIGURATION_QUERY;
2903#else
2904 gatt_client->state = P_W2_SEND_READ_CLIENT_CHARACTERISTIC_CONFIGURATION_QUERY;
2905#endif
2906 gatt_client_run();
2907 return ERROR_CODE_SUCCESS;
2908}
2909
2900 gatt_client->start_group_handle = characteristic->value_handle;
2901 gatt_client->end_group_handle = characteristic->end_handle;
2902 little_endian_store_16(gatt_client->client_characteristic_configuration_value, 0, configuration);
2903
2904#ifdef ENABLE_GATT_FIND_INFORMATION_FOR_CCC_DISCOVERY
2905 gatt_client->gatt_client_state = P_W2_SEND_FIND_CLIENT_CHARACTERISTIC_CONFIGURATION_QUERY;
2906#else
2907 gatt_client->state = P_W2_SEND_READ_CLIENT_CHARACTERISTIC_CONFIGURATION_QUERY;
2908#endif
2909 gatt_client_run();
2910 return ERROR_CODE_SUCCESS;
2911}
2912
2913uint8_t gatt_client_write_client_characteristic_configuration(btstack_packet_handler_t callback, hci_con_handle_t con_handle, gatt_client_characteristic_t * characteristic, uint16_t configuration){
2914 return gatt_client_write_client_characteristic_configuration_with_context(callback, con_handle, characteristic, configuration, 0, 0);
2915}
2916
2910uint8_t gatt_client_read_characteristic_descriptor_using_descriptor_handle(btstack_packet_handler_t callback, hci_con_handle_t con_handle, uint16_t descriptor_handle){
2911 gatt_client_t * gatt_client;
2912 uint8_t status = gatt_client_provide_context_for_request(con_handle, &gatt_client);
2913 if (status != ERROR_CODE_SUCCESS){
2914 return status;
2915 }
2916
2917 gatt_client->callback = callback;

--- 883 unchanged lines hidden ---
2917uint8_t gatt_client_read_characteristic_descriptor_using_descriptor_handle(btstack_packet_handler_t callback, hci_con_handle_t con_handle, uint16_t descriptor_handle){
2918 gatt_client_t * gatt_client;
2919 uint8_t status = gatt_client_provide_context_for_request(con_handle, &gatt_client);
2920 if (status != ERROR_CODE_SUCCESS){
2921 return status;
2922 }
2923
2924 gatt_client->callback = callback;

--- 883 unchanged lines hidden ---