Changes between Version 1 and Version 2 of wireless/bleproject


Ignore:
Timestamp:
07/09/2020 09:20:58 PM (4 years ago)
Author:
Ryan Erbstoesser
Comment:

clean up formatting

Legend:

Unmodified
Added
Removed
Modified
  • wireless/bleproject

    v1 v2  
    1 
     1= BLE Demonstration
     2[[PageOutline]]
    23= Bluetooth 5 and BLE =
    34== Introduction ==
     
    1314its predecessors.
    1415
    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
     16To read more about Bluetooth 5, view the following link:\\
     17https://www.bluetooth.com/blog/exploring-bluetooth-5-going-the-distance/
     18
     19To look further in depth at how Bluetooth 5 accomplishes these improvements, look at the following link:\\
     20https://e2e.ti.com/blogs_/b/process/archive/2017/01/30/how-does-bluetooth-5-increase-the-achievable-range-of-a-bluetooth-low-energy-connection
    2421
    2522'''The Bluetooth Core Spec'''
     
    3128
    3229This spec details every operation available to Bluetooth developers.
    33 Some important sections for Bluetooth development using GateWorks
    34 boards include the following:
     30
     31Some important sections for Bluetooth development using Gateworks boards include the following:
    3532* ''Vol 4, Part E'': Host Controller Interface (HCI) Functional Spec (p.1794) - Describes the command interface to a Bluetooth Controller
    3633* ''5.4.1'': HCI Command Packet Descriptions (p.1890) – Command descriptions and packet formats to send to the controller
     
    113110
    114111== Connecting GW16126 With Devices Using Bluez ==
     112
    115113'''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
     115Follow 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]
    120117
    121118'''Bluez Configuration'''
    122119
    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.
     120Before 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.
    128121
    129122=== Setting Up a Connection ===
    130123'''Using bluetoothctl'''
    1311241. 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]# }}}
     1261. Run {{{show}}} This should list the configuration information for your Bluetooth controller.
     1271. 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.
     1281. To enable the controller and prepare for pairing with a device, run the following:
    137129{{{
    138130[bluetooth]# power on
     
    145137Changing pairable on succeeded
    146138}}}
    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:
     1391. 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}}}
     1401. Once you find the device in the scanning list, trust the MAC address and then connect:
    149141{{{
    150142[bluetooth]# trust XX:XX:XX:XX:XX:XX
     
    153145Attempting to connect to XX:XX:XX:XX:XX:XX
    154146}}}
    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}}}
     1471. If the connection is successful, run {{{info XX:XX:XX:XX:XX:XX}}} to see information about the device you are connected to.
     1481. {{{quit}}}
    157149''Tip: Known MAC addresses can be tab completed in Bluetoothctl.'' Note: To automate bluetoothctl commands try using
    158150{{{bluetoothctl -–command}}}
    159151
    160152'''Using hcitool'''
     153
    1611541. 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>}}}
     1552. Scan for the desired MAC address {{{hcitool -i hci0 lescan | grep <desired MAC>}}}
    164156a. MAC in format XX:XX:XX:XX:XX:XX
    165 3. Start the connection
    166 {{{hcitool -i hci0 lecc --random <desired MAC>}}}
     1573. Start the connection {{{hcitool -i hci0 lecc --random <desired MAC>}}}
     158
    167159'''Using LE Coded PHY'''
     160
    1681611. Run init scripts to setup your HCI UART connection (if you have not already)
    1691622. Inactive Connection:
     
    176169
    177170'''Useful Commands''':
     171
    178172* LE Set Default PHY (BCS p.2571): Sets the default PHY for either Tx or Rx on the Bluetooth controller.
    179173* OGF = 0x08
     
    203197'''Troubleshooting'''
    204198
    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
    208201== Setting up a GATT !Client/Server ==
    209202This section talks about setting up a generic Bluetooth GATT
     
    219212https://learn.adafruit.com/introduction-to-bluetooth-low-energy/gatt
    220213
    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
     216An example GATT Client and Server is provided in the Bluez source code, see '''Installing Bluez from Source''' to get the source code.
     217
    225218Before starting the server, run the following:
    226219{{{
     
    233226}}}
    234227
    235 In your Bluez source directory, make the executable and start the
    236 server with the following command:
     228In your Bluez source directory, make the executable and start the server with the following command:
    237229
    238230{{{tools/btgatt-server -i hci0 -s low -t random -r -v}}}
     
    255247
    256248'''Setup Azure MySQL Database Server'''
     249
    257250Follow the most recent instructions to create a MySQL database with Azure using the web portal (Azure account necessary):
    258251https://docs.microsoft.com/en-us/azure/mysql/quickstart-create-mysql-server-database-using-azure-portal
     
    260253'''Connecting to the database server'''
    261254
    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
     255The 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
    265256
    266257To connect the the server using a Gateworks SBC and Ubuntu Linux, run the following command to install MySQL support:
     
    277268This will prompt for a password and then start a MySQL command shell.
    278269
    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
     270Once 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
    282271
    283272'''Connecting to the database using Python on SBC with Ubuntu'''