You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by GitBox <gi...@apache.org> on 2020/02/12 22:14:01 UTC

[GitHub] [mynewt-core] ccollins476ad commented on a change in pull request #2192: Add generic API to retrieve provisioned data from BSP

ccollins476ad commented on a change in pull request #2192: Add generic API to retrieve provisioned data from BSP
URL: https://github.com/apache/mynewt-core/pull/2192#discussion_r378543882
 
 

 ##########
 File path: hw/hal/include/hal/hal_bsp.h
 ##########
 @@ -79,8 +80,73 @@ int hal_bsp_hw_id_len(void);
  *
  * @return 0 on success, non-zero error code on failure
  */
+__attribute__((deprecated))
 int hal_bsp_hw_id(uint8_t *id, int max_len);
 
+/* Provisioned data identifiers */
+#define HAL_BSP_PROV_HW_ID                  0x0001
+#define HAL_BSP_PROV_BLE_PUBLIC_ADDR        0x0002
+#define HAL_BSP_PROV_BLE_STATIC_ADDR        0x0003
+#define HAL_BSP_PROV_BLE_IRK                0x0004
+/* First id for user-defined data identifiers */
+#define HAL_BSP_PROV_USER                   0x8000
+
+/**
+ * Get provisioned data
+ *
+ * \p length input value shall be set to size of buffer pointer by \p data.
+ * On success, \p length output value is set to size of provisioned data and
+ * may be larger than input value.
+ *
+ * Caller can set \p data to NULL to query for required \p length to read
+ * complete data. In such case \p length input value does not matter.
+ *
+ * If provided buffer is too small to store all provisioned data, returned data
+ * may be either truncated (check \p length to see complete data length) or
+ * error is returned. The former can usually happen for variable-length data
+ * where application should first query data length, the latter can usually
+ * happen for fixed-length data where data length is well known.
 
 Review comment:
   This is just a personal thing, but I dislike it when a library makes me do extra work to check for truncation.  I prefer it when it is always an error if the supplied buffer is too small.  I could be mistaken, but looking at the list of data types, I don't see any that can be safely truncated.
   
   One alternative would be to have a second function that allows truncation.
   
   Just my two cents.
   
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services