LoRa-BLE-Sensor
Loading...
Searching...
No Matches
Functions
ble_sensor_service.c File Reference

This is a library to handle the BLE services for the sensor. It allows for configurations of the sensor, including power configuration, sensor configuration, and data frequency. It also allows for the retrieval of the sensor data. More...

#include "ble_sensor_service.h"
#include <zephyr/bluetooth/bluetooth.h>
#include <zephyr/bluetooth/gatt.h>
#include <zephyr/logging/log.h>
#include "sensor_nvs.h"
#include "sensor_names.h"
Include dependency graph for ble_sensor_service.c:

Functions

 LOG_MODULE_REGISTER (BLE_SENSOR_SERVICE, LOG_LEVEL_DBG)
 
 BT_GATT_SERVICE_DEFINE (sensor_svc, BT_GATT_PRIMARY_SERVICE(BT_UUID_SENSOR), BT_GATT_CHARACTERISTIC(BT_UUID_SENSOR_STATE, BT_GATT_CHRC_READ|BT_GATT_CHRC_WRITE, BT_GATT_PERM_READ|BT_GATT_PERM_WRITE, read_sensor_state, write_sensor_state, NULL), BT_GATT_CHARACTERISTIC(BT_UUID_SENSOR1_ENABLED, BT_GATT_CHRC_READ|BT_GATT_CHRC_WRITE, BT_GATT_PERM_READ|BT_GATT_PERM_WRITE, read_sensor1_enabled, write_sensor1_enabled, NULL), BT_GATT_CHARACTERISTIC(BT_UUID_SENSOR1_CONFIG, BT_GATT_CHRC_READ|BT_GATT_CHRC_WRITE, BT_GATT_PERM_READ|BT_GATT_PERM_WRITE, read_sensor1_config, write_sensor1_config, NULL), BT_GATT_CHARACTERISTIC(BT_UUID_SENSOR1_PWR_CONFIG, BT_GATT_CHRC_READ|BT_GATT_CHRC_WRITE, BT_GATT_PERM_READ|BT_GATT_PERM_WRITE, read_sensor1_pwr_config, write_sensor1_pwr_config, NULL), BT_GATT_CHARACTERISTIC(BT_UUID_SENSOR1_DATA_FREQ, BT_GATT_CHRC_READ|BT_GATT_CHRC_WRITE, BT_GATT_PERM_READ|BT_GATT_PERM_WRITE, read_sensor1_data_freq, write_sensor1_data_freq, NULL), BT_GATT_CHARACTERISTIC(BT_UUID_SENSOR1_DATA, BT_GATT_CHRC_READ, BT_GATT_PERM_READ, read_sensor1_data, NULL, NULL), BT_GATT_CHARACTERISTIC(BT_UUID_SENSOR1_DATA_TIMESTAMP, BT_GATT_CHRC_READ, BT_GATT_PERM_READ, read_sensor1_data_time, NULL, NULL), BT_GATT_CHARACTERISTIC(BT_UUID_SENSOR2_ENABLED, BT_GATT_CHRC_READ|BT_GATT_CHRC_WRITE, BT_GATT_PERM_READ|BT_GATT_PERM_WRITE, read_sensor2_enabled, write_sensor2_enabled, NULL), BT_GATT_CHARACTERISTIC(BT_UUID_SENSOR2_CONFIG, BT_GATT_CHRC_READ|BT_GATT_CHRC_WRITE, BT_GATT_PERM_READ|BT_GATT_PERM_WRITE, read_sensor2_config, write_sensor2_config, NULL), BT_GATT_CHARACTERISTIC(BT_UUID_SENSOR2_PWR_CONFIG, BT_GATT_CHRC_READ|BT_GATT_CHRC_WRITE, BT_GATT_PERM_READ|BT_GATT_PERM_WRITE, read_sensor2_pwr_config, write_sensor2_pwr_config, NULL), BT_GATT_CHARACTERISTIC(BT_UUID_SENSOR2_DATA_FREQ, BT_GATT_CHRC_READ|BT_GATT_CHRC_WRITE, BT_GATT_PERM_READ|BT_GATT_PERM_WRITE, read_sensor2_data_freq, write_sensor2_data_freq, NULL), BT_GATT_CHARACTERISTIC(BT_UUID_SENSOR2_DATA, BT_GATT_CHRC_READ, BT_GATT_PERM_READ, read_sensor2_data, NULL, NULL), BT_GATT_CHARACTERISTIC(BT_UUID_SENSOR2_DATA_TIMESTAMP, BT_GATT_CHRC_READ, BT_GATT_PERM_READ, read_sensor2_data_time, NULL, NULL),)
 
int ble_sensor_service_init (sensor_app_config_t *config)
 Initialize the BLE sensor service.
 

Detailed Description

This is a library to handle the BLE services for the sensor. It allows for configurations of the sensor, including power configuration, sensor configuration, and data frequency. It also allows for the retrieval of the sensor data.

Author
Tyler Garcia
Version
0.1
Date
2025-05-06

Function Documentation

◆ ble_sensor_service_init()

int ble_sensor_service_init ( sensor_app_config_t config)

Initialize the BLE sensor service.

Parameters
configPointer to the sensor app config
Returns
int 0 if successful, < 0 if unsuccessful