EliasKotlyar / Xiaomi-Dafang-Hacks

4.17k stars 1k forks source link

Feedback / Support - Issue #7

Closed EliasKotlyar closed 6 years ago

EliasKotlyar commented 6 years ago

This issues is for support and/or general discussions. Open up an issue if you want to have something improved.

deennoo commented 6 years ago

Looks ok for me, horizontal en vertical calibration works great, and end motor are well define.

Any way to count (on a software) how many horizontal and vertical step from 0 ? Goal is to set point of view preset

EliasKotlyar commented 6 years ago

@deennoo : That should be totally possible. You just need to store the points after the calibration is done. Refer to this Code: https://github.com/EliasKotlyar/Xiaomi-Dafang-Software/blob/master/motor/motor.c

deennoo commented 6 years ago

@EliasKotlyar thx, but i'm not on this level...i can copy/past/adapt what was already done, i need one exemple to understand, hard for me to start from 0

blackgearit commented 6 years ago

Hi all. I think i've installed successfully the .bin file, then formatted the SD card and copy firmware_mod to the root of SD, changed the wpa_suppliant.conf file and the hostname.conf, then I've inserted into the camera slot and powered. Now the camera change the led color to blue for one or two seconds then the led turn to yellow. The router device list does not show the camera. cannot do anything else...

EliasKotlyar commented 6 years ago

@blackgearit : Remove the SDCard and boot up the system. If the LED dont turn to blue for 5 seconds, it means that the new firmware havent been flashed.

blackgearit commented 6 years ago

@eliaskotlyal without the SD card, the camera turns on with orange, than switch to blue for 5/6secs then orange again..

Antimus commented 6 years ago

@blackgearit Have you double checked the wireless configuration file to make sure the SSID and Password are correct?

blackgearit commented 6 years ago

@antimus also tried with my office's access point, same thing..

blackgearit commented 6 years ago

The only thing I see a bit different from tuto is that flashing the bin file does not take 5 minutes but less than one..

Antimus commented 6 years ago

I had the same experience when flashing the firmware, but it does what is supposed to do

Antimus commented 6 years ago

@blackgearit can you check wireshark to see what dhcp traffic comes from the device? It's fairly simple, even I managed to find it, used this guide: https://documentation.meraki.com/zGeneral_Administration/Tools_and_Troubleshooting/Using_Packet_capture_to_troubleshoot_client-side_DHCP_issues

blackgearit commented 6 years ago

I'm at office now, I've changed the config, plug the sd card and the power... nothing is captured! I'm on linux and using tcpdump sudo tcpdump -vnes0 -i enp2s0 port 67 or port 68 i can see my phone when i toggle the phone's wifi connection, but nothing when turn on the camera. Will try at home under windows but I think I will be the same...

PS: Sorry I've used the wrong Access-Point that is into another VLAN an my phone is connected to the hidden one, in the same vlan of other pcs... will check TCPDUMP at home...

PPS: Using the config for the hidden ssid, tcpdump dumps nothing, but it's a hidden ssid so .... will try at home

blackgearit commented 6 years ago

No, now i'm at home, i'm able to see my phone dhcp requests when toggle wifi on the device, but nothing else when turn on the camera...

MasterPIC commented 6 years ago

@blackgearit Did you include, as expected, also quotation marks in ssid and pwd in wpa_supplicant.conf file?

blackgearit commented 6 years ago

@MasterPIC here it is

ctrl_interface=/var/run/wpa_supplicant
ctrl_interface_group=0
ap_scan=1

network={
        ssid="Alice-52700377"
        key_mgmt=WPA-PSK
        pairwise=CCMP TKIP
        group=CCMP TKIP WEP104 WEP40
        psk="xxxxxxxxxxxxxxxx"
        priority=2
}

@EliasKotlyar any chance to have a system log temporary enabled so i can see what's happening?

blackgearit commented 6 years ago

the camera takes dhcp ip without the sd card inside, after less than a minute when powered... turn on power, orange led, then blue for few secs, then orange anagin, then reset motor, and then makes dhcp request... the ip is assigned and the led turns off.

Antimus commented 6 years ago

Same, my camera gets an IP address fine without the SD Card . We seem to have similar issues though I'm definitely seeing DHCP traffic. I've attached the packet information for the DHCP discovery and request DHCP packets.txt

So it is getting an IP address, according to that log, the device is requesting a .29 address, and it's setting it itself, just because the router isn't offering that IP address doesn't change that. So I can get to .29 and get the web server, and the RTSP stream, it seems to work fine.

My other Dafang is in the router table and has an IP address, but that thing's been turned on for weeks, it might have done the same thing at first.

so @EliasKotlyar Just out of curiosity, as I'm not an expert on anything like this, is it possible with some sort of RTSP server to set up a security camera type setup, with remote viewing from the internet and motion detection video capture? if so can you recommend one?

@trisk Can I ask, do you get a full DHCP discovery, offer, request, acknowledge when your camera starts up? or do you also just see a discovery then request?

Ok so I have 2 Dafangs, one is untouched, when that starts up it gets an IP, and the IP is in the routing table on the router. the one I've flashed with the custom firmware doesn't get an IP in the table, but does get an IP. When I reflashed with the original FW Wireshark shows the same, only a discovery and request, but the IP address is now back in the routing table. So something's going on that my router doesn't like with the custom firmware. Tried downgrading to custom 1.1, still the same problem

EliasKotlyar commented 6 years ago

@everyone: I managed to compile a new RTSP-Server, which is hopefully running better. Its basically based on https://github.com/mpromonet/v4l2rtspserver and has a lot of configuration parameters.

Greatings Elias

jmtatsch commented 6 years ago

Love the new RTSP-Server! Its incredible how crisp the video from this little camera is. How difficult would it be to get the audio in the stream going?

EliasKotlyar commented 6 years ago

@jmtatsch : Should be possible without many efforts. Its basically included in the source of this RTSP-Server, but needs to be modified to support OSS instead of ALSA. There is a compatiblity layer(OSS->ALSA), which can be used to make it work

darioxxx89 commented 6 years ago

Great!!! So this RTSP server is usable by now? i mean, can i use this rtsp server daily or is there any kind of problem? Such as starting every time the rtsp server when the camera reboot etc etc..

EliasKotlyar commented 6 years ago

@jmtatsch : Okey, i corrected it. Was really easy, cause there is a great tutorial for OSS. Much easier as ALSA. Now the audio should work.

@darioxxx89: Yeah, you can use it for daily use. You can autostart the rtsp by editing the run.sh file.

darioxxx89 commented 6 years ago

@EliasKotlyar thank you very much ! ;) i'll try to install it soon!

MasterPIC commented 6 years ago

@EliasKotlyar By editing action.cgi to have no cropped (RTSP) frames I get only about half frames (the bottom part of each frame is missing). Should I reduce FPS? Can I edit action.cgi by telnet instead of removing the SD card?

P.s. I'm playing by telnet on the SD card... I'd like to get RTSP frames at full resolution.

EliasKotlyar commented 6 years ago

@MasterPIC How did you edit this? I dont think that "reducing" the fps will help you.

You can edit it trough FTP and/or telnet.

MasterPIC commented 6 years ago

@EliasKotlyar In fact I wasn't able to get 1920x1080 resolution. I see that at lower resolution the frame is cropped: in a few words setting the resolution currently means cropping the 1920x1080 frame...

Lucas0511 commented 6 years ago

@EliasKotlyar really exciting to find RTSP available for my Dafang - already working great on the Xiaofang. As a noob can I attempt installation as per your tut? Not sure if I need new firmware, or have to make any changes (SSID etc.) like in wireless config? Maybe there is a more detailed tut for casual users? Happy New Year!

MasterPIC commented 6 years ago

@Lucas0511 You can follow the indications at https://github.com/EliasKotlyar/Xiaomi-Dafang-Hacks/blob/master/hacks/install_cfw.md You just need to update the bootloader, then you can reformat the microSD card to copy the firmware mod content and edit the wpa file (by entering your SSID and pwd).

blackgearit commented 6 years ago

Please how can I investigate why the custom fw doesn't work on my camera? Now I'm using my dafang without the SD card inside with xiaomi home app as usual..

fnxpt commented 6 years ago

@EliasKotlyar is it possible to run the cfw and still access the camera using the Mi Home app?

MasterPIC commented 6 years ago

@fnxpt Just remove the microSD card or delete/rename the file run.sh from the root of the microSD...

EliasKotlyar commented 6 years ago

@blackgearit Where exactly are you stuck?

@fnxpt : You cannot run both the same time due to technical limitations. However, if you remove your microsd or delete the run.sh file, the cam wont boot into the CFW and you can use your normal firmware.

markus0m commented 6 years ago

Just managed to get almost everything to run.

blackgearit commented 6 years ago

@eliaskotlyal my dafang does not execute the code into the SD card. As you suggested, I've sniffed the dhcp requests, and with sd card inside, the camera does not make any request. I've tried to put a '>. /log.txt' redirect after each row of run.sh but nothing was written out. Without the SD card inside the camera, the camera request its ip and I can connect with the mi home app...

EliasKotlyar commented 6 years ago

@blackgearit : If you remove the SDCard and boot up - does the blue LED shine for 5 seconds?

qingz2004 commented 6 years ago

Got error when trying to watch H264 RTSP stream. The following error was printed by v4l2rtspserver-master. [NOTICE] /home/eko/Dokumente/projects/Xiaomi-Dafang-Software/v4l2rtspserver-master/src/ServerMediaSubsession.cpp:24 Creating Source... seek seekNPT:0 slice:0 numBytes:0 RTCPInstance::RTCPInstance error: totSessionBW parameter should not be zero!

EliasKotlyar commented 6 years ago

@qingz2004 This is not an error, its a warning. I opened up a ticket here: https://github.com/EliasKotlyar/Xiaomi-Dafang-Hacks/issues/28

@markus0m : What kind of cropped Image do you receive? Flipping Image should be possible, but is not implemented yet.

Cyri1 commented 6 years ago

@blackgearit did you check the type of protection of your wifi on your router, mine was WPA2 and it doesnt work, i switched to WPA-PSK and now i can see the cam on the device list

markus0m commented 6 years ago

@EliasKotlyar Flipping would be very helpful! For the MJPEG RTSP, I get a 640x480 stream of the top left corner of the camera image, audio stutters. H264 RTSP actually starts loading a single frame after a while, but then freezes and seems to have memory problems CPU: 2.3% usr 2.7% sys 0.0% nic 93.8% idle 0.0% io 0.0% irq 1.0% sirq Load average: 2.34 2.39 1.84 1/59 567 PID PPID USER STAT VSZ %VSZ CPU %CPU COMMAND 550 1 root S 108m111.1 0 2.3 /system/sdcard/bin/v4l2rtspserver-master -S

Cyri1 commented 6 years ago

my h264 stream : image my mjpeg stream : image

blackgearit commented 6 years ago

@Cyri1 my router is setted to wpa/wpa2 psk, the camera without the SD card connects without problems, so I think is not the problem.. But I'll try.. @eliaskotlyal yes, the camera turns on with orange led, then blue for 5/6secs, and then return to orange. Then start motor calibration..

PaulSka commented 6 years ago

@blackgearit Hi Blackgearit, I have the same issues, without SDcard, i see camera (DAFANGHACK) but with SDcard and firmware_mod.

PaulSka commented 6 years ago

The sequence with SDCard is yellow, quick blue and yellow. After nothing happens, no ip from dhcp

EliasKotlyar commented 6 years ago

@markus0m : I implemented flipping, and also solved this cropping issue. Now it automatically scales it to the right size. Can you please test again?

@blackgearit : It seems that the firmware was installed correctly. Is something else on the microsd? Could you format it to FAT32 and then try again?

PaulSka commented 6 years ago

@EliasKotlyar @blackgearit Reformatting to FAT32, retry and not it's work ....

Thanks

The led still on yellow

markus0m commented 6 years ago

@EliasKotlyar No more cropping on MJPEG, H264 works better now. Thanks! Flip works but is also mirrored - any chance for a flipped (not mirrored) stream? :) Another suggestion: pause any streams while an image is requested - right now it just fails if a stream is running.

@PaulSka Most likely your card just won't work. I had the same problem on an ADATA 8GB and only using another card did the trick.

Is anyone here using Apple HomeKit? Would be cool if that could be implemented directly on the camera. I'll try fiddling with that once I find some time.

EliasKotlyar commented 6 years ago

@markus0m : Would it help if i flip it also horizontally? There is no code for mirroring...

About Homekit: Dont think it can be implemented. Apple is not the most "open source" friendly company...

@PaulSka : If you remove the SDCard and boot up - does the blue LED shine for 5 seconds?

mattg1000 commented 6 years ago

@ronsk How did you get this to work with your Synology Surveillance Station? I've tried to use the following and get an error message: Failed to receive stream.

IP address: IP of camera Port: 8554 Brand: [User Define] Video format: H.264 (also tried MJPEG, MPEG4) Source path: /unicast Username: blank Password: blank

I can see the stream in VLC at rtsp://192.168.1.xx:8554/unicast

Thanks.

markus0m commented 6 years ago

@EliasKotlyar That's what I meant by mirrored. It needs to be flipped horizontally as well. The HomeKit implementation via homebridge already exists

ronsk-zz commented 6 years ago

@mattg1000 With the new RTSP server (I think it was introduced 2017/12/26), Synology Surveillance Station stopped working. Not sure what the problem is and had no time to look into yet. If I remember correctly, the configuration you posted would have worked with the old h.264 RTSP server (except the source path, it was something like /teststream, don't really rember...).