|
29 | 29 | static CborEncoder s_encoder, s_result_map, s_diag_map, s_diag_data_map;
|
30 | 30 | static CborEncoder s_meta_encoder, s_meta_result_map, s_diag_meta_map, s_diag_meta_data_map;
|
31 | 31 |
|
| 32 | +#define CBOR_ENC_MAX_CBS 10 |
| 33 | +static struct cbor_encoder_data { |
| 34 | + insights_cbor_encoder_cb_t cb[CBOR_ENC_MAX_CBS]; |
| 35 | + int cb_cnt; |
| 36 | +} s_priv_data; |
| 37 | + |
32 | 38 | static inline void _cbor_encode_meta_hdr(CborEncoder *hdr_map, const rtc_store_meta_header_t *hdr);
|
33 | 39 |
|
| 40 | +esp_err_t esp_insights_cbor_encoder_register_meta_cb(insights_cbor_encoder_cb_t cb) |
| 41 | +{ |
| 42 | + if (s_priv_data.cb_cnt == CBOR_ENC_MAX_CBS) { |
| 43 | + return ESP_ERR_NO_MEM; |
| 44 | + } |
| 45 | + ESP_LOGV(TAG, "Registering callback %p", cb); |
| 46 | + s_priv_data.cb[s_priv_data.cb_cnt++] = cb; |
| 47 | + return ESP_OK; |
| 48 | +} |
| 49 | + |
34 | 50 | void esp_insights_cbor_encode_diag_begin(void *data, size_t data_size, const char *version)
|
35 | 51 | {
|
36 | 52 | cbor_encoder_init(&s_encoder, data, data_size, 0);
|
@@ -681,6 +697,25 @@ void esp_insights_cbor_encode_meta_data_end(void)
|
681 | 697 | cbor_encoder_close_container(&s_diag_meta_map, &s_diag_meta_data_map);
|
682 | 698 | }
|
683 | 699 |
|
| 700 | +void esp_insights_cbor_encode_conf_meta_data_begin(void) |
| 701 | +{ |
| 702 | + cbor_encode_text_stringz(&s_diag_meta_map, "data"); |
| 703 | + cbor_encoder_create_map(&s_diag_meta_map, &s_diag_meta_data_map, CborIndefiniteLength); |
| 704 | +#ifdef NEW_META_STRUCT |
| 705 | + for (int i = 0; i < s_priv_data.cb_cnt; i++) { |
| 706 | + if (s_priv_data.cb[i]) { |
| 707 | + s_priv_data.cb[i] (&s_diag_meta_data_map, INSIGHTS_MSG_TYPE_META); |
| 708 | + } |
| 709 | + } |
| 710 | +#endif |
| 711 | +} |
| 712 | + |
| 713 | +/** Vikram: remove? */ |
| 714 | +void esp_insights_cbor_encode_conf_meta_data_end(void) |
| 715 | +{ |
| 716 | + cbor_encoder_close_container(&s_diag_meta_map, &s_diag_meta_data_map); |
| 717 | +} |
| 718 | + |
684 | 719 | #if CONFIG_DIAG_ENABLE_METRICS
|
685 | 720 | static void encode_metrics_meta_element(CborEncoder *map, const esp_diag_metrics_meta_t *metrics)
|
686 | 721 | {
|
|
0 commit comments