Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
f98272e
src/time_sync: proof of concept implementation of time sync using cts
DennisMoschina Dec 3, 2025
b31f857
prj.conf, prj_fota.conf: enabled configurations for CTS
DennisMoschina Dec 3, 2025
8bc5167
CMakeLists.txt: added time_sync module
DennisMoschina Dec 3, 2025
aeadc19
unicast_server/main.cpp: init time_sync
DennisMoschina Dec 3, 2025
3c10f55
first sensor check
hith-1801 Dec 4, 2025
887299f
src/time_sync: implemented custom time sync service
DennisMoschina Dec 5, 2025
ecd0b98
prj.conf, prj_fota.conf: removed unused configurations for CTS
DennisMoschina Dec 5, 2025
b19d6b3
src/time_sync/README.md: added documentation for time syncing
DennisMoschina Dec 5, 2025
10c618b
unicast_server/main.cpp: added default implementation for oe_micros
DennisMoschina Dec 6, 2025
0b15138
include/openearable_common.h: use custom implementation for micros()
DennisMoschina Dec 6, 2025
f88f46f
src/time_sync: send current time instead of time since boot, receive …
DennisMoschina Dec 6, 2025
9cfc44b
include/openearable_common.h: made oe_micros available to c++
DennisMoschina Dec 8, 2025
aaa67ab
unicast_server/main.cpp: removed default implementation of oe_micros()
DennisMoschina Dec 8, 2025
dd67f8b
draft: decimation filter
Dec 9, 2025
f6359d2
draft: decimation filter q15
Dec 10, 2025
96f1ac9
draft: fix coefficients
Dec 10, 2025
97c3bb3
draft: f32 for stereo
Dec 10, 2025
a9c7ddd
draft: cascaded decimator
Dec 10, 2025
d2c8296
draft: enable downsampling make configurable via App
Dec 10, 2025
3c438e4
draft: no decimator option
Dec 10, 2025
b9d0edf
fix decimation factor 1
Dec 11, 2025
159bb83
draft: play multitone on startup
Dec 11, 2025
9822ce8
start recording on multitone
Dec 11, 2025
1d4dd63
stop micro correctly
Dec 11, 2025
aedb6d7
draft: rfft
Dec 12, 2025
7a40dc5
seal check quality measure prototype
Dec 12, 2025
24afd1a
implement gatt service
Dec 12, 2025
f45f039
improved seal index
Dec 13, 2025
dc1d2d3
Merge branch 'time_sync' into seal-check
Dec 13, 2025
ac63123
seal check without sd card
Dec 13, 2025
cec61e9
fix: seal check without sd
Dec 14, 2025
18956f3
move seal check to separate file
Dec 14, 2025
e78fe40
remove multitone and add buffer playback
Dec 14, 2025
5b06b07
clean up
Dec 14, 2025
304c392
The default ids and frequency rates for the senscheck
hith-1801 Dec 14, 2025
3ccd8a7
The default ids and frequency rates for the senscheck with a correction.
hith-1801 Dec 14, 2025
c258ec7
fix: sd card crash at the end of the recording
Dec 16, 2025
eda0c5a
draft: decimation filter
Dec 9, 2025
0ba2b24
draft: decimation filter q15
Dec 10, 2025
a61d965
draft: fix coefficients
Dec 10, 2025
24bebd2
draft: f32 for stereo
Dec 10, 2025
6b76a84
draft: cascaded decimator
Dec 10, 2025
a53d779
draft: enable downsampling make configurable via App
Dec 10, 2025
f643bed
draft: no decimator option
Dec 10, 2025
817bd35
fix decimation factor 1
Dec 11, 2025
467fab0
draft: play multitone on startup
Dec 11, 2025
6dc3da4
start recording on multitone
Dec 11, 2025
9bf29a5
stop micro correctly
Dec 11, 2025
16582d5
draft: rfft
Dec 12, 2025
e6c7b2a
seal check quality measure prototype
Dec 12, 2025
b37a0ab
implement gatt service
Dec 12, 2025
616603b
improved seal index
Dec 13, 2025
efa2880
seal check without sd card
Dec 13, 2025
bdab276
fix: seal check without sd
Dec 14, 2025
d9d1b5d
move seal check to separate file
Dec 14, 2025
4be925f
remove multitone and add buffer playback
Dec 14, 2025
9c1675b
clean up
Dec 14, 2025
de5b7ca
fix: sd card crash at the end of the recording
Dec 16, 2025
2b81638
fix: add mutex to decimator to prevent crash at end of recording
Dec 22, 2025
d3f11d7
remove test tone
Dec 22, 2025
e8ae7b2
sampleratevalidation in works
hith-1801 Jan 12, 2026
0de4f7a
just small
hith-1801 Jan 14, 2026
2cc9285
Samplerate check complete
hith-1801 Jan 18, 2026
bb70acb
Merge branch 'seal-check' of https://github.com/OpenEarable/open-eara…
Jan 25, 2026
44c0f17
sine_wavechck test
hith-1801 Feb 15, 2026
45da68a
sine_wave
hith-1801 Feb 15, 2026
d538418
sine_wave-test complete
hith-1801 Feb 16, 2026
fd3a208
seal check merged
hith-1801 Feb 16, 2026
ad2fa9c
sine-wave-test amp
hith-1801 Feb 16, 2026
dabbfd7
Sensor-check and speaker polarity check complete
hith-1801 Feb 16, 2026
1e403a4
Gyro issue fixed
hith-1801 Mar 9, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions include/openearable_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,14 @@ struct sensor_config {
uint8_t storageOptions;
} __attribute__((packed));

struct seal_check_data {
uint8_t version;
uint8_t quality;
uint8_t mean_magnitude;
uint8_t num_peaks;
uint16_t frequencies[9]; // 12.4 fixed point
uint16_t magnitudes[9];
} __attribute__((packed));

struct battery_settings {
float u_nominal;
Expand Down
9 changes: 9 additions & 0 deletions prj.conf
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ CONFIG_SFLOAT=y

CONFIG_FPU=y

CONFIG_CMSIS_DSP=y
CONFIG_CMSIS_DSP_TRANSFORM=y
CONFIG_CMSIS_DSP_COMPLEXMATH=y

CONFIG_NEWLIB_LIBC=y
CONFIG_NEWLIB_LIBC_FLOAT_PRINTF=y
CONFIG_NEWLIB_LIBC_FLOAT_SCANF=y
Expand Down Expand Up @@ -182,6 +186,11 @@ CONFIG_FS_FATFS_EXFAT=y # Enable exFAT support

CONFIG_FDSP=y

# CMSIS-DSP Configuration
CONFIG_CMSIS_DSP=y
CONFIG_CMSIS_DSP_TRANSFORM=y
CONFIG_CMSIS_DSP_COMPLEXMATH=y

CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=4096

#CONFIG_USB_MASS_STORAGE=y
Expand Down
4 changes: 4 additions & 0 deletions prj_fota.conf
Original file line number Diff line number Diff line change
Expand Up @@ -261,3 +261,7 @@ CONFIG_MCUMGR_GRP_OS_RESET_HOOK=y
#CONFIG_MCUMGR_GRP_SETTINGS_ACCESS_HOOK=y

CONFIG_SETUP_FUEL_GAUGE=y

CONFIG_CMSIS_DSP=y
CONFIG_CMSIS_DSP_TRANSFORM=y
CONFIG_CMSIS_DSP_COMPLEXMATH=y
8 changes: 0 additions & 8 deletions src/Battery/BQ25120a.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,10 +243,8 @@ uint8_t BQ25120a::write_LDO_voltage_control(float volt) {

readReg(registers::LS_LDO_CTRL, &status, sizeof(status));

//status |= (((uint16_t)((volt - 0.8) * 10)) & 0x1F) << 2;
status &= 1 << 7;
status |= ((uint8_t)((volt - 0.8f) * 10 + EPS)) << 2;
//status |= 1 << 7;

writeReg(registers::LS_LDO_CTRL, &status, sizeof(status));

Expand Down Expand Up @@ -292,8 +290,6 @@ chrg_state BQ25120a::read_termination_control() {

struct chrg_state chrg;

// if (!ret) printk("failed to read\n");

chrg.enabled = status & 0x2;
//chrg.high_impedance = status & 0x1;

Expand Down Expand Up @@ -343,8 +339,6 @@ ilim_uvlo BQ25120a::read_uvlo_ilim() {

bool ret = readReg(registers::ILIM_UVLO, (uint8_t *) &status, sizeof(status));

// if (!ret) printk("failed to read\n");

param.uvlo_v = CLAMP(3.0f- 0.2f * ((status & 0x7) - 2), 2.2, 3.0);
param.lim_mA = 50.f + 50.f * ((status >> 3) & 0x7);

Expand Down Expand Up @@ -410,8 +404,6 @@ button_state BQ25120a::read_button_state() {
uint8_t status = 0;
bool ret = readReg(registers::BTN_CTRL, (uint8_t *) &status, sizeof(status));

// if (!ret) printk("failed to read\n");

btn.wake_1 = status & 0x2;
btn.wake_2 = status & 0x1;

Expand Down
24 changes: 2 additions & 22 deletions src/Battery/PowerManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,7 @@ int PowerManager::power_down(bool fault) {
ret = pm_device_action_run(ls_sd, PM_DEVICE_ACTION_SUSPEND);
ret = pm_device_action_run(ls_3_3, PM_DEVICE_ACTION_SUSPEND);
ret = pm_device_action_run(ls_1_8, PM_DEVICE_ACTION_SUSPEND);
ret = pm_device_action_run(cons, PM_DEVICE_ACTION_SUSPEND);
ret = pm_device_action_run(cons, PM_DEVICE_ACTION_SUSPEND);

/*const struct device *const i2c = DEVICE_DT_GET(DT_NODELABEL(i2c1));
ret = pm_device_action_run(i2c, PM_DEVICE_ACTION_SUSPEND);
Expand Down Expand Up @@ -666,27 +666,7 @@ void PowerManager::charge_task() {
battery_controller.enable_charge();
}

//if (last_charging_state != charging_state || ) {
k_work_submit(&fuel_gauge_work);
//state_inidicator.set_state()
/*switch (charging_state) {
case 0:
LOG_INF("charging state: ready");
break;
case 1:
LOG_INF("charging state: charging");
break;
case 2:
LOG_INF("charging state: done");
break;
case 3:
LOG_WRN("charging state: fault");

//battery_controller.setup(_battery_settings);

break;
}*/
//}
k_work_submit(&fuel_gauge_work);

last_charging_state = charging_state;
}
Expand Down
6 changes: 3 additions & 3 deletions src/ParseInfo/DefaultSensors.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,8 @@ SensorScheme defaultSensors[SENSOR_COUNT] = {
.availableOptions = DATA_STORAGE | FREQUENCIES_DEFINED, // no streaming
.frequencyOptions = {
.frequencyCount = sizeof(Microphone::sample_rates.reg_vals),
.defaultFrequencyIndex = 1,
.maxBleFrequencyIndex = 1,
.defaultFrequencyIndex = 0,
.maxBleFrequencyIndex = 0,
.frequencies = Microphone::sample_rates.sample_rates,
},
},
Expand All @@ -159,7 +159,7 @@ SensorScheme defaultSensors[SENSOR_COUNT] = {
.availableOptions = DATA_STREAMING | DATA_STORAGE | FREQUENCIES_DEFINED,
.frequencyOptions = {
.frequencyCount = sizeof(PPG::sample_rates.reg_vals),
.defaultFrequencyIndex = 2,
.defaultFrequencyIndex = 1,
.maxBleFrequencyIndex = 12,
.frequencies = PPG::sample_rates.sample_rates,
},
Expand Down
2 changes: 1 addition & 1 deletion src/ParseInfo/ParseType.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ enum ParseType {
PARSE_TYPE_DOUBLE,
};

const int parseTypeSizes[] = {
static const int parseTypeSizes[] = {
1, // PARSE_TYPE_INT8
1, // PARSE_TYPE_UINT8

Expand Down
20 changes: 12 additions & 8 deletions src/SD_Card/SDLogger/SDLogger.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,6 @@ static_assert(BUFFER_SIZE % SD_BLOCK_SIZE == 0, "BUFFER_SIZE must be a multiple

// Singleton pattern
class SDLogger {
protected:
// Add static instance pointer for work handler
//static SDLogger* instance_ptr;
//friend void sd_work_handler(struct k_work* work);

private:

SDCardManager* sd_card = nullptr;
Expand Down Expand Up @@ -80,14 +75,23 @@ class SDLogger {
*/
int write_sensor_data(const void* const* data_blocks, const size_t* lengths, size_t block_count);

/**
* @brief Write a single sensor_data message to the log file
* @param msg The sensor_data message to write
* @return 0 on success, negative error code on failure
*/
int write_sensor_data(const sensor_data& msg);

/**
* @brief End logging and close the current file
* @return 0 on success, negative error code on failure
*/
* @brief End logging and close the current file
* @return 0 on success, negative error code on failure
*/
int end();

/**
* @brief Check if the logger is currently recording
* @return true if active, false otherwise
*/
bool is_active();

SDLogger(SDLogger const&) = delete;
Expand Down
4 changes: 2 additions & 2 deletions src/SensorManager/IMU.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ bool IMU::init(struct k_msgq * queue) {
}

imu.setAccelRange(eAccelRange_2G);

imu.setGyroRange(eGyroRange_500DPS);
sensor_queue = queue;

k_work_init(&sensor.sensor_work, update_sensor);
Expand All @@ -89,7 +89,7 @@ void IMU::start(int sample_rate_idx) {
k_timeout_t t = K_USEC(1e6 / sample_rates.true_sample_rates[sample_rate_idx]);

imu.setAccelODR(sample_rates.reg_vals[sample_rate_idx]);

imu.setGyroODR(sample_rates.reg_vals[sample_rate_idx]);
_running = true;

k_timer_start(&sensor.sensor_timer, K_NO_WAIT, t);
Expand Down
19 changes: 12 additions & 7 deletions src/SensorManager/Microphone.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,18 @@ extern void empty_fifo();
#endif

#include <zephyr/logging/log.h>
//LOG_MODULE_DECLARE(BMX160);
LOG_MODULE_REGISTER(microphone, CONFIG_LOG_DEFAULT_LEVEL);

extern struct data_fifo fifo_rx;

Microphone Microphone::sensor;

const SampleRateSetting<1> Microphone::sample_rates = {
{ 0 },
const SampleRateSetting<9> Microphone::sample_rates = {
{ 1, 2, 3, 4, 6, 8, 12, 16, 24 },

{ 48000 },
{ 48000, 24000, 16000, 12000, 8000, 6000, 4000, 3000, 2000 },

{ 48000.0 }
{ 48000.0, 24000.0, 16000.0, 12000.0, 8000.0, 6000.0, 4000.0, 3000.0, 2000.0 }
};

bool Microphone::init(struct k_msgq * queue) {
Expand All @@ -55,16 +54,20 @@ bool Microphone::init(struct k_msgq * queue) {
}

void Microphone::start(int sample_rate_idx) {
ARG_UNUSED(sample_rate_idx);
//ARG_UNUSED(sample_rate_idx);

int ret;

if (!_active) return;

record_to_sd(true);
LOG_INF("Starting Microphone at %d Hz", sample_rates.sample_rates[sample_rate_idx]);

audio_datapath_aquire(&fifo_rx);

audio_datapath_decimator_init(sample_rates.reg_vals[sample_rate_idx]);

record_to_sd(true);

_running = true;
}

Expand All @@ -78,5 +81,7 @@ void Microphone::stop() {

audio_datapath_release();

//audio_datapath_decimator_cleanup();

_running = false;
}
2 changes: 1 addition & 1 deletion src/SensorManager/Microphone.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class Microphone : public EdgeMlSensor {
void start(int sample_rate_idx) override;
void stop() override;

const static SampleRateSetting<1> sample_rates;
const static SampleRateSetting<9> sample_rates;
private:
bool _active = false;
};
Expand Down
Loading