Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
protocentralashwin committed Nov 13, 2024
2 parents e688f17 + b78a7f9 commit d4c8609
Show file tree
Hide file tree
Showing 27 changed files with 189 additions and 229 deletions.
Binary file modified .DS_Store
Binary file not shown.
2 changes: 2 additions & 0 deletions app/src/ble_module.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ void ble_resp_rate_notify(uint16_t resp_rate);
void ble_ecg_notify(int32_t *ecg_data, uint8_t len);
void ble_ppg_notify(int16_t ppg_data);
void ble_bioz_notify(int32_t *resp_data, uint8_t len);
void healthypi5_service_send_data(const uint8_t *data, uint16_t len);

10 changes: 5 additions & 5 deletions app/src/cmd_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ void ces_parse_packet(char rxch)

void hpi_decode_data_packet(uint8_t *in_pkt_buf, uint8_t pkt_len)
{
int rc;
//int rc;
uint8_t cmd_cmd_id = in_pkt_buf[0];

// printk("Recd Command: %X\n", cmd_cmd_id);
Expand Down Expand Up @@ -353,11 +353,11 @@ void cmd_serial_cb(const struct device *dev, void *user_data)
}
*/

static void cmd_init(void)
/*static void cmd_init(void)
{
printk("CMD Module Init\n");
/*if (!device_is_ready(esp_uart_dev))
if (!device_is_ready(esp_uart_dev))
{
printk("UART device not found!");
return;
Expand All @@ -382,8 +382,8 @@ static void cmd_init(void)
return;
}
uart_irq_rx_enable(esp_uart_dev);
*/
}
}*/

/*void cmd_thread(void)
{
Expand Down
9 changes: 6 additions & 3 deletions app/src/cmd_module.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,13 @@
void cmdif_send_ble_progress(uint8_t m_stage, uint16_t m_total_time, uint16_t m_curr_time, uint16_t m_current, uint16_t m_imped);
void cmdif_send_ble_command(uint8_t m_cmd);
void cmdif_send_ble_device_status_response(void);

//void cmdif_send_ble_data(const char *buf, size_t len);
void cmdif_send_ble_file_data(int8_t *m_data, uint8_t m_data_len);
//void cmdif_send_ble_file_data(uint8_t *m_data, uint32_t number_writes,uint8_t m_data_len);
void cmdif_send_memory_status(uint8_t m_cmd);
void cmdif_send_session_count(uint8_t m_cmd,uint8_t indication);
void cmdif_send_ble_session_data(int8_t *m_data, uint8_t m_data_len);
void cmdif_send_ble_data_idx(uint8_t *m_data, uint8_t m_data_len);



enum cmdsm_state
{
Expand Down
56 changes: 21 additions & 35 deletions app/src/data_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
LOG_MODULE_REGISTER(data_module, CONFIG_SENSOR_LOG_LEVEL);

#ifdef CONFIG_HEALTHYPI_DISPLAY_ENABLED
#include "display_module.h"`
#include "display_module.h"
#endif

#include "fs_module.h"
Expand Down Expand Up @@ -67,16 +67,20 @@ const uint8_t hpi_ov3_packet_footer[2] = {0, CES_CMDIF_PKT_STOP};
uint8_t hpi_ov3_ecg_bioz_data[HPI_OV3_DATA_ECG_BIOZ_LEN];
uint8_t hpi_ov3_ppg_data[HPI_OV3_DATA_PPG_LEN];

/*extern bool settings_send_usb_enabled;
extern bool settings_send_ble_enabled;
extern bool settings_send_display_enabled;*/

static bool settings_send_usb_enabled = true;
static bool settings_send_ble_enabled = true;
static bool settings_send_display_enabled = true;
static bool settings_send_rpi_uart_enabled = false;
static bool settings_plot_enabled = true;

extern bool settings_log_data_enabled; // true;
extern bool sd_card_present;
extern struct fs_mount_t *mp_sd;
extern struct hpi_log_session_header_t hpi_log_session_header;
static int settings_data_format = DATA_FMT_HPI5_OV3; // DATA_FMT_PLAIN_TEXT;

// struct hpi_sensor_data_t log_buffer[LOG_BUFFER_LENGTH];
struct hpi_sensor_logging_data_t log_buffer[LOG_BUFFER_LENGTH];
Expand Down Expand Up @@ -254,7 +258,7 @@ void send_ecg_bioz_data_ov3_format(int32_t *ecg_data, int32_t ecg_sample_count,
}
}*/

void send_data_text(int32_t ecg_sample, int32_t bioz_samples, int32_t raw_red)
/*void send_data_text(int32_t ecg_sample, int32_t bioz_samples, int32_t raw_red)
{
char data[100];
float f_ecg_sample = (float)ecg_sample / 1000;
Expand All @@ -281,7 +285,7 @@ void send_data_text_1(int32_t in_sample)
sprintf(data, "%.3f\r\n", (double)f_in_sample);
send_usb_cdc(data, strlen(data));
}
}*/

// Start a new session log
void flush_current_session_logs()
Expand Down Expand Up @@ -424,30 +428,20 @@ void data_thread(void)
{
printk("Data Thread starting\n");

struct hpi_sensor_data_t sensor_sample;
struct hpi_computed_data_t computed_data;

struct hpi_ecg_bioz_sensor_data_t ecg_bioz_sensor_sample;
struct hpi_ppg_sensor_data_t ppg_sensor_sample;

// record_init_session_log();

int m_temp_sample_counter = 0;

uint32_t irBuffer[500]; // infrared LED sensor data
uint32_t redBuffer[500]; // red LED sensor data

float ecg_filt_in[8];
float ecg_filt_out[8];

int32_t bufferLength; // data length
int32_t m_spo2; // SPO2 value
int8_t validSPO2; // indicator to show if the SPO2 calculation is valid
int32_t m_hr; // heart rate value
int8_t validHeartRate; // indicator to show if the heart rate calculation is valid

uint32_t ppg_buffer_count = 0;

uint32_t spo2_time_count = 0;

/* Initialize the FIR filter */
Expand Down Expand Up @@ -475,20 +469,6 @@ void data_thread(void)
// Get Sample from ECG / BioZ sampling queue
if (k_msgq_get(&q_ecg_bioz_sample, &ecg_bioz_sensor_sample, K_NO_WAIT) == 0)
{
// printk("S: %d", ecg_bioz_sensor_sample.ecg_num_samples);

/*for (int i = 0; i < ecg_bioz_sensor_sample.ecg_num_samples; i++)
{
ecg_filt_in[i] = (float)(ecg_bioz_sensor_sample.bioz_samples[i]/1000.0000 );
}
arm_fir_f32(&sFIR, ecg_filt_in, ecg_filt_out, BLOCK_SIZE);
for (int i = 0; i < ecg_bioz_sensor_sample.ecg_num_samples; i++)
{
ecg_bioz_sensor_sample.bioz_samples[i] = (int32_t)(ecg_filt_out[i] * 1000.0000);
}*/

int16_t resp_i16_buf[4];
int16_t resp_i16_filt_out[4];

Expand Down Expand Up @@ -523,7 +503,7 @@ void data_thread(void)
// #endif

#ifdef CONFIG_HEALTHYPI_DISPLAY_ENABLED
if (settings_plot_enabled)
if (settings_plot_enabled && settings_send_display_enabled)
{
k_msgq_put(&q_plot_ecg_bioz, &ecg_bioz_sensor_sample, K_NO_WAIT);
}
Expand All @@ -547,7 +527,7 @@ void data_thread(void)
// #endif

#ifdef CONFIG_HEALTHYPI_DISPLAY_ENABLED
if (settings_plot_enabled)
if (settings_plot_enabled && settings_send_display_enabled)
{
k_msgq_put(&q_plot_ppg, &ppg_sensor_sample, K_NO_WAIT);
}
Expand Down Expand Up @@ -575,21 +555,27 @@ void data_thread(void)
if (validSPO2)
{
#ifdef CONFIG_HEALTHYPI_DISPLAY_ENABLED
hpi_scr_home_update_spo2(m_spo2);
if (settings_send_display_enabled)
{
hpi_scr_home_update_spo2(m_spo2);
}
#endif
// #ifdef CONFIG_BT
ble_spo2_notify(m_spo2);
if (settings_send_ble_enabled)
{
ble_spo2_notify(m_spo2);
}

if (settings_send_usb_enabled)
{
spo2_serial = m_spo2;
}
// #endif
}

if (validHeartRate)
{
#ifdef CONFIG_HEALTHYPI_DISPLAY_ENABLED
hpi_scr_home_update_pr(m_hr);
if (settings_send_display_enabled)
hpi_scr_home_update_pr(m_hr);
#endif
}

Expand Down
4 changes: 3 additions & 1 deletion app/src/data_module.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,6 @@ struct hpi_computed_data_t {
int32_t spo2;
uint8_t hr_valid;
uint8_t spo2_valid;
};
};

void flush_current_session_logs(void);
35 changes: 5 additions & 30 deletions app/src/datalog_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ void hpi_get_session_count(void)
if (res)
{
printk("Error opening dir %s [%d]\n", path, res);
return res;
//return res;
}

for (;;)
Expand Down Expand Up @@ -277,7 +277,7 @@ void hpi_get_session_index(void)
if (res)
{
printk("Error opening dir %s [%d]\n", path, res);
return res;
//return res;
}

for (;;)
Expand All @@ -298,8 +298,7 @@ void hpi_get_session_index(void)

if (entry.type != FS_DIR_ENTRY_DIR)
{
char session_header[80];

//char session_header[80];

hpi_log_session_header.session_id =(uint16_t)atoi(entry.name);
hpi_log_session_header.session_size = (uint32_t)entry.size;
Expand Down Expand Up @@ -379,10 +378,10 @@ uint32_t hpi_log_session_get_length(char *m_file_name)
void hpi_session_fetch(uint16_t session_id,uint8_t file_no)
{
int8_t m_buffer[FILE_TRANSFER_BLE_PACKET_SIZE];
char m_session_id[20];
//char m_session_id[20];
char m_session_name[30];
char m_session_path[50] = "/SD:/";
char m_session_file_type[4];
char m_session_file_type[5];

if (file_no == 1)
strcpy(m_session_file_type, "ECG");
Expand Down Expand Up @@ -502,7 +501,6 @@ void hpi_datalog_delete_all(void)

void hpi_datalog_delete_session(uint16_t session_id,uint8_t file_no)
{
int res;
struct fs_dir_t dir;
fs_dir_t_init(&dir);

Expand All @@ -519,29 +517,6 @@ void hpi_datalog_delete_session(uint16_t session_id,uint8_t file_no)

snprintf(session_name, sizeof(session_name), "/SD:/%d_%s.CSV", session_id,m_session_file_type);
fs_unlink(session_name);
/*res = fs_opendir(&dir, "/SD:/");
if (res)
{
printk("Unable to open (err %d)", res);
}
while (1)
{
struct fs_dirent entry;
res = fs_readdir(&dir, &entry);
if (res)
{
printk("Unable to read directory");
break;
}
if (strcmp(session_name, entry.name) == 0)
{
fs_unlink(entry.name);
}
}
fs_closedir(&dir);*/
printk("%s\n",session_name);

}
Expand Down
8 changes: 7 additions & 1 deletion app/src/datalog_module.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,13 @@ struct hpi_log_session_header_t
struct healthypi_time_t session_start_time;
};

void hpi_datalog_start_session(in_pkt_buf);
void hpi_datalog_start_session(uint8_t *in_pkt_buf);
void hpi_session_fetch(uint16_t session_id,uint8_t file_no);
void hpi_get_session_count(void);
void hpi_log_session_write_file();
void hpi_datalog_delete_session(uint16_t session_id,uint8_t file_no);
void hpi_datalog_delete_all(void);
void hpi_get_session_index(void);



Loading

0 comments on commit d4c8609

Please sign in to comment.