raw voltage values

This commit is contained in:
leo 2023-06-24 19:30:39 +02:00
parent 4374fc2c37
commit 65240ee603
Signed by: leo
GPG Key ID: 0DD993BFB2B307DB
3 changed files with 18 additions and 19 deletions

@ -1 +1 @@
Subproject commit c879e0dd70ae36d9db3c6d50ef0c62bc9259055d
Subproject commit 6a651ce129cf9d0ce562aa676cbdd9789ff6011e

View File

@ -1,6 +1,7 @@
#include <stdint.h>
#include <stdio.h>
#include "BLE_UUID.h"
#include "esp_attr.h"
#include "esp_err.h"
#include "esp_log.h"
@ -9,6 +10,7 @@
#include "freertos/projdefs.h"
#include "freertos/task.h"
#include "freertos/portmacro.h"
#include "host/ble_uuid.h"
#include "spinlock.h"
#include "esp_adc/adc_continuous.h"
@ -22,6 +24,7 @@
#include "sdkconfig.h"
#include "BLEh.h"
#include "simple_gatt_value_server.h"
#include "BLE.h"
@ -108,7 +111,21 @@ void app_main(void){
nvs_flash_init();
uint32_t raw_mv_meas[ADC_IN_PIN_NUM];
struct char_pres_format mv_char_pres_format = {
.format = FORMAT_UINT32,
.unit = VOLTS_UNIT_UUID,
.exponent = -3,
.namespc = 1,
.descrH = NSP_DESC_MAIN & 0xff,
.descrL = (NSP_DESC_MAIN>>8) & 0xff,
};
simple_gatt_value_server(&raw_mv_meas, sizeof(uint32_t), ADC_IN_PIN_NUM, mv_char_pres_format, &gatt_svcs[RAW_VALUES_SVC_ID], BLE_UUID16_DECLARE(VOLTAGE_CHAR));
set_gatt_services(gatt_svcs, SVCS_NUM);
initBLE("ALIM");
ESP_ERROR_CHECK(adc_continuous_register_event_callbacks(adc_handle, &adc_event, NULL));

View File

@ -23,24 +23,6 @@ struct ble_gatt_svc_def gatt_svcs[] = {
[RAW_VALUES_SVC_ID] = {
.type = BLE_GATT_SVC_TYPE_PRIMARY,
.uuid = BLE_UUID16_DECLARE(METROLOGY_SERVICE),
.characteristics = (struct ble_gatt_chr_def[]){
[0] = {
.uuid = BLE_UUID16_DECLARE(VOLTAGE_CHAR),
.access_cb = gatt_char_access_placeholder,
.flags = BLE_GATT_CHR_F_READ | BLE_GATT_CHR_F_NOTIFY,
.min_key_size = 0,
.arg = NULL,
.descriptors = (struct ble_gatt_dsc_def[]){
[0] = {
.uuid = BLE_UUID16_DECLARE(CHAR_PRES_FORMAT),
.att_flags = BLE_GATT_CHR_F_READ,
.access_cb = gatt_char_access_placeholder,
},
{ 0 },
},
},
{ 0 },
},
},
[CONFIGURATION_SVC_ID] = {
.type = BLE_GATT_SVC_TYPE_PRIMARY,