2929
3030#include <inttypes.h>
3131#include "nimble/ble.h"
32+ #include "../../host/src/ble_gatt_priv.h"
3233
3334#ifdef __cplusplus
3435extern "C" {
@@ -40,13 +41,16 @@ extern "C" {
4041 * @{
4142 */
4243/** Object type: Our security material. */
43- #define BLE_STORE_OBJ_TYPE_OUR_SEC 1
44+ #define BLE_STORE_OBJ_TYPE_OUR_SEC 1
4445
4546/** Object type: Peer security material. */
46- #define BLE_STORE_OBJ_TYPE_PEER_SEC 2
47+ #define BLE_STORE_OBJ_TYPE_PEER_SEC 2
4748
4849/** Object type: Client Characteristic Configuration Descriptor. */
49- #define BLE_STORE_OBJ_TYPE_CCCD 3
50+ #define BLE_STORE_OBJ_TYPE_CCCD 3
51+
52+ /** Object type: Peer Client Supported Features. */
53+ #define BLE_STORE_OBJ_TYPE_PEER_CL_SUP_FEAT 4
5054
5155/** @} */
5256
@@ -154,6 +158,33 @@ struct ble_store_value_cccd {
154158 unsigned value_changed :1 ;
155159};
156160
161+ /**
162+ * Used as a key for lookups of stored client supported features of specific
163+ * peer. This struct corresponds to the BLE_STORE_OBJ_TYPE_PEER_CL_SUP_FEAT
164+ * store object type.
165+ */
166+ struct ble_store_key_cl_sup_feat {
167+ /**
168+ * Key by peer identity address;
169+ * peer_addr=BLE_ADDR_NONE means don't key off peer.
170+ */
171+ ble_addr_t peer_addr ;
172+
173+ /** Number of results to skip; 0 means retrieve the first match. */
174+ uint8_t idx ;
175+ };
176+
177+ /**
178+ * Represents a stored client supported features of specific peer. This struct
179+ * corresponds to the BLE_STORE_OBJ_TYPE_PEER_CL_SUP_FEAT store object type.
180+ */
181+ struct ble_store_value_cl_sup_feat {
182+ /** The peer address associated with the stored supported features. */
183+ ble_addr_t peer_addr ;
184+ /** Client supported features of a specific peer. */
185+ uint8_t peer_cl_sup_feat [BLE_GATT_CHR_CLI_SUP_FEAT_SZ ];
186+ };
187+
157188/**
158189 * Used as a key for store lookups. This union must be accompanied by an
159190 * object type code to indicate which field is valid.
@@ -163,6 +194,8 @@ union ble_store_key {
163194 struct ble_store_key_sec sec ;
164195 /** Key for Client Characteristic Configuration Descriptor store lookups. */
165196 struct ble_store_key_cccd cccd ;
197+ /** Key for Peer Client Supported Features store lookpus. */
198+ struct ble_store_key_cl_sup_feat feat ;
166199};
167200
168201/**
@@ -174,6 +207,8 @@ union ble_store_value {
174207 struct ble_store_value_sec sec ;
175208 /** Stored Client Characteristic Configuration Descriptor. */
176209 struct ble_store_value_cccd cccd ;
210+ /** Stored Client Supported Features. */
211+ struct ble_store_value_cl_sup_feat feat ;
177212};
178213
179214/** Represents an event associated with the BLE Store. */
@@ -556,6 +591,64 @@ int ble_store_write_cccd(const struct ble_store_value_cccd *value);
556591 */
557592int ble_store_delete_cccd (const struct ble_store_key_cccd * key );
558593
594+ /**
595+ * @brief Reads Client Supported Features value from a storage
596+ *
597+ * This function reads client supported features value from a storage based
598+ * on the provied key and stores the retrieved value in the specified output
599+ * structure.
600+ *
601+ * @param key A pointer to a 'ble_store_key_cl_sup_feat'
602+ * struct representing the key to identify
603+ * Client Supported Features value to be read.
604+ * @param out_value A pointer to a 'ble_store_value_cl_sup_feat'
605+ * struct to store the Client Supported
606+ * Features value read from a storage
607+ *
608+ * @return 0 if the Client Supported Features values was
609+ * successfully read and stored in the
610+ * 'out_value' structure;
611+ * Non-zero on error
612+ */
613+ int
614+ ble_store_read_peer_cl_sup_feat (const struct ble_store_key_cl_sup_feat * key ,
615+ struct ble_store_value_cl_sup_feat * out_value );
616+
617+ /**
618+ * @brief Writes a Client Supported Features value to a storage.
619+ *
620+ * This function writes a Client Supported Features value to a storage based on
621+ * the provided value
622+ *
623+ * @param value A pointer to a 'ble_store_value_cl_sup_feat'
624+ * structure representing the Client Supported
625+ * Features value to be written to a storage.
626+ *
627+ * @return 0 if the value was successfully written to
628+ * a storage;
629+ * Non-zero on error.
630+ */
631+ int
632+ ble_store_write_peer_cl_sup_feat (const struct ble_store_value_cl_sup_feat
633+ * value );
634+
635+ /**
636+ * @brief Deletes a Client Supported Features value from a storage.
637+ *
638+ * This function deletes a Client Supported Features value from a storage based
639+ * on the provided key.
640+ *
641+ * @param key A pointer to a 'ble_store_key_cl_sup_feat'
642+ * structure identifying the Client Supported
643+ * Features value to be deleted from
644+ * a storage.
645+ *
646+ * @return 0 if the Client Supported Features value was
647+ * successfully written to a storage;
648+ * Non-zero on error.
649+ */
650+ int ble_store_delete_peer_cl_sup_feat (const struct ble_store_key_cl_sup_feat
651+ * key );
559652
560653/**
561654 * @brief Generates a storage key for a security material entry from its value.
@@ -587,6 +680,26 @@ void ble_store_key_from_value_sec(struct ble_store_key_sec *out_key,
587680void ble_store_key_from_value_cccd (struct ble_store_key_cccd * out_key ,
588681 const struct ble_store_value_cccd * value );
589682
683+ /**
684+ * @brief Generates a storage key for a Client Supported Features entry from
685+ * its value
686+ *
687+ * This function generates a storage key for a Client Supported Features value
688+ * entry based on the provided value.
689+ *
690+ * @param out_key A pointer to a 'ble_store_key_cl_sup_feat'
691+ * structure where the generated key will be
692+ * stored.
693+ * @param value A pointer to a 'ble_store_value_cl_sup_feat'
694+ * structure containing the Client Supported
695+ * Features value from which the key will be
696+ * generated.
697+ */
698+ void
699+ ble_store_key_from_value_peer_cl_sup_feat (struct ble_store_key_cl_sup_feat
700+ * out_key ,
701+ const struct ble_store_value_cl_sup_feat
702+ * value );
590703
591704/**
592705 * @brief Generates a storage key from a value based on the object type.
0 commit comments