File size: 1,490 Bytes
2b49295
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
604d53b
 
 
 
 
 
 
 
 
2b49295
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include <Arduino.h>

// This header is automatically generated by HEARTFLOW_OS /export_tinyml
// Place the exported model.h file in the src/ directory alongside this main.cpp
#include "model.h"

void setup() {
  Serial.begin(115200);
  while (!Serial);
  
  Serial.println("==========================================");
  Serial.println("HEARTFLOW_OS // EDGE INFERENCE NODE ONLINE");
  Serial.println("==========================================");
  
  // Mock Telemetry Vector
  // Format: [Heart_Rate, SpO2_Level, Systolic_BP, Diastolic_BP, Body_Temp]
  float features[5] = {75.0, 98.0, 120.0, 80.0, 37.0};
  
  Serial.println("Feeding telemetry payload to C-compiled Random Forest...");
  
  unsigned long start_time = micros();
  
  // The predict() function is defined in model.h
  // Returns integer class (e.g., 0 = Healthy, 1 = Heart Disease, etc.)
  int prediction = predict(features);
  
  unsigned long end_time = micros();
  
  Serial.print(">> INFERENCE RESULT: CLASS ");
  Serial.print(prediction);
#ifdef CLASS_NAMES
  if (prediction >= 0 && prediction < N_CLASSES) {
    Serial.print(" (");
    Serial.print(CLASS_NAMES[prediction]);
    Serial.print(")");
  }
#endif
  Serial.println();
  
  Serial.print(">> INFERENCE TIME: ");
  Serial.print(end_time - start_time);
  Serial.println(" microseconds");
}

void loop() {
  // In a real environment, read from physical sensors (MAX30102, MLX90614) here
  // then pass to predict() and emit via BLE or MQTT.
  delay(5000);
}