This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Is bas some base required service for all GATT apps or is there a hidden m_bas?

Hi!

So I went from the Battery Service example to create my own service which went well and everything. Now I don't need a battery service, which is why I was trying to remove it.

I was able to rip out every single piece of code involving the battery service whilst the app still works

If I rip out those last lines:

memset(&bas_init, 0, sizeof(bas_init));

    // Here the sec level for the Battery Service can be changed/increased.
    BLE_GAP_CONN_SEC_MODE_SET_OPEN(&bas_init.battery_level_char_attr_md.cccd_write_perm);
    BLE_GAP_CONN_SEC_MODE_SET_OPEN(&bas_init.battery_level_char_attr_md.read_perm);
    BLE_GAP_CONN_SEC_MODE_SET_NO_ACCESS(&bas_init.battery_level_char_attr_md.write_perm);

    BLE_GAP_CONN_SEC_MODE_SET_OPEN(&bas_init.battery_level_report_read_perm);

    bas_init.evt_handler          = NULL;
    bas_init.support_notification = true;
    bas_init.p_report_ref         = NULL;
    bas_init.initial_batt_level   = 100;

    err_code = ble_bas_init(&m_bas, &bas_init);
    APP_ERROR_CHECK(err_code);

the app supposedly starts writing into memory that it is not allowed to. The characteristics will start displaying weird values and everything falls down until everything crashes ...

I verified with a grep that I am nowwhere else using the bas module:

Noahs-MacBook-Pro:src yatekii$ grep -r bas .
./cble.c:#include "ble_bas.h"
./cble.c:            // The local database has likely changed, send service changed indications.
./cble.c:            pm_local_database_has_changed();
./power_service.c:    ble_uuid128_t   base_uuid = APP_UUID;
./power_service.c:    err_code = sd_ble_uuid_vs_add(&base_uuid, &ble_uuid.type);
./power_service.c:    // Update databasee.
./services.c:    ble_bas_init_t bas_init;
./services.c:    memset(&bas_init, 0, sizeof(bas_init));
./services.c:    BLE_GAP_CONN_SEC_MODE_SET_OPEN(&bas_init.battery_level_char_attr_md.cccd_write_perm);
./services.c:    BLE_GAP_CONN_SEC_MODE_SET_OPEN(&bas_init.battery_level_char_attr_md.read_perm);
./services.c:    BLE_GAP_CONN_SEC_MODE_SET_NO_ACCESS(&bas_init.battery_level_char_attr_md.write_perm);
./services.c:    BLE_GAP_CONN_SEC_MODE_SET_OPEN(&bas_init.battery_level_report_read_perm);
./services.c:    bas_init.evt_handler          = NULL;
./services.c:    bas_init.support_notification = true;
./services.c:    bas_init.p_report_ref         = NULL;
./services.c:    bas_init.initial_batt_level   = 100;
./services.c:    //err_code = ble_bas_init(&m_bas, &bas_init);

The absolutely weirdest part for me is that m_bas is non-existant in my code and the gcc does NOT complain. Which let's me guess that there is an m_bas somewhere hidden in the nordic code. I tried to verify that with a grep too:

Noahs-MacBook-Pro:src yatekii$ grep -r m_bas .
./services.c:    //err_code = ble_bas_init(&m_bas, &bas_init);
Noahs-MacBook-Pro:src yatekii$ grep -r m_bas ../inc/
Noahs-MacBook-Pro:src yatekii$

Can somebody give me a hint on what I am doing wrong?

Sorry for asking such stupid things but it's driving me nuts ...

Best regards Yatekii

Parents Reply Children
No Data
Related