bluetooth data demonstration 4 with spp demonstration...

30
2014-2015 Microchip Technology Inc. page 1 Bluetooth Data Demonstration 4 with SPP Demonstration ReadMe 1.1 DESCRIPTION Bluetooth data support only for Windows and Android mobile devices. Bluetooth Stack with SPP and Bootloader. Refer to Table 3-1 in Chapter 3. “Interoperability Testing Results” of the “PIC32 Bluetooth Audio Development Kit Reference Guide” (DS70005140) for the list of tested Bluetooth-enabled devices. In this demonstration, the basic Bluetooth audio profiles and decoders have been removed, (i.e., A2DP, AVRCP, SBC and/or AAC). This demonstration provides basic data transport of non-audio full-duplex data transfers over the Bluetooth link. This demonstration does not provide any USB audio support. The demonstration allows a user to perform terminal emulation and echo characters from an Android smartphone or PC over a Bluetooth connection to the graphic display of the development board, and then back to the PC or smartphone emulation application menu. This demonstration also supports the capability to write binary images into external memory over SPP for use by the PIC32 bootloader 1.2 BASIC FUNCTIONALITY 1.2.1 Bluetooth Module The PIC32 Bluetooth Audio Development Kit provides hardware support for the BlueCore® CSR8811™ and the RDA Microelectronics RDA5876 through compile-time switches. 1.2.1.1 CSR8811 The CSR8811 is a single-chip radio and baseband IC for Bluetooth 2.4 GHz systems including Enhanced Data Rate (EDR) to 3 Mbps and Bluetooth low energy. The CSR8811 supports Bluetooth Class 1 transmission, and supports multiple device connection. The PIC32 Bluetooth Audio Development Kit uses a module based on the CSR8811 radio in its default configuration (see Note). Software projects using the default board configuration should select the CSR8811 configuration in MPLAB X IDE. Note: This ReadMe provides detailed demonstration information. For additional information, please consult the companion document, “PIC32 Bluetooth Audio Development Kit Reference Guide” (DS70005140). This reference guide is available for download from www.microchip.com. Note: Apple iOS support is also available. This support is restricted to Apple MFi licensees only. Please contact a Microchip sales office for information. Note: The CSR8811 daughter board is included in the PIC32 Bluetooth Audio Development Kit.

Upload: others

Post on 12-Aug-2020

4 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Bluetooth Data Demonstration 4 with SPP Demonstration ReadMeww1.microchip.com/downloads/en/DeviceDoc/BT_Data... · The BT_Data_Demo_4 supports the PIC32 bootloader data interface

Bluetooth Data Demonstration 4 with SPP Demonstration ReadMe

1.1 DESCRIPTION

Bluetooth data support only for Windows and Android mobile devices. Bluetooth Stack withSPP and Bootloader.

Refer to Table 3-1 in Chapter 3. “Interoperability Testing Results” of the “PIC32 BluetoothAudio Development Kit Reference Guide” (DS70005140) for the list of testedBluetooth-enabled devices.

In this demonstration, the basic Bluetooth audio profiles and decoders have been removed,(i.e., A2DP, AVRCP, SBC and/or AAC). This demonstration provides basic data transport ofnon-audio full-duplex data transfers over the Bluetooth link. This demonstration does notprovide any USB audio support. The demonstration allows a user to perform terminalemulation and echo characters from an Android smartphone or PC over a Bluetoothconnection to the graphic display of the development board, and then back to the PC orsmartphone emulation application menu. This demonstration also supports the capability towrite binary images into external memory over SPP for use by the PIC32 bootloader

1.2 BASIC FUNCTIONALITY

1.2.1 Bluetooth Module

The PIC32 Bluetooth Audio Development Kit provides hardware support for the BlueCore®CSR8811™ and the RDA Microelectronics RDA5876 through compile-time switches.

1.2.1.1 CSR8811

The CSR8811 is a single-chip radio and baseband IC for Bluetooth 2.4 GHz systemsincluding Enhanced Data Rate (EDR) to 3 Mbps and Bluetooth low energy. The CSR8811supports Bluetooth Class 1 transmission, and supports multiple device connection. ThePIC32 Bluetooth Audio Development Kit uses a module based on the CSR8811 radio in itsdefault configuration (see Note). Software projects using the default board configurationshould select the CSR8811 configuration in MPLAB X IDE.

Note: This ReadMe provides detailed demonstration information. For additional information, please consult the companion document, “PIC32 Bluetooth Audio Development Kit Reference Guide” (DS70005140). This reference guide is available for download from www.microchip.com.

Note: Apple iOS support is also available. This support is restricted to Apple MFi licensees only. Please contact a Microchip sales office for information.

Note: The CSR8811 daughter board is included in the PIC32 Bluetooth Audio Development Kit.

2014-2015 Microchip Technology Inc. page 1

Page 2: Bluetooth Data Demonstration 4 with SPP Demonstration ReadMeww1.microchip.com/downloads/en/DeviceDoc/BT_Data... · The BT_Data_Demo_4 supports the PIC32 bootloader data interface

Bluetooth Data Demonstration 4 with SPP

1.2.1.2 RDA5876

The RDA5876 integrates Bluetooth and a FM radio tuner into one device and is optimizedfor mobile applications. Bluetooth and FM can work simultaneously and independently, withlow-power consumption levels targeted to battery powered devices. For the highestintegration level, the required board space has been minimized and customer cost has beenreduced. The RDA5876 meets Class 2 and Class 3 transmitting power requirements. TheRDA5876 radio solution is a low-cost alternative for single point Bluetooth audio and dataapplications.

1.2.2 Supported Hardware

The Bluetooth Data Demonstration 4 with SPP supports the following hardware:

• PIC32 Bluetooth Audio Development Kit (P/N: DV320032)• PIC32 Bluetooth Starter Kit (P/N: DM320018)• PIC32MX270F256D Plug-in Module (PIM) for Bluetooth Audio Development Kit (P/N:

MA320013)• PIC32MX270F512L PIM for Bluetooth Audio Development Kit (P/N: MA320017)

1.2.2.1 SELECTING THE CONFIGURATION

A compile-time switch in the application code provides software support for the CSR8811,RDA5876, PIC32MX270F256D, and PIC32MX270F512L (see Figure 1-2). Othercombinations are available by selecting the CSR8811 or RDA5876 with the desired PIC32device with the Display ON/Display OFF option.

If the Display OFF option is needed for any project configuration, do the following:

1. Open Project Properties > x32-gcc > Preprocessing and Messages and select Preprocessor Macros. The Preprocessor macros window dialog appears, as shown in Figure 1-1.

2. Select USE_DISPLAY and click Destroy, and then click OK.3. Save the project.

Similarly, do the following if the RDA5876 is needed for any project configuration:

1. Open Project Properties > x32-gcc > Preprocessing and Messages and select Preprocessor Macros. The Preprocessor macros dialog appears, as shown in Figure 1-1.

2. In the Preprocessor macros dialog, replace BT_HARDWARE_CSR with BT_HARDWARE_RDA, and then click OK.

3. Save the project.

FIGURE 1-1: PROJECT CONFIGURATION

Note: Contact your local Microchip sales office to request a RDS5876 daughter board.

Note: The following combinations are not available:• The PIC32MX270F256D does not support the display.• The PIC32 Bluetooth Starter Kit only supports the CSR8811.

page 2 2014-2015 Microchip Technology Inc.

Page 3: Bluetooth Data Demonstration 4 with SPP Demonstration ReadMeww1.microchip.com/downloads/en/DeviceDoc/BT_Data... · The BT_Data_Demo_4 supports the PIC32 bootloader data interface

Demonstration ReadMe

FIGURE 1-2: CONFIGURATION SELECTION

1.2.3 Connections

If multiple Bluetooth devices are connected and paired but the user walks out of Bluetoothrange, by default, the system will continuously search for the last Bluetooth connectionsource (see Section 1.2.7 “Connection Retry Time Limit”). Then, when and if, theBluetooth-enabled device comes back into range, it will automatically reconnect. If thesmartphone or Bluetooth-enabled device, while still in range, disables it's Bluetoothconnectivity, the Bluetooth Audio Development Board Bluetooth software will not attempt toautomatically reconnect with the device.

1.2.4 Bluetooth Device IDs

The Bluetooth software remembers and stores in Flash memory the last 10 unique Bluetoothdevice IDs to which it successfully paired to facilitate faster automatic reconnection whenthere is no currently active Bluetooth connection. If Bluetooth is turned OFF on a usersmartphone that is currently connected and re-enabled later, it will automatically reconnect ifin range or when it comes back into range. In addition, when the Bluetooth AudioDevelopment Board is powered on, the Bluetooth software will automatically pair andconnect to the last Bluetooth-enabled device, assuming it is still active; otherwise, it willsearch for the next most recently connected device in the list and repeat.

1.2.5 Bluetooth Pair/Unpair

If the user presses and holds SW1, which forces Bluetooth to unpair, the user must manuallyforce their smartphone to “forget” the Bluetooth demonstration name of the development kitto enable their smartphone to rediscover and subsequently re-pair with the development kit.If the user selects SW2 (Bluetooth disconnect), the user does not need to force theirsmartphone to forget the demonstration name of the development kit and can reconnect atwill.

1.2.6 Bluetooth Device Address

By default, when the development kit is powered on for the first time, it generates a one-timerandom unique Bluetooth Device Address for any given development kit hardware.Optionally, at design time, the user can specify a Bluetooth Device Address in the applicationcode of the development kit.

The device address is a six byte hexadecimal value. The macro, BT_DEVICE_ID, definesthe first 4 bytes of the hexadecimal value and BT_DEVICE_ID_2LSB defines the last 2 bytesof the hexadecimal value. The last two bytes of the device address can be randomized byenabling BT_DEVICE_ID_2LSB_RANDOMIZE. These macros are defined inHardwareProfile_PIC32_Bluetooth_Audio_Development_Board.h.

Setting a specific hard-coded device address is not recommended during the design anddevelopment state, as Bluetooth connection problems may be experienced if anotherdevelopment board with the same Bluetooth Device Address is within range.

2014-2015 Microchip Technology Inc. page 3

Page 4: Bluetooth Data Demonstration 4 with SPP Demonstration ReadMeww1.microchip.com/downloads/en/DeviceDoc/BT_Data... · The BT_Data_Demo_4 supports the PIC32 bootloader data interface

Bluetooth Data Demonstration 4 with SPP

1.2.7 Connection Retry Time Limit

This feature, which was introduced in demonstration v2.0, enables a connection retry timelimit. The limit will define a set period (in approximate seconds) that the unit will continue toretry to connect to the Bluetooth device from which it has lost a connection. After this period,the device will discontinue trying to automatically connect. However, the device can stillmanually establish a previously paired connection, or form a new pair as previously stated.The feature can be enabled in the user_config.h file.

1.2.8 SPP Data Communication

The PIC32 Bluetooth Audio Development Kit can simultaneously connect up to sevenAndroid or Windows devices or up to three Android and three Apple iOS devices. Thedemonstration allows a user to perform terminal emulation and echo characters from anAndroid or Windows smartphone or a personal computer over a Bluetooth connection to thegraphic display (if hardware supports the display) of the development kit and then back tothe personal computer or smartphone.

The demonstration supports full duplex data transmission through SPP. This demonstrationalso allows the user to send single command to change both the display name and thedevice name.

1.2.9 Bootloader

The BT_Data_Demo_4 supports the PIC32 bootloader data interface. The PIC32 bootloaderis a specialized program that is capable of writing a new program to the device without theuse of a physical memory programmer. This functionality is supported through the use of theBluetooth SPP protocol to receive program data.

Note: This configuration is only supported by the Revision 3 PIC32 Bluetooth Audio Development Kit.

page 4 2014-2015 Microchip Technology Inc.

Page 5: Bluetooth Data Demonstration 4 with SPP Demonstration ReadMeww1.microchip.com/downloads/en/DeviceDoc/BT_Data... · The BT_Data_Demo_4 supports the PIC32 bootloader data interface

Demonstration ReadMe

1.3 BLUETOOTH DATA DEMONSTRATION SETUPDownload a terminal emulator echo application.

A terminal emulator application developed by Microchip can be obtained by visiting:

https://play.google.com/store/apps/details?id=com.mchp.android.PIC32_BTSK&hl=en

An alternate Android application can be obtained by visiting:

https://play.google.com/store/apps/details?id=mobi.dzs.android.BLE_SPP_PRO&hl=en

1.4 RUNNING BLUETOOTH DATA ANDROID DEMONSTRATION 41. Program the device with the hex file, BT Data Demo 4.hex for the

CSR8811_BT_RADIO or RDA5876_BT_RADIO Bluetooth controller. This can be done by selecting the hardware support from the drop down box during compilation, as shown in the following figure.

2. Enable Bluetooth on the Android device.3. Open the Android terminal emulator application.4. Connect and pair the Android device with the Bluetooth Audio Development Board to the

device named BT Data Demo 4.5. If prompted by your Bluetooth device for a PIN, enter 0000. The device should connect

and pair, and indicate as such on the display, as shown in the following figure.

6. After pairing, the Android device must be connected to the development kit. Please note that some terminal emulator applications do this automatically upon pairing. Once the device is connected, the display updates from “Not Connected” to “BT Connected” (see the following figure), and LED D5 illuminates.

2014-2015 Microchip Technology Inc. page 5

Page 6: Bluetooth Data Demonstration 4 with SPP Demonstration ReadMeww1.microchip.com/downloads/en/DeviceDoc/BT_Data... · The BT_Data_Demo_4 supports the PIC32 bootloader data interface

Bluetooth Data Demonstration 4 with SPP

7. Enter characters in the Android device application under “CMD Line Mode”, “Keyboard Mode”, or “Byte Stream Mode”. The characters (not a command) will be displayed on the LCD of the development board, and are then echoed back by the PIC32 device and displayed on the Android device menu.

In Keyboard Mode, phrases can be saved to buttons.

Once the button is pressed or a string is entered, it will appear on the display of thedevelopment kit, as shown in the following figure.

The received text will “round robin” on the bottom five lines.

Alternatively, the PIC32 Bluetooth Starter Kit application can also be used to connect toDemonstration 4. Once connected, it can be used to change the color of the display ascan be seen in the previous figure.

Note: The display is not supported on the PIC32 Bluetooth Starter Kit and the PIC32MX270F256D PIM.

page 6 2014-2015 Microchip Technology Inc.

Page 7: Bluetooth Data Demonstration 4 with SPP Demonstration ReadMeww1.microchip.com/downloads/en/DeviceDoc/BT_Data... · The BT_Data_Demo_4 supports the PIC32 bootloader data interface

Demonstration ReadMe

1.5 BLUETOOTH DATA WINDOWS PC DEMONSTRATION SETUP1. Program the device with the hex file, BT Data Demo 4.hex for the CSR8811_BT_RADIO

or RDA5876_BT_RADIO Bluetooth controller. This can be done by selecting the hardware support from the drop down box during compilation, as shown in the following figure.

2. On a Windows PC, select Start > Control Panel > Hardware and Sounds >Add a device. A dialog appears with a list of available bluetooth devices. From the list, select BT Data

Demo 4.3. Once BT Data Demo 4 is selected, the Windows PC will install the drivers and will allocate

COM ports. When driver installations are complete, a pop-up message appears indicating the device is ready for use. The allocated COM ports vary, depending on the Windows configuration.

2014-2015 Microchip Technology Inc. page 7

Page 8: Bluetooth Data Demonstration 4 with SPP Demonstration ReadMeww1.microchip.com/downloads/en/DeviceDoc/BT_Data... · The BT_Data_Demo_4 supports the PIC32 bootloader data interface

Bluetooth Data Demonstration 4 with SPP

4. The COM ports used can also be identified from the Device Manager.

5. Open a terminal emulator. For this example, PuTTY was used. This PC application can be obtained by visiting: http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html.

page 8 2014-2015 Microchip Technology Inc.

Page 9: Bluetooth Data Demonstration 4 with SPP Demonstration ReadMeww1.microchip.com/downloads/en/DeviceDoc/BT_Data... · The BT_Data_Demo_4 supports the PIC32 bootloader data interface

Demonstration ReadMe

6. Once the terminal connection is established, a new terminal window opens and the transmitted and received data will be displayed, as shown in the following figure.

7. The transmitted data is displayed, as shown in the following figure.

2014-2015 Microchip Technology Inc. page 9

Page 10: Bluetooth Data Demonstration 4 with SPP Demonstration ReadMeww1.microchip.com/downloads/en/DeviceDoc/BT_Data... · The BT_Data_Demo_4 supports the PIC32 bootloader data interface

Bluetooth Data Demonstration 4 with SPP

1.6 BLUETOOTH DATA WINDOWS PHONE DEMONSTRATION SETUPDownload a terminal emulator application for windows mobile. An application can be obtained from Microsoft by visiting:

http://apps.microsoft.com/windows/en-us/app/b9a0abda-0e28-4b3c-936b-3b9f415fdcdf

1.7 RUNNING BLUETOOTH DATA DEMONSTRATION 41. Program the device with the hex file, BT Data Demo 4.hex for the

CSR8811_BT_RADIO or RDA5876_BT_RADIO Bluetooth controller. This can be done by selecting the hardware support from the drop down box during compilation, as shown in the following figure.

2. Enable Bluetooth on the smartphone.3. Connect and pair the Windows phone with the PIC32 Bluetooth Audio Development Kit to

the device named BT Data Demo 4.4. If prompted by your Bluetooth device for a PIN, enter 0000. The device should connect

and pair, and indicate as such on the display, as shown in the following figure.

5. After pairing, the Windows phone must be connected to the development kit using a termi-nal emulator. Connect to the device in Settings > Bluetooth.

6. After connecting to the device, open BT TERMINAL (the Windows application for SPP communication), as shown in the following figure

page 10 2014-2015 Microchip Technology Inc.

Page 11: Bluetooth Data Demonstration 4 with SPP Demonstration ReadMeww1.microchip.com/downloads/en/DeviceDoc/BT_Data... · The BT_Data_Demo_4 supports the PIC32 bootloader data interface

Demonstration ReadMe

7. The connected device name will be listed on the terminal emulator window.8. Select the required device name and the BT terminal will establish connection with the

device.

9. Once the Windows phone is connected, the display updates from “Not Connected” to “BT Connected” (see the following figure), and LED D5 illuminates.

10. Data can now be received and sent from the terminal emulator. The data will be displayed on the LCD of the development board, and is then echoed back by the PIC32 device and displayed on the Windows phone.

2014-2015 Microchip Technology Inc. page 11

Page 12: Bluetooth Data Demonstration 4 with SPP Demonstration ReadMeww1.microchip.com/downloads/en/DeviceDoc/BT_Data... · The BT_Data_Demo_4 supports the PIC32 bootloader data interface

Bluetooth Data Demonstration 4 with SPP

1.8 BLUETOOTH DATA SMARTPHONE DEMONSTRATION SETUP FOR ANDROID

The Microchip SPP application is available in mobile_apps\Android. Refer to thefollowing section for installation steps or download a terminal emulator echo application

1.8.1 Installing the Microchip Application

Do the following the install the application:

1. Connect the handset to the computer using a mini-B USB connector.2. It is suggested to copy the PIC32 SPP App to the download folder of the mobile device.

3. Using the File Manager of the mobile device, select My Files > All Files > Download > PIC32_SPP.apk.

4. After selecting the file, a warning message indicating the installation is blocked will appear.

Note: If the device does not have a File Manager app, a File Manager app is available for download from Google Play.

page 12 2014-2015 Microchip Technology Inc.

Page 13: Bluetooth Data Demonstration 4 with SPP Demonstration ReadMeww1.microchip.com/downloads/en/DeviceDoc/BT_Data... · The BT_Data_Demo_4 supports the PIC32 bootloader data interface

Demonstration ReadMe

5. Select Settings to open the Security screen and enable installations from unknown sources, and then select OK to confirm the change.

6. A message appears requesting whether to install an update to the existing application. Select Install. A confirmation screen appears when the application has been installed, and then select Open to run the application.

2014-2015 Microchip Technology Inc. page 13

Page 14: Bluetooth Data Demonstration 4 with SPP Demonstration ReadMeww1.microchip.com/downloads/en/DeviceDoc/BT_Data... · The BT_Data_Demo_4 supports the PIC32 bootloader data interface

Bluetooth Data Demonstration 4 with SPP

7. Select UI Control.

8. Select PIC32 SPP and then select Pair and Connect a device.

page 14 2014-2015 Microchip Technology Inc.

Page 15: Bluetooth Data Demonstration 4 with SPP Demonstration ReadMeww1.microchip.com/downloads/en/DeviceDoc/BT_Data... · The BT_Data_Demo_4 supports the PIC32 bootloader data interface

Demonstration ReadMe

9. Once installation is complete, select Open to run the app.

10. After opening the app, select UI Control.

 

 

2014-2015 Microchip Technology Inc. page 15

Page 16: Bluetooth Data Demonstration 4 with SPP Demonstration ReadMeww1.microchip.com/downloads/en/DeviceDoc/BT_Data... · The BT_Data_Demo_4 supports the PIC32 bootloader data interface

Bluetooth Data Demonstration 4 with SPP

11. Next, select PIC32 SPP, which is located in the top left corner of the app.

12. While scanning, the device name will be identified faster in Pause mode.13. Change the audio from Pause mode to Play mode. The device name is listed before

connecting to the device.14. Connect the smartphone with the PIC32 Bluetooth Audio Development Kit to the paired

device (BT Demo 4/iAP).15. If prompted by your Bluetooth device for a PIN, enter 0000. The device should connect

and indicate as such on the display, as shown in the following figure. Once the Bluetooth device is connected to the mobile handset, data can be transferred and received during audio playback. The application demonstrates functionalities for SPP full duplex data transmission, as described in the next section.

 

page 16 2014-2015 Microchip Technology Inc.

Page 17: Bluetooth Data Demonstration 4 with SPP Demonstration ReadMeww1.microchip.com/downloads/en/DeviceDoc/BT_Data... · The BT_Data_Demo_4 supports the PIC32 bootloader data interface

Demonstration ReadMe

1.8.2 Demonstration Features

1.8.2.1 LED CONTROL

The user can provide any number from 0 through 31 in decimal format and the LEDs on thedevelopment kit will toggle representing the binary format of the input data. The commanddetails are provided in a following section. LED5 represents the LSB and LED9 representsthe MSB. The following table shows the results if the decimal numbers “4, 8, and 31” areprovided as input data.

1.8.2.2 NAME CHANGE FUNCTIONALITY

The demonstration allows the user to change the name of the Bluetooth device and thedisplay name by entering the string in the text field of the Name change label. The Bluetoothdevice name and the display name are defined in user_config.h asBT_AUDIO_CONNECT_NAME and BT_AUDIO_DISPLAY_NAME. The name change can bevisualized by disconnecting from the Bluetooth device and rescanning for available devices.The Bluetooth device with the new name “Microchip” is listed in the list of scanned devices.The command that is sent is displayed on the Bluetooth device display screen as“NMicrochip”.

To retain the name change, the macro, USE_SPP_PROVIDEDNAME, is provided in theuser_config.h file. If this flag is defined, the board will take the new name provided in theprevious step once power is cycled.

1.8.2.3 BACKGROUND COLOR

The demonstration allows the user to change the background color of the display throughone of two methods.

1. By entering the desired B# command, where “#” is a number from 1 to 3.

2. Background color can also be changed by sending a 255,03,R,G,B command. The R, G, and B values must be between 0 and 255.

Decimal Input

LED State

LED5 LED6 LED7 LED8 LED9

4 OFF OFF ON OFF OFF

8 OFF OFF OFF ON OFF

31 ON ON ON ON ON

Command Color

B1/b1 White

B2/b2 Light Green

B3/b3 Bright Yellow

2014-2015 Microchip Technology Inc. page 17

Page 18: Bluetooth Data Demonstration 4 with SPP Demonstration ReadMeww1.microchip.com/downloads/en/DeviceDoc/BT_Data... · The BT_Data_Demo_4 supports the PIC32 bootloader data interface

Bluetooth Data Demonstration 4 with SPP

1.8.3 Other Android Applications

1.8.3.1 BLUETOOTH SPP PRO

The Bluetooth data smartphone demonstration can also be executed using the BluetoothSPP-pro application. This app is available for download by visiting:

https://play.google.com/store/apps/details?id=mobi.dzs.android.BLE_SPP_PRO&hl=en

Once installed, the commands can be sent and received in CMD line mode/Keyboard modeof the terminal emulator of the application. The commands will be sent and received in theformat shown in the following table.

1.8.3.2 MICROCHIP PIC32 BLUETOOTH STARTER KIT

The Microchip PIC32 Bluetooth Starter Kit app can also be used in this demo. The app canbe downloaded by visiting:

https://play.google.com/store/apps/details?id=com.mchp.android.PIC32_BTSK&hl=en

Once installed, the commands can be sent and received in Text mode. It can also be usedto change the display color.

TABLE 1-1: COMMANDS

Feature Command TX RX Description Example

LED Toggle

L0-L31, I0-I31 L5 N/A Toggles the LED on the board representing the binary format of the input number

L0,L5,L31

Display Name Change

N(Name), n(Name) Nmicro N/A Modifies the Name displayed on the board

Nmicro, nTomTom

Display Color Change

B1-B3, b1-b3, 255,03,R,G,B(where R, G, B are between 0 and 255)

B1255,3,240,10,15

N/A Modifies the color of the display B1,b3255,03,240,10,5

Note: Valid commands do not appear on the display, with the exception of the PIC32 Bluetooth Starter Kit and the PIC32MX270F256D PIM. Invalid commands are only displayed.

page 18 2014-2015 Microchip Technology Inc.

Page 19: Bluetooth Data Demonstration 4 with SPP Demonstration ReadMeww1.microchip.com/downloads/en/DeviceDoc/BT_Data... · The BT_Data_Demo_4 supports the PIC32 bootloader data interface

Demonstration ReadMe

1.9 BLUETOOTH DATA SMARTPHONE DEMONSTRATION FOR APPLEDue to Apple's strict App distribution policy, customers cannot be provided with an App thatcan be installed directly to their iOS device. However, Microchip can supply iOS-compatiblesource code for engineering teams with an Apple Development License account. This sourcecode can be built and installed directly onto their own provisioned devices.

1.9.1 Running The Demonstration

1. Establish a Bluetooth connection between the development kit and the iOS device by powering the kit with the Demo 4 firmware.

2. Enable Bluetooth on the Apple device via Settings > Bluetooth.3. Set the Bluetooth switch to the ON position.4. In the list, locate and tap the entry BT Demo 4 iAP.5. When the display indicates “Connected”, tap the Home button.

6. Locate the Demo 13 icon and tap it to launch the application.

7. To connect multiple devices (limit of three MFi-enabled devices) over the iAP, follow steps 1 through 6. The Demo tab allows interaction with the development kit. When the accessory establishes an iAP connection with the iOS device, the Accessory Information will be populated.

2014-2015 Microchip Technology Inc. page 19

Page 20: Bluetooth Data Demonstration 4 with SPP Demonstration ReadMeww1.microchip.com/downloads/en/DeviceDoc/BT_Data... · The BT_Data_Demo_4 supports the PIC32 bootloader data interface

Bluetooth Data Demonstration 4 with SPP

1.9.2 Demonstration Features

1.9.2.1 LED CONTROL

The switches under LED Controls control the LEDs on the development kit. Toggle theswitches on the app to toggle the LEDs on the board.

1.9.2.2 NAME CHANGE FUNCTIONALITY

The demonstration allows the user to change the name of the Bluetooth device and thedisplay name by sending the name in the Change name field. The Bluetooth device nameand the display name are defined in user_config.h as BT_AUDIO_CONNECT_NAME andBT_AUDIO_DISPLAY_NAME.

The name change can be visualized by disconnecting from the Bluetooth device andrescanning for available devices. The Bluetooth device with the new name “Microchip” islisted in the list of scanned devices. The command that is sent is displayed on the Bluetoothdevice display screen as “NMicrochip”. To change the displayed name on the developmentkit, enter the string in the text field, and touch Change name.

page 20 2014-2015 Microchip Technology Inc.

Page 21: Bluetooth Data Demonstration 4 with SPP Demonstration ReadMeww1.microchip.com/downloads/en/DeviceDoc/BT_Data... · The BT_Data_Demo_4 supports the PIC32 bootloader data interface

Demonstration ReadMe

1.10 LOADING NEW CODE TO THE TARGET PLATFORMThe PIC32 bootloader is a specialized program that is capable of writing a new program tothe device without the use of a physical memory programmer.

The PIC32 bootloader occupies the beginning of program Flash memory and the applicationis placed after it, as shown in the following figure.

The actual memory addresses used depends on the settings specified in the specializedlinker scripts. The linker scripts are added to the program and compiled, generating a hexfile. The linker script determines the memory location where the application needs to bewritten.

The generated hex file needs to be converted into a binary file using specialized tools thatare provided with this demonstration. This generated binary file should be saved to thesmartphone, as it will be used by specialized Android/iOS apps provided with thisdemonstration for boot loading the target platform through SPP/iAP via Bluetooth.

1.10.1 Bootloading Process

The BT_Audio_Demo13 supports bootloading through SPI Flash. The smartphone appfragments the binary file into chunks of data packets (4096 bytes) and transmits to the targetboard through SPP/iAP via Bluetooth. The target board receives the packet and continuessaving it into the SPI Flash until all of the code packets are received. Once all of the code isreceived, a flag is set in the SPI Flash. Upon reset, this flag is checked if set, and then theon-chip Flash is written by the target code stored in the SPI Flash.

The following figure shows the bootloader flow diagram.

FIGURE 1-3: PIC32 BOOTLOADER FLOW DIAGRAM

Power On

Image Flag Set

Jump to Application

No Yes

Flash NewApplication

Clear ImageFlag

2014-2015 Microchip Technology Inc. page 21

Page 22: Bluetooth Data Demonstration 4 with SPP Demonstration ReadMeww1.microchip.com/downloads/en/DeviceDoc/BT_Data... · The BT_Data_Demo_4 supports the PIC32 bootloader data interface

Bluetooth Data Demonstration 4 with SPP

1.10.2 Bootloader Awareness

Boot loader awareness is defined as being able to recognize incoming program binary datain the SPP data stream and storing that data in the proper external memory location.

1.10.3 Program Memory Placement

Proper memory addressing is configured through the use of specialized linker scripts. ThePIC32 bootloader program is compiled with a specialized linker script to place it properly intoboth boot and program memory. Any program that needs to be loaded by the bootloadermust also be compiled with the same specialized linker script.

1.10.4 Running Bootloader Aware Code

Open the MPLAB X IDE project and select the project configuration,MX470L_AK4384_CSR_BLDR/MX470L_AK4384_CSR_BLDR_IAP. Build the project and run iton the target board.

For convenience, bt_audio_demo_13g.bin and bt_audio_demo_13y.bin, have beenprovided with this demonstration. These files will be used by the Android/iOS apps todemonstrate the bootloading process. The following two sections are optional, and can beskipped if customized boot loading code for the target platform is not required.

1.10.5 Building Customized Bootloader Code (Optional)

The following optional steps are for building customized bootloader code for the target andcan be skipped. If a new binary file is not required (using the provided binary file with thisdemonstration), Section 1.10.6 “Hex to Binary File Conversion” can also be skipped.

1. Open the project in MPLAB X IDE; for example, Demo4, and select the configuration MX470K_CSR_BLDR/MX470K_CSR_BLDR_IAP.

2. Right-click the Linker Files folder and select Add Existing File. The pic32_application.ld linker script file available in the location:..\..\boot_loader\linker_scripts\pic32_application.ld.

The file name, pic32_application.ld, will appear as an entry within the Linker Filesfolder, as shown in the following figure.

Note: If the program that is running on the development kit is not “Bootloader Aware” (unified code with bootloader), the bootloader capability will be left inert, as there will be no program available to handle new binary program data, which results in bootloader applications generating an upload error.

Note: As memory requirements differ for each application, the provided application linker script may not be correct and would require modifications.

Note: The linker script is added to the project by default.

page 22 2014-2015 Microchip Technology Inc.

Page 23: Bluetooth Data Demonstration 4 with SPP Demonstration ReadMeww1.microchip.com/downloads/en/DeviceDoc/BT_Data... · The BT_Data_Demo_4 supports the PIC32 bootloader data interface

Demonstration ReadMe

3. Compile the project and generate the hex file for the MX470L_CSR8811_BLDR/MX470L_CSR_BLDR_IAP configuration by selecting the configuration, as shown in the following figure.

4. It is possible that the code will not build due to lack of memory. If this occurs, reduce the heap memory to a smaller value, as shown in the following figure.

5. Open the PIC32 bootloader workspace in MPLAB X IDE and make it the main project. The project is available in the location:..\..\bootloader\pic32_bootloader\ pic32_bootloader.X

6. Right click the Loadables folder and select Add Loadable Project.

2014-2015 Microchip Technology Inc. page 23

Page 24: Bluetooth Data Demonstration 4 with SPP Demonstration ReadMeww1.microchip.com/downloads/en/DeviceDoc/BT_Data... · The BT_Data_Demo_4 supports the PIC32 bootloader data interface

Bluetooth Data Demonstration 4 with SPP

7. When the Open File dialog appears, navigate to and select the Bluetooth Demonstration 4 MPLAB X IDE workspace folder and add the hex file that was generated for the MX470L_CSR8811_BLDR/MX470L_CSR_BLDR_IAP configuration. This action adds an entry within the Loadables folder named bt_audio_demo_4.

8. Build the PIC32 bootloader project.9. Program the PIC32 Bluetooth Audio Development Kit with the PIC32 bootloader project.

Demo 4 is now the bootloader target running on the kit.

1.10.6 Hex to Binary File Conversion

A specialized Java program, hex_to_bin.jar, which is located inbootloader\hex_to_bin\dist, is provided with this demonstration to convert a hex fileinto a binary file. Using hex_to_bin.jar, the hex file created by building the MPLAB XIDE project, bt_audio_demo_4.X.production.hex, is converted to a binary file.

Note: There is the possibility that the build will fail with the error “(944) data conflict at address 1D003010h .....”. This message indicates that there are two files containing the same pragmas (board.c and bootloader.c). To correct this issue, comment out all of the board configuration pragmas in the board.c file of Demo 13 and repeat Steps 3 through 8.

Note: This program is a Java-based .jar file and requires Java JRE v1.7. For information on how to properly install and configure Java, please visit:http://java.com/en/download/help/index_installing.xml

page 24 2014-2015 Microchip Technology Inc.

Page 25: Bluetooth Data Demonstration 4 with SPP Demonstration ReadMeww1.microchip.com/downloads/en/DeviceDoc/BT_Data... · The BT_Data_Demo_4 supports the PIC32 bootloader data interface

Demonstration ReadMe

1.10.7 Bootloading Method

The binary file generated in Section 1.10.6 “Hex to Binary File Conversion” should becopied to the download folder of the Android phone.

a) Android Handset Application > Update Firmware:

Select Settings > Bluetooth > BT Audio Demo 4. The device is now connected to thePIC32 Bluetooth Audio Development Kit. After establishing a Bluetooth connection,open the app and select Reprogram, as shown in the following figure.

After selecting Reprogram, choose the file that needs to be loaded. Once the fileupload is complete, reset the board and the new program is written to memory. Theboard is now programmed with the new demonstration. For verification purposes,before creating the bin file, enable the BOOTLOADER_DEMO macro in theuser_config.h file.

Now, when the new bin file is downloaded and programmed, the background displaycolor will be yellow.

Note: Due to strict nature of iOS, binary files cannot be copied directly into the iOS folder. Instead the iOS app should be updated with the binary file.

Note: On a power reset, the display screen of the PIC32 Bluetooth Audio Development Kit will be blank and it will take approximately 30 seconds for the board to be programmed with the new demonstration.

2014-2015 Microchip Technology Inc. page 25

Page 26: Bluetooth Data Demonstration 4 with SPP Demonstration ReadMeww1.microchip.com/downloads/en/DeviceDoc/BT_Data... · The BT_Data_Demo_4 supports the PIC32 bootloader data interface

Bluetooth Data Demonstration 4 with SPP

b) Apple Handset Application > Update Firmware:

Select Settings > Bluetooth > BT Audio Demo 4 iAP. The device is now connected tothe PIC32 Bluetooth Audio Development Kit. After establishing a Bluetoothconnection, open the app and select Firmware 1 (or Firmware 2) to download thebinary file, as shown in the following figure.

The binary file that needs to be updated should be added to the app. This mobileapplication is appended with two binary files. When Firmware 1 or Firmware 2 isselected, chunks of data are downloaded. The bytes downloaded are displayed in theapp as shown in the following figure. The progress bar is updated accordingly.

page 26 2014-2015 Microchip Technology Inc.

Page 27: Bluetooth Data Demonstration 4 with SPP Demonstration ReadMeww1.microchip.com/downloads/en/DeviceDoc/BT_Data... · The BT_Data_Demo_4 supports the PIC32 bootloader data interface

Demonstration ReadMe

Once the download is complete, the status is updated in the app as shown in thefollowing figure. On a power reset, the board is programmed with the latest firmware.

Note: On a power reset, the display screen of the PIC32 Bluetooth Audio Development Kit will be blank and it will take almost 30 to 60 seconds for the board to be programmed with the new firmware.

2014-2015 Microchip Technology Inc. page 27

Page 28: Bluetooth Data Demonstration 4 with SPP Demonstration ReadMeww1.microchip.com/downloads/en/DeviceDoc/BT_Data... · The BT_Data_Demo_4 supports the PIC32 bootloader data interface

Bluetooth Data Demonstration 4 with SPP

1.11 BOOTLOADER COMMANDS AND PROTOCOLThis section discusses the communication protocol used by BT_Data_Demo_4 to identify,receive, and verify incoming program binary data, and lists the commands that can be issuedto the demonstration.

Binary data is sent in four kilobyte logical segments. Each segment is hashed previous tosending and the hash is sent before the segment.

TABLE 1-2: COMMANDS

TABLE 1-3: RESPONSES

The protocol for executing a binary transfer to the BT_Data_Demo_4 is shown in Figure 1-4.

FIGURE 1-4: BINARY TRANSFER EXECUTION PROTOCOL

Note: No hashing algorithm has been implemented at this time. Dummy hashes are sent and are not checked for consistency.

CommandSize

(bytes)Value Description

Reset 4 0x00B00701 Attempts to soft-reset the device. (Not veri-fied)

Identify 4 0x00B00702 Returns an identification string.

Receive* 8 0x00B00703 00000000 Signals the impending arrival of program binary data.

Last 4 bytes is the size of the incoming data. Normal demo SPP functions will be sus-pended until this many bytes are received.

ResponseSize

(bytes)Value Description

ACK 1 0x0 Positive Acknowledgment

NAK 1 0x1 Negative Acknowledgment

Send Receive Commandand Size of Datato be Transferred

Send Hashof Segment

Receive ACK

Send Segment

Receive ACK

While there is data to send

Receive ACK

TransferCompleted

page 28 2014-2015 Microchip Technology Inc.

Page 29: Bluetooth Data Demonstration 4 with SPP Demonstration ReadMeww1.microchip.com/downloads/en/DeviceDoc/BT_Data... · The BT_Data_Demo_4 supports the PIC32 bootloader data interface

Demonstration ReadMe

1.12 KNOWN ISSUESThe following issues are known to exist in this demonstration:

• The boot image transfer protocol cannot recover from an interrupted transfer. A reset is required.

1.13 REVISION HISTORY

Version1.0.1

This revision includes the following updates:

• Updates to RTOS files• XC32 v1.3 complier compatibility improvements

Version 1.0.2

This revision includes the following updates:

• Missing library components were added to enable compilation

Version 2.0

This revision includes the following updates:

• RTOS was removed• The Graphics Driver was updated to support future displays• A top-level user configuration header file (user_config.h), which includes global

constraints was added

Version 3.0

This revision includes the following updates:

• RDA Bluetooth module support was added• A global definition for Bluetooth Device ID value (CSR only) was added• The common display design defined by display_config.h was added• The application architecture was updated to enable compatibility with other demonstrations

Version 3.0.1

This revision includes the following updates:

• The assert diagnostics were revised, which are now user configurable (default is OFF)• Stack usage diagnostics were added (default is OFF)• Options in the user_config.h file were revised• The Bluetooth SPP Library (1.3.1 - 1.5.1) was revised

Version 3.5

This revision includes the following updates:

• Improved random addressing feature, automatic reconnect• Added new features to user configuration including number of pairing systems• Added ability to eliminate the display from the project source, saving Flash memory• Added iAP over Bluetooth support• Added Bootloader over Bluetooth support

Version 4.0

This version includes the following updates:

• New Bluetooth Stack v2.1• Data break-in feature. Up to seven Android devices can be paired and connected in the

non-iAP version and up to three Android and up to three Apple iOS devices can be paired and connected simultaneously in the iOS version.

• Improved display

2014-2015 Microchip Technology Inc. page 29

Page 30: Bluetooth Data Demonstration 4 with SPP Demonstration ReadMeww1.microchip.com/downloads/en/DeviceDoc/BT_Data... · The BT_Data_Demo_4 supports the PIC32 bootloader data interface

Bluetooth Data Demonstration 4 with SPP

NOTES:

page 30 2014-2015 Microchip Technology Inc.