completed README.md

This commit is contained in:
strawmanbobi
2026-01-31 21:30:54 +08:00
parent 8a665776e7
commit 733d111528
3 changed files with 62 additions and 5 deletions

View File

@@ -4,7 +4,7 @@ This project shows how can you develop an Android APP remote controller quickly.
The key components of the Android remote example includes:
## The Cloud-SDK
## <img src='app/src/main/res/mipmap-xxhdpi/button_home.png' style='padding-top: 12px; height: 32px; width: 20px;'> Use The Cloud-SDK to Index Remote
The Cloud SDK calls the Rest API provided by the IRext index service to complete the APP login and
help use indexing targeted remote controller from category to remote index.
@@ -17,7 +17,6 @@ implementation 'net.irext.webapi:irext-androidapi:1.5.2
And then add the meta-data in your AndroidManifest.xml to make the Cloud SDK login to the indexing server for the access token
```xml
<meta-data
android:name="irext_app_key"
android:value="c49c3bd5ff6b3efb67d8af2c" />
@@ -29,7 +28,7 @@ And then add the meta-data in your AndroidManifest.xml to make the Cloud SDK log
Follow the examples of calling `mApp.mWeAPIs` in corresponding UI flows in order to find the targeted remote index, download the remote control binary file.
## Use Mobile Phone as Remote Control
## <img src='app/src/main/res/mipmap-xxhdpi/button_power.png' style='padding-top: 12px; height: 32px; width: 20px;'> Use Mobile Phone as Remote Control
After the remote index binary code is downloaded, you can see the remote control panel,
by pressing control buttons, the binary code would be decoded into IR timing series. If you have an Android phone with IR transmitter,
you can send the 38KHz infra-red waves directly to control the home appliances.
@@ -39,10 +38,20 @@ As a reference, you need to integrate the IR decode library, see the shared libr
By calling API provided by the decode library in order to open and decode remote control binary files into infra-red timing series:
```java
public int irControl(int category, int subCategory, int keyCode) {
int []decoded;
StringBuilder debugStr = new StringBuilder();
ACStatus acStatus = new ACStatus();
int inputKeyCode = ControlHelper.translateKeyCode(category, keyCode, acStatus);
decoded = mIRDecode.decodeBinary(inputKeyCode, acStatus);
ControlHelper.transmitIr(mContext, decoded);
return 0;
}
```
## Working with Arduino Remote Control <img src='app/src/main/res/mipmap-xxhdpi/button_link.png' style='padding-top: 12px; height: 32px; width: 20px;'>
**Here you need to manage your AC Status in Android application according to user interactions.**
## <img src='app/src/main/res/mipmap-xxhdpi/button_link.png' style='padding-top: 12px; height: 32px; width: 20px;'> Working with Arduino Remote Control
There is another example project <a href='https://opensource.irext.net/irext/examples/-/tree/master/arduino-example'>arduino-example</a> which can be co-worked with this
Android APP remote controller.

View File

@@ -1 +1,49 @@
# IRext Arduino Example
This is a simple example of how to use IRext with an Arduino UNO R4.
Please follow the diagram below to connect the IR transmitter module to your Arduino or use a breadboard, IR LED and MOSFET.
<img src="arduino-example.png" style="max-width: 320px;">
## Connect to Wi-Fi
The project uses WiFiS3 library to connect the Arduino UNO R4 WiFi to your local network. You need to configure your WiFi credentials in [src/configure.h](src/configure.h):
```cpp
#define SECRET_SSID "your_wifi_ssid"
#define SECRET_PASS "your_wifi_password"
```
The Arduino connects as a WiFi client (station mode) and starts a TCP server on port 8000 to communicate with external devices, typically an Android application.
## Use TCP Server Socket to Communicate with Android APP
The Arduino runs a TCP server on port 8000 that handles communication with an Android application. The communication protocol includes:
- Hello handshake: [a_hello](src/main.cpp#L32) command initiates connection, responded with [e_hello](src/main.cpp#L33)
- Binary transmission: [a_bin](src/main.cpp#L34) command sends IR binary data, responded with [e_bin](src/main.cpp#L35)
- Control commands: [a_control](src/main.cpp#L36) command sends IR control commands, responded with [e_control](src/main.cpp#L37) or success/failure indicators
- Error handling: [a_error](src/main.cpp#L38) command triggers error response [e_error](src/main.cpp#L39)
The communication is bidirectional - the Android app sends commands to control the IR transmission, and the Arduino responds with status updates.
## Receive IR Binary and Open with IR Decode API
The system receives encoded IR binary data via the TCP protocol. The binary data is Base64-encoded and transmitted in the format:
`a_bin,[categoryId],[subCategoryId],[length],[binary_data_base64]`
The system decodes the Base64 data and loads it into the IR decoding engine using the `ir_binary_open()` function. This prepares the system to handle specific IR protocols for different device types (air conditioners, TVs, etc.).
## Receive IR Control Command, Decode and Transmit
When a control command is received in the format:
`a_control,[length],[command_json_base64]`
The system:
1. Decodes the Base64-encoded JSON command
2. Parses the control parameters (temperature, power state, modes, etc.)
3. Uses the IR decode API to generate the appropriate raw IR signal data
4. Transmits the IR signal using the IRremote library on pin 3
The system supports various IR protocols and device types through its modular decoder architecture located in the [src/ir_decode](src/ir_decode) directory.

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 MiB