Skip to main content
Topic: Android Application with USB IR Toy v2 (Read 13153 times) previous topic - next topic

Android Application with USB IR Toy v2

Greetings of the day!

I am facing the problem in developing the android application which should work with the electronics hardware (USB IR toy v2) .

I have a hardware of USB IR toy v2 and OTG cable and I want to develop an android application by which I can record the incoming signal from the hardware and can able to transmit that signal whenever I want to; through android application.

Cellphone: Samsung Galaxy Note 2
Electronics Hardware: USB IR toy v2.
Mobile is supporting USB Device via. OTG cable.
I have seen the ODK (Open data kit) which working on similar type functions but can't get the real time idea to work.
I have one android developer (my friend) with me.

> How to get data from the USB IR toy v2 in my mobile application ?
> Is driver needed to communicate between Electronics hardware and Mobile application.
> How to develop android app ? > I want steps !
> Can we move with the API ?
> Give your suggestion.
Try to reply ASAP.


Re: Android Application with USB IR Toy v2

Reply #1
Hi Khilan

Happy to see your posting, I'm currently having also the same idea: control IrToy via Android; but as you maybe have also realized: there is currently nothing out of the box available. the effort required is quite high. but it possible!

I'm currently playing around with a Huawei MediaPad 10 FHD and I'm also using the way via an OTG cable.
Here are links to two threads which helped me a lot and is a good starting point for getting into it:

I'm currently using the FTDriver which you will find in the first linked posting. It is more or less an additional layer that is using the Android USB host API. it does not need an additional driver or rooted device.
Then an implementation of the sample mode is needed, it is described here: ... pling_mode

To keep my project a little bit more simple, I'm currently not researching on how to get data from the toy. So I'm connecting the irtoy to the PC and record the codes via the perl script provided by the USBIRToy.package.v22.
however, here I had the first challenge that the perl script ( is not giving the same codes as the IRToyRecPlay sample is giving. the codes from the IRToyRecPlay did not work when I sent them out, the ones from the perl script are working.
Once I have the hex codes, I implement them in my android application and send them out.
--> sending the hex codes out seems to work. I first play around with my kenwood hi-fi system and it is able to control the volume. at least a start.

I can share some bit of code later, currently I have a few issues:
- sometimes when I plug in the OTG cable, my tablet is just restarting. this might be an issue on the tablet or on the irtoy, but at the end it is a problem which prevents from using the solution :(
- sometimes the irtoy just stopps working. when I plugin the device, the LED stays on, it stucks in bootloader mode I guess. but connecting it to windows is showing a yellow icon on the HID devide. the only way to fix it I have currently is to apply the jumper and flash the firmware again (v22). however this is also an killer issue.

Re: Android Application with USB IR Toy v2

Reply #2
attached the current state of my playground.
it contains the which I have a little bit enhanced with debug statements to be able to see where it fails.
then it contains the which should become an 'IrToy API' to init the device, send commands and close the device. it contains the implementation of the sampling mode.
and there is also the which is nothing more than a simple app with an init button, two buttons to send commands and a big logging area to see what happens.

please note that the exception handling is rubbish at the moment, there is a lot to do. and sorry, a part of the code is commented in german, a translator might be your friend ;)

Re: Android Application with USB IR Toy v2

Reply #3
I have done what you both have done, but I am not able to get the device to work my tv at all.  You can see the IR light if you use a video camera,  so it is sending data.  I even tried all the baud rates with no luck...

I am trying to get this to work with my samsung TV and JVC sound system.

Re: Android Application with USB IR Toy v2

Reply #4
I did translate your code in to English manitu,  thank you.
Your code has been a big help,  shame I still not having as good as luck as you are.

I am getting my IR code from the perl script record, and using HxD to open the .bin file so I can copy and past the hex code in to my program. 

Here the code I am using.  it the same as what Manitu wrote,  but in english.

Re: Android Application with USB IR Toy v2

Reply #5
yeah I forgot one thing.
As I mentioned, I'm taking also the hex codes using the perl script by taking the codes from the original remote.
to convert the .bin file into hex codes, I made a small C# script that I want to share now.
the attachment contains the binary exe and the sourcecode as well.
it is very easy to use:
Code: [Select]
bin2hex.exe input.bin output.txt
Code: [Select]
bin2hex.exe input.bin
where it creates input.txt as output file.
It should be possible to send these hex codes.
it works at least for my Samsung TV, the Sony HiFi and also the RC6 windows media center (but here I had to disable the debounce).

I'm corrently optimizing my api class, it needs to be more stable.
but my biggest problem is that the device sometimes stuck in bootload mode (led is on all the time) when the tables goes to sleep.
there is another thread in this forum regarding this problem, but it is mainly about windows.

Re: Android Application with USB IR Toy v2

Reply #6
In my app I have 3 remotes listed in there own .java file.  When I switch between the remotes my app will crash when it tries to close the device.  If I remove the close so it does not kill the connection,  my app will crash when I try to change to the other remote in the same app.

Re: Android Application with USB IR Toy v2

Reply #7
in my case, I also have 3 different remotes/devices to control.
but at the end, it doesn't matter from which remote you have learned the command. you are just sending hex codes and the correct target device will understand it.
so create a connection at the start of the app and close it at the end. between, you send the desired commands as hex codes from whatever remote.

Re: Android Application with USB IR Toy v2

Reply #8
What firmware are you using on the IR Toy?
May I see your app code to see how you done this?  mine is badly unstable,  and can use some ref to make it better.

Re: Android Application with USB IR Toy v2

Reply #9
I am having much better luck with firmware 22,  I will post my app here tomorrow.

Re: Android Application with USB IR Toy v2

Reply #10
My app still just keeps crashing,  can someone tell me what I am doing wrong?
When you click on Remotes, then pick TV remote,  my app will crash as soon as you touch any of the buttons.

I even try to load in Manitu test under my device button,  and even it will only work some of the time.

here a link to my app,  any help will be greatfull. ...

Re: Android Application with USB IR Toy v2

Reply #11
I have made a huge improvement to my app,  it almost working good.
When you launch my app you need to go to the device screen and hit init.
From there you can go to one of the remotes screen and use the remotes and press back to switch to the other.

I need to find away to avoid having to go to the device screen and pressing the init button.

here is my code ...

Re: Android Application with USB IR Toy v2

Reply #12
Ok I have fixed my main issues, and my app is ready for the most part to work with two devices. 
here a link to my code below,  I want to add that most of the good code that allows this to work came from Manitu ...

Next I want to see if i can retrieve data from the USB IR TOY to my Android
You need to use the FTdriver but here my code so far,  right now all it does it crash. ... es/ ...

Re: Android Application with USB IR Toy v2

Reply #13
Ok I see it is working quite good.
Here my latest state of the proof-of-concept app.
But as I can see, there is not that much improvment :(
You don't need to take over the whole class and lose the translation, you can simply merge it. the only improvment seems to be in the leseTransmitCount() function where it can handle now the correct handshake when there was sent more than 256 bytes (maybe not relevant for your project, but you never know).

Except the receiving part, is it working perfect now for the sending stuff? Or are there still any issues?
I still have two issues where I'm working on:
- I want to create a 'send synchronous' function where the calling thread is blocked and gets a boolean response if the send was successfull (required for sending depending commands). current issue: when the sending is called multiple times (eg. the button is hitted multiple times), it is crashing and the LED keeps on, even if I synchronize the work :(
- Sometimes when my tablet goes to standby, the irtoy freezes at the bootloader mode and will not work anymore until the firmware is flashed. do you have also such problems?

Re: Android Application with USB IR Toy v2

Reply #14
Sorry it taken so long to get back, I been real busy.

My app also does freeze if I let i go to standby.  I am able to fix it by restarting my phone and closing the app right with the IRTOY attached.  The last app I posted was a rush job to get somethin to show for my project day,  it now time for to go back and clean up  lot of code.