mcchas / g2h-camera-mods

Modifying the G2H camera with rtsp, security and not to call home
MIT License
108 stars 14 forks source link

RTSP server not starting #10

Closed s1rd4v3 closed 3 years ago

s1rd4v3 commented 3 years ago

Nice to see that it should be finally possible to use the g2h as a rtsp cam. Telnet is working fine on my end but I'm unable to start the rtsp server on startup. Your hostname file seems to load fine as all the other files are correctly backuped or created. But after using netstat -anl I don't see the rtsp service running on port 554.

# netstat -anl
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State
tcp        0      0 127.0.0.1:101           0.0.0.0:*               LISTEN
tcp        0      0 127.0.0.1:54355         0.0.0.0:*               LISTEN
tcp        0      0 0.0.0.0:23              0.0.0.0:*               LISTEN
tcp        0      0 127.0.0.1:1883          0.0.0.0:*               LISTEN
tcp        0      0 127.0.0.1:48383         127.0.0.1:1883          ESTABLISHED
tcp        0      0 127.0.0.1:1883          127.0.0.1:48383         ESTABLISHED
tcp        0    328 10.0.0.152:23           10.0.0.13:58851         ESTABLISHED
tcp        0      0 127.0.0.1:1883          127.0.0.1:48384         ESTABLISHED
tcp        0      0 127.0.0.1:48384         127.0.0.1:1883          ESTABLISHED
udp        0      0 0.0.0.0:32869           0.0.0.0:*
udp        0      0 0.0.0.0:5353            0.0.0.0:*
udp        0      0 127.0.0.1:51858         0.0.0.0:*
udp        0      0 0.0.0.0:55707           0.0.0.0:*
udp        0      0 0.0.0.0:10020           0.0.0.0:*
Active UNIX domain sockets (servers and established)
Proto RefCnt Flags       Type       State         I-Node Path
unix  2      [ ACC ]     STREAM     LISTENING       1825 /dev/socket/property_service
unix  2      [ ACC ]     STREAM     LISTENING       1893 /var/run/mdnsd
unix  3      [ ]         DGRAM                      2714 /var/run/wpa_supplicant/wlan0
unix  2      [ ]         DGRAM                      2718 /tmp/wpa_ctrl_123-1
unix  2      [ ACC ]     STREAM     LISTENING       2138 @property_service
unix  3      [ ]         STREAM     CONNECTED       2143
unix  3      [ ]         STREAM     CONNECTED       2152
unix  3      [ ]         STREAM     CONNECTED       2658
unix  3      [ ]         STREAM     CONNECTED       1827
unix  3      [ ]         STREAM     CONNECTED       2144
unix  3      [ ]         STREAM     CONNECTED       2185
unix  3      [ ]         STREAM     CONNECTED       1828
unix  3      [ ]         STREAM     CONNECTED       2184
unix  3      [ ]         STREAM     CONNECTED       2145
unix  3      [ ]         STREAM     CONNECTED       2153 @property_service
unix  3      [ ]         STREAM     CONNECTED       2146
unix  3      [ ]         STREAM     CONNECTED       2659 /var/run/mdnsd

To me it seems that the whole homekit stuff is still running... not sure what I'm doing wrong.

Is there any difference if I'm connecting the Wifi of the Cam via hostname file, homekit or Aqara Mobile App? Should the sdcard be inserted at the very beginning or only after successfully connecting Wifi?

ads1230 commented 3 years ago

Hi, are you on FW 2.2.0? It seems to break the mod. You need to downgrade using telnet: https://github.com/ads1230/G2HTesting For some reason the bin file fails to extract on the G2H, so you have to manually extract and then upload. If you want to do it yourself

  1. Download the firmware and extract it
  2. save in a folder called upgrade on your SD card
  3. Run the commands
    cp -r /sdcard/upgrade /tmp/upgrade
    /tmp/upgrade/check_coor.sh
    /tmp/upgrade/copy_files.sh
    rm -rf /tmp/upgrade
    rm -rf /sdcard/upgrade
s1rd4v3 commented 3 years ago

Hey @ads1230. My current firmware seems to be 2.1.0. But will try to upgrade to 2.1.1 with your instructions. Thanks

s1rd4v3 commented 3 years ago

🎉 seems to work now with 2.1.1. thanks a lot @ads1230

geldelo commented 3 years ago

Please, help me: how to integrate G2H into Home assistant? I can’t reset password via telnet: my g2h can’t load file ‘hostname’ with script… firmware 2.2.1

mcchas commented 3 years ago

Hi, are you on FW 2.2.0? It seems to break the mod.

Downgrading probably isn't necessary, it's most likely due to the way hexdump and sed are being used to match and replace the bytes in the binary. If you send me the latest camera binary I can fix this. To test you might be able to just replace the second occurrence of the string 'miio_task' with 'rtsp_task' using sed or a text/hex editor.

ads1230 commented 3 years ago

Hi, are you on FW 2.2.0? It seems to break the mod.

Downgrading probably isn't necessary, it's most likely due to the way hexdump and sed are being used to match and replace the bytes in the binary. If you send me the latest camera binary I can fix this. To test you might be able to just replace the second occurrence of the string 'miio_task' with 'rtsp_task' using sed or a text/hex editor.

https://github.com/ads1230/G2HTesting/blob/ce4140777510624c51bf2382dce7ebf7a31022c3/Camera%20Binary/2.2.1%20(global)/camera

From the Global FW. Hope it helps :).

mcchas commented 3 years ago

Thanks @ads1230 - I created a branch with an untested fix. It should do the trick.

ads1230 commented 3 years ago

Thanks @ads1230 - I created a branch with an untested fix. It should do the trick.

Just tested, working well!