Hackster is hosting Hackster Holidays, Ep. 6: Livestream & Giveaway Drawing. Watch previous episodes or stream live on Monday!Stream Hackster Holidays, Ep. 6 on Monday!
1NH21CE005_Adnan_Aadil_Burhan
Created September 3, 2024

Smart Hiking Assistant for Visually Impaired Individuals

Enhance hiking safety for visually impaired users with real-time environmental data and audio feedback through a smart system integrating it

17
Smart Hiking Assistant for Visually Impaired Individuals

Things used in this project

Hardware components

Seeed Studio XIAO ESP32S3 Sense
Seeed Studio XIAO ESP32S3 Sense
×1
NRF52840 Development Kit
×1
nRF52 Development Kit
Nordic Semiconductor nRF52 Development Kit
×1
Navigation Assistance
×1

Story

Read more

Schematics

image 1

Code

code

C/C++
#include "nrf_ble_gatt.h"
#include "nrf_ble_qwr.h"
#include "nrf_ble_scan.h"
#include "ble_advertising.h"
#include "app_error.h"
#include "bsp.h"
#include "nrf_log.h"
#include "nrf_log_ctrl.h"
#include "nrf_log_default_backends.h"

#define DEVICE_NAME                     "NRF52840"
#define SERVICE_UUID                    0x1234
#define CHARACTERISTIC_UUID             0x1235

static nrf_ble_gatt_t m_gatt;
static nrf_ble_qwr_t m_qwr;
static ble_advertising_t m_advertising;
static uint16_t m_conn_handle = BLE_CONN_HANDLE_INVALID;

static void on_ble_evt(ble_evt_t const * p_ble_evt, void * p_context) {
    if (p_ble_evt->header.evt_id == BLE_GAP_EVT_CONNECTED) {
        m_conn_handle = p_ble_evt->evt.gap_evt.conn_handle;
    }
    else if (p_ble_evt->header.evt_id == BLE_GAP_EVT_DISCONNECTED) {
        m_conn_handle = BLE_CONN_HANDLE_INVALID;
    }
}

static void ble_stack_init(void) {
    uint32_t err_code;
    nrf_ble_gatt_init(&m_gatt, NULL);
    ble_advertising_init_t init;
    memset(&init, 0, sizeof(init));
    init.advdata.name_type = BLE_ADVDATA_FULL_NAME;
    init.advdata.include_appearance = false;
    init.advdata.flags = BLE_GAP_ADV_FLAGS_LE_ONLY_LIMITED_DISC_MODE;
    init.advdata.p_service_data_array = NULL;
    init.advdata.service_data_count = 0;
    init.advdata.p_manuf_data = NULL;
    init.advdata.manuf_data_len = 0;
    init.advdata.p_service_uuid_array = NULL;
    init.advdata.service_uuid_count = 0;
    init.advdata.include_ble_version = false;
    init.advdata.p_slave_conn_interval = NULL;

    init.advdata.name_type = BLE_ADVDATA_NO_NAME;
    init.advdata.include_appearance = false;
    init.advdata.p_service_uuid_array = NULL;
    init.advdata.service_uuid_count = 0;

    init.srdata.name_type = BLE_ADVDATA_NO_NAME;
    init.srdata.include_appearance = false;
    init.srdata.p_service_uuid_array = NULL;
    init.srdata.service_uuid_count = 0;

    init.srdata.include_tx_power_level = false;

    ble_advertising_init(&m_advertising, &init);
}

static void advertising_start(void) {
    uint32_t err_code;
    err_code = ble_advertising_start(&m_advertising, BLE_ADV_MODE_FAST);
    APP_ERROR_CHECK(err_code);
}

int main(void) {
    // Initialize the logger.
    NRF_LOG_INIT(NULL);
    NRF_LOG_DEFAULT_BACKENDS_INIT();

    // Initialize BLE stack
    ble_stack_init();

    // Start advertising
    advertising_start();

    for (;;) {
        NRF_LOG_FLUSH();
        __WFE();
    }
}

Credits

1NH21CE005_Adnan_Aadil_Burhan

1NH21CE005_Adnan_Aadil_Burhan

1 project • 1 follower

Comments