2

I have the IR sequence available in hexadecimal format which I want to transmit from device on click of a button. I could not find any documentation that explains to implement it with example. Any help would be appreciated.

Edit:

Example hex code: E172E817 (NEC format) This hex code was captured from a projector remote by arduino using adafruit's IR Library

I have tried to transmit it using the following code:

consumerIRManager.transmit(70000,new int[]{57714,59415});

When I run it,there is no error but it does not transmit any IR code.

Tushar Kathuria
  • 645
  • 2
  • 8
  • 22

2 Answers2

3

I believe what you need is the AndroidInfrared project on GitHub. It has a specific command to issue NEC Ir commands:

 ConsumerIrManager manager = ConsumerIrManager.getSupportConsumerIrManager(context);

    // Check whether IrEmitter is avaiable on the device.
    if (!manager.hasIrEmitter()) {
        Log.e("AndroidInfraredDemo", "Cannot found IR Emitter on the device");
    }

    // Build IR Command with predefined schemes.
    IrCommand necCommand = IrCommand.NEC.buildNEC(32, 0x723F);
    manager.transmit(necCommand);
pleft
  • 7,567
  • 2
  • 21
  • 45
  • 1
    I have updated the question with hex format. We have tested this hex code by turning on projector using a ir transmitter in projector remote. Now I want to implement same using android. Can you provide exact answer to achieve this. – Tushar Kathuria Feb 16 '16 at 12:26
  • 1
    The Hex code alone is not enough. I dont even know what this Hex code stands for or how it was encoded. How did you capture this code? using which program or device? Is it in pronto hex format? You see there are many questions to answer, try to figure out yourself maybe check here: https://www.remotecentral.com/cgi-bin/codes/ Since you haven't provided any source code I cannot help you any further. – pleft Feb 16 '16 at 14:37
  • Thanks a lot. At least it transmitted something, though the transmitted data is not the same as the hex code passed as a parameter(we tested it using arduino). I think I will need to change some default values in IrCommand class to achieve it. – Tushar Kathuria Feb 18 '16 at 14:27
1

Check this

      //Check for SDK version

      if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) {
        //create an instance of ConsumerIrManager class         
      ConsumerIrManager  cIr = (ConsumerIrManager) getApplicationContext().getSystemService(Context.CONSUMER_IR_SERVICE);

         //Check weather device has the IR hardware component or not

        boolean feature_consumer_ir = cIr.hasIrEmitter();

        if (feature_consumer_ir) {
            Log.i("Test",cIr.getCarrierFrequencies().toString());
            Toast.makeText(this, "Yep this device has the IR Hardware Component", Toast.LENGTH_SHORT).show();

        }else
        { Toast.makeText(this, "This Phone Does't have any IR Hardware Component", Toast.LENGTH_SHORT).show();

        }
    }

Now If you want to send the signal use this

    int[] pattern=new int[2];
    pattern[0]=1000000;  // delay time in micro seconds
    pattern[1]=1000000;  // delay time in micro seconds

    int frequency=57437537;

    //call transmit method with pattern and frequency parameters using ConsumerIrManager object
    cIr.transmit(frequency, pattern);

You can see that IR device will send the signal.To know weather it is sending or not hold your device infront of camera of another device it will show blinking of IR blaster

Note : The problem now is that you need to know the IR signal frequecny i.e you need to decode the signals.

To get IR signals decoded this might help you Is it possible to capture/receive IR signals in an Android application?

AgentP
  • 6,261
  • 2
  • 31
  • 52