Upload
marsala-nisto
View
223
Download
0
Embed Size (px)
Citation preview
8/13/2019 DN CEC Develop Apps Embedded Android Networking Day1
1/21
Develop Apps for Embedded AndroidNetworking
01/13/2014
Fred Eady
Class 1: A Basic4Android Wireless Digital I/O App
8/13/2019 DN CEC Develop Apps Embedded Android Networking Day1
2/21
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 Enginewith a Communications Activity toProduce a Remote Control App
2
AGENDA
8/13/2019 DN CEC Develop Apps Embedded Android Networking Day1
3/21
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 AdapterUsing the BluetoothAdmin Object
3
Basic4Android Serial Library
8/13/2019 DN CEC Develop Apps Embedded Android Networking Day1
4/21
A Basic4Android Wireless Digital I/O App
4
Code a Simple Bluetooth EngineStep 1: Declare the Global Variables
8/13/2019 DN CEC Develop Apps Embedded Android Networking Day1
5/21
A Basic4Android Wireless Digital I/O App
5
Code a Simple Bluetooth EngineStep 2: Code the bluAdmin/ bluSPP Object InitializationStep 3: Write Code to Load Layout the File simpleEngine
8/13/2019 DN CEC Develop Apps Embedded Android Networking Day1
6/21
A Basic4Android Wireless Digital I/O App
6
8/13/2019 DN CEC Develop Apps Embedded Android Networking Day1
7/21
8/13/2019 DN CEC Develop Apps Embedded Android Networking Day1
8/21
A Basic4Android Wireless Digital I/O App
8
Code a Simple Bluetooth EngineStep 5: Write the Bluetooth Administration Code
8/13/2019 DN CEC Develop Apps Embedded Android Networking Day1
9/21
A Basic4Android Wireless Digital I/O App
9
Code a Simple Bluetooth EngineStep 6: Write the Device Discovery Code
8/13/2019 DN CEC Develop Apps Embedded Android Networking Day1
10/21
A Basic4Android Wireless Digital I/O App
10
Code a Simple Bluetooth EngineStep 7: Write the Device Selection/Connection Code
8/13/2019 DN CEC Develop Apps Embedded Android Networking Day1
11/21
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
8/13/2019 DN CEC Develop Apps Embedded Android Networking Day1
12/21
A Basic4Android Wireless Digital I/O App
12
Setup and Code the Remote Device
8/13/2019 DN CEC Develop Apps Embedded Android Networking Day1
13/21
A Basic4Android Wireless Digital I/O App
13
Setup and Code the Remote Device
8/13/2019 DN CEC Develop Apps Embedded Android Networking Day1
14/21
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 = OUTPUT
TRISASET = 0x0001 RA0 = INPUT
LATASET = 0x0001 RA0 = 1
LATAINV = 0x0001 RA0 = 0
8/13/2019 DN CEC Develop Apps Embedded Android Networking Day1
15/21
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 EmbeddedBluetooth Driver.
8/13/2019 DN CEC Develop Apps Embedded Android Networking Day1
16/21
A Basic4Android Wireless Digital I/O App
Bluetooth Usage Based on the AsyncStreamsObject 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
8/13/2019 DN CEC Develop Apps Embedded Android Networking Day1
17/21
A Basic4Android Wireless Digital I/O App
17
Code a Data Communications Activity
Step 1: Declare the Global Variables
8/13/2019 DN CEC Develop Apps Embedded Android Networking Day1
18/21
A Basic4Android Wireless Digital I/O App
18
Code a Data Communications Activity
Step 2: Code the Layout Sequence and Pipe Initialization.
8/13/2019 DN CEC Develop Apps Embedded Android Networking Day1
19/21
A Basic4Android Wireless Digital I/O App
19
Code a Data Communications Activity
Step 3: Code the Button Event Handlers
8/13/2019 DN CEC Develop Apps Embedded Android Networking Day1
20/21
A Basic4Android Wireless Digital I/O App
20
A Bluetooth Remote Control App
8/13/2019 DN CEC Develop Apps Embedded Android Networking Day1
21/21
A Basic4Android Wireless Digital I/O App
21
Day 1 Topic Review
We Used BluetoothAdmin and SerialObjects to Spawn a Bare Bones BluetoothEngine.
We Used a Digilent WF32 to Create anEmbedded Bluetooth-Capable Device.
We Attached an AsyncStreams-Based
Basic4Android Module to Our SimpleBluetooth Engine and Built a Useful
Android App.