Changes between Version 1 and Version 2 of wireless/bleproject
- Timestamp:
- 07/09/2020 09:20:58 PM (4 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
wireless/bleproject
v1 v2 1 1 = BLE Demonstration 2 [[PageOutline]] 2 3 = Bluetooth 5 and BLE = 3 4 == Introduction == … … 13 14 its predecessors. 14 15 15 To read more about Bluetooth 5, view the following link: 16 https://www.bluetooth.com/blog/exploring-bluetooth-5-going-the-distan 17 ce/ 18 19 To look further in depth at how Bluetooth 5 accomplishes these 20 improvements, look at the following link: 21 https://e2e.ti.com/blogs_/b/process/archive/2017/01/30/how-does-bluet 22 ooth-5-increase-the-achievable-range-of-a-bluetooth-low-energy-connec 23 tion 16 To read more about Bluetooth 5, view the following link:\\ 17 https://www.bluetooth.com/blog/exploring-bluetooth-5-going-the-distance/ 18 19 To look further in depth at how Bluetooth 5 accomplishes these improvements, look at the following link:\\ 20 https://e2e.ti.com/blogs_/b/process/archive/2017/01/30/how-does-bluetooth-5-increase-the-achievable-range-of-a-bluetooth-low-energy-connection 24 21 25 22 '''The Bluetooth Core Spec''' … … 31 28 32 29 This spec details every operation available to Bluetooth developers. 33 Some important sections for Bluetooth development using GateWorks 34 boards include the following:30 31 Some important sections for Bluetooth development using Gateworks boards include the following: 35 32 * ''Vol 4, Part E'': Host Controller Interface (HCI) Functional Spec (p.1794) - Describes the command interface to a Bluetooth Controller 36 33 * ''5.4.1'': HCI Command Packet Descriptions (p.1890) – Command descriptions and packet formats to send to the controller … … 113 110 114 111 == Connecting GW16126 With Devices Using Bluez == 112 115 113 '''Initial Setup''' 116 Follow the setup instructions for the GW16126 u-blox BLE module to 117 setup the module as an available Bluetooth Interface. This can be 118 found at: 119 http://trac.gateworks.com/wiki/expansion/gw16126#BluetoothHCIGW16126 114 115 Follow the setup instructions for the GW16126 u-blox BLE module to setup the module as an available Bluetooth 116 Interface. This can be found at: [wiki:expansion/gw16126#BluetoothHCIGW16126] 120 117 121 118 '''Bluez Configuration''' 122 119 123 Before continuing, you may want to edit your 124 {{{ 125 /etc/bluetooth/main.conf 126 }}} 127 file to the desired values. It is recommended that you set the DiscoverableTimeout and PairableTimeout to 0 to disable them for testing purposes. 120 Before continuing, you may want to edit your {{{/etc/bluetooth/main.conf}}} file to the desired values. It is recommended that you set the !DiscoverableTimeout and !PairableTimeout to 0 to disable them for testing purposes. 128 121 129 122 === Setting Up a Connection === 130 123 '''Using bluetoothctl''' 131 124 1. Start {{{bluetoothctl}}} 132 If your controller is set up properly, the first thing to display should be the MAC address of your Bluetooth controller. Bluetoothctl will then provide a prompt {{{[bluetooth]# }}} 133 134 2. Run {{{show}}} This should list the configuration information for your Bluetooth controller. 135 3. Run {{{devices}}} This provides the user with a list of available devices. If you have not scanned yet, this list may be empty except for your own Bluetooth controller. 136 4. To enable the controller and prepare for pairing with a device, run the following: 125 1. If your controller is set up properly, the first thing to display should be the MAC address of your Bluetooth controller. Bluetoothctl will then provide a prompt {{{[bluetooth]# }}} 126 1. Run {{{show}}} This should list the configuration information for your Bluetooth controller. 127 1. Run {{{devices}}} This provides the user with a list of available devices. If you have not scanned yet, this list may be empty except for your own Bluetooth controller. 128 1. To enable the controller and prepare for pairing with a device, run the following: 137 129 {{{ 138 130 [bluetooth]# power on … … 145 137 Changing pairable on succeeded 146 138 }}} 147 5. To search for available Bluetooth devices, enable scanning with {{{scan on}}} This will begin listing all devices transmitting within range. Turn this off anytime with {{{scan off}}}148 6. Once you find the device in the scanning list, trust the MAC address and then connect:139 1. To search for available Bluetooth devices, enable scanning with {{{scan on}}} This will begin listing all devices transmitting within range. Turn this off anytime with {{{scan off}}} 140 1. Once you find the device in the scanning list, trust the MAC address and then connect: 149 141 {{{ 150 142 [bluetooth]# trust XX:XX:XX:XX:XX:XX … … 153 145 Attempting to connect to XX:XX:XX:XX:XX:XX 154 146 }}} 155 7. If the connection is successful, run {{{info XX:XX:XX:XX:XX:XX}}} to see information about the device you are connected to.156 8. {{{quit}}}147 1. If the connection is successful, run {{{info XX:XX:XX:XX:XX:XX}}} to see information about the device you are connected to. 148 1. {{{quit}}} 157 149 ''Tip: Known MAC addresses can be tab completed in Bluetoothctl.'' Note: To automate bluetoothctl commands try using 158 150 {{{bluetoothctl -–command}}} 159 151 160 152 '''Using hcitool''' 153 161 154 1. Run the init scripts to setup the HCI interface (if you have not already) 162 2. Scan for the desired MAC address 163 {{{hcitool -i hci0 lescan | grep <desired MAC>}}} 155 2. Scan for the desired MAC address {{{hcitool -i hci0 lescan | grep <desired MAC>}}} 164 156 a. MAC in format XX:XX:XX:XX:XX:XX 165 3. Start the connection 166 {{{hcitool -i hci0 lecc --random <desired MAC>}}} 157 3. Start the connection {{{hcitool -i hci0 lecc --random <desired MAC>}}} 158 167 159 '''Using LE Coded PHY''' 160 168 161 1. Run init scripts to setup your HCI UART connection (if you have not already) 169 162 2. Inactive Connection: … … 176 169 177 170 '''Useful Commands''': 171 178 172 * LE Set Default PHY (BCS p.2571): Sets the default PHY for either Tx or Rx on the Bluetooth controller. 179 173 * OGF = 0x08 … … 203 197 '''Troubleshooting''' 204 198 205 * Run btmon in the background to monitor HCI communications with the Bluetooth controller. Rerun the commands and view the output. 206 207 {{{btmon &}}} 199 * Run btmon in the background to monitor HCI communications with the Bluetooth controller. Rerun the commands and view the output. {{{btmon &}}} 200 208 201 == Setting up a GATT !Client/Server == 209 202 This section talks about setting up a generic Bluetooth GATT … … 219 212 https://learn.adafruit.com/introduction-to-bluetooth-low-energy/gatt 220 213 221 === GATT Client/Server Example ===222 223 An example GATT Client and Server is provided in the Bluez source 224 code, see '''Installing Bluez from Source''' to get the source code. 214 === GATT !Client/Server Example === 215 216 An example GATT Client and Server is provided in the Bluez source code, see '''Installing Bluez from Source''' to get the source code. 217 225 218 Before starting the server, run the following: 226 219 {{{ … … 233 226 }}} 234 227 235 In your Bluez source directory, make the executable and start the 236 server with the following command: 228 In your Bluez source directory, make the executable and start the server with the following command: 237 229 238 230 {{{tools/btgatt-server -i hci0 -s low -t random -r -v}}} … … 255 247 256 248 '''Setup Azure MySQL Database Server''' 249 257 250 Follow the most recent instructions to create a MySQL database with Azure using the web portal (Azure account necessary): 258 251 https://docs.microsoft.com/en-us/azure/mysql/quickstart-create-mysql-server-database-using-azure-portal … … 260 253 '''Connecting to the database server''' 261 254 262 The database server can be accessed from any computer with internet connection and a verified IP address. Verified IP addresses can be added to the server under the 'Connection Security' option: 263 https://docs.microsoft.com/en-us/azure/sql-database/sql-database-firewall-confi 264 gure 255 The database server can be accessed from any computer with internet connection and a verified IP address. Verified IP addresses can be added to the server under the 'Connection Security' option: https://docs.microsoft.com/en-us/azure/sql-database/sql-database-firewall-configure 265 256 266 257 To connect the the server using a Gateworks SBC and Ubuntu Linux, run the following command to install MySQL support: … … 277 268 This will prompt for a password and then start a MySQL command shell. 278 269 279 Once connected, use MySQL commands to create and select a database, add tables, 280 and insert data. Example queries can be found here: 281 https://dev.mysql.com/doc/refman/8.0/en/creating-database.html 270 Once connected, use MySQL commands to create and select a database, add tables, and insert data. Example queries can be found here: https://dev.mysql.com/doc/refman/8.0/en/creating-database.html 282 271 283 272 '''Connecting to the database using Python on SBC with Ubuntu'''