-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathluis.tbh
100 lines (87 loc) · 3.49 KB
/
luis.tbh
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
'***********************************************************************************************************
' LUIS LIBRARY
'***********************************************************************************************************
'1- debug output in console.
'0- no debug output.
#ifndef LUIS_DEBUG_PRINT
#define LUIS_DEBUG_PRINT 0
#endif
'Name of the LUIS configuration file
'This file must be in your project and contain correct data!
#ifndef LUIS_CONFIG_FILE
#error "please define LUIS_CONFIG_FILE with the name of the LUIS configuration file"
#endif
'Bluetooth RX Buffer
#ifndef LUIS_BT_RX_BUF_SIZE
#define LUIS_BT_RX_BUF_SIZE 5
#endif
'Bluetooth TX Buffer
#ifndef LUIS_BT_TX_BUF_SIZE
#define LUIS_BT_TX_BUF_SIZE 5
#endif
'RST line mapping.
#ifndef LUIS_BT_RST
#define LUIS_BT_RST PL_IO_NUM_51
#endif
'CS line mapping.
#ifndef LUIS_BT_CS
#define LUIS_BT_CS PL_IO_NUM_49
#endif
'DI line mapping.
#ifndef LUIS_BT_DI
#define LUIS_BT_DI PL_IO_NUM_52
#endif
'DO line mapping.
#ifndef LUIS_BT_DO
#define LUIS_BT_DO PL_IO_NUM_50
#endif
'CLK line mapping.
#ifndef LUIS_BT_CLK
#define LUIS_BT_CLK PL_IO_NUM_53
#endif
'Status codes for luis-related operations
enum en_luis_status_codes
EN_LUIS_STATUS_OK, 'Operation completed successfully
EN_LUIS_STATUS_NOT_STARTED, 'luis_start() was not called or failed
EN_LUIS_BT_FAILURE, 'BLE interface failure
EN_LUIS_FILE_HTML_ERROR, 'Failed to open html file
EN_LUIS_FILE_CONFIG_ERROR 'Failed to open configuration file
end enum
'State of html file being sent
enum en_luis_html_send_states
EN_LUIS_HTML_GOP_RESULT,
EN_LUIS_HTML_SEND_PART1,
EN_LUIS_HTML_SEND_CONFIG,
EN_LUIS_HTML_SEND_PART2
end enum
declare function luis_start() as en_luis_status_codes
'Boots the WA2000, enables bluetooth, and sets the advertised name of the device
declare function luis_bt_data_arrival() as en_luis_status_codes
'Parses commands sent by the connected device and processes them<br/>
'currently supports:<br/>
'GOP - get operation mode, returns {type:"SPA", length:file_length}<br/>
'B - Buzzes the device<br/>
'G<settings_name> - gets settings with name<br/>
'S<settings_name> - sets setting with name<br/>
'E - reboots the device<br/>
'I - initializes settings<br/>
declare sub luis_on_bt_data_sent()
'Handles sending the html file to the device
declare sub luis_on_bt_event(bt_event as enum pl_bt_events)
'Callback procedure, call when state of bluetooth changes<br/>
declare sub callback_luis_bt_connected()
'Callback procedure, a device has connected via bluetooth.<br/>
'Procedure body has to be created elsewhere in the project (externally with respect to the library).
declare sub callback_luis_bt_disconnected()
'Callback procedure, a bluetooth device has disconnected.<br/>
'Procedure body has to be created elsewhere in the project (externally with respect to the library).
declare sub callback_luis_bt_enabled()
'Callback procedure, bluetooth has been enabled successfully.<br/>
'bt.enable() is asynchronous so use this to tell if bluetooth has been started successfully<br/>
'Procedure body has to be created elsewhere in the project (externally with respect to the library).
declare sub callback_luis_bt_disabled()
'Callback procedure, bluetooth has been disabled.<br/>
'Procedure body has to be created elsewhere in the project (externally with respect to the library).
declare sub callback_luis_buzz_command()
'Callback procedure, received the "B" buzz command from the connected device.<br/>
'Procedure body has to be created elsewhere in the project (externally with respect to the library).