Skip to content

Commit

Permalink
RP2040: report battery charge level over BLE [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
Linar Yusupov committed May 13, 2023
1 parent f1b8f82 commit f8b363b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SoftRF       [![Join the chat at https://gitter.im/lyusupov/SoftRF](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/lyusupov/SoftRF?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![Build Status](https://github.com/lyusupov/SoftRF/actions/workflows/main.yml/badge.svg)](https://github.com/lyusupov/SoftRF/actions/workflows/main.yml "Build Status")
# SoftRF       [![Join the chat at https://gitter.im/lyusupov/SoftRF](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/lyusupov/SoftRF?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![Build Status](https://github.com/lyusupov/SoftRF/actions/workflows/main.yml/badge.svg)](https://github.com/lyusupov/SoftRF/actions/workflows/main.yml "Build Status") ![](https://github.com/lyusupov/SoftRF/raw/master/documents/images/radio_day_small.jpg)
DIY, multi-functional, compatible, sub-1 GHz ISM band radio based proximity awareness system for general aviation.

[<img src="https://github.com/lyusupov/SoftRF/raw/master/documents/images/Prime3-banner.jpg">](https://github.com/lyusupov/SoftRF/wiki/Prime-Edition-MkIII)
Expand Down
Binary file added documents/images/radio_day_small.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 6 additions & 2 deletions software/firmware/source/SoftRF/src/driver/Bluetooth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1591,6 +1591,7 @@ IODev_ops_t nRF52_Bluetooth_ops = {
#include "EEPROM.h"
#include "WiFi.h"
#include "Bluetooth.h"
#include "Battery.h"

static bool _running = false;
static mutex_t _mutex;
Expand Down Expand Up @@ -2163,7 +2164,6 @@ static void att_attributes_init(void){
(const uint8_t *) "HMSoft", strlen("HMSoft"));
}

uint8_t _battery = 100; /* TBD */
static unsigned long BLE_Aux_Tx_TimeMarker = 0;

/* ------- BLE END ------ */
Expand Down Expand Up @@ -2241,7 +2241,7 @@ static void CYW43_Bluetooth_setup()
att_server_init(_attdb, NULL, att_write_callback);

// Setup battery service
battery_service_server_init(_battery);
battery_service_server_init((uint8_t) Battery_charge());

static char SerialNum[9];
snprintf(SerialNum, sizeof(SerialNum), "%08X", SoC->getChipId());
Expand Down Expand Up @@ -2305,6 +2305,10 @@ static void CYW43_Bluetooth_loop()
}
BLE_Aux_Tx_TimeMarker = millis();
}

if (isTimeToBattery()) {
battery_service_server_set_battery_value((uint8_t) Battery_charge());
}
break;
case BLUETOOTH_NONE:
case BLUETOOTH_SPP:
Expand Down

0 comments on commit f8b363b

Please sign in to comment.