NOTICE: The Processors Wiki will End-of-Life on January 15, 2021. It is recommended to download any files or other content you may need that are hosted on processors.wiki.ti.com. The site is now set to read only.
WL18xx TI Bluetooth Stack PANM Demo App
Return to WL18xx AM335x TI Bluetooth Stack
Contents
Demo Overview[edit]
Note: : This instructions can be used to run this demo on the AM335x Platform.
PAN User to PAN User[edit]
In this demo we will demonstrate how to use the Bluetopia PM PANM module to connect two PAN User (PANU) devices to each other. Note that a PANU to PANU connection is a device-to-device connection only, it is different from a traditional network connection, and is used to simulate a cross-over cable between two nodes. For more information on PAN roles please refer to the Personal Area Network Profile Specification linked at the bottom of the https://developer.bluetooth.org/TechnologyOverview/Pages/PAN.aspx page. The remote device used in this demonstration is a Windows 7 64-bit PC running the default Windows Bluetooth stack with a Belkin F8T016 Bluetooth USB dongle.
It is recommended that the user visits the kit setup Getting Started Guide for AM335x pages before trying the application described on this page.
Running the Bluetooth Code[edit]
Note: : Currently all available serial SDK needs the following patch to run the PAN Demo App:
Description | Patch type | Support for board | Link to patch |
---|---|---|---|
TTY buffer overrun patch (for PAN and high bandwidth BT use cases) | Bug fix | All AM335x variants | <patch> |
The patch requires recompiling the zImage:
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- zImage cp arch/arm/boot/zImage [target-rootfs]/boot/
Once the am335x is initialized on the terminal, follow the instructions;
To use the PAN profile first start the Stonestreet One-provided Virtual Network driver (VNET driver) on the target. The VNET driver creates a virtual network interface that can be used like a typical network interface, e.g. eth0. Applications can access the PAN virtual network connection using the virtual network interface provided by the VNET driver when a Bluetooth PAN connection is established. To start the VNET driver run:
cd ~/BluetopiaPM/Bluetopia/VNET/ chmod +x driver/VNETInst/Kernel_2_6/VNETMInst.sh ./driver/VNETInst/Kernel_2_6/VNETMInst.sh start
root@am335x-evm:~/BluetopiaPM# cd ~/BluetopiaPM/Bluetopia/VNET/ root@am335x-evm:~/BluetopiaPM# cd ~/BluetopiaPM/Bluetopia/VNET/chmod +x driver/VNETInst/Kernel_2_6/VNETMInst.sh root@am335x-evm:~/BluetopiaPM/Bluetopia/VNET/driver/VNETInst/Kernel_2_6# ./driver/VNETInst/Kernel_2_6/VNETMInst.sh start Installing SS1 Virtual Network Driver: [ 632.187408] printk NumberOfDevices 1 [ 632.191223] Allocate Memory for 1 [ 632.194671] Return Allocate Memory for 1 Ptr cf2c6800 [ 632.200042] alloc_chrdev_region returned 0 [ 632.204315] VNETCharacterDeviceMajorNumber returned 250 0 Driver started and devices entries refreshed. root@am335x-evm:~/BluetopiaPM/Bluetopia/VNET/#
Next run "ifconfig -a" and look for the network interface named ss1vnet0 to verify that the driver was properly loaded.
root@am335x-evm:~/BluetopiaPM/Bluetopia/VNET/# ifconfig -a eth0 Link encap:Ethernet HWaddr 00:18:31:92:17:31 inet addr:192.168.1.82 Bcast:192.168.1.255 Mask:255.255.255.0 UP BROADCAST RUNNING ALLMULTI MULTICAST MTU:1500 Metric:1 RX packets:26175 errors:0 dropped:513 overruns:0 frame:0 TX packets:12838 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:27550505 (26.2 MiB) TX bytes:1991786 (1.8 MiB) eth1 Link encap:Ethernet HWaddr 00:18:31:92:17:32 BROADCAST ALLMULTI MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:0 (0.0 B) TX bytes:0 (0.0 B) lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:0 (0.0 B) TX bytes:0 (0.0 B) ss1vnet0 Link encap:Ethernet HWaddr 00:02:03:04:05:06 BROADCAST MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:256 RX bytes:0 (0.0 B) TX bytes:0 (0.0 B) root@am335x-evm:~/BluetopiaPM/Bluetopia/VNET/#
Enter the Sample Application folder, for this example “cd ~/BluetopiaPM/bin”
root@am335x-evm:~# cd ~/BluetopiaPM/bin/ root@am335x-evm:~/BluetopiaPM/bin#
Start the Server and the Demo application by typing “./SS1BTPM & ./LinuxPANM”
root@am335x-evm:~/BluetopiaPM/bin# ./SS1BTPM & ./LinuxPANM [1] 1789
Now the help screen is displayed
****************************************************************** * Command Options: 1) Initialize * * 2) Cleanup * * 3) QueryDebugZoneMask * * 4) SetDebugZoneMask * * 5) ShutdownService * * 6) RegisterEventCallback, * * 7) UnRegisterEventCallback, * * 8) QueryDevicePower * * 9) SetDevicePower * * 10)QueryLocalDeviceProperties * * 11)SetLocalDeviceName * * 12)SetLocalClassOfDevice * * 13)SetDiscoverable * * 14)SetConnectable * * 15)SetPairable * * 16)StartDeviceDiscovery * * 17)StopDeviceDiscovery * * 18)QueryRemoteDeviceList * * 19)QueryRemoteDeviceProperties * * 20)AddRemoteDevice * * 21)DeleteRemoteDevice * * 22)DeleteRemoteDevices * * 23)PairWithRemoteDevice * * 24)CancelPairWithRemoteDevice * * 25)UnPairRemoteDevice * * 26)QueryRemoteDeviceServices * * 27)RegisterAuthentication * * 28)UnRegisterAuthentication * * 29)PINCodeResponse * * 30)PassKeyResponse * * 31)UserConfirmationResponse * * 32)ChangeSimplePairingParameters * * 33)ConnectionRequestResponse * * 34)ConnectRemoteServer * * 35)CloseConnection * * 36)QueryConnectedDevices * * 37)QueryCurrentConfiguration * * 38)ChangeIncomingConnectionFlags * * 39)PANRegisterEventCallback * * 40)PANUnRegisterEventCallback * * 41)EnableBluetoothDebug * * Help, Quit. * ******************************************************************
Demo Application[edit]
The demo application provides a description on how to use the demo application to connect two devices and form an ad-hoc network over Bluetooth.
Personal Area Network (PAN)[edit]
Windows PC initiate the PAN connection[edit]
- To verify PANM functionality, start by running the "LinuxPANM" executable, initializing, and powering on the local device if necessary, first register PAN events.
- a) Initialize the profile by typing “1 1” or “Initialize 1”.
- b) Powering up the Bluetooth device by typing “9 1” or "SetDevicePower 1”, if the device is already powered up you’ll receive an error that the device is already powered up
PANM>Initialize 1 BTPM_Initialize() Success: 0. DEVM_RegisterEventCallback() Success: 5. PANM>SetDevicePower 1 [256151.498556] (hci_tty): inside hci_tty_open (ecb2e788, ebbbec00) [256151.505629] (stc): chnl_id list empty :4 [256151.509745] (stk) : st_kim_start(stk) :ldisc_install = 1uim:poll broke due to event 10(PRI:2/ERR:8) uim:read 1 from install uim:@ st_uart_config uim: signal received, opening /dev/ttyS1 uim:@ set_baud_rate uim:set_baud_rate() done uim:Setting speed to 3000000 uim:@ read_command_complete uim: Command complete started uim:@ read_hci_event uim: read_hci_event uim:Command complete done [256151.672556] (stc): st_tty_open uim:Speed changing to 3000000, 1 uim:@ set_custom_baud_rate (stk) :line discipline installeduim:Installed N_TI_WL Line displine [256151.686798] (stk) :TIInit_11.8.32.bts uim:begin polling... (stk) :change remote baud rate command in firmware [256151.700113] (stk) :skipping the wait event of change remote baud[256152.456904] (stc): add_channel_to_table: id 4 [256152.461420] (stc): add_channel_to_table: id 2 [256152.465884] (stc): add_channel_to_table: id 3 BT COMM PORT (/dev/hci_tty): 1 DEVM_PowerOnDevice() Success: 0. PANM> Device Powered On. PANM>
- c) Registering an Authentication
PANM>RegisterAuthentication DEVM_RegisterAuthentication() Success: 5. PANM>
- d) Registering an PAN Events
PANM>PANRegisterEventCallback Attempting to Register for Events. PANM_Register_Event_Callback() Success. Callback ID: 1. PANM>
- e) Now in Windows discover, connect, and pair to the local device by doing the following:
1. Click the Bluetooth icon in the Windows system tray, choose "Add a Device". 2. Select the device named "WL183x Device" or "WL18xx Device" and choose Next. 3. Verify the pass code displayed in Windows matches the pass code displayed in the LinuxPANM app and press Next.
PANM> Remote Device Properties Changed. BD_ADDR: 00190E06ABE8 Device Flags: 0x80000009 Connect State: TRUE PANM> Authentication Request received for 00190E06ABE8. I/O Capability Response. Remote I/O Capabilities: Display Yes/No, MITM Protection: TRUE. PANM> Authentication Request received for 00190E06ABE8. I/O Capability Request. DEVM_AuthenticationResponse() Success. PANM> Authentication Request received for 00190E06ABE8. User Confirmation Request. User Confirmation: 981178 Respond with the command: UserConfirmationResponse
- f) In LinuxPANM confirm that the pass codes match by running:
PANM>UserConfirmationResponse 1 DEVM_AuthenticationResponse(), User Confirmation Response Success. PANM> Remote Device Properties Changed. BD_ADDR: 00190E06ABE8 Device Flags: 0x8000008D Paired State : TRUE PANM> Remote Device Properties Changed. BD_ADDR: 00190E06ABE8 Device Flags: 0x8000009D Encrypt State: TRUE PANM> Remote Device Properties Changed. BD_ADDR: 00190E06ABE8 Device Flags: 0x80000085 Connect State: FALSE Encrypt State: FALSE PANM> Remote Device Properties Changed. BD_ADDR: 00190E06ABE8 Device Flags: 0x8000008D Connect State: TRUE PANM> Remote Device Properties Changed. BD_ADDR: 00190E06ABE8 Device Flags: 0x8000009D Encrypt State: TRUE PANM> PANM: Device Connected BD_ADDR : 00190E06ABE8 Service Type: PAN User PANM>
- g) Now on the Windows computer wait for Windows to finish trying to update the driver software, any "No driver found" errors can be ignored, they will not affect this demonstration.
Now that we have paired, next let's establish a PAN connection. To establish a PAN connection, in Windows do the following:
1. Click the Bluetooth icon in the system tray, and choose "Join a Personal Area Network". 2. Right click the device named "WL183x Device" or "WL18xx Device" and choose "Connect using" --> "Direct connection".
- h) If all went well you should see a pop-up in Windows that says "Connection successful". In LinuxPANM you will see the "PANM: Device Connected ... Service Type: PAN User" message.
Now that we have connected we will need to configure the ss1vnet0 network interface in Linux. First quit LinuxPANM using the following:
PANUnRegisterEventCallback 1 UnRegisterAuthentication Cleanup Quit
PANM>PANUnRegisterEventCallback 1 Attempting to Un-Register Events. PANM_Un_Register_Event_Callback() Success. PANM>UnRegisterAuthentication DEVM_UnRegisterAuthentication() Success. PANM>Cleanup PANM>Quit root@am335x-evm:~/BluetopiaPM/bin#
Bluetopia PM initiate the PAN connection[edit]
- To verify PANM functionality, start by running the "LinuxDEVM" executable.
after running the "LinuxPANM" executable, initializing, and powering on the local device if necessary, first register PAN events.
- a) Initialize the profile by typing “1 1” or “Initialize 1”.
- b) Powering up the Bluetooth device by typing “9 1” or "SetDevicePower 1”, if the device is already powered up you’ll receive an error that the device is already powered up
PANM>Initialize 1 BTPM_Initialize() Success: 0. DEVM_RegisterEventCallback() Success: 5. PANM>SetDevicePower 1 [256151.498556] (hci_tty): inside hci_tty_open (ecb2e788, ebbbec00) [256151.505629] (stc): chnl_id list empty :4 [256151.509745] (stk) : st_kim_start(stk) :ldisc_install = 1uim:poll broke due to event 10(PRI:2/ERR:8) uim:read 1 from install uim:@ st_uart_config uim: signal received, opening /dev/ttyS1 uim:@ set_baud_rate uim:set_baud_rate() done uim:Setting speed to 3000000 uim:@ read_command_complete uim: Command complete started uim:@ read_hci_event uim: read_hci_event uim:Command complete done [256151.672556] (stc): st_tty_open uim:Speed changing to 3000000, 1 uim:@ set_custom_baud_rate (stk) :line discipline installeduim:Installed N_TI_WL Line displine [256151.686798] (stk) :TIInit_11.8.32.bts uim:begin polling... (stk) :change remote baud rate command in firmware [256151.700113] (stk) :skipping the wait event of change remote baud[256152.456904] (stc): add_channel_to_table: id 4 [256152.461420] (stc): add_channel_to_table: id 2 [256152.465884] (stc): add_channel_to_table: id 3 BT COMM PORT (/dev/hci_tty): 1 DEVM_PowerOnDevice() Success: 0. PANM> Device Powered On. PANM>
- c) Registering an Authentication
PANM>RegisterAuthentication DEVM_RegisterAuthentication() Success: 5. PANM>
- d) Registering an PAN Events
PANM>PANRegisterEventCallback Attempting to Register for Events. PANM_Register_Event_Callback() Success. Callback ID: 1. PANM>
- e) Connect to remote Server
PANM>ConnectRemoteServer 00190E06ABE8 1 1 0x3
Where 00190E06ABE8 is the Bluetooth Device Address (BD_ADDR) of the USB dongle. Note that the BD_ADDR can be easily found by looking at the messages in LinuxPANM from the previous connection. On success you will see a "PANM: Connection Status ... Status : 0" message in LinuxPANM. Note that you do not have to reconfigure the ss1vnet0 driver again, the 2 devices are both configured and ready, however, when the target is restarted you will have to restart the VNET driver and also reconfigure the ss1vnet0 interface. Now that the PAN connection has been established you can verify connectivity by initiating a ping from either device.
PANM>ConnectRemoteServer 00190E06ABE8 1 1 0x3 Attempting to Open Remote Server. PANM_Connect_Remote_Device() Success: 0. PANM> Remote Device Properties Changed. BD_ADDR: 00190E06ABE8 Device Flags: 0x800000CD Connect State: TRUE PANM> Remote Device Properties Changed. BD_ADDR: 00190E06ABE8 Device Flags: 0x800000DD Encrypt State: TRUE PANM> PANM: Connection Status BD_ADDR : 00190E06ABE8 Service Type: PAN User Status : 0 PANM> PANM: Device Connected BD_ADDR : 00190E06ABE8 Service Type: PAN User PANM>
- f) Now that we have shown how to initiate a PAN connection in Bluetopia PM, let's close the PAN sample application, to do so run the following in LinuxPANM:
CloseConnection 00190E06ABE8 PANUnRegisterEventCallback 1 Cleanup Quit
PANM>CloseConnection 00190E06ABE8 Attempting to Close Connection. PANM: Device Disconnected BD_ADDR : 00190E06ABE8 Service Type: PAN User PANM>PANM_Close_Connection() Success: 0. PANM> Remote Device Properties Changed. BD_ADDR: 00190E06ABE8 Device Flags: 0x80000085 Connect State: FALSE Encrypt State: FALSE PANM>PANUnRegisterEventCallback 1
Attempting to Un-Register Events. PANM_Un_Register_Event_Callback() Success.
PANM>Cleanup
PANM>Quit root@am335x-evm:~/BluetopiaPM/bin#
Verify Connectivity[edit]
Once the connection is established and you close the demo application you can configure the devices and verify connectivity.
- a) In Windows run ipconfig to determine the appropriate network configuration to use in Linux. Look for an adapter named "Bluetooth Network Connection" or similar. Note its IPv4 Address and Subnet Mask. In this example we will assume the Windows PC has an IPv4 Address of 169.254.2.170 and an Subnet Mask of 255.255.0.0. With the network configuration from the Windows PC we can now configure the ss1vnet0 interface on the target, to configure the interface run:
ifconfig ss1vnet0 169.254.2.171 netmask 255.255.0.0
On the Windows PC:
C:\Users\ss1>ipconfig Windows IP Configuration Ethernet adapter Bluetooth Network Connection 2: Connection-specific DNS Suffix . : Link-local IPv6 Address . . . . . : fe80::f4b9:c353:ea9e:2aa%27 Autoconfiguration IPv4 Address. . : 169.254.2.170 Subnet Mask . . . . . . . . . . . : 255.255.0.0 Default Gateway . . . . . . . . . :
root@am335x-evm:~/BluetopiaPM/bin# ifconfig ss1vnet0 169.254.2.171 netmask 255.255.0.0
- b) Now that we have configured ss1vnet0 we can ping the Windows PC. On the target run:
ping 169.254.2.170
On the target:
root@am335x-evm:~/BluetopiaPM/bin# ping 169.254.2.170 PING 169.254.2.170 (169.254.2.170): 56 data bytes 64 bytes from 169.254.2.170: seq=0 ttl=128 time=39.001 ms 64 bytes from 169.254.2.170: seq=1 ttl=128 time=24.200 ms 64 bytes from 169.254.2.170: seq=2 ttl=128 time=149.048 ms ^C --- 169.254.2.170 ping statistics --- 3 packets transmitted, 3 packets received, 0% packet loss round-trip min/avg/max = 24.200/70.749/149.048 ms root@am335x-evm:~/BluetopiaPM/bin#
If everything is configured correctly you should see "64 bytes from 169.254.2.170: seq=0 ttl=128 time=39.001 ms" or a similar message.
- c)To verify connectivity on the Windows PC run:
ping 169.254.2.171
On the Windows PC:
C:\Users\ss1>ping 169.254.2.171 Pinging 169.254.2.171 with 32 bytes of data: Reply from 169.254.2.171: bytes=32 time=22ms TTL=64 Reply from 169.254.2.171: bytes=32 time=8ms TTL=64 Reply from 169.254.2.171: bytes=32 time=6ms TTL=64 Reply from 169.254.2.171: bytes=32 time=24ms TTL=64
You should see "Reply from 169.254.2.171: bytes=32 time=34ms TTL=64" or a similar message.
Ping statistics for 169.254.2.171: Packets: Sent = 4, Received = 4, Lost = 0 (0% loss), Approximate round trip times in milli-seconds: Minimum = 6ms, Maximum = 24ms, Average = 15ms
- d) Now that we have demonstrated connectivity between the devices we can close the PAN connection. On the Windows PC do the following:
1. Click the Bluetooth icon in the system tray, choose "Show Bluetooth Devices". 2. Right click the device named "WL183x Device" or "WL18xx Device" and choose "Disconnect from device network".
C:\Users\ss1>