Programming problem

Hi All,

New to the forum here but a long distance admirer. I have a problem and I think it might be the library for the ESP8266

I am trying to build a remote control translator and have been communicating with a gentleman accross the pond from the US named Dougal.

The code I am using now seems to work with simple remotes. This is something I need for my aging Mother In Law. She seems to think all remotes are the same.

Anyway, when using an RC6 control, anything over 32 bits seems to get truncated. Being a more hardware oriented guy I cannot seem to figure where the bug is.

Is there anyone that might want to help with this so I can understand it what is wrong.

I have included the code and schematic for someone that might be interested in helping. (43.9 KB)

transcodeer_esp8266_6OCAYdNGPn.PDF (24.2 KB)

the IRremoteESP8266 library has a class decode_results which reads like this

class decode_results {
  decode_type_t decode_type;  // NEC, SONY, RC5, UNKNOWN
  // value, address, & command are all mutually exclusive with state.
  // i.e. They MUST NOT be used at the same time as state, so we can use a union
  // structure to save us a handful of valuable bytes of memory.
  union {
    struct {
      uint64_t value;    // Decoded value
      uint32_t address;  // Decoded device address.
      uint32_t command;  // Decoded command.
    uint8_t state[kStateSizeMax];  // Multi-byte results.
  uint16_t bits;              // Number of bits in decoded value
  volatile uint16_t *rawbuf;  // Raw intervals in .5 us ticks
  uint16_t rawlen;            // Number of records in rawbuf.
  bool overflow;
  bool repeat;  // Is the result a repeat code?

You can see that the Decoded value is stored in a uint64_t, so has 64 bits

The standard Arduino-IRremote library has the same class decode_results but it reads:

class decode_results
		decode_type_t          decode_type;  // UNKNOWN, NEC, SONY, RC5, ...
		unsigned int           address;      // Used by Panasonic & Sharp [16-bits]
		unsigned long          value;        // Decoded value [max 32-bits]
		int                    bits;         // Number of bits in decoded value
		volatile unsigned int  *rawbuf;      // Raw intervals in 50uS ticks
		int                    rawlen;       // Number of records in rawbuf
		int                    overflow;     // true iff IR raw code too long

so you can see there that the value is coded as an unsigned long which is 32 bits.

if you have been borrowing code written for the standard arduino, some expects to see 32 bits and will force the use of a uint32_t type.

for example in your file ESP8266_IoT_Trancoder.ino I can see that the value is cast to 32 bits before being printed:  DecodeResults += String((uint32_t)results->value, HEX) ; 

Also looking at the Print.h header, it seems that Serial.print() can't actually handle 64 bits prints directly there a way to fix this or am I stuck.

When I receive the code it receives all but the 8 MSBits in raw form. It does not happen when it splits the code so I am even more confused.

I’m on my iPad so can’t see/test much. Seems the esp version of the IR library handles 64 bits fine, it might be just the printout that truncates the information. You might want also to double check if switch/case handles unsigned long long (uint64_t) correctly on the ESP (it should) and make sure all the variables that hold a value are of type uint64_t