Single RF transmitter and receiver, multiple libraries

For two different types of devices, Sonoff RF window/door sensor and RF power outlets, I would like to make a device to control both via MQTT.

So far i made a device with an ESP8266 and a RF transmitter that can control the power outlets. I sniffed the protocol and coding used and hardcoded this.This works fine. I send a command via MQTT and the transmitter switches one of the outlets. Since I have little experience I am wondering if it is possible for a single RF receiver to listen and decode two different protocols. The door sensor could send a message or it can be used to “pair” a new rf remote which uses a different protocol.

Within my code i have to load a library and assign it to a gpio. I tested and cant seem to use two libraries with the same gpio.

Any tips or ideas to point me in the right direction?

What do you mean by protocol?

The message format/code of the devices differ. I can only get one device to work with a certain library and need another one for the other device.

So you can get either one to work but only one at a time? So all the frequencies are matched up?

Without knowing the particulars of your program since you're not posting code or linking to libraries that you are using, then all I can say is that there's a chance that you can get them both working if there's no conflict in the resources they each call. But also there's a chance there are conflicts. It's anyone's guess at this point until you share more relevant information.

Most implementations of RF sensor message reception and decoding are done "on the fly", meaning that the receiver/MCU is expecting a certain protocol and decodes the bit transition timing as the message comes in.

It is extremely difficult, and perhaps impossible, to write code that does that for two different protocols simultaneously, so you would need to store the entire received message for later analysis. An Arduino probably doesn't have the memory for that.

I definitely think it's doable.

It just requires an intimate understanding of both protocols.

How long are the packets. Say 256 bits max?

Check if each transition is within the bounds for either of the protocols, and if so, store the duration of that bit to an array. If you can get away with only looking at the highs or only looking at the lows, that's ideal...

Then store the duration in an array, and at the end, process that array. You'd end up using 512 ~ 2048 bytes of ram for the array, but on an esp8266, you have that....

Or have your input capture ISR decoding as if both protocols were active, and declaring a packet invalid only if bit length recorded isn't valid for either one.

Both are viable approaches, I think.

On the transmit side, it's much easier (once you know what you need to transmit) assuming you wrote the code to send the data yourself or understand what it's doing - just have two different functions that you call to send, one for each protocol, and you're golden.