220 likes | 406 Views
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
E N D
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
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
A Basic4Android Wireless Digital I/O App Code a Simple Bluetooth Engine Step 1: Declare the Global Variables
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
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.
A Basic4Android Wireless Digital I/O App Code a Simple Bluetooth Engine Step 5: Write the Bluetooth Administration Code
A Basic4Android Wireless Digital I/O App Code a Simple Bluetooth Engine Step 6: Write the Device Discovery Code
A Basic4Android Wireless Digital I/O App Code a Simple Bluetooth Engine Step 7: Write the Device Selection/Connection Code
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
A Basic4Android Wireless Digital I/O App • Setup and Code the Remote Device
A Basic4Android Wireless Digital I/O App • Setup and Code the Remote Device
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 RA0 = OUTPUT TRISASET = 0x0001 RA0 = INPUT LATASET = 0x0001 RA0 = 1 LATAINV = 0x0001 RA0 = 0
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 { 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 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
A Basic4Android Wireless Digital I/O App Code a Data Communications Activity Step 1: Declare the Global Variables
A Basic4Android Wireless Digital I/O App Code a Data Communications Activity Step 2: Code the Layout Sequence and “Pipe” Initialization.
A Basic4Android Wireless Digital I/O App Code a Data Communications Activity Step 3: Code the Button Event Handlers
A Basic4Android Wireless Digital I/O App A Bluetooth Remote Control App
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.