[Library] Samsung TV Wrapper (sending remote-control code to Samsung TVs)
Samsung TV Wrapper-library (sending remote-control code to Samsung TVs)
In this thread (http://www.b4x.com/forum/basic4android-updates-questions/23765-samsung-tv-anyone.html#post139014) Kevin asked for some assistance in testing some code to simulate some remote-control commands for Samsung TVs. I tried the code but could not get it to work with my Samsung TV. Instead, I opted for writing a wrapper-library of some existing and well-tested Java-code to perform the same task.
This library wraps code found in the the following app SamyGo Remote by Tom Quist which can be found on Google Play (https://play.google.com/store/apps/details?id=de.quist.app.samyGoRemote). The source of this app was available here https://github.com/tomquist/SamyGo-Android-Remote until yesterday when I noted the page was not available any longer (perhaps a temporary error?).
Prerequisites:
1) This code should work with most Samsung TVs starting from the C-series and upwards although not all models are supported. I made my test on my Samsung TV which is a D-series TV and it works nicely. I have read that it should work also with the E-series. Previous series such as the B-series are not supported. This is the description of the app and I guess this information applies to this wrapper-library as well.
If you have a C-Series or D-Series TV, make sure you activated "Remote Control" in your TVs Menu under System-Settings. If there is no such setting, your TV is not supported.
The following TVs are Supported without modification:
• TVs from 2010 with Internet@TV feature: Models greater or equal to LCD 650, LED 6500, PDP 6500
• TV from 2011 with AllShare feature: Models greater or equal to LCD 550, LED 5500, PDP 5500
• TV from 2012 with AllShare feature: Models greater or equal to LCD 550, LED 5500, PDP 5500
• Bluerad Disc Player released in 2011 with Smart Hub feature
The following TVs are currently known to be unsupported: C490, C5100, C6300, C680, C687
2) The java-code seems to run on the main-thread and therefore it will not work with ICS (perhaps also Honeycomb). In order to resolve this you must not target said SDK(s) in the Manifest. Perhaps using Agraham's Threading-library you can find a work-around although I have not tried it.
Usage:
-add the 2 library-files in your Additional Library folder.
-you also need the ABWifi-library (for the MAC-address=b4auniqueId) found here:
http://www.b4x.com/forum/additional-libraries-classes-official-updates/8613-wifi-library.html#post48035
The methods are the following ones (self-explanatory I think). Thanks to Martin (warwound) for the script:
b4asamsungtv
Author: moster67
Version: 1.4
If the TV is supported, the first time the app is being run, the user will be prompted on the TV-screen to allow your app to be used with the TV. The user must say YES. As far as I know, this verification cannot be by-passed. I am not sure if it is the application-name, the device's MAC-address (uniqueId) or a combination of both which determine this verification. You will need to test yourself.
I have also attached a sample B4A-project. In the B4A-project you can find all remote-codes supported from C-series and onwards although I have only tested the most common ones on my TV. Note: if you power off the TV, you cannot power it on again from your app since the TV's LAN will be shut down and the TVs do not support Wake On LAN.
IMPORTANT NOTES:
Since the original code is under GNU General Public License, I guess also my wrapper must be the same.
Therefore read this carefully:
' ****
' * SAMSUNG TV WRAPPER-LIBRARY for B4A by moster67 (December 5, 2012)
' * ONLY WORKS WITH SAMSUNG TV C, D and probably E-series (B-serie DOES NOT work)
' * This wrapper is free software; you can redistribute it AND/OR modify
' * it under the terms of the GNU General Public License as published by
' * the Free Software Foundation; either version 2 of the License, OR
' * (at your option) any later version.
' * This wrapper Is distributed in the hope that it will be useful,
' * but WITHOUT ANY WARRANTY; without even the implied warranty of
' * MERCHANTABILITY OR FITNESS For A PARTICULAR PURPOSE.
'
' * IF YOU BRICK YOUR TV OR SOMEONE ELSE'S TV, THAT IS YOUR PROBLEM, NOT MINE,
' * ALTHOUGH IT WAS TESTED ON MY D-SERIES TV AND WORKED NICELY.
' * SOURCE OF WRAPPER IS AVAILABLE IN THIS POST.
'
' WRAPPER-LIBRARY BASED ON CODE FROM
' https://github.com/tomquist/SamyGo-Android-Remote.
'
' * Copyright (C) 2011 Tom Quist
' *
' * This program Is free software; you can redistribute it AND/OR modify
' * it under the terms of the GNU General Public License As published by
' * the Free Software Foundation; either version 2 of the License, OR
' * (at your option) any later version.
' *
' * This program Is distributed In the hope that it will be useful,
' * but WITHOUT ANY WARRANTY; without even the implied warranty of
' * MERCHANTABILITY OR FITNESS For A PARTICULAR PURPOSE. See the
' * GNU General Public License For more details.
' *
' * You can get the GNU General Public License at
' * The GNU General Public License v3.0 - GNU Project - Free Software Foundation (FSF)
I am not a lawyer but I think the license implies that if someone wants to see your sources,
you must provide the same. Maybe a workaround would be to write the remote-control as a plugin
and if sources are requested, you can give the sources of the plugin (and not your app). But
as I said, I am not a lawyer so I cannot tell.
Alternatively you can write your own code in B4A using the code-base Kevin provided in the link I posted in the beginning of this post.
Future:
I might add a discovery-class which will search for Samsung TVs available on the LAN
and indicate if it is compatible or not (i.e. C-serie or upwards). We'll see.
I hope this wrapper will work for you.
Good luck!
Samsung TV Wrapper-library (sending remote-control code to Samsung TVs)
In this thread (http://www.b4x.com/forum/basic4android-updates-questions/23765-samsung-tv-anyone.html#post139014) Kevin asked for some assistance in testing some code to simulate some remote-control commands for Samsung TVs. I tried the code but could not get it to work with my Samsung TV. Instead, I opted for writing a wrapper-library of some existing and well-tested Java-code to perform the same task.
This library wraps code found in the the following app SamyGo Remote by Tom Quist which can be found on Google Play (https://play.google.com/store/apps/details?id=de.quist.app.samyGoRemote). The source of this app was available here https://github.com/tomquist/SamyGo-Android-Remote until yesterday when I noted the page was not available any longer (perhaps a temporary error?).
Prerequisites:
1) This code should work with most Samsung TVs starting from the C-series and upwards although not all models are supported. I made my test on my Samsung TV which is a D-series TV and it works nicely. I have read that it should work also with the E-series. Previous series such as the B-series are not supported. This is the description of the app and I guess this information applies to this wrapper-library as well.
If you have a C-Series or D-Series TV, make sure you activated "Remote Control" in your TVs Menu under System-Settings. If there is no such setting, your TV is not supported.
The following TVs are Supported without modification:
• TVs from 2010 with Internet@TV feature: Models greater or equal to LCD 650, LED 6500, PDP 6500
• TV from 2011 with AllShare feature: Models greater or equal to LCD 550, LED 5500, PDP 5500
• TV from 2012 with AllShare feature: Models greater or equal to LCD 550, LED 5500, PDP 5500
• Bluerad Disc Player released in 2011 with Smart Hub feature
The following TVs are currently known to be unsupported: C490, C5100, C6300, C680, C687
2) The java-code seems to run on the main-thread and therefore it will not work with ICS (perhaps also Honeycomb). In order to resolve this you must not target said SDK(s) in the Manifest. Perhaps using Agraham's Threading-library you can find a work-around although I have not tried it.
Usage:
-add the 2 library-files in your Additional Library folder.
-you also need the ABWifi-library (for the MAC-address=b4auniqueId) found here:
http://www.b4x.com/forum/additional-libraries-classes-official-updates/8613-wifi-library.html#post48035
The methods are the following ones (self-explanatory I think). Thanks to Martin (warwound) for the script:
b4asamsungtv
Author: moster67
Version: 1.4
- RemoteSession
Methods:- Connect
- Initialize (b4aapplicationName As String, b4auniqueId As String, b4ahost As String, b4aport As Int)
Initialize the RemoteSession object - IsInitialized As Boolean
- sendCode (mykey As String)
- uninitialize
If the TV is supported, the first time the app is being run, the user will be prompted on the TV-screen to allow your app to be used with the TV. The user must say YES. As far as I know, this verification cannot be by-passed. I am not sure if it is the application-name, the device's MAC-address (uniqueId) or a combination of both which determine this verification. You will need to test yourself.
I have also attached a sample B4A-project. In the B4A-project you can find all remote-codes supported from C-series and onwards although I have only tested the most common ones on my TV. Note: if you power off the TV, you cannot power it on again from your app since the TV's LAN will be shut down and the TVs do not support Wake On LAN.
IMPORTANT NOTES:
Since the original code is under GNU General Public License, I guess also my wrapper must be the same.
Therefore read this carefully:
' ****
' * SAMSUNG TV WRAPPER-LIBRARY for B4A by moster67 (December 5, 2012)
' * ONLY WORKS WITH SAMSUNG TV C, D and probably E-series (B-serie DOES NOT work)
' * This wrapper is free software; you can redistribute it AND/OR modify
' * it under the terms of the GNU General Public License as published by
' * the Free Software Foundation; either version 2 of the License, OR
' * (at your option) any later version.
' * This wrapper Is distributed in the hope that it will be useful,
' * but WITHOUT ANY WARRANTY; without even the implied warranty of
' * MERCHANTABILITY OR FITNESS For A PARTICULAR PURPOSE.
'
' * IF YOU BRICK YOUR TV OR SOMEONE ELSE'S TV, THAT IS YOUR PROBLEM, NOT MINE,
' * ALTHOUGH IT WAS TESTED ON MY D-SERIES TV AND WORKED NICELY.
' * SOURCE OF WRAPPER IS AVAILABLE IN THIS POST.
'
' WRAPPER-LIBRARY BASED ON CODE FROM
' https://github.com/tomquist/SamyGo-Android-Remote.
'
' * Copyright (C) 2011 Tom Quist
' *
' * This program Is free software; you can redistribute it AND/OR modify
' * it under the terms of the GNU General Public License As published by
' * the Free Software Foundation; either version 2 of the License, OR
' * (at your option) any later version.
' *
' * This program Is distributed In the hope that it will be useful,
' * but WITHOUT ANY WARRANTY; without even the implied warranty of
' * MERCHANTABILITY OR FITNESS For A PARTICULAR PURPOSE. See the
' * GNU General Public License For more details.
' *
' * You can get the GNU General Public License at
' * The GNU General Public License v3.0 - GNU Project - Free Software Foundation (FSF)
I am not a lawyer but I think the license implies that if someone wants to see your sources,
you must provide the same. Maybe a workaround would be to write the remote-control as a plugin
and if sources are requested, you can give the sources of the plugin (and not your app). But
as I said, I am not a lawyer so I cannot tell.
Alternatively you can write your own code in B4A using the code-base Kevin provided in the link I posted in the beginning of this post.
Future:
I might add a discovery-class which will search for Samsung TVs available on the LAN
and indicate if it is compatible or not (i.e. C-serie or upwards). We'll see.
I hope this wrapper will work for you.
Good luck!
Attachments
Last edited: