-
Notifications
You must be signed in to change notification settings - Fork 8
/
main.c
60 lines (53 loc) · 1.67 KB
/
main.c
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
51
52
53
54
55
56
57
58
59
60
#include "iec1107.h"
#include "esp_log.h"
extern export_values_t* export_hdl;
extern const int export_params_size;
static void print_exported_fields()
{
for (int i = 0; i < export_params_size; ++i)
{
ESP_LOGI("Field Tag", "Exported Val %s", export_hdl -> export_holder[i]);
}
}
static void iec1107_event_handler(void* event_handler_arg, esp_event_base_t event_base, int32_t event_id, void* event_data)
{
switch(event_id)
{
case IEC1107_PROTOCOL_ERROR:
ESP_LOGI("Event Handler", "IEC1107_PROTOCOL_ERROR");
break;
case IEC1107_START_MESSAGE_NOT_RECIEVED:
ESP_LOGI("Event Handler", "IEC1107_START_MESSAGE_NOT_RECIEVED");
break;
case IEC1107_START_MESSAGE_NOT_SENDED:
ESP_LOGI("Event Handler", "IEC1107_START_MESSAGE_NOT_SENDED");
break;
case IEC1107_START_MESSAGE_SENDED:
ESP_LOGI("Event Handler", "IEC1107_START_MESSAGE_SENDED");
break;
case IEC1107_START_MESSAGE_RECEIVED:
ESP_LOGI("Event Handler", "SIEC1107_START_MESSAGE_RECEIVED");
break;
case IEC1107_READOUT_MESSAGE_SENDED:
ESP_LOGI("Event Handler", "IEC1107_READOUT_MESSAGE_SENDED");
break;
case IEC1107_READOUT_MESSAGE_NOT_RECEIVED:
ESP_LOGI("Event Handler", "IEC1107_READOUT_MESSAGE_NOT_RECEIVED");
break;
case IEC1107_READOUT_MESSAGE_RECEIVED:
ESP_LOGI("Event Handler", "IEC1107_READOUT_MESSAGE_RECEIVED");
break;
case IEC1107_FIELDS_UPDATED:
print_exported_fields();
ESP_LOGI("Event Handler", "IEC1107_FIELDS_UPDATED");
break;
default:
break;
}
}
void app_main()
{
iec1107_parser_handle_t iec1107 = iec1107_parser_init(LOOP, 10000);
iec1107_parser_add_handler(iec1107, iec1107_event_handler, NULL);
iec1107_start(iec1107);
}