Reposting my Reddit sub - not much of help there :)
I have two different DIY projects, based on ESP32 BLE stack:
- https://github.com/formatBCE/ESP32_BLE_presense - presence tracker
- https://github.com/formatBCE/Airbnk-MQTTOpenGateway - smart lock gateway.
They both are pretty similar by the nature - what they mostly do is scanning BLE advertisements (first one for tags, second one - for lock status) and interact with MQTT. You may check corresponding files in src/esphome directories to see pure logic.
However, they're pretty different in a way to use data.
Tracker project:
- does scan for several devices, so has stable scanning intervals;
- does send generic payload to defined topic;
- that's it.
Lock gateway:
- does search for one device only, so scan is restarted right after getting adv from lock (or by timeout, as in tracker project);
- does send advertisement data to defined topic;
- has subscription to command topic, and does create BLEClient on command to connect to lock, write payload to some characteristic, and send result after.
The problem statement is following:
Right now I use separate devices for both projects. I have SONOFF NSpanel right beside the front door (I made custom alarm panel from it, so it's convenient). So I included my tracker to it's firmware, and it sends command to open the door for me right while I'm approaching. NSpanel has pretty good range BTW.
Also, as lock gateway should be pretty close to the lock for good connection, I have another ESP32 with lock gateway firmware. But it's still pretty far from lock, as I don't have sockets in vicinity.
Would be super-cool to have both tracker and lock functionality on NSpanel.
So I'm thinking, how (and if) I can merge these into one project, considering all unsimilarities in logic.
Does someone have any thoughts? Bumping my head for couple days already.