niclet / xiaomi_hack

Xiaomi common hack for cameras (Mijia 360)
138 stars 35 forks source link

RTSP / HTTP Support for Mijia 360 #4

Open sandundev opened 7 years ago

sandundev commented 7 years ago

Hi Niclet,

Is it possible to stream the video of this device on a web browser / RTSP ?

Is there any way to build REST API to control this device over a HTTP instead of MI apps?

Thanks,

niclet commented 7 years ago

Hi,

It is not currently available with this hack. And unfortunately, I don't have enough time to work on it for now.

Regards.

pronsta commented 7 years ago

Hi,

Any development on this?

Thanks.

fittogp commented 7 years ago

Hi niclet.

Do you know if you could to work for RTSP someday?

Thanks a lot in advanced

brtwrs commented 7 years ago

I managed to get a RTSP server working on the Mijia 360 720p. Look at this threat maybe it will help you: https://github.com/Filipowicz251/mijia-1080P-hacks/issues/5

deennoo commented 7 years ago

@brtws, any way to share your work please ? Google Drive with à copy of your sd ? Or à repo with thé content.

brtwrs commented 7 years ago

Sure! But there is not much to share. Ik just downloaded the SDK from the project I mentioned https://github.com/Filipowicz251/mijia-1080P-hacks/wiki You'll find all the source code in there. I used the code and makefile from de SDK (GM8136 SDK release v1.0/Software/Embedded_Linux/source/gm_graph/product/GM8136_1MP/samples) I did changed the make file a bit. Added the croscompile and made it build static:

GMLIB=../../../gm_lib CROSS_COMPILE=arm-linux-gnueabi-

ifeq ($(shell find $(GMLIB)/../ -name gmlib.mak),) sinclude /usr/src/arm-linux-3.3/linux-3.3-fa/cross_compiler_def else sinclude $(GMLIB)/gmlib.mak endif

uclibc=$(shell echo $(CROSS_COMPILE)|grep uclib) ifeq ($(uclibc),) LIBRTSP=librtsp_glibc.a else LIBRTSP=librtsp.a endif

CC=$(CROSS_COMPILE)gcc CPP=$(CC) -E LD=$(CROSS_COMPILE)ld AS=$(CROSS_COMPILE)as MAKE=make PROGS=rtspd

LDFLAGS += -L$(GMLIB)/lib -lpthread -lm -lrt -lgm

CFLAGS += -I$(GMLIB)/inc

CFLAGS += -Wall -I$(GMLIB)/inc -static

TARGETS := $(PROGS)

.PHONY: $(TARGETS)

all: $(TARGETS)

$(TARGETS): %: %.c Makefile $(GMLIB)/inc/gmlib.h $(CC) $(CFLAGS) $< $(LIBRTSP) $(LDFLAGS) -o $@

clean: rm -f $(TARGETS)

Or do you need something else?

btw did any of you guys made any progress on how to control the motors end ir leds from anything but the Xiaomi app? As far as I can see its been done from the miio_avstreamer process which also sets up the stream to Xiaomi. I tried to decompile the binary file but its very hard te read the decompiled code.

deennoo commented 7 years ago

@brtwrs thx for your input...i'm not confortable with crosscompile and other stuff like this.

Having à .img from your sdcard will be perfect, but that à bit easy i understand. I just get my cam today , on looks how it Works.

Rstp or http://ip/snap.img can be good as it was already do for the fang or ante One. Thé great feature who is missing is just position préset, as i understand this will only Can be done when WE will have accès to motorisation driver.

brtwrs commented 7 years ago

@deennoo, just an image of my sdcard wont help you. You also need to change some init scripts on the cam itself and enable telnet to do so. Look at my comments here on how to do that: Filipowicz251/mijia-1080P-hacks#5 . If it helps, here is the compiled binary: https://bartwijers.stackstorage.com/s/1VdEqFz77VVcY9v

FYI on my cam I've disabled the miio_avstreamer proces at startup so the cam doesn't move when rebooting and keeps its position. I still havent found a way to make the cam move and sadly dont have much time to do more research. Hope this helps

deennoo commented 7 years ago

Thx for your input, will try your way to do when i will have time

deennoo commented 6 years ago

@brtwrs i'm looking hard on your comment, but can't find a way to start telnet server, any advice on i_t please ?

brtwrs commented 6 years ago

@deennoo You have to take the camera apart and look for the rx and tx pins. ( I didnt took a picture so I cant tell you exactly which one but its marked in the pcb) Connect a serial to usb cable to the rx, tx and ground on the camera and you will get a uboot console on your pc. You have to change the console variable (or something like that) in uBoot to make the output point to /dev/ttyS0 instead of /dev/null (make sure to save it) and reboot the camera. If all good you'll see a linux console and you can enable the telnet startup script (by removing the "_" from the name if I recall correctly). Now the telnet session will be active on your next reboot. I hope this helps you. Im sorry I dont have a more detailed description because I wrote this all from memory. Goodluck!

niclet commented 6 years ago

@brtwrs Your post looks very interesting to me. Do you know if I can use a raspberry pi to connect RX/TX/GND from camera to RPI GPIO and have a console on the RPI ? Or do I have to buy a serial to usb cable ? In any case, do you have some links which would guide me on such console installation/usage ? I have never used such low level hacking, but it seems very promising.

brtwrs commented 6 years ago

That should work. Google is your friend;) this is the first hit google gave me: https://oscarliang.com/raspberry-pi-and-arduino-connected-serial-gpio/ You could try without resistors at first. I dont think you need them.

When in the uboot cli:

  1. printenv that should print al the env variables. look for the bootargs variable
  2. setenv bootargs "bootargs variable string you got from step 1 but replace the console variable with /dev/ttyS0"
  3. saveenv
  4. reset or reboot (im not sure about this one)

now you should boot into a linux console

niclet commented 6 years ago

Thanks a lot :) On google, I had found many articles to monitor the serial port of RPI, but not from RPI. I'll test it asap, thanks again.

pronsta commented 6 years ago

@brtwrs @niclet any development on the mijia 1080 360 hack?

brtwrs commented 6 years ago

Check these projects: https://github.com/ghoost82/mijia-720p-hack https://github.com/cck56/mijia-720p-ctrl :)

pronsta commented 5 years ago

I also didnt find any infos about the JTSXJ01CM camera. I hope someday this will be hacked :)