You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 34 Next »

Summary

Bluetooth is a short-range wireless technology that allows broadcasting the data over specific Bluetooth channels. 

There are 40 unique bands (channels) and each band has a 2 MHz separation. 37, 38, and 39 channels are used for advertising, and 0-36 are used for data transmission.

During the advertising process, the BLE advertising packet is broadcasted. This packet contains the Preamble, Access Address, PDU and CRS fields.

The Preamble and Access Address fields help the receiver detect frames. CRS field is used to check errors. PDU consists of PDU Header and PDU Payload. PDU defines the packet itself.

PDU Header contains information about the PDU type. Based on the type, the payload fields may differ.

For example, when PDU type is ADV_NONCONN_IND → PDU Payload consists of "AdvA" (a field that contains information about the advertiser's address) and "AdvData" (a field that contains data information) fields:

1 octet = 1 byte = 8 bits

Preamble1 octet
Access-Address4 octets
PDU
  • PDU Header = 2 octets
  • PDU Payload = AdvA (6 octets)+AdvData (0...31 octets)
CRS3 octets

There are different PDU types, like:

  • ADV_IND (where payload consists of AdvA [6octets] + AdvData [0-31 octets] and which is used for connectable, scannable undirected advertising);
  • ADV_NOCONN_IND (where payload consists of AdvA [6octets] + AdvData [0-31 octets] and which is used for non-connectable, non-scannable undirected advertising);
  • ADV_SCAN_IND (where payload consists of AdvA [6octets] + AdvData [0-31 octets] and which is used for scannable, undirected advertising);
  • SCAN_REQ (where payload consists of ScanA [6octets] + AdvA [6octets], where ScanA field contains scanner's address and AdvA contains advertiser's address, and which is used for requesting SCAN_RSP response);
  • SCAN_RSP (where payload consists of AdvA [6octets] + ScanRspData [0-31 octets], where ScanRspData can contain any data from the advertiser's host and which is used to reply/respond to a scannable advertisement);
  • ADV_DIRECT_IND (where payload consists of AdvA [6octets] + TargetA [6octets], where TargetA is the device address field to which the PDU is addressed, and which is used for connectable, directed advertising);
  • etc

You can find more information about the packet structure over here (Bluetooth specifications).

The main application for the Bluetooth interface in RouterOS is to monitor Bluetooth advertising packets (scanner feature) that are broadcasted by other devices (like for example, Bluetooth tags) or broadcast advertising packets (advertiser feature).

Configuration

Sub-menu: /iot bluetooth

note: iot package is required.

note: Check your device's specifications page to make sure that the Bluetooth is supported by the unit.

IoT package is available with RouterOS version 6.48.3. You can get it from our download page - under "Extra packages".

Devices

In this menu you can check and set general Bluetooth chip parameters:

[admin@device] > iot bluetooth print
Columns: NAME, PUBLIC-ADDRESS, RANDOM-STATIC-ADDRESS, ANTENNA
  #  NAM  PUBLIC-ADDRESS     RANDOM-STATIC-ADD  ANTENNA 
  0  bt1  00:00:00:00:00:00  F4:4E:E8:04:77:3A  internal
[admin@device] /iot bluetooth set

note: Public address is the IEEE registered, permanent address. This address can not be changed.

Configurable settings are shown below:

PropertyDescription
antenna (string; Default: internal)Choose whether to use an internal or an external Bluetooth antenna
name (string; Default: )Descriptive name of Bluetooth chip/interface

random-static-address (MAC address; Default: )

A unique static user-configurable address for the Bluetooth chip

You can monitor chip stats with the command:

[admin@device] /iot bluetooth print stats
Columns: NAME, RX-BYTES, TX-BYTES, RX-ERRORS, TX-ERRORS, RX-EVT, TX-CMD, RX-ACL, TX-ACL
  #  NAM  RX-BYTE  TX-  R  T  RX-EV  TX  R  T
  0  bt1  1857835  235  0  0  46677  45  0  0

Advertisers

In this menu, it is possible to set up the Bluetooth chip to broadcast advertising packets. You can check and set advertiser settings with the commands:

[admin@device] > iot bluetooth advertisers print
Flags: X - DISABLED
Columns: DEVICE, MIN-INTERVAL, MAX-INTERVAL, OWN-ADDRESS-TYPE, CHANNEL-MAP, AD-SIZE
#   DEVICE  MIN-INTERVAL  MAX-INTERVAL  OWN-ADDRESS-TYPE  CHANNEL-MAP  AD-SIZE
0 X bt1     1280ms        2560ms        random-static              37        0
                                                                   38         
                                                                   39         
[admin@device] /iot bluetooth advertisers set

Configurable settings are shown below:

PropertyDescription
ad-structures (string; Default: )Choose a pre-configured structure for the advertisement packets. For more information see the "AD structures" section.
channel-map (37 | 38 | 39; Default: 37, 38, 39)Channels used for advertising.

disabled (yes | no; Default: yes)

An option to disable or enable the Bluetooth chip to broadcast advertising packets.

max-interval (integer:20..10240; Default: 1280 ms)

The maximal interval for broadcasting advertising packets.

min-interval (integer:20..10240; Default: 2560 ms)

The minimal interval for broadcasting advertising packets.

own-address-type (public | random-static | rpa-fallback-to-public | rpa-fallback-to-random; Default: random-static)

The MAC address that is going to be used in the advertising packet's payload:

  • public →  to use the IEEE registered, permanent address.
  • random-static →  to use user-configurable address (will be changed on the next power-cycle).
  • rpa-fallback-to-public → to use Resolvable Random Private Address (RPA) that can only be resolved if the receiver has our Identity Resolving Key (IRK). If RPA can not be generated, the public address will be used instead.
  • rpa-fallback-to-random → same as "rpa-fallback-to-public" but if RPA can not be generated, the random-static address will be used instead.

note: Advertising packets will be broadcasted each min-interval > X < max interval milliseconds.

AD structures

This section allows you to define the payload for the advertising packets that are going to be broadcasted by the Bluetooth chip.

Currently, only 3 types are supported: 0x08 "Shortened Local Name"; 0x09 "Complete Local Name"; 0xFF "Manufacturer Specific Data".

You can check and set "AD structures" settings with the commands:

[admin@device] > iot bluetooth advertisers ad-structures print
Columns: NAME, TYPE, DATA
#  NAME  TYPE              DATA
0  test  short-local-name  test
[admin@device] > iot bluetooth advertisers ad-structures set 

Configurable properties are shown below:

PropertyDescription
data (string; Default: )Define advertising packet's AdvData part of the payload
name (string; Default: )Descriptive name of AD structure

type (complete-local-name | manufacturer-data | short-local-name; Default: )

An option to set AD structure's type:

  • 0x08 "Shortened Local Name"
  • 0x09 "Complete Local Name"
  • 0xFF "Manufacturer Specific Data"

If, for example, the "Shortened Local Name" type is chosen and the "data" field is configured with "test" → AdvData part of the payload is going to look like this:

05 08 54 45 53 54 (hexadecimal format)

, where the first octet (05) shows the length (5 bits) and the second octet (08) shows the type (Shortened Local Name). 3d, 4th, 5th and 6th (and etc) octets are the "data" [54 (hex)=T (ASCII), 45 (hex)=E (ASCII), 53 (hex)=S (ASCII), 54 (hex)=T (ASCII)].

The same applies to the "Complete Local Name" type. Only the second octet in the AdvData payload is going to differ and will be set to 09.

For the "Manufacturer Specific Data" type, you will need to configure the "data" field in the hexadecimal format. The second octet for this type is going to be set to FF.

Scanners

In this menu, you can set up the scanner settings for the Bluetooth chip. When disabled, the device is no longer able to receive advertising reports. When enabled, you can monitor advertising reports in the "Advertising reports" tab (which will be explained later in the guide). You can check and set scanner settings with the commands:

[admin@device] > iot bluetooth scanners print
Flags: X - DISABLED
Columns: DEVICE, TYPE, INTERVAL, WINDOW, OWN-ADDRESS-TYPE, FILTER-POLICY, FILTER-DUPL
ICATES
#   DEVICE  TYPE     INTERVAL  WINDOW  OWN-ADDRESS-TYPE  FILTER-POLICY  FIL
0 X bt1     passive  10ms      10ms    random-static     default        off
[admin@device] /iot bluetooth scanners set

Configurable properties are shown below:

PropertyDescription
disabled (yes | no; Default: no)An option to disable or enable the Bluetooth chip to receive advertising reports.
filter-duplicates (keep-newest | keep-oldest | off; Default: off)

An option to discard duplicate advertisements from the same advertiser:

  • keep-newest → Keeps the newest report (discards the oldest). Only the newest PDU from a single AdvA will be kept.
  • keep-oldest → Keeps the oldest report (discards the newest). Only the oldest PDU from a single AdvA will be kept. This type of PDU filtering happens at the controller level and as such it's the most efficient (energy/bandwidth-wise) method of duplicate filtering.
  • off → Duplicates are not discarded. All PDUs with the same AdvA will be kept.

filter-policy (default | whitelist | no; Default: default)

An option to set up a filtering policy (controller-level advertisement filtering):

  • default → When this policy is enabled, the scanner will only accept ADV_IND, ADV_NOCONN_IND, ADV_SCAN_IND, SCAN_RSP, and ADV_DIRECT_IND (where TargetA is the scanner's own Bluetooth address) PDU types.
  • whitelist → When this policy is enabled, the scanner will only accept ADV_IND, ADV_NOCONN_IND, ADV_SCAN_IND, SCAN_RSP PDU types that are broadcasted by the advertiser, whose address is configured in the whitelist section, and ADV_DIRECT_IND type PDU (where TargetA is the scanner's own Bluetooth address).

interval (integer:3..10240; Default: 10 ms)

Time after which scanner will start scanning the next advertisement channel.

own-address-type (public | random-static | rpa-fallback-to-public | rpa-fallback-to-random; Default: random-static)

Address type used in scan requests (if active scanning type is used):

  • public →  to use the IEEE registered, permanent address.
  • random-static →  to use user-configurable address (will be changed on the next power-cycle).
  • rpa-fallback-to-public → to use Resolvable Random Private Address (RPA) that can only be resolved with our Identity Resolving Key (IRK). If RPA can not be generated, the public address will be used instead.
  • rpa-fallback-to-random → same as "rpa-fallback-to-public" but if RPA can not be generated, the random-static address will be used instead.

type (active | passive; Default: passive)

Defines the scanner's type:

  • active → Scanner can send scan requests if it receives a scannable advertisement. The scanner can send a SCAN_REQ in order to acquire a SCAN_RSP response.
  • passive → Scanner will only listen for advertisements, no data will be sent (no scanning PDUs will be sent).
window (integer:3..10240; Default: 10 ms)Time scanner will spend scanning a single advertisement channel.

For example, if the scanner interval is set to 20ms, it means that only after 20ms, the device will begin scanning the next channel in line. If the scanner window is set to 10ms, it means that the device will scan each channel only during that 10ms window. Meaning, it will scan channel 37 for 10ms (window time) and begin scanning the next channel after 10 more ms (20ms[interval]-10ms[window]). It will take 10ms to scan channel 38, and after 10 more ms, the device will begin scanning channel 39.

Advertising reports

In this section, it is possible to monitor Bluetooth advertising reports (from the nearby broadcasters). You can monitor advertising reports with the command:

[admin@device] > iot bluetooth scanners advertisements print      
Columns: DEVICE, PDU-TYPE, TIME, ADDRESS-TYPE, ADDRESS, RSSI
 #  DEV  PDU-TYPE        TIME                  ADDRES  ADDRESS            RSSI  
 0  bt1  adv-noconn-ind  jul/28/2021 09:30:56  public  2C:C8:1B:93:16:49  -24dBm
 1  bt1  adv-noconn-ind  jul/28/2021 09:30:56  random  0B:16:17:9E:7B:EF  -60dBm

It is possible to set up a filter for the reports with the command:

[admin@device] > iot bluetooth scanners advertisements print where  

For example, to print only reports that are broadcasted only by a specific MAC address, use the command:

[admin@device] > iot bluetooth scanners advertisements print where address=XX:XX:XX:XX:XX:XX
 # DEVICE    PDU-TYPE       TIME                 ADD... ADDRESS                    RSSI     LENGTH DATA    
79 bt1       adv-noconn-ind jul/28/2021 09:46:38 public XX:XX:XX:XX:XX:XX        -70dBm         30 02010...
80 bt1       adv-noconn-ind jul/28/2021 09:46:43 public XX:XX:XX:XX:XX:XX        -67dBm         30 02010...
81 bt1       adv-noconn-ind jul/28/2021 09:46:44 public XX:XX:XX:XX:XX:XX        -70dBm         28 1bff0...
82 bt1       adv-noconn-ind jul/28/2021 09:46:48 public XX:XX:XX:XX:XX:XX        -75dBm         30 02010...

Possible filters are shown below:

FilterDescription
idItem number
addressAdvertiser Bluetooth address

data

Advertisement data in hex format
epochMilliseconds since Unix Epoch
filter-commentComment of the matching whitelist filter
lengthAdvertisement data length
rssiSignal strength
  • No labels