Commit df4e28b8 authored by a's avatar a
Browse files

initial SDK version (can compile a C++ program, which runs on the camera),...

initial SDK version (can compile a C++ program, which runs on the camera), added telnet instructions
parent a7423718
Loading
Loading
Loading
Loading
+36 −2
Original line number Diff line number Diff line
@@ -17,6 +17,34 @@ Control (JSON): TCP 192.168.42.1:7878
	./shoot.sh


## Get root shell on the camera

Copy autorun.ash to the micro SD card root. Then connect over telnet (user: root, no password):

	telnet 192.168.42.1

(source: https://github.com/sybond/MiSphere-hack)


## Compile an application natively for the camera

	cd sdk

Build a Docker container with the development environment and compile a "hello world" executable by running

	./run.sh

Then copy the resulting binary to the camera:

 - run on the computer:

	nc -l 1234 < hello

 - then run on the camera:

	nc 192.168.42.5 1234 > /tmp/hello && chmod +x /tmp/hello && /tmp/hello


# Running the script on Android (5.0+)

Install [Termux](https://wiki.termux.com/wiki/Main_Page) (from F-droid)
@@ -27,6 +55,12 @@ Connect to Wi-Fi, turn off mobile data and `./shoot.sh`

# Further resources and ideas

https://github.com/sybond/MiSphere-hack - info about filesystem contents and a guide how to run telnet on the device - can we run the script directly on the camera?
 - https://github.com/sybond/MiSphere-hack - info about filesystem contents and a guide how to run telnet on the device - can we run the script directly on the camera?

 - https://github.com/rnbguy/pysphere - an unofficial GUI in Python

 - as nc is present on the camera filesystem, it may be possible to run the "shoot.sh" script directly on the camera

 - it would be nice to make dropbear and sftp server run on the camera for easier file exchange and command execution

https://github.com/rnbguy/pysphere - an unofficial GUI in Python
 - can we re-use an already pre-compiled repository of packages, e.g. from OpenWRT?

autoexec.ash

0 → 100644
+6 −0
Original line number Diff line number Diff line
# This autoexec ambshell script will enable Telnet Daemon in the device
# For MiSphere only.
# Copyright (c) 2019 Bondan Sumbodo <sybond@gmail.com>

sleep 5
t ipc rpc clnt exec2 '/usr/sbin/telnetd > /dev/null'

sdk/Dockerfile

0 → 100644
+19 −0
Original line number Diff line number Diff line
FROM debian:10-slim

RUN apt-get update
RUN apt-get install -y --no-install-recommends wget xz-utils
RUN apt-get install -y --no-install-recommends ca-certificates
RUN wget 'https://releases.linaro.org/archive/14.09/components/toolchain/binaries/gcc-linaro-arm-linux-gnueabihf-4.9-2014.09_linux.tar.xz'
RUN unxz gcc-linaro-arm-linux-gnueabihf-4.9-2014.09_linux.tar.xz
RUN tar xf gcc-linaro-arm-linux-gnueabihf-4.9-2014.09_linux.tar
RUN rm gcc-linaro-arm-linux-gnueabihf-4.9-2014.09_linux.tar
ENV PATH="/gcc-linaro-arm-linux-gnueabihf-4.9-2014.09_linux/bin:$PATH"
#RUN find gcc-linaro-arm-linux-gnueabihf-4.9-2014.09_linux

RUN dpkg --add-architecture i386
RUN apt-get update
RUN apt-get install -y libc6-i386 zlib1g:i386
RUN apt-get install -y lib32stdc++6


WORKDIR /workdir

sdk/hello.cpp

0 → 100644
+6 −0
Original line number Diff line number Diff line
#include <iostream>

int main() {
	std::cout << "Hello from C++" << std::endl;
	return 0;
}

sdk/run.sh

0 → 100755
+4 −0
Original line number Diff line number Diff line
#!/bin/sh -euxo pipefail

docker build -t mi_camera_sdk .
docker run -it --rm -v "$PWD":/workdir mi_camera_sdk bash -c 'cp hello.cpp /tmp && arm-linux-gnueabihf-c++ -o /workdir/hello /tmp/hello.cpp'