Develop Apps for Embedded Android Networking
01/13/2014Fred Eady
Class 1: A Basic4Android Wireless Digital I/O App
A Basic4Android Wireless Digital I/O App
Basic4Android Serial Library Code a Simple Bluetooth Engine Setup and Code the Remote Device Basic4Android RandomAccessFile
Library Code a Data Communications Activity Combine the Simple Bluetooth Engine
with a Communications Activity to Produce a Remote Control App
2
AGENDA
A Basic4Android Wireless Digital I/O App
Allows Communication with Bluetooth Devices
Functionality Based on RFCOMM Usage Based on the Serial Object
Properties Allows Administration of the Bluetooth
Adapter Using the BluetoothAdmin Object
3
Basic4Android Serial Library
A Basic4Android Wireless Digital I/O App
4
Code a Simple Bluetooth EngineStep 1: Declare the Global Variables
A Basic4Android Wireless Digital I/O App
5
Code a Simple Bluetooth EngineStep 2: Code the bluAdmin / bluSPP Object Initialization
Step 3: Write Code to Load Layout the File simpleEngine
A Basic4Android Wireless Digital I/O App
6
A Basic4Android Wireless Digital I/O App
7
Code a Simple Bluetooth EngineStep 4: Write the Button Event Code
The btnScan_Click subroutine shell was created by employing the services of the Abstract Designer’s Generate Members function.
A Basic4Android Wireless Digital I/O App
8
Code a Simple Bluetooth EngineStep 5: Write the Bluetooth Administration Code
A Basic4Android Wireless Digital I/O App
9
Code a Simple Bluetooth EngineStep 6: Write the Device Discovery Code
A Basic4Android Wireless Digital I/O App
10
Code a Simple Bluetooth EngineStep 7: Write the Device Selection/Connection Code
A Basic4Android Wireless Digital I/O App
11
Code a Simple Bluetooth EngineStep 8: Test Our Simple Bluetooth App
Attempt to connect to EDTPBLU.
1234 and CONNECTED
A Basic4Android Wireless Digital I/O App
12
Setup and Code the Remote Device
A Basic4Android Wireless Digital I/O App
13
Setup and Code the Remote Device
A Basic4Android Wireless Digital I/O App
14
Setup and Code the Remote DevicePIC32MX Atomic Port I/O Operations
TRISxSET - TRISxCLR PORTxSET – PORTxCLR - PORTxINV LATxSET – LATxCLR – LATxINV
TRISACLR = 0x0001 RA0 = OUTPUTTRISASET = 0x0001 RA0 = INPUT
LATASET = 0x0001 RA0 = 1LATAINV = 0x0001 RA0 = 0
A Basic4Android Wireless Digital I/O App
15
Setup and Code the Remote DeviceStep 1: Define the WF32 LEDs 5 and 6.
Step 2: Code the LED Command Handler.
TRISFCLR = 0x0001; //WF32 RF0 = OUTPUT - LED5 TRISGCLR = 0x0040; //WF32 RG6 = OUTPUT - LED6
if(CharInQueue()) //print received character {
biteIn = recvchar();switch(biteIn)
{ case 0x35: LATFINV = 0x0001; //LED5 break; case 0x36: LATGINV = 0x0040; //LED6 break; } }
This code is added to the main function of the EDTP Embedded Bluetooth Driver.
A Basic4Android Wireless Digital I/O App
Bluetooth Usage Based on the AsyncStreams Object Properties
Allows Reading and Writing to I/O Streams Without Blocking the Main Thread
Facilitates Easy Movement of Any Amount of Data
Easily Transports Files, Arrays and Objects
16
Basic4Android RandomAccessFile Library
A Basic4Android Wireless Digital I/O App
17
Code a Data Communications ActivityStep 1: Declare the Global Variables
A Basic4Android Wireless Digital I/O App
18
Code a Data Communications ActivityStep 2: Code the Layout Sequence and “Pipe” Initialization.
A Basic4Android Wireless Digital I/O App
19
Code a Data Communications ActivityStep 3: Code the Button Event Handlers
A Basic4Android Wireless Digital I/O App
20
A Bluetooth Remote Control App
A Basic4Android Wireless Digital I/O App
21
Day 1 Topic Review
We Used BluetoothAdmin and Serial Objects to Spawn a Bare Bones Bluetooth Engine.
We Used a Digilent WF32 to Create an Embedded Bluetooth-Capable Device.
We Attached an AsyncStreams-Based Basic4Android Module to Our Simple Bluetooth Engine and Built a Useful Android App.