Sequence of ibus messages

I m trying to engage a relay using a sequence of kline messages. The sketch complies but i dont think my programming skills are up to the task .
I can read the ibus messages without any problems but when it comes to react to specific kline messages nothing happens .

Sketch code example 1 :

 // react to unlock message form kline , testing only . 
  if(memcmp_P(packet, REMOTE_LOCK, 6) == 0 ) {  
    debugSerial.println(F("Remote control lock PRESSED"));
                digitalWrite(2, HIGH);
                delay(500);
                digitalWrite(2, LOW);

Sketch code example 2 ( here i think i m way off ) :

 // UNLOCK WHILE UNLOCKED,  K-LINE SEQUENCE 
  if(memcmp_P(packet, GM_READY, 6) == 0 ) {
    if(memcmp_P(packet, CTRLK_UNLOCKED, 7) == 0 ) {
      if(memcmp_P(packet, DEV_STATUS, 6) == 0 ) {
         if(memcmp_P(packet, IGNITION_OFF, 6) == 0 ) {
          if(memcmp_P(packet, REMOTE_UNLOCK, 6) == 0 ) {
            if(memcmp_P(packet, NO_KEY, 6) == 0 ) {
              if(memcmp_P(packet, REMOTE_RELEASE, 6) == 0 ) {
                debugSerial.println(F("BAZINGA!"));
                digitalWrite(2, HIGH);
                delay(250);
                digitalWrite(2, LOW);
              }

The entire sketch and the library used are attached . This its based on this project http://curious.ninja/blog/arduino-bmw-i-bus-interface-intro/

E46_KBus_sketch.zip (2.59 KB)

Ibus_library.zip (11 KB)

You really need to look at the documentation for memcmp(). The _P version simply compares data in flash memory rather than SRAM.

If the value in memory is GM_READY, it is highly unlikely that the value is also CTRLK_UNLOCKED.

Now i see what i ve done , example 2 its garbage .
The code in example its not working either. i start to look around in the code for somme clues an i found
in ibusserial.cpp some sort of filter.

// only process messages we're interested in
    if(source != 0x50    //MFL
    && source != 0x68    //RAD
	&& source != 0x00    //gm
    && source != 0x18    //CDC
    && source != 0x6A    //DSP
	&& source != 0x44    //ews
	&& source != 0x80    //ike
    && source != 0xC8    //TEL
    && source != 0xB0    //SES
	&& source != 0xE8	 //RLS
    )

//lowercase are added by me .
The sketch complies but still no reaction when it supposed to happen .
This is what i was getting on Serialmonitor, before i made the adjustment in ibusserial.cpp, when lock button was pressed on the remote: DISCARDED: 00 04 BF 72 12 DB ( tested multiple times , 100% sure its the rite ibus message )
Remote_lock its defined in the library
const byte REMOTE_LOCK [6] PROGMEM = {
0x00 , 0x04 , 0xBF , 0x72 , 0x12 , 0xDB }; // Remote control lock PRESSED

This is the entire sketch.

// v0.1.0 - Beta branch

#include <avr/interrupt.h>
#include <IbusGlobals.h>
#include <IbusSerial.h>
#include <RingBuffer.h>

IbusSerial ibus; // Create an instance of the Ibus library called ibus.

// If using processor board with more than one HardwareSerial port, you don't need to use SoftwareSerial, or AltSoftSerial for
// DEBUG, so just define which HardwareSerial port you plan to use.
//#define debugSerial Serial2

// If using Arduino with only one hardware serial port (Uno, Nano etc) AND using MCP interface chip, use AltSoftSerial instead  
// of SoftwareSerial for DEBUG messages. SoftwareSerial uses pin change interrrupts that clash with the Ibus library. Also note
// that AltSoftSerial only works on pins 8(Rx) & 9(Tx).
#include <AltSoftSerial.h>
AltSoftSerial debugSerial;

// Software serial can be used with Melexis interface chip, but not with Microchip MCP Lin bus transceiver chips.
//#include <SoftwareSerial.h>
//SoftwareSerial debugSerial(7, 8); // 7 is Rx, 8 is Tx

// Setting up our variables
boolean goodPacket; //boolean value set true if good IBUS message detected
byte source;
byte length;
byte *pDebugByte;
byte databytes[36]; // Byte array to store message data bytes. ibusByte array of 40 - 4 for (Source, length, destination, checksumByte) = 36
byte outgoingMsg[32];
int outgoingSize;
unsigned long currentTime;


void setup()
{
  ibus.setIbusSerial(Serial); // Tell library which serial port is used for IBUS. Must be HardwareSerial port.
  ibus.setScrollSpeed(1500,1000,200,2); // Start delay, End delay, scroll speed & number of repeats. Defaults to 2000, 1000, 200, 2 if no alternatives specified
  ibus.setIbusPacketHandler(packetHandler); // Define callback function. This is the function that is called by the library when it has a complete IBUS packet/message.
  //ibus.sleepEnable(60); // Enable sleep timer, and set sleep time in seconds. Comment out/delete line to disable timer.
  debugSerial.begin(9600); // Set debug Baud rate
  ibus.setIbusDebug(debugSerial); // Tell library which serial port is used for DEBUG. Comment out line if debug disabled in IbusGlobals.h
  debugSerial.println(F("--IBUS reader V2--"));
  attachInterrupt(digitalPinToInterrupt(3), startTimer, CHANGE);
  pinMode(13, OUTPUT);
}
void loop()
{
  ibus.run(); // This keeps the IbusSerial library running.
}

// This is where we compare the received message with all the message bytes
// in IbusGlobals.h, or to known source/destination, and respond accordingly.
// 2. Implement timer to remove written text from radio display after X seconds

void packetHandler(byte *packet) // callback function
{
  
  source = packet[0];
  length = packet[1];
  byte destination = packet[2];
  pDebugByte = packet;

  // Identify message databytes - populate our databytes array
  for (int i = 0, s = 3; i <= length - 3; i++, s++) {
    databytes[i] = packet[s];
  }
  // react to unlock message form kline , testing only . 
  if(memcmp_P(packet, REMOTE_LOCK, 6) == 0 ) {  
    debugSerial.println(F("Remote control lock PRESSED"));
    debugSerial.println(F("BAZINGA!"));
                digitalWrite(13, HIGH);
                delay(500);
                digitalWrite(13, LOW);
                delay(500);
                digitalWrite(13, HIGH);
                delay(500);
                digitalWrite(13, LOW);
    }
  // Message from MFL_VOL_UP
  if(memcmp_P(packet, MFL_VOL_UP, 6) == 0 ) {
    // This is how to send text message to the Business CD/Radio display
    ibus.radioWrite("Vol UP Vol UP Vol UP ");
  }
  // Message from MFL_VOL_DOWN
  if(memcmp_P(packet, MFL_VOL_DOWN, 6) == 0 ) {
    ibus.radioWrite("Vol DOWN");
  }
  // Message from RLS to LCM
  if ((source == 0x00) && (destination == 0x04)){
    if (databytes[3] == 0x11) { 
      debugSerial.println(F("It's dark out, lights commanded on"));
      // TODO: 
      // Blinking alert LED wire will come into arduino as a digital input (Radar detector alert LED).
      // Implement dimming feature here. If this I-Bus message is present, find a method to dim this LED
      // Arduino output to actual LED == Increase resistance to ground? PWM? Or activate a relay that includes resistor?
    }
  }
}

void startTimer()
{
  ibus.startTimer();
}