Develop Apps for Embedded Android Networking Class 1: A Basic4Android Wireless Digital I/O App 01/13/2014 Fred Eady A Basic4Android Wireless Digital I/O App AGENDA 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 A Basic4Android Wireless Digital I/O App Basic4Android Serial Library 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 A Basic4Android Wireless Digital I/O App Code a Simple Bluetooth Engine Step 1: Declare the Global Variables 4 A Basic4Android Wireless Digital I/O App Code a Simple Bluetooth Engine Step 2: Code the bluAdmin / bluSPP Object Initialization Step 3: Write Code to Load Layout the File simpleEngine 5 A Basic4Android Wireless Digital I/O App 6 A Basic4Android Wireless Digital I/O App Code a Simple Bluetooth Engine Step 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. 7 A Basic4Android Wireless Digital I/O App Code a Simple Bluetooth Engine Step 5: Write the Bluetooth Administration Code 8 A Basic4Android Wireless Digital I/O App Code a Simple Bluetooth Engine Step 6: Write the Device Discovery Code 9 A Basic4Android Wireless Digital I/O App Code a Simple Bluetooth Engine Step 7: Write the Device Selection/Connection Code 10 A Basic4Android Wireless Digital I/O App Code a Simple Bluetooth Engine Step 8: Test Our Simple Bluetooth App Attempt to connect to EDTPBLU. 1234 and CONNECTED 11 A Basic4Android Wireless Digital I/O App Setup and Code the Remote Device 12 A Basic4Android Wireless Digital I/O App Setup and Code the Remote Device 13 A Basic4Android Wireless Digital I/O App Setup and Code the Remote Device PIC32MX Atomic Port I/O Operations TRISxSET - TRISxCLR PORTxSET – PORTxCLR - PORTxINV LATxSET – LATxCLR – LATxINV TRISACLR = 0x0001 TRISASET = 0x0001 RA0 = OUTPUT RA0 = INPUT LATASET = 0x0001 LATAINV = 0x0001 RA0 = 1 RA0 = 0 14 A Basic4Android Wireless Digital I/O App Setup and Code the Remote Device Step 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 This code is added to the main { function of the EDTP Embedded biteIn = recvchar(); Bluetooth Driver. switch(biteIn) { case 0x35: LATFINV = 0x0001; //LED5 break; case 0x36: LATGINV = 0x0040; //LED6 break; } } 15 A Basic4Android Wireless Digital I/O App Basic4Android RandomAccessFile Library 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 A Basic4Android Wireless Digital I/O App Code a Data Communications Activity Step 1: Declare the Global Variables 17 A Basic4Android Wireless Digital I/O App Code a Data Communications Activity Step 2: Code the Layout Sequence and “Pipe” Initialization. 18 A Basic4Android Wireless Digital I/O App Code a Data Communications Activity Step 3: Code the Button Event Handlers 19 A Basic4Android Wireless Digital I/O App A Bluetooth Remote Control App 20 A Basic4Android Wireless Digital I/O App 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. 21