roleoroleo / sonoff-hack

Custom firmware for Sonoff GK-200MP2B camera
GNU General Public License v3.0
200 stars 45 forks source link

fix motion detection for newer firmware #103

Closed darkxst closed 1 year ago

darkxst commented 1 year ago

Restore MQTT motion events on firmware V5520.2053.0402build20220712. Manually set config MQTT_IPCSYS_DB=0 for these devices. This could be set automatically when saving the mqtt config, however I not sure exactly which models/firmware are affected.

Probably resolves issue #69

roleoroleo commented 1 year ago

I think this solution also works on old firmware. I need a couple of days to test it on my cam but probably we could set MQTT_IPCSYS_DB=1 for all models.

darkxst commented 1 year ago

I assume you meant MQTT_IPCSYS_DB=0? If that works on all models, maybe dont really need the config flag. However maybe safer to keep it just in case its needed on others?

roleoroleo commented 1 year ago

I assume you meant MQTT_IPCSYS_DB=0?

Yes.

If that works on all models, maybe dont really need the config flag. However maybe safer to keep it just in case its needed on others?

I think it's best to leave it.

I will test in the weekend.

roleoroleo commented 1 year ago

I tested the new db with the old cam. It works but the row arrives 30-40 seconds after the event while in ipcsys.db it arrives immediately. I think it would be better to add the option to the interface or try to detect automatically if ipcsys.db exists.

darkxst commented 1 year ago

@roleoroleo ipcsys.db always exists, just that t_alarm_log table is always empty on these new cameras/firmwares.

I not sure on the behaviour of the older cams, however even the eWeLink notifications seem to have similar delay for the motion events (on my camera). Its as if they dont trigger until the video is finished recording.

Where does this point on your camera? sqlite3 /mnt/mtd/db/ipcsys.db 'select * from t_rec_dbfile' does its show the ipcsys.db or the db on the sd card?

EDIT: otherwise we could only auto-detect on t_alarm_log being empty, which wont be reliable after startup or a reboot.

darkxst commented 1 year ago

or the other option would be to set the option based on firmware version perhaps? but happy to add it into the webUI as an option.

roleoroleo commented 1 year ago

Where does this point on your camera?

[root@GK]# sqlite3 /mnt/mtd/db/ipcsys.db "select * from t_rec_dbfile;"
2022-03-01 14:48:48|/mnt/mmc/AVRecordFile.db

Probably a manual option into the web gui is better.

darkxst commented 1 year ago

OK, will add that shortly.

Have you done any work to investigate the ipc of the AlarmServer app? I do wonder if there is a way to get instant notification of events on these firmware.

roleoroleo commented 1 year ago

Have you done any work to investigate the ipc of the AlarmServer app? I do wonder if there is a way to get instant notification of events on these firmware.

No, I didn't work on it at the moment.

darkxst commented 1 year ago

I have added manual option to webui (and reverted to default setting of 1)

roleoroleo commented 1 year ago

Thank you again for your code.