├── README.md
├── android-btsim-application
├── AndroidManifest.xml
├── bin
│ ├── BluetoothEmulator.apk
│ ├── classes.dex
│ ├── dk
│ │ └── itu
│ │ │ └── android
│ │ │ ├── bluetooth
│ │ │ ├── BluetoothAdapter$1.class
│ │ │ ├── BluetoothAdapter.class
│ │ │ ├── BluetoothClass$Device$Major.class
│ │ │ ├── BluetoothClass$Device.class
│ │ │ ├── BluetoothClass$Service.class
│ │ │ ├── BluetoothClass.class
│ │ │ ├── BluetoothDevice.class
│ │ │ ├── BluetoothServerSocket$1.class
│ │ │ ├── BluetoothServerSocket.class
│ │ │ └── BluetoothSocket.class
│ │ │ └── btemu
│ │ │ ├── BTEnableControl.class
│ │ │ ├── Main$1.class
│ │ │ ├── Main$10$1.class
│ │ │ ├── Main$10.class
│ │ │ ├── Main$2.class
│ │ │ ├── Main$3.class
│ │ │ ├── Main$4.class
│ │ │ ├── Main$5.class
│ │ │ ├── Main$6.class
│ │ │ ├── Main$7.class
│ │ │ ├── Main$8.class
│ │ │ ├── Main$9.class
│ │ │ ├── Main.class
│ │ │ ├── R$attr.class
│ │ │ ├── R$drawable.class
│ │ │ ├── R$id.class
│ │ │ ├── R$layout.class
│ │ │ ├── R$string.class
│ │ │ ├── R.class
│ │ │ └── service
│ │ │ ├── BTEmulator$1.class
│ │ │ ├── BTEmulator.class
│ │ │ ├── BTService.class
│ │ │ └── cmd
│ │ │ ├── BaseCommand.class
│ │ │ ├── CommandType.class
│ │ │ ├── Discovery$WithDevices.class
│ │ │ ├── Discovery.class
│ │ │ ├── Join.class
│ │ │ ├── Leave.class
│ │ │ ├── ModifyService.class
│ │ │ └── NoParamsBaseCommand.class
│ └── resources.ap_
├── default.properties
├── dist-shared
│ └── btsim.jar
├── dist
│ └── BluetoothEmulator.apk
├── gen
│ └── dk
│ │ └── itu
│ │ └── android
│ │ └── btemu
│ │ └── R.java
├── res
│ ├── drawable-hdpi
│ │ └── icon.png
│ ├── drawable-ldpi
│ │ └── icon.png
│ ├── drawable-mdpi
│ │ └── icon.png
│ ├── layout
│ │ ├── ctrl.xml
│ │ ├── main.xml
│ │ └── row.xml
│ └── values
│ │ └── strings.xml
├── src-sysactivities
│ └── dk
│ │ └── itu
│ │ └── android
│ │ └── btemu
│ │ └── BTEnableControl.java
├── src-testapp
│ └── dk
│ │ └── itu
│ │ └── android
│ │ └── btemu
│ │ └── Main.java
└── src
│ └── dk
│ └── itu
│ └── android
│ ├── bluetooth
│ ├── BluetoothAdapter.java
│ ├── BluetoothClass.java
│ ├── BluetoothDevice.java
│ ├── BluetoothServerSocket.java
│ └── BluetoothSocket.java
│ └── btemu
│ └── service
│ ├── BTEmulator.java
│ ├── BTService.java
│ └── cmd
│ ├── BaseCommand.java
│ ├── CommandType.java
│ ├── Discovery.java
│ ├── Join.java
│ ├── Leave.java
│ ├── ModifyService.java
│ └── NoParamsBaseCommand.java
└── btsim-server
├── bin
└── dk
│ └── itu
│ └── btemu
│ ├── BTMacForwardingsChecker$DeviceAddr.class
│ ├── BTMacForwardingsChecker.class
│ ├── CommandParser.class
│ ├── Server$1.class
│ ├── Server.class
│ ├── State.class
│ ├── cmd
│ ├── BaseCommand$Param.class
│ ├── BaseCommand.class
│ ├── CommandType.class
│ ├── Discovery.class
│ ├── Join.class
│ ├── Leave.class
│ └── ModifyService.class
│ ├── state
│ ├── Device.class
│ └── Service.class
│ └── test
│ └── VarTest.class
├── client-src
└── dk
│ └── itu
│ └── btemu
│ └── client
│ └── BtEmuClient.java
├── dist
└── btsimserver.jar
├── src
└── dk
│ └── itu
│ └── btemu
│ ├── BTMacForwardingsChecker.java
│ ├── CommandParser.java
│ ├── Server.java
│ ├── State.java
│ ├── cmd
│ ├── BaseCommand.java
│ ├── CommandType.java
│ ├── Discovery.java
│ ├── Join.java
│ ├── Leave.java
│ └── ModifyService.java
│ └── state
│ ├── Device.java
│ └── Service.java
└── test
└── dk
└── itu
└── btemu
└── test
└── VarTest.java
/README.md:
--------------------------------------------------------------------------------
1 | # Android Bluetooth Simulator
2 |
3 | ## What is it
4 |
5 | It's a tcp-based implementation of part of the android bluetooth API.
6 | As for now, you can communicate between different emulators using the RFComm protocol, you can start a discovery phase and enable/disable the bluetooth.
7 |
8 | What you need to do in order to use the simulator instead of the android API, is to change the import from `android.bluetooth` to `dk.itu.android.bluetooth` (and also add the `INTERNET` permission in the android manifest file).
9 |
10 | There is a slight modification to the code, in order to use the simulator:
11 |
12 | - call `BluetoothAdapter.SetContext(this);` at some point (the `onCreate` method is fine) in your activity/service.
13 |
14 | ## How do I use it?
15 |
16 | You will have to follow some steps:
17 |
18 | - download everything in this repository
19 | - compile and install into at least 2 android emulators the *android-bt-simulator* application
20 | - a precompiled version of the application is provided in the *dist* directory
21 | - there are 3 source directories, `src`, `src-sysactivities` and `src-testapp`. The application need all of them, but for the library jar you just need to compile the main one (`src`). The jar library is provided as convenience in the `dist-shared` directory
22 | - compile the *btsim-server* and run it.
23 | - there is an already precompiled jar in *dist*, execute `java -jar btsimserver.jar --help` to see some options (if you don't have the `adb` command in your path, you will need to set the `adb.path` variable)
24 |
25 | You need to install the application because it will handle the *system activities* of the bluetooth, like switching on/off the radio and start a discovery.
26 |
27 | Then you can create a new android project.
28 | My preferred workflow, at this point, is:
29 |
30 | - add the necessary permissions for the bluetooth AND for internet access (required by the bt simulator).
31 | - add the *btsim.jar* to the libraries of the project
32 | - add the call to `BluetoothAdapter.SetContext(this);` in the `onCreate` method of the activity
33 | - start using the bluetooth API, importing the `dk.itu.android.bluetooth` version
34 | - set up two launch configurations for the project (one for each android emulator)
35 |
36 | Then, depending on your needs, when you want to deploy the application on an actual device, you will need to delete or comment the `SetContext` call (as this will not compile, since it is not part of the android bluetooth api, but just a custom call for the simulator) and delete and re-import all the bluetooth stuff (this time using the `android.bluetooth` classes).
37 |
38 | I hope this will be useful for somebody, I know that it implements just a subset of the API and it is not possible to put into play different devices than the emulators themselves, but until we got something in the android emulator itself, this is what we got :D
39 |
40 | ## Adding dummy devices
41 |
42 | You can add dummy devices to the server, so that you can check if the discovery phase works. This involves communicating directly with the bluetooth emulator server, which accept text-based command.
43 |
44 | First of all, fire up a terminal and telnet to localhost, port 8199:
45 |
46 | telnet localhost 8199
47 |
48 | when the terminal prompt, use the following syntax:
49 |
50 | 0]tcp.address=10.0.2.2¬.android.emulator=true&bt.address=
&device.name=]
51 |
52 | e.g. :
53 |
54 | 0]tcp.address=10.0.2.2¬.android.emulator=true&bt.address=00:11:22:AA:BB:CC&device.name=Dummy1]
55 |
56 | In general, the bluetooth emulator server accepts commands on the form:
57 |
58 | ]=&...]
59 |
60 | Another useful command is the discovery one, if you want to know which devices are listed in the server, telnet and enter:
61 |
62 | 2]]
63 |
64 | then the list of the devices and relative registered services will appear.
--------------------------------------------------------------------------------
/android-btsim-application/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
32 |
33 |
--------------------------------------------------------------------------------
/android-btsim-application/bin/BluetoothEmulator.apk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cheng81/Android-Bluetooth-Simulator/68aca94792b97dab9f9d8531cbae642da8635457/android-btsim-application/bin/BluetoothEmulator.apk
--------------------------------------------------------------------------------
/android-btsim-application/bin/classes.dex:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cheng81/Android-Bluetooth-Simulator/68aca94792b97dab9f9d8531cbae642da8635457/android-btsim-application/bin/classes.dex
--------------------------------------------------------------------------------
/android-btsim-application/bin/dk/itu/android/bluetooth/BluetoothAdapter$1.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cheng81/Android-Bluetooth-Simulator/68aca94792b97dab9f9d8531cbae642da8635457/android-btsim-application/bin/dk/itu/android/bluetooth/BluetoothAdapter$1.class
--------------------------------------------------------------------------------
/android-btsim-application/bin/dk/itu/android/bluetooth/BluetoothAdapter.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cheng81/Android-Bluetooth-Simulator/68aca94792b97dab9f9d8531cbae642da8635457/android-btsim-application/bin/dk/itu/android/bluetooth/BluetoothAdapter.class
--------------------------------------------------------------------------------
/android-btsim-application/bin/dk/itu/android/bluetooth/BluetoothClass$Device$Major.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cheng81/Android-Bluetooth-Simulator/68aca94792b97dab9f9d8531cbae642da8635457/android-btsim-application/bin/dk/itu/android/bluetooth/BluetoothClass$Device$Major.class
--------------------------------------------------------------------------------
/android-btsim-application/bin/dk/itu/android/bluetooth/BluetoothClass$Device.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cheng81/Android-Bluetooth-Simulator/68aca94792b97dab9f9d8531cbae642da8635457/android-btsim-application/bin/dk/itu/android/bluetooth/BluetoothClass$Device.class
--------------------------------------------------------------------------------
/android-btsim-application/bin/dk/itu/android/bluetooth/BluetoothClass$Service.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cheng81/Android-Bluetooth-Simulator/68aca94792b97dab9f9d8531cbae642da8635457/android-btsim-application/bin/dk/itu/android/bluetooth/BluetoothClass$Service.class
--------------------------------------------------------------------------------
/android-btsim-application/bin/dk/itu/android/bluetooth/BluetoothClass.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cheng81/Android-Bluetooth-Simulator/68aca94792b97dab9f9d8531cbae642da8635457/android-btsim-application/bin/dk/itu/android/bluetooth/BluetoothClass.class
--------------------------------------------------------------------------------
/android-btsim-application/bin/dk/itu/android/bluetooth/BluetoothDevice.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cheng81/Android-Bluetooth-Simulator/68aca94792b97dab9f9d8531cbae642da8635457/android-btsim-application/bin/dk/itu/android/bluetooth/BluetoothDevice.class
--------------------------------------------------------------------------------
/android-btsim-application/bin/dk/itu/android/bluetooth/BluetoothServerSocket$1.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cheng81/Android-Bluetooth-Simulator/68aca94792b97dab9f9d8531cbae642da8635457/android-btsim-application/bin/dk/itu/android/bluetooth/BluetoothServerSocket$1.class
--------------------------------------------------------------------------------
/android-btsim-application/bin/dk/itu/android/bluetooth/BluetoothServerSocket.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cheng81/Android-Bluetooth-Simulator/68aca94792b97dab9f9d8531cbae642da8635457/android-btsim-application/bin/dk/itu/android/bluetooth/BluetoothServerSocket.class
--------------------------------------------------------------------------------
/android-btsim-application/bin/dk/itu/android/bluetooth/BluetoothSocket.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cheng81/Android-Bluetooth-Simulator/68aca94792b97dab9f9d8531cbae642da8635457/android-btsim-application/bin/dk/itu/android/bluetooth/BluetoothSocket.class
--------------------------------------------------------------------------------
/android-btsim-application/bin/dk/itu/android/btemu/BTEnableControl.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cheng81/Android-Bluetooth-Simulator/68aca94792b97dab9f9d8531cbae642da8635457/android-btsim-application/bin/dk/itu/android/btemu/BTEnableControl.class
--------------------------------------------------------------------------------
/android-btsim-application/bin/dk/itu/android/btemu/Main$1.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cheng81/Android-Bluetooth-Simulator/68aca94792b97dab9f9d8531cbae642da8635457/android-btsim-application/bin/dk/itu/android/btemu/Main$1.class
--------------------------------------------------------------------------------
/android-btsim-application/bin/dk/itu/android/btemu/Main$10$1.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cheng81/Android-Bluetooth-Simulator/68aca94792b97dab9f9d8531cbae642da8635457/android-btsim-application/bin/dk/itu/android/btemu/Main$10$1.class
--------------------------------------------------------------------------------
/android-btsim-application/bin/dk/itu/android/btemu/Main$10.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cheng81/Android-Bluetooth-Simulator/68aca94792b97dab9f9d8531cbae642da8635457/android-btsim-application/bin/dk/itu/android/btemu/Main$10.class
--------------------------------------------------------------------------------
/android-btsim-application/bin/dk/itu/android/btemu/Main$2.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cheng81/Android-Bluetooth-Simulator/68aca94792b97dab9f9d8531cbae642da8635457/android-btsim-application/bin/dk/itu/android/btemu/Main$2.class
--------------------------------------------------------------------------------
/android-btsim-application/bin/dk/itu/android/btemu/Main$3.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cheng81/Android-Bluetooth-Simulator/68aca94792b97dab9f9d8531cbae642da8635457/android-btsim-application/bin/dk/itu/android/btemu/Main$3.class
--------------------------------------------------------------------------------
/android-btsim-application/bin/dk/itu/android/btemu/Main$4.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cheng81/Android-Bluetooth-Simulator/68aca94792b97dab9f9d8531cbae642da8635457/android-btsim-application/bin/dk/itu/android/btemu/Main$4.class
--------------------------------------------------------------------------------
/android-btsim-application/bin/dk/itu/android/btemu/Main$5.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cheng81/Android-Bluetooth-Simulator/68aca94792b97dab9f9d8531cbae642da8635457/android-btsim-application/bin/dk/itu/android/btemu/Main$5.class
--------------------------------------------------------------------------------
/android-btsim-application/bin/dk/itu/android/btemu/Main$6.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cheng81/Android-Bluetooth-Simulator/68aca94792b97dab9f9d8531cbae642da8635457/android-btsim-application/bin/dk/itu/android/btemu/Main$6.class
--------------------------------------------------------------------------------
/android-btsim-application/bin/dk/itu/android/btemu/Main$7.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cheng81/Android-Bluetooth-Simulator/68aca94792b97dab9f9d8531cbae642da8635457/android-btsim-application/bin/dk/itu/android/btemu/Main$7.class
--------------------------------------------------------------------------------
/android-btsim-application/bin/dk/itu/android/btemu/Main$8.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cheng81/Android-Bluetooth-Simulator/68aca94792b97dab9f9d8531cbae642da8635457/android-btsim-application/bin/dk/itu/android/btemu/Main$8.class
--------------------------------------------------------------------------------
/android-btsim-application/bin/dk/itu/android/btemu/Main$9.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cheng81/Android-Bluetooth-Simulator/68aca94792b97dab9f9d8531cbae642da8635457/android-btsim-application/bin/dk/itu/android/btemu/Main$9.class
--------------------------------------------------------------------------------
/android-btsim-application/bin/dk/itu/android/btemu/Main.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cheng81/Android-Bluetooth-Simulator/68aca94792b97dab9f9d8531cbae642da8635457/android-btsim-application/bin/dk/itu/android/btemu/Main.class
--------------------------------------------------------------------------------
/android-btsim-application/bin/dk/itu/android/btemu/R$attr.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cheng81/Android-Bluetooth-Simulator/68aca94792b97dab9f9d8531cbae642da8635457/android-btsim-application/bin/dk/itu/android/btemu/R$attr.class
--------------------------------------------------------------------------------
/android-btsim-application/bin/dk/itu/android/btemu/R$drawable.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cheng81/Android-Bluetooth-Simulator/68aca94792b97dab9f9d8531cbae642da8635457/android-btsim-application/bin/dk/itu/android/btemu/R$drawable.class
--------------------------------------------------------------------------------
/android-btsim-application/bin/dk/itu/android/btemu/R$id.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cheng81/Android-Bluetooth-Simulator/68aca94792b97dab9f9d8531cbae642da8635457/android-btsim-application/bin/dk/itu/android/btemu/R$id.class
--------------------------------------------------------------------------------
/android-btsim-application/bin/dk/itu/android/btemu/R$layout.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cheng81/Android-Bluetooth-Simulator/68aca94792b97dab9f9d8531cbae642da8635457/android-btsim-application/bin/dk/itu/android/btemu/R$layout.class
--------------------------------------------------------------------------------
/android-btsim-application/bin/dk/itu/android/btemu/R$string.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cheng81/Android-Bluetooth-Simulator/68aca94792b97dab9f9d8531cbae642da8635457/android-btsim-application/bin/dk/itu/android/btemu/R$string.class
--------------------------------------------------------------------------------
/android-btsim-application/bin/dk/itu/android/btemu/R.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cheng81/Android-Bluetooth-Simulator/68aca94792b97dab9f9d8531cbae642da8635457/android-btsim-application/bin/dk/itu/android/btemu/R.class
--------------------------------------------------------------------------------
/android-btsim-application/bin/dk/itu/android/btemu/service/BTEmulator$1.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cheng81/Android-Bluetooth-Simulator/68aca94792b97dab9f9d8531cbae642da8635457/android-btsim-application/bin/dk/itu/android/btemu/service/BTEmulator$1.class
--------------------------------------------------------------------------------
/android-btsim-application/bin/dk/itu/android/btemu/service/BTEmulator.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cheng81/Android-Bluetooth-Simulator/68aca94792b97dab9f9d8531cbae642da8635457/android-btsim-application/bin/dk/itu/android/btemu/service/BTEmulator.class
--------------------------------------------------------------------------------
/android-btsim-application/bin/dk/itu/android/btemu/service/BTService.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cheng81/Android-Bluetooth-Simulator/68aca94792b97dab9f9d8531cbae642da8635457/android-btsim-application/bin/dk/itu/android/btemu/service/BTService.class
--------------------------------------------------------------------------------
/android-btsim-application/bin/dk/itu/android/btemu/service/cmd/BaseCommand.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cheng81/Android-Bluetooth-Simulator/68aca94792b97dab9f9d8531cbae642da8635457/android-btsim-application/bin/dk/itu/android/btemu/service/cmd/BaseCommand.class
--------------------------------------------------------------------------------
/android-btsim-application/bin/dk/itu/android/btemu/service/cmd/CommandType.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cheng81/Android-Bluetooth-Simulator/68aca94792b97dab9f9d8531cbae642da8635457/android-btsim-application/bin/dk/itu/android/btemu/service/cmd/CommandType.class
--------------------------------------------------------------------------------
/android-btsim-application/bin/dk/itu/android/btemu/service/cmd/Discovery$WithDevices.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cheng81/Android-Bluetooth-Simulator/68aca94792b97dab9f9d8531cbae642da8635457/android-btsim-application/bin/dk/itu/android/btemu/service/cmd/Discovery$WithDevices.class
--------------------------------------------------------------------------------
/android-btsim-application/bin/dk/itu/android/btemu/service/cmd/Discovery.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cheng81/Android-Bluetooth-Simulator/68aca94792b97dab9f9d8531cbae642da8635457/android-btsim-application/bin/dk/itu/android/btemu/service/cmd/Discovery.class
--------------------------------------------------------------------------------
/android-btsim-application/bin/dk/itu/android/btemu/service/cmd/Join.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cheng81/Android-Bluetooth-Simulator/68aca94792b97dab9f9d8531cbae642da8635457/android-btsim-application/bin/dk/itu/android/btemu/service/cmd/Join.class
--------------------------------------------------------------------------------
/android-btsim-application/bin/dk/itu/android/btemu/service/cmd/Leave.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cheng81/Android-Bluetooth-Simulator/68aca94792b97dab9f9d8531cbae642da8635457/android-btsim-application/bin/dk/itu/android/btemu/service/cmd/Leave.class
--------------------------------------------------------------------------------
/android-btsim-application/bin/dk/itu/android/btemu/service/cmd/ModifyService.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cheng81/Android-Bluetooth-Simulator/68aca94792b97dab9f9d8531cbae642da8635457/android-btsim-application/bin/dk/itu/android/btemu/service/cmd/ModifyService.class
--------------------------------------------------------------------------------
/android-btsim-application/bin/dk/itu/android/btemu/service/cmd/NoParamsBaseCommand.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cheng81/Android-Bluetooth-Simulator/68aca94792b97dab9f9d8531cbae642da8635457/android-btsim-application/bin/dk/itu/android/btemu/service/cmd/NoParamsBaseCommand.class
--------------------------------------------------------------------------------
/android-btsim-application/bin/resources.ap_:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cheng81/Android-Bluetooth-Simulator/68aca94792b97dab9f9d8531cbae642da8635457/android-btsim-application/bin/resources.ap_
--------------------------------------------------------------------------------
/android-btsim-application/default.properties:
--------------------------------------------------------------------------------
1 | # This file is automatically generated by Android Tools.
2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED!
3 | #
4 | # This file must be checked in Version Control Systems.
5 | #
6 | # To customize properties used by the Ant build system use,
7 | # "build.properties", and override values to adapt the script to your
8 | # project structure.
9 |
10 | # Indicates whether an apk should be generated for each density.
11 | split.density=false
12 | # Project target.
13 | target=android-5
14 |
--------------------------------------------------------------------------------
/android-btsim-application/dist-shared/btsim.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cheng81/Android-Bluetooth-Simulator/68aca94792b97dab9f9d8531cbae642da8635457/android-btsim-application/dist-shared/btsim.jar
--------------------------------------------------------------------------------
/android-btsim-application/dist/BluetoothEmulator.apk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cheng81/Android-Bluetooth-Simulator/68aca94792b97dab9f9d8531cbae642da8635457/android-btsim-application/dist/BluetoothEmulator.apk
--------------------------------------------------------------------------------
/android-btsim-application/gen/dk/itu/android/btemu/R.java:
--------------------------------------------------------------------------------
1 | /* AUTO-GENERATED FILE. DO NOT MODIFY.
2 | *
3 | * This class was automatically generated by the
4 | * aapt tool from the resource data it found. It
5 | * should not be modified by hand.
6 | */
7 |
8 | package dk.itu.android.btemu;
9 |
10 | public final class R {
11 | public static final class attr {
12 | }
13 | public static final class drawable {
14 | public static final int icon=0x7f020000;
15 | }
16 | public static final class id {
17 | public static final int Devices=0x7f050003;
18 | public static final int Disable=0x7f050001;
19 | public static final int Discovery=0x7f050002;
20 | public static final int EchoResponse=0x7f050006;
21 | public static final int Enable=0x7f050000;
22 | public static final int StartClient=0x7f050005;
23 | public static final int StartServer=0x7f050004;
24 | public static final int list_value=0x7f050007;
25 | }
26 | public static final class layout {
27 | public static final int btenablecontrol=0x7f030000;
28 | public static final int main=0x7f030001;
29 | public static final int row=0x7f030002;
30 | }
31 | public static final class string {
32 | public static final int app_name=0x7f040001;
33 | public static final int btctrl=0x7f040002;
34 | public static final int btctrl_title=0x7f040003;
35 | public static final int hello=0x7f040000;
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/android-btsim-application/res/drawable-hdpi/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cheng81/Android-Bluetooth-Simulator/68aca94792b97dab9f9d8531cbae642da8635457/android-btsim-application/res/drawable-hdpi/icon.png
--------------------------------------------------------------------------------
/android-btsim-application/res/drawable-ldpi/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cheng81/Android-Bluetooth-Simulator/68aca94792b97dab9f9d8531cbae642da8635457/android-btsim-application/res/drawable-ldpi/icon.png
--------------------------------------------------------------------------------
/android-btsim-application/res/drawable-mdpi/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cheng81/Android-Bluetooth-Simulator/68aca94792b97dab9f9d8531cbae642da8635457/android-btsim-application/res/drawable-mdpi/icon.png
--------------------------------------------------------------------------------
/android-btsim-application/res/layout/ctrl.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
12 |
--------------------------------------------------------------------------------
/android-btsim-application/res/layout/main.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
12 |
13 |
14 |
15 |
16 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/android-btsim-application/res/layout/row.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
12 |
--------------------------------------------------------------------------------
/android-btsim-application/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | Hello World, Main!
4 | BluetoothEmulator
5 | BluetoothEmulatorControl
6 | BluetoothEmulatorControl
7 |
8 |
--------------------------------------------------------------------------------
/android-btsim-application/src-sysactivities/dk/itu/android/btemu/BTEnableControl.java:
--------------------------------------------------------------------------------
1 | package dk.itu.android.btemu;
2 |
3 | import dk.itu.android.bluetooth.BluetoothAdapter;
4 | import android.app.Activity;
5 | import android.content.Intent;
6 | import android.os.Bundle;
7 | import android.util.Log;
8 |
9 | public class BTEnableControl extends Activity {
10 |
11 | @Override
12 | protected void onCreate(Bundle savedInstanceState) {
13 | super.onCreate(savedInstanceState);
14 | setContentView(R.layout.ctrl);
15 |
16 | BluetoothAdapter.SetContext(this);
17 | }
18 |
19 | @Override
20 | protected void onStart() {
21 | super.onStart();
22 | Intent started = getIntent();
23 | Log.i("BTCTRL", "start with action: "+started.getAction());
24 | if(started.getAction().equals(BluetoothAdapter.ACTION_REQUEST_ENABLE)) {
25 | //start
26 | BluetoothAdapter.getDefaultAdapter().enable();
27 | setResult(RESULT_OK);
28 |
29 | } else if(started.getAction().equals(BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE)) {
30 | //enabled discoverable
31 | setResult(RESULT_OK);
32 | }
33 | try {
34 | Thread.sleep(500);
35 | } catch (InterruptedException e) {
36 | // TODO Auto-generated catch block
37 | e.printStackTrace();
38 | }
39 | finish();
40 | }
41 |
42 | }
43 |
--------------------------------------------------------------------------------
/android-btsim-application/src-testapp/dk/itu/android/btemu/Main.java:
--------------------------------------------------------------------------------
1 | package dk.itu.android.btemu;
2 |
3 | import java.io.BufferedReader;
4 | import java.io.IOException;
5 | import java.io.InputStreamReader;
6 | import java.util.ArrayList;
7 | import java.util.HashMap;
8 | import java.util.List;
9 | import java.util.Map;
10 | import java.util.UUID;
11 |
12 | import android.app.Activity;
13 | import android.content.BroadcastReceiver;
14 | import android.content.Context;
15 | import android.content.Intent;
16 | import android.content.IntentFilter;
17 | import android.os.Bundle;
18 | import android.util.Log;
19 | import android.view.View;
20 | import android.widget.AdapterView;
21 | import android.widget.Button;
22 | import android.widget.ListView;
23 | import android.widget.SimpleAdapter;
24 | import android.widget.TextView;
25 | import android.widget.AdapterView.OnItemClickListener;
26 | import dk.itu.android.bluetooth.BluetoothAdapter;
27 | import dk.itu.android.bluetooth.BluetoothDevice;
28 | import dk.itu.android.bluetooth.BluetoothServerSocket;
29 | import dk.itu.android.bluetooth.BluetoothSocket;
30 |
31 | public class Main extends Activity {
32 | final BroadcastReceiver mReceiver = new BroadcastReceiver() {
33 | @Override
34 | public void onReceive(Context context, Intent intent) {
35 | String action = intent.getAction();
36 | if(BluetoothDevice.ACTION_FOUND.equals(action)) {
37 | addDevice( (BluetoothDevice)intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE) );
38 | }
39 | }
40 | };
41 | static final String ITEM_KEY = "key";
42 | ListView devices;
43 | BluetoothAdapter bta;
44 | @Override
45 | public void onCreate(Bundle savedInstanceState) {
46 | super.onCreate(savedInstanceState);
47 | setContentView(R.layout.main);
48 | BluetoothAdapter.SetContext(this);
49 | bta = BluetoothAdapter.getDefaultAdapter();
50 | IntentFilter filter = new IntentFilter(BluetoothDevice.ACTION_FOUND);
51 | registerReceiver(mReceiver, filter);
52 |
53 | Button enableBtn = (Button)findViewById(R.id.Enable);
54 | Button disableBtn = (Button)findViewById(R.id.Disable);
55 | Button discoveryBtn = (Button)findViewById(R.id.Discovery);
56 |
57 | Button serverBtn = (Button)findViewById(R.id.StartServer);
58 | Button clientBtn = (Button)findViewById(R.id.StartClient);
59 | serverBtn.setOnClickListener(new View.OnClickListener() {
60 | @Override
61 | public void onClick(View v) {
62 | startServer();
63 | }
64 | });
65 | clientBtn.setOnClickListener(new View.OnClickListener() {
66 | @Override
67 | public void onClick(View v) {
68 | startClient();
69 | }
70 | });
71 |
72 | devices = (ListView)findViewById(R.id.Devices);
73 | // devices.setOnClickListener(new View.OnClickListener() {
74 | // @Override
75 | // public void onClick(View v) {
76 | // }
77 | // });
78 | devices.setOnItemClickListener(new OnItemClickListener() {
79 | @Override
80 | public void onItemClick(AdapterView> arg0, View arg1, int position,
81 | long arg3) {
82 | Log.i("BTEMU_TEST", "selecting remote device at position: "+position);
83 | other = (BluetoothDevice)list.get(position).get("DEVICE");
84 | Log.i("BTEMU_TEST", "other device is: "+other);
85 | }
86 | });
87 |
88 | enableBtn.setOnClickListener(new View.OnClickListener() {
89 | @Override
90 | public void onClick(View v) {
91 | enableBT();
92 | }
93 | });
94 | disableBtn.setOnClickListener(new View.OnClickListener() {
95 | @Override
96 | public void onClick(View v) {
97 | disableBT();
98 | }
99 | });
100 | discoveryBtn.setOnClickListener(new View.OnClickListener() {
101 | @Override
102 | public void onClick(View v) {
103 | startDiscovery();
104 | }
105 | });
106 |
107 | adapter = new SimpleAdapter(this, list, R.layout.row, new String[]{ITEM_KEY}, new int[]{R.id.list_value});
108 | this.devices.setAdapter(adapter);
109 | }
110 | SimpleAdapter adapter;
111 | List