ESP32 BLE advertising data

I am new to mongoose OS and struggling to write code to advertise data over ble

  1. My goal is: to advertise moisture sensor data…basically send this to another esp32 which then controls the water valve
  2. My actions are:here is the current code:

`
#include “mgos.h”

#include “mgos_adc.h”

#include “mgos_timers.h”

#include “mgos_app.h”

#include “mgos_sys_config.h”

#include “mgos_bt.h”

#define ADC_PIN 34

#define VERY_DRY_BOUNDARY 2000

#define DRY_BOUNDARY 1250

#define WET_BOUNDARY 760

#define VERY_WET_BOUNDARY 0

#define SERVICE_UUID “4eb64a0f-6853-a880-4737-4bc914ef4636”

#define CHAR_UUID “5f6d4f53-5f52-5043-5f64-6174615f5f5f”

static struct mgos_bt_gatts_conn *s_conn = NULL;

static uint16_t s_char_handle = 0; // Store the characteristic handle

bool deviceConnected = false;

typedef enum {

VERY_DRY = 0,

DRY = 1,

WET = 2,

VERY_WET = 3,

} MoistureLevel;

static MoistureLevel get_moisture_level(int adc_value) {

if (adc_value >= VERY_WET_BOUNDARY && adc_value < WET_BOUNDARY) {

return VERY_WET;

} else if (adc_value >= WET_BOUNDARY && adc_value < DRY_BOUNDARY) {

return WET;

} else if (adc_value >= DRY_BOUNDARY && adc_value < VERY_DRY_BOUNDARY) {

return DRY;

} else {

return VERY_DRY;

}

}

static const char *moisture_level_to_string(MoistureLevel level) {

switch (level) {

case VERY_DRY: return "VERY_DRY";

case DRY: return "DRY";

case WET: return "WET";

case VERY_WET: return "VERY_WET";

default: return "UNKNOWN";

}

}

static void timer_cb(void *arg) {

int moisture_value = mgos_adc_read(ADC_PIN);

MoistureLevel soil_moisture = get_moisture_level(moisture_value);

const char *result = moisture_level_to_string(soil_moisture);

LOG(LL_INFO, (“MOISTURE_LEVEL: %s”, result));

LOG(LL_INFO, (“ADC_VALUE: %d”, moisture_value));

}

enum mgos_app_init_result mgos_app_init(void) {

if (!mgos_adc_enable(ADC_PIN)) {

LOG(LL_ERROR, ("Couldn't Enable ADC Pin"));

return MGOS_APP_INIT_ERROR;

}

LOG(LL_INFO, (“Starting Timer”));

mgos_set_timer(1000, MGOS_TIMER_REPEAT, timer_cb, NULL);

return MGOS_APP_INIT_SUCCESS;

}
`

I am not understanding how to go about this. Any guidance on this matter would help a lot!

For arduino you ideally create a server-> then a service → characteristic

I want to notify every couple of seconds (atleast for the testing phase of this project)