App SDK IR code management
API Overview
名称 | 描述 |
---|---|
Get the ID of the supported Ircode device | Get the ID of the supported Ircode device |
Get brand ID(deviceBrand | requestIRCodeDeviceBrands |
Get region ID of STB | requestSubAreas |
Get STB provider ID | requestSTBProvider |
Get STB channel list | Get STB channel list |
Get STB script URL | requestSTBIRCodeScriptDownloadUrl |
Get TV script URL | requestTVIRCodeScriptDownloadUrl |
Get AC script URL by brand ID | requestACIRCodeScriptDownloadUrl |
Auto Match,Get AC script URL | recognizeIRCode |
Download IR Code Script | downloadIRCodeScript |
Get IR Code Information | queryACIRCodeInfomation |
Get AC IR Code | queryACIRCodeData |
1. Overview
BroadLink integrated multiple sets of IR code for home appliances. The developers need to apply separately to BroadLink for the permission of using IR code library.
The SDK provides interfaces for querying and downloading IR codes, obtaining basic information and generating control commands.
There are several steps for using IR code service
- Obtain IR code script
- After the IR code script is downloaded, you can call the API to obtain the product function parameters of the specified product
- You can obtain the IR command in binary after the function parameters are obtained in API
- You can send the binary command to universal remote via API to control appliance.
You can use either way to obtain the IR code script: one button match and model selection.
One button match works as follows:
- Set universal remote in learning mode
- Point the remote to universal remote and press the button (normally ON/OFF)
- Send the learnt command to matched API
- If the API is matched, the script URL will be returned from cloud
2. API Description
Home management interfaces will be instantiated as singleton after initialization of BLLet class in BLLetCore library.
You can invoke ircode attribute in BLLet class and relevant instance on iOS.
You can invoke ircode static method in BLLet class on Android.
2.1 Get the ID of the supported Ircode device
For example: AC ,TV can know if it supports the Ircode of this mode by querying device type and brand id,and at the same time, obtain the download script URL.
2.1.1 Get device type ID(deviceType)
The SDK supports the following device types,and the corresponding IDs are as follows:
public class BLIRCodeDeviceType {
/** ALL **/
public static final int BL_IRCODE_DEVICE_ALL = 0;
/** TV **/
public static final int BL_IRCODE_DEVICE_TV = 1;
/** STB **/
public static final int BL_IRCODE_DEVICE_TV_BOX = 2;
/** AC **/
public static final int BL_IRCODE_DEVICE_AC = 3;
}
2.1.2 Get brand ID(deviceBrand)
You can query all supported brand IDs by passed device type ID and find the required device from returned data.
public static BLResponseResult requestIRCodeDeviceBrands(int deviceType);
Request Parameter
Parameter Name | Parameter Type | Note |
---|---|---|
deviceType | int | Device type id |
Return Parameter
BLResponseResult
Parameter Name | Parameter Type | Note |
---|---|---|
responseBody | String | Returned data (needs to be resolved) |
2.2 Interface for STB IR codes
You need to get the IR code script for set-top box (STB) by querying region and carrier ID instead of using brand ID.
2.2.1 Get region ID of STB
You can get the region ID by querying specific country ID in SDK.
This interface is designed with tree structure with top value 0 for all country IDs.
If you find the leaf node isleaf is 0, it means there are regions can be queried. If isleaf is 1, the query will be invalid.
/**
* Gets the list of regions under the specified region ID
* if ID = 0, get all countries‘ ids
* if isleaf = 0, you need call this interface again to get the list of regions.
* if isleaf = 1, don't need get again.
*
* @param locateid Region ID
* @return the list of regions
*/
public BLResponseResult requestSubAreas(int locateid);
Request Parameter
Parameter Name | Parameter Type | Note |
---|---|---|
locateid | int | region ID |
2.2.2 Get STB provider ID
- 1.You can query all providers with their IDs if region ID is specified.
public static BLResponseResult requestSTBProvider(int locateid);
- 2.You can query all providers with their IDs if the name of country/province/city is specified.
public static BLResponseResult requestSTBProvider(String country, String province, String city);
2.2.3 Get STB channel list
You can request from cloud for channel list supported by this STB using the region ID and provider ID got from the interface mentioned in 2.2.2.
public static BLResponseResult requestSTBChannelList(int locateid, int providerid);
Request Parameter
Parameter Name | Parameter Type | Note |
---|---|---|
locateid | int | Region ID |
providerid | int | Provider ID |
2.2.4 Get STB script URL
You can request from cloud for Ircode script URL by using the region ID and provider ID got from the interface mentioned in 2.2.2.
public static BLResponseResult requestSTBIRCodeScriptDownloadUrl(int locateid, int providerid, int brandId);
Request Parameter
Parameter Name | Parameter Type | Note |
---|---|---|
locateid | int | Region ID |
providerid | int | Provider ID |
brandId | int | Brand ID of STB, if not clear this ID, pass -1 |
2.3 Get TV script URL
You can know that if the device is supported and the device type ID and brand ID from the interface mentioned in 2.1
You can request from cloud for Ircode script URL by using the device type ID and brand ID
public static BLResponseResult requestTVIRCodeScriptDownloadUrl(int deviceBrand);
Request Parameter
Parameter Name | Parameter Type | Note |
---|---|---|
deviceBrand | int | Brand ID |
2.4 Get AC script URL
2.4.1 Get AC script URL by brand ID
You can know that if the device is supported and the device type ID and brand ID from the interface mentioned in 2.1
You can request from cloud for Ircode script URL by using the device type ID and brand ID
public static BLResponseResult requestACIRCodeScriptDownloadUrl(int deviceBrand);
Request Parameter
Parameter Name | Parameter Type | Note |
---|---|---|
deviceBrand | int | Brand ID |
2.4.2 Auto Match,Get AC script URL
If you already have one of the IR code for the device, you can convert it to HEX string and submit it to cloud. The cloud server will automatically recognize the IR code and return the script URL list.
You may need to request for more than one IR code for precise recognition to minimize the list.
The returned result contains Downloading URL and Ransom key of script.
public static BLResponseResult recognizeIRCode(String hexString);
Request Parameter
Parameter Name | Parameter Type | Note |
---|---|---|
hexString | String | HEX string of IR code |
2.5 Download IR Code Script
You can request for downloading the IR code script from cloud according to the obtained script URL mentioned in previous sections.
public static BLDownLoadIRCodeResult downloadIRCodeScript(String UrlString, String savePath, String randkey);
Request Parameter
Parameter Name | Parameter Type | Note |
---|---|---|
UrlString | String | Downloading URL of script |
savePath | String | Script saved path |
randkey | String | Random key of script |
2.6 Get IR Code Information
Different IR code scripts need to be processed separately: 1. The IR code scripts for ACs are linear and you can get the range of control parameter from basic information. 2.The IR code scripts for TV/STB are button-based and different buttons represent for different functions which require different IR codes.
public static BLIrdaConProductResult queryACIRCodeInfomation(String scriptPath);
Request Parameter
Parameter Name | Parameter Type | Note |
---|---|---|
savePath | String | Script saved path |
Return Parameter
BLIrdaConProductResult
Parameter Name | Parameter Type | Note |
---|---|---|
name | String | Device name |
max_temperature | int | max temperature |
min_temperature | int | mini temperature |
state | int | AC on/off state |
mode | int | AC mode |
windspeed | int | AC windspeed |
windirect | int | AC windirect |
2.7 Get AC IR Code
You can get the required data to be passed in this interface according to script basic information and then obtain the HEX string accordingly.
public static BLIrdaConDataResult queryACIRCodeData(String scriptPath, BLQueryIRCodeParams params);
Request Parameter
Parameter Name | Parameter Type | Note |
---|---|---|
savePath | String | Script saved path |
params | BLQueryIRCodeParams | AC configuration parameters |
BLQueryIRCodeParams
Parameter Name | Parameter Type | Note |
---|---|---|
state | int | On/Off state |
mode | int | Mode |
speed | int | Fan speed |
direct | int | Wind direction |
temperature | int | Target temperature |
key | int | Buttons (only for some models) |
freq | int | IR frequency (default is 38 kHz) |
Return Parameter
BLIrdaConDataResult
Parameter Name | Parameter Type | Note |
---|---|---|
freq | int | IR frequency (default is 38 kHz) |
ircode | String | HEX string of IR code |