-
Notifications
You must be signed in to change notification settings - Fork 2
/
bling.vsp.sb
171 lines (141 loc) · 6.62 KB
/
bling.vsp.sb
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
'******************************************************************************
' @brief
' Velo Bling-Bling smartBASIC BL652 application
'
' BLE Cycling Speed and Cadence Profile Server (peripheral role)
' Smart Phone <-Central-BLE-Peripheral-> BL652 CSC Server <-Master I2C Slave-> uC
'
' vSP Bridge Mode for Command Line Interface
' Smart Phone <-Central-BLE-Peripheral-> BL652 vSP <-UART-> uC (Bling)
'
' Advertice following services:
' 0x180A Device Information
' 0x180F Battery Service
' 0x1816 Cycling Speed and Cadence
' 569a1101-b87f-490c-92cb-11ba5ea5167c vSP
'
' Appearence 0x2A01: 1154 Cycling Speed Sensor
' Writable GAP Device Name characteristic
'
' Advertising interval (CSC Profile)
' 30 ms to 60 ms (fast connection, first 30 s)
' 1 to 1.2 s (reduced power, after 30 s)
'
' @file
' bling.vsp.sb
' @author
' Peter Schmid, [email protected]
' @date
' 2014-05-14
' @remark
' Language: smartBASIC 1.8.88.0, LAIRD BL600/BL652 Module
' Example : BleVSpUartBridge.sb (See in BL600CodeSnippets.zip)
' upass.vsp.sb
' @version
' 2.5
' @copyright
' Peter Schmid, Switzerland
'
' This file is part of "Velo Bling-Bling" BLE application software.
'
' "Velo Bling-Bling" software is free software: you can redistribute it
' and/or modify it under the terms of the GNU General Public License as
' published by the Free Software Foundation, either version 3 of the
' License, or (at your option) any later version.
'
' "Velo Bling-Bling" is distributed in the hope that it will be useful,
' but WITHOUT ANY WARRANTY; without even the implied warranty of
' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
' GNU General Public License for more details.
'
' You should have received a copy of the GNU General Public License along
' with "Velo Bling-Bling". If not, see <http://www.gnu.org/licenses/>.
'
'******************************************************************************
'******************************************************************************
' Definitions
'******************************************************************************
' Set this to 0 to disable all debugging messages
#define ENABLE_DEBUG_PRINTS 0
#define DEVICENAME "VeloBling"
#define DEVICENAME_WRITABLE 1
'#define APPEARANCE BLE_APPEARANCE_GENERIC_TAG
' Cycling: Speed Sensor
#define APPEARANCE 1154
#define MANF_NAME "spyr"
#define MODELSTR "Velo Bling-Bling"
#define SERIALNUM "12345"
#define HWREV "2.3"
#define SWREV "2.5"
'#define SYSID ""
'#define REGLIST ""
'#define PNPID ""
#define SYSID "@"
'#define SYSID "\01\02\03\04\05\06\07\08"
#define REGLIST "\DE\AD\C0\DE"
#define PNPID "\01\04\BF\03\20\00\01"
#define CHAR_CR 13
' Minimum acceptable connection interval (7.5ms)
#define MIN_CONN_INTERVAL 7500
' Maximum acceptable connection interval (1 second).
#define MAX_CONN_INTERVAL 1000000
' Slave latency -- number of conn events that can be missed
' Effective Conn interval will be (SLAVE_LATENCY+1)*ACTUAL_CONN_INTERVAL
#define SLAVE_LATENCY 0
' Connection supervisory timeout (4 seconds) - max 32 seconds
'#define CONN_SUP_TIMEOUT 500000
#define CONN_SUP_TIMEOUT 10000000
' DiscoverableMode, set to BLE_DISCOVERABILITY_xxx
#define DISCOVERY_MODE BLE_DISCOVERABILITY_GENERAL
#define MAX_DEVNAME_CHRS 12
' Set Appearance advertise 0 to suppress
'#define ADV_APPEARANCE 0
#define ADV_APPEARANCE 1
' Advertise interval
#define ADV_INTERVAL_MS 500
' Advertise timeout
#define ADV_TIMEOUT_MS 0
' Whitelist Policy in Adverts
'#define ADV_WHITELIST_FILTER_POLICY ADV_FILTERPOLICY_BOTH
#define ADV_WHITELIST_FILTER_POLICY ADV_FILTERPOLICY_ANY
' Minimum long term key size in octets
#define MIN_LTK_SIZE 8
' Maximum long term key size in octets
#define MAX_LTK_SIZE 16
' Set this to non-zero to enable notiy on batt service
#define BATT_NOTIFY 0
#define BATT_INIT_LEVEL_PERC 100
' This sets the pairing i/p capability using bonding
' None also known as ‘Just Works’ (unauthenticated pairing)
#define PAIRING_IOCAPABILITY BLE_IOCAPABILITY_NONE
' Connection Update Negotiation paramters
#define FIRST_CONN_PARAMS_UPDATE_DELAY 5000
#define NEXT_CONN_PARAMS_UPDATE_DELAY 5000
#define MAX_CONN_PARAMS_UPDATE_DELAY 15000
' I/O Definitions
#define I2C_DATA_READY 25
#define DIGITAL_IN 1
#define DIGITAL_OUT 2
#define ANALOG_IN 3
#define PULL_DOWN_WEAK 1
#define PULL_UP_WEAK 2
#define PULL_DOWN_STRONG 3
#define PULL_UP_STRONG 4
#define LOW_TO_HIGH 0
#define HIGH_TO_LOW 1
#define DVK_BUTTON0 16
#define DVK_BUTTON1 17
#define DVK_LED0 18
#define DVK_LED1 19
'******************************************************************************
' Library Import
'******************************************************************************
#include "lib\vsp.csc.sblib"
'******************************************************************************
' Equivalent to main() in C
'******************************************************************************
'------------------------------------------------------------------------------
' Wait for a synchronous event.
' An application can have multiple <WaitEvent> statements
'------------------------------------------------------------------------------
WaitEvent