Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Send a 64bit Infrared signal with android

Using a raspberry pi 3 and an infrared reciver. with the help of a library called LIRC I recorded the signal of my android box remote control.

begin remote

    name  MyRemote
    driver devinput
    bits           64
    eps            30
    aeps          100

    one             0     0
    zero            0     0
    pre_data_bits   64
    pre_data       0x0
    gap          509
    toggle_bit_mask 0x0
    frequency    38000

    begin codes
        KEY_1                    0x116B000001000268
        KEY_2                    0x1169000001000267
        KEY_3                    0x116800000100026E
        KEY_4                    0x116E00000100025C
        KEY_5                    0x116C000001000263
        KEY_6                    0x116800000100024E
        KEY_7                    0x115D000001000268
        KEY_8                    0x116E000001000263
        KEY_9                    0x116B000001000267
        KEY_0                    0x116F000001000265
        KEY_DOWN                 0x0360000001000076
        KEY_LEFT                 0x1167000001000264
        KEY_UP                   0x117800000100025E
        KEY_RIGHT                0x1169000001000266
        KEY_BACK                 0x1170000001000262
        KEY_ENTER                0x1167000001000268
    end codes

end remote

The problem is I can not find a library that can help me write code to send the IR signal from my Note3.

like image 841
Methnani Bilel Avatar asked Jul 27 '18 18:07

Methnani Bilel


People also ask

Where can I find the infrared transmitter for the Android device?

There are Lightning, 30Pin, Type-C connectors – this means that the USB key for the Android device for iPhone is no longer suitable. By climbing the catalogs of Chinese online stores, you can find many infrared transmitters. Quite often in the open spaces of the network there are photos of such a positive hardware key.

What if your smartphone doesn’t have an infrared port?

If your smartphone doesn’t have an infrared port, don’t despair. Available on one of the IR transmitters on the Chinese market. This small device will cost a maximum of 20 USD, and at the same time will be a full-fledged alternative to the gadget’s built-in infrared port.

How to activate the infrared port on a Nokia mobile phone?

Most of the mobile phones have their own menu item to activate the infrared port. For example, for a Nokia mobile phone you have to choose Menu -> Infrared. After activating the infrared port, you will see the following symbol at the top left corner on the display of your Nokia mobile phone and you will know that the infrared port is enabled.

How to remotely control smartphones with IR?

The infrared port on your smartphone allows you to remotely control your devices at home. To take advantage of this opportunity, the gadget owner must download and install one of the special applications on the mobile device. The most well-known universal IR program is ZaZaRemote . If your smartphone doesn’t have an infrared port, don’t despair.


1 Answers

I tested ConsumerIrManager on Redmi Note 4, probably it will work on Note3 too.

Add permission to the manifest:

<uses-permission android:name="android.permission.TRANSMIT_IR" />

And in code:

  1. Retrieve ConsumerIrManager

val irService = getSystemService(Context.CONSUMER_IR_SERVICE) as ConsumerIrManager
  1. Check if emitter exists

irService.hasIrEmitter()
  1. Check if target frequency is supported by emitter

fun isSupportedFrequency(irService: ConsumerIrManager, targetFreq: Int): Boolean {
        irService.carrierFrequencies.forEach {
            if (it.minFrequency <= targetFreq && targetFreq <= it.maxFrequency) {
                return true
            }
        }
        return false
}
  1. Transmit data

irService.transmit(targetFreq, data)

UPD1:

To send 64 bit keys maybe you can split them into two 32 bit keys.

UPD2:

Under the hood ConsumerIrManager uses ConsumerIrService, which uses native method private static native int halTransmit(int carrierFrequency, int[] pattern);, which supports only 32 bit pattern slices. So probably there is no hacky way to send 64 bit slices, if splitting won't help.

like image 167
Ufkoku Avatar answered Sep 29 '22 16:09

Ufkoku