Gary Roumanis
Published

IoT Remote

A simple iOS application that allows me to control my TV. No more losing remotes!

Full instructions provided2,786
IoT Remote

Things used in this project

Hardware components

Spark Core
Particle Spark Core
×1
IR Led Kit
×1
Breadboard and various hookup wires
×1
iOS device
×1
Basic Television
×1

Story

Read more

Code

code.txt

Python
def intToBinaryString(num, size):
  binaryString = "{0:b}".format(num)
  while len(binaryString) < size:
    binaryString = "0" + binaryString
  return binaryString


def complementBinaryString(string):
  complement = ""
  for bit in string:
    if bit == "0":
      complement += "1"
    else:
      complement += "0"
  return complement

def binaryStringToHex(string):
  return hex(int(string,2))

def hexToBinary(hexval):
        thelen = len(hexval)*4
        binval = bin(int(hexval, 16))[2:]
        while ((len(binval)) < thelen):
            binval = '0' + binval
        return binval

def funcToHexString(num):
  """ Returns the corresponding hex code for provided function number"""
  prefix = intToBinaryString(num,8)[::-1]
  suffix = complementBinaryString(prefix)
  return binaryStringToHex(prefix + suffix)

def hexStringToFunc(hexString):
  """ Returns the corresponding function number for provided hex code"""
  binaryString = hexToBinary(hexString)
  funcString = ""
  for num in range(0, 8):
    funcString += binaryString[num]
  return int(funcString[::-1],2)

funcCodes = ["18E7", "F00F", "00FF", "807F", "40BF", "C03F", "A05F", "20DF", "609F", "E01F", "10EF", "906F", "E817", "08F7", "708F", "B04F", "50AF", "30CF", "D02F", "28D7", "D827", "9867", "48B7", "8877", "38C7","C837"]
funcNums = []
for code in funcCodes:
  funcNums.append(hexStringToFunc(code))
funcNums.sort()
print("Function codes already decoded:")
print(funcNums)

codesToTest = []
for num in range(0,30):
  if num not in funcNums:
    codesToTest.append(funcToHexString(num))
print("Function codes to test:")
print(codesToTest)

Github

https://github.com/qwertzguy/Spark-Core-IRremote

Github

https://github.com/grouma/TVRemote

Credits

Gary Roumanis

Gary Roumanis

1 project • 1 follower

Comments