background image

How to use 

Connect the Bluetooth USB Adapter to your computer. It opens a virtual serial port (COM port) 
that you can use to send commands to and from the Bluetooth USB Adapter. 

 

Control Bluetooth USB Adapter using predefined commands. 

List of AT Commands

 

The Smart USB Dongle 2.0 includes a bootloader which allows you to easily update the firmware 
(or flash your own application to the dongle) 

After connecting, you can use the following sample python script to set up your own iBeacon. 

 

 

 

 

 

 

 

 

 

Содержание BleuIO

Страница 1: ......

Страница 2: ... use 4 Windows 4 Linux Raspberry Pi 7 Mac OS X 10 Issues 14 Firmware Updates 15 Troubleshooting 17 AT COMMANDS 18 Scripts Tutorials 28 Getting Started 28 iBeacon 29 Eddystone Beacon 33 Scan Example 38 Scan and Store Example 41 SPS Script 44 ...

Страница 3: ... advertising set custom advertising and response data allow a Central device to connect to it and receive and transmit data via the SPS profile It is also possible to update the firmware via the USB port Requirements The following hardware and software elements are required to use the Smart USB Dongle 2 0 The Smart USB Dongle 2 0 A Windows OS Computer with a functioning USB port A terminal softwar...

Страница 4: ...How to use Windows Step 1 Figure 1 Connect the dongle to your computer ...

Страница 5: ... to the dongle more on that HERE When starting up the dongle will open up a COM port for the bootloader for 10 seconds to allow you to update the firmware or flash your own application Afterwards it will close that port and open a new port for the Smart USB Dongle 2 0 application which is the one we re interested in here NOTE The COM port number may vary and may not be the same as in the picture a...

Страница 6: ...ommand for example AT If you get an OK response that means the dongle is working Done Great job You are now ready to start using Smart USB Dongle 2 0 Now check out the different AT Commands available or how to get started using scripts ...

Страница 7: ...Linux Raspberry Pi Step 1 Figure 1 Connect the dongle to your Linux RaspberryPi ...

Страница 8: ... USB Dongle 2 0 includes a bootloader which allows you to easily update the firmware or flash your own application to the dongle more on that HERE When starting up the dongle will open up a COM port for the bootloader for 10 seconds to allow you to update the firmware or flash your own application Afterwards it will close that port and open a new port for the Smart USB Dongle 2 0 application which...

Страница 9: ... be using Minicom You can get Minicom by running 1 sudo apt get install minicom Now to start using the dongle run the following command if for example your dongle is connected to the device name ttyACM0 1 minicom b 9600 o D dev ttyACM0 Figure 3 Open your terminal software Step 4 Now try typing an AT Command For example AT If you get an OK response that means the dongle is working Done Great job Yo...

Страница 10: ...ll open up a COM port for the bootloader for 10 seconds to allow you to update the firmware or flash your own application Unfortunately this is not as of yet available on Mac Afterwards it will close that port and open a new port for the Smart USB Dongle 2 0 so you might need to wait a few seconds before doing the next step Step 3 You can either use the Mac OS X built in Terminal and screen or an ...

Страница 11: ... dev cu usbmodem123456781 9600 With Minicom If you have Homebrew you can get Minicom by simply running 1 sudo brew install minicom If you don t have Homebrew click here to find out how to install it Now you need to setup Minicom by running 1 minicom s ...

Страница 12: ...Figure 2 Minicom settings Go to Serial port setup Serial Device and type in dev cu usbmodem123456781 in the field and press enter Then Save setup as dfl Now to start using the dongle just run 1 minicom ...

Страница 13: ...yping an AT Command For example AT If you get an OK response that means the dongle is working Done Great job You are now ready to start using Smart USB Dongle 2 0 Now check out the different AT Commands available or how to get started using scripts ...

Страница 14: ...Issues Showing advertising and or response data either when setting or querying has been temporarily disabled ...

Страница 15: ...ion and a host USB loader application that you can get HERE for Windows host_usb_updater zip or HERE for Linux host_usb_updaterlinux zip USB loader application for Mac is unfortunately not available at the moment Latest Firmware 2020 06 30 v1 0 7 Firmware Version 1 0 7 Download Release Notes Older Firmwares Version 1 0 6 Download Release Notes Version 1 0 5 Download Release Notes Version 1 0 4 Dow...

Страница 16: ...pt in the directory where the host_usb_updater exe is located Run with host_usb_updater exe 24 example_firmware img verbose The 24 means COM port number of USB CDC device You can see the COM port number on Windows device manager COM port number may vary on different machines Debug message can be enabled by verbose option NOTE For simplicity s sake it is recommended to keep the image file and host_...

Страница 17: ...e window where the bootloader is open Make sure you have closed down anything like serial communication programs e g TeraTerm or Minicom that might be connected to the dongle before trying to upload a new image For Linux users Try disabling the modemmanager As it may lock up the com port for awhile and not leaving enough time to use the boodloader before the main app starts up Firmware issues I ha...

Страница 18: ... 2 Executing AT 3 4 OK ATI Device information query Returns firmware version hardware type and unique organization identifier Command Syntax ATI ATI Example 1 ATI 2 Executing ATI 3 4 OK 5 SSD005 Dongle DA14683 v 1 0 1 ATR Trigger platform reset Command Syntax ATR ATR ...

Страница 19: ...d Syntax AT ADVDATA AT ADVDATA xx xx xx xx xx xx AT ADVDATA xx xx xx xx xx xx xx xx xx Example 1 AT ADVDATA 04 09 43 41 54 2 Executing AT ADVDATA 04 09 43 41 54 3 4 5 6 OK AT ADVDATAI Sets advertising data in a way that let s it be used as an iBeacon Command Syntax AT ADVDATAI AT ADVDATAI UUID MAJOR MINOR TX Example 1 AT ADVDATAI ebbaaf47 0e4f 4c65 8b08 dd07c98c41ca0000000000 2 3 Executing AT ADVD...

Страница 20: ... unlimited Returns ERROR if advertising is already active or if the device is in central role Command Syntax AT ADVSTART AT ADVSTART AT ADVSTART mode intv_min intv_max time_ms Supported modes Code Mode 0 Non connectable mode 1 Undirected mode 2 Directed mode 3 Directed Low Duty Cycle mode Example 1 AT ADVSTART 1 200 300 20 2 Executing AT ADVSTART 3 4 OK 5 6 7 ADVERTISING AT ADVSTOP ...

Страница 21: ...SP Sets or queries scan response data Data must be provided as hex string Changes to take effect after restart of advertising Command Syntax AT ADVRESP AT ADVRESP xx xx xx xx xx xx xx Example 1 AT ADVRESP 04 09 43 41 54 2 Executing AT ADVRESP 3 4 OK AT CENTRAL Sets the device Bluetooth role to central role Advertising must be stopped and any connection must be terminated before the role change is ...

Страница 22: ...se data and the services of the peripheral The local device must be in central role Command Syntax AT GAPCONNECT AT GAPCONNECT slave_address Example 1 AT GAPCONNECT FD 37 13 D0 6D 02 2 Executing AT GAPCONNECT FD 37 13 D0 6D 02 3 4 OK 5 6 CONNECTING 7 CONNECTED AT GAPDISCONNECT Disconnects from a peer Bluetooth device This command can be used in both central and peripheral role Command Syntax AT GA...

Страница 23: ...ue indefinitly in no parameters set or until amount of time set is reached Scan will abort if user presses CTRL C Command Syntax AT GAPSCAN AT GAPSCAN AT GAPSCAN seconds Example 1 AT GAPSCAN 2 Executing AT GAPSCAN 3 4 OK 5 6 SCANNING 7 8 01 Device 1 30 63 C5 D0 B1 DE RSSI 38 9 02 Device 0 D0 76 50 80 0A 98 RSSI 75 closebeacon com 10 03 Device 1 27 5D B8 2E 96 B0 RSSI 51 11 04 Device 1 5E CE CF C5 ...

Страница 24: ...cted to a peripheral Command Syntax AT GATTCREAD AT GATTCREAD handle param Example 1 AT GATTCREAD 001B 2 Executing AT GATTCREAD 001B 3 4 OK 5 6 handle_evt_gattc_read_completed conn_idx 0000 handle 001b status 0 7 8 Value read HELLO 9 Hex 0x48454C4C4F 10 Size 5 AT GATTCWRITE Write attribute to remote GATT server in ASCII Can only be used in Central role and when connected to a peripheral Command Sy...

Страница 25: ... to a peripheral Command Syntax AT GATTCWRITEB AT GATTCWRITEB handle param msg Example 1 AT GATTCWRITE 001B 2 Executing AT GATTCWRITE 001B 0101 3 4 OK 5 6 DATA WRITTEN 0101 7 Size 2 AT PERIPHERAL Sets the device Bluetooth role to peripheral Any connection must be terminated before the role change is accepted Command Syntax AT PERIPHERAL AT PERIPHERAL Example 1 AT PERIPHERAL 2 Executing AT PERIPHER...

Страница 26: ... 00 00 00 00 00 01 3 4 OK 5 6 SCANNING 7 8 01 Device Data DataXYZ 9 01 Device Data DataXYZ 10 01 Device Data DataXYZ 11 01 Device Data DataXYZ 12 01 Device Data DataXYZ AT SPSSEND Send a message or data via the SPS profile Without parameters it opens a stream for continiously sending data Command Syntax AT SPSSEND AT SPSSEND message AT SPSSEND Example 1 AT SPSSEND HELLO 2 Executing AT SPSSEND HELL...

Страница 27: ... H Shows all AT Commands Command Syntax H H Example 1 H 2 3 AT A Basic AT Command 4 ATI A Device information query 5 AT ADVDATA P 6 ...

Страница 28: ...eady have after installing Python by running Python2 1 pip install pyserial Python3 1 python3 m pip install pyserial Now you can download the script you want to use from our GITHUB PAGE Then open up the command prompt inside the directory where the script you want to run is Then run 1 python scriptname py NOTE You will need to manually change the COM port in the script to which ever your dongle us...

Страница 29: ...IBeacon easily using Smart USB dongle 2 0 and Python script This device works equally well in Windows 10 Linux or macOS iBeacon are defined by the Apple company including following parameters UUID Major and Minor You can build your own beacon by defining your own parameter values What is UUID UUID stands for Universally Unique Identifier It contains 32 hexadecimal digits split into 5 groups like t...

Страница 30: ... and from the Bluetooth USB Adapter Control Bluetooth USB Adapter using predefined commands List of AT Commands The Smart USB Dongle 2 0 includes a bootloader which allows you to easily update the firmware or flash your own application to the dongle After connecting you can use the following sample python script to set up your own iBeacon ...

Страница 31: ... __bool__ 32 get keyboard input once 33 if new_input 1 34 Python 2 users 35 input raw_input Enter the UUID 36 new_input input Enter the UUID x string with Major j Minor n and TX t format 37 xxxxxxxx xxxx xxxx xxxx xxxxxxxxxxxxjjjjnnnntt 38 time sleep 0 1 39 sends the commands to the dongle Important to send the r as that is the return key 40 console write str encode AT ADVDATAI 41 console write ne...

Страница 32: ...Youtube Tutorial Follow the Youtube tutorial https www youtube com watch v CixqMR3leGs ...

Страница 33: ... 26 print n nConnected to Dongle n 27 print n Welcome to the Eddystone example n n 28 29 30 new_input 1 31 while 1 and console is_open __bool__ 32 get keyboard input once 33 if new_input 1 34 Python 2 users 35 input raw_input Enter the Eddystone url hex string 36 new_input input Enter the Eddystone url hex string 37 time sleep 0 1 38 sends the commands to the dongle Important to send the r as that...

Страница 34: ...o prepare one Eddystone url hex string Let s say we want to send http google com The url hex string will then looks like this 0d 16 aa fe 10 00 03 67 6f 6f 67 6c 65 07 0d Length of the following string in hex 0D is 13 and as you see there is 13 bits after this one It is important that this correspondes with your length otherwise it will not run Keep in mind that you have a maximum of 17 bytes wort...

Страница 35: ...popular prefixes and sufixes 67 hex for g 6f hex for o 6f hex for o 67 hex for g 6c hex for l 65 hex for e 07 com Eddystone has a list of 1 byte codes for popular prefixes and sufixes Here is two helpful sites that can help you autogenerate an eddystone hex url string https www mkompf com tech eddystoneurl html https yencarnacion github io eddystone url calculator Just keep in mind that you will s...

Страница 36: ...Supported prefix list Hex Expansion 00 http www 01 https www 02 http 03 https Supported sufix list Hex Expansion 00 com 01 org 02 edu 03 net 04 info 05 biz 06 gov 07 com 08 org 09 edu ...

Страница 37: ...Hex Expansion 0a net 0b info 0c biz 0d gov 0e to 20 Reserved for Future Use 7F to FF Reserved for Future Use Full source also available on GitHub ...

Страница 38: ...except 22 print Dongle not connected Please reconnect Dongle 23 time sleep 5 24 25 26 print n nConnected to Dongle n 27 print nWelcome to the Bluetooth device Scanning example n n 28 29 30 new_input NEW INPUT 31 while 1 and console is_open __bool__ 32 get keyboard input once 33 if new_input NEW INPUT 34 Python 2 users 35 input raw_input Select n1 If you 36 new_input input Select n1 If you d like t...

Страница 39: ...rite r encode 70 else 71 print That was not a choice Please choose one of the options 72 new_input NEW INPUT 73 let s wait one second before reading output let s give device time to answer 74 time sleep 1 75 out 76 while console inWaiting 0 77 out console read console inWaiting decode 78 else 79 if not out isspace 80 We make sure it doesn t print the same message over and over again by setting out...

Страница 40: ...response data of 31 bytes from the selected device And that is how we scan for Bluetooth devices If you want to stop the script you can simply press control C Youtube Tutorial Follow the Youtube tutorial https www youtube com watch v oidvEd5QoXg ...

Страница 41: ...b to see the other settings 13 while connecting_to_dongle 0 14 try 15 console serial Serial 16 port COM14 17 baudrate 57600 18 parity N 19 stopbits 1 20 bytesize 8 21 timeout 0 22 23 if console is_open __bool__ 24 connecting_to_dongle 1 25 except 26 print Dongle not connected Please reconnect Dongle 27 time sleep 5 28 29 30 print n nConnected to Dongle n 31 print n Welcome to the Scan and Store ex...

Страница 42: ...1 out 72 Let s wait one second before reading output let s give device time to answer 73 time sleep 1 74 print nCollecting data nPress Ctrl C to stop 75 while console inWaiting 0 76 out console read console inWaiting decode 77 else 78 if not out isspace 79 We make sure it doesn t print the same message over and over again by setting o ut to blankspace 80 and check for blankspace and that out isn t...

Страница 43: ...t For example SavedData txt The script will run until you stop it You can then have a look in the text file Note that the script will not work if the text file is open or altered during runtime And that is how we store data that we scanned from Bluetooth devices If you want to stop the script you can simply press control C ...

Страница 44: ...his to the peripheral s mac address 5 your_com_port COM14 Change this to the com port your dongle is connected to 6 7 Global 8 connecting_to_dongle True 9 counter 0 10 msg 11 latest_msg 12 error_counter 0 13 14 print Connecting to dongle 15 Trying to connect to dongle until connected Make sure the port and baudrate is the same as your dongle 16 You can check in the device manager to see what port ...

Страница 45: ...e str encode AT SPSSEND 64 console write r encode 65 connected 1 66 print Connected 67 dongle_output 68 elif role_input 2 69 This is what will be sent back and forth between the dongles 70 You can change this message to whatever you like 71 msg Echo 72 Sends the commands to the dongle Important to send the r as that is the return key 73 console write str encode AT CENTRAL 74 console write r encode...

Страница 46: ...use the last received message instead and increment t he error counter 120 msg latest_msg 121 error_counter 1 122 print This is what we will send msg 123 Encodes the string msg than sends it back to the other dongle 124 console write str encode msg 125 counter 1 126 Just a little counter to show how many messages we ve sent 127 print str counter message s sent str error_counter error s 128 In case...

Страница 47: ...now be prompted to enter 1 or 2 depending on what role the dongle should have Set one as Peripheral and the other as Central It is advisable to setup the Peripheral first as the Central will need someone to connect to You should now see in the terminal how the dongles send and recieve data to and from each other The script will run until you stop it And that is an example of how we can send data b...

Отзывы: