Giter Site home page Giter Site logo

madagaga / mjsxj02hl_application Goto Github PK

View Code? Open in Web Editor NEW

This project forked from kasitoru/mjsxj02hl_application

0.0 0.0 0.0 1.78 MB

Application for Xiaomi Smart Camera Standard Edition (MJSXJ02HL) with RTSP and MQTT support.

Home Page: https://io-net.ru/mjsxj02hl_firmware/

License: Apache License 2.0

C++ 4.67% C 92.18% Makefile 3.15%

mjsxj02hl_application's Introduction

MJSXJ02HL application

Donate

Application for Xiaomi Smart Camera Standard Edition (MJSXJ02HL) with RTSP and MQTT support. It is used in a custom firmware.

Attention! This firmware is no longer supported by the author. We recommend using OpenIPC.

Build

  1. Install Hi3518Ev300 toolchain:
tar -zxf arm-himix100-linux.tgz
sudo ./arm-himix100-linux.install
  1. Copy the libraries from directory /usr/app/lib of the original firmware to directory /opt/hisi-linux/x86-arm/arm-himix100-linux/target/usr/app/lib:
sudo mkdir -p /opt/hisi-linux/x86-arm/arm-himix100-linux/target/usr/app/lib
sudo chmod 777 /opt/hisi-linux/x86-arm/arm-himix100-linux/target/usr/app/lib

git clone https://github.com/kasitoru/mjsxj02hl_firmware
cp -a ./mjsxj02hl_firmware/firmware/app/lib/. /opt/hisi-linux/x86-arm/arm-himix100-linux/target/usr/app/lib/
rm -Rf mjsxj02hl_firmware
  1. Clone the repository:
git clone https://github.com/kasitoru/mjsxj02hl_application
cd mjsxj02hl_application
  1. Update submodules (optional):
make update-libs
  1. Build application:
make

To save time, you can disable the build of external shared libraries:

make SKIP_SHARED_LIBS=ON

...and skip step โ„–4.

Configuration

Default config /usr/app/share/mjsxj02hl.conf:

[general]
name = My Camera               ; Device name
led = true                     ; Enable onboard LED indicator

[logger]
level = 2                      ; Log level (0 = disable, 1 = error, 2 = warning, 3 = info, 4 = debug)
file =                         ; Write log to file (empty for disable)

[osd]
enable = false                 ; Enable On-Screen Display (OSD)
oemlogo = true                 ; Display OEM logo (MI)
oemlogo_x = 2                  ; X position of the OEM logo
oemlogo_y = 0                  ; Y position of the OEM logo
oemlogo_size = 0               ; Size of the OEM logo (can take negative values)
datetime = true                ; Display date and time
datetime_x = 48                ; X position of the date and time
datetime_y = 0                 ; Y position of the date and time
datetime_size = 0              ; Size of the date and time (can take negative values)
motion = false                 ; Display detected motions in rectangles
humanoid = false               ; Display detected humanoids in rectangles

[video]
gop = 1                        ; Group of pictures (GOP) every N*FPS (20)
flip = false                   ; Flip image (all channels)
mirror = false                 ; Mirror image (all channels)
primary_type = 1               ; Video compression standard for primary channel (1 = h264, 2 = h265)
secondary_type = 1             ; Video compression standard for secondary channel (1 = h264, 2 = h265)
primary_bitrate = 1800         ; Bitrate for primary channel
secondary_bitrate = 900        ; Bitrate for secondary channel
primary_rcmode = 2             ; Rate control mode for primary channel (0 = constant bitrate, 1 = constant quality, 2 = variable bitrate)
secondary_rcmode = 2           ; Rate control mode for secondary channel (0 = constant bitrate, 1 = constant quality, 2 = variable bitrate)

[audio]
volume = 70                    ; Audio volume level (0-100)
primary_enable = true          ; Enable audio for primary channel
secondary_enable = true        ; Enable audio for secondary channel

[speaker]
volume = 70                    ; Speaker volume level (0-100)
type = 1                       ; Default file format (1 = PCM, 2 = G711)

[alarm]
enable = true                  ; Enable alarms
motion_sens = 150              ; Motion sensitivity (1-255)
humanoid_sens = 150            ; Humanoid sensitivity (1-255)
motion_timeout = 60            ; Motion timeout (in seconds)
humanoid_timeout = 60          ; Humanoid timeout (in seconds)
motion_detect_exec =           ; Execute the command when motion is detected (empty for disable)
humanoid_detect_exec =         ; Execute the command when humanoid is detected (empty for disable)
motion_lost_exec =             ; Execute the command when motion is lost (empty for disable)
humanoid_lost_exec =           ; Execute the command when humanoid is lost (empty for disable)

[rtsp]
enable = true                  ; Enable RTSP server
port = 554                     ; Port number
username =                     ; Username (empty for disable)
password =                     ; Password
primary_name = primary         ; Name of the primary channel
secondary_name = secondary     ; Name of the secondary channel
primary_multicast = false      ; Use multicast for primary channel
secondary_multicast = false    ; Use multicast for secondary channel
primary_split_vframes = true   ; Split video frames into separate packets for primary channel
secondary_split_vframes = true ; Split video frames into separate packets for secondary channel

[mqtt]
enable = false                 ; Enable MQTT client
server =                       ; Server address
port = 1883                    ; Port number
username =                     ; Username (empty for anonimous)
password =                     ; Password (empty for disable)
topic = mjsxj02hl              ; Name of the root topic
qos = 1                        ; Quality of Service (0, 1 or 2)
retain = true                  ; Retained messages
reconnection_interval = 60     ; Reconnection interval (in seconds)
periodical_interval = 60       ; Interval of periodic message (in seconds)
discovery = homeassistant      ; Discovery prefix (https://www.home-assistant.io/docs/mqtt/discovery/#discovery-topic)

[night]
mode = 2                       ; Night mode (0 = off, 1 = on, 2 = auto)
gray = 2                       ; Grayscale (0 = off, 1 = on, 2 = auto)

Usage

mjsxj02hl [<action> [options...]]

Running without arguments starts the main thread of the application.

--config <filename> Specify the location of the configuration file for the main thread of application.

--factory-reset Reset device settings to default values. Attention: this action cannot be undone!

--get-image <filename> Output the camera image to a file. Requires a running main thread of mjsxj02hl application.

--help Display help message.

RTSP

Network URL: rtsp://[<rtsp_user>:<rtsp_password>@]<ip-address>:<port>/<channel_name>

Example: rtsp://192.168.1.18:554/primary or rtsp://user:[email protected]:554/secondary

MQTT

<root_topic>: The value is set in the settings file (section: mqtt, name: topic). It is recommended to use the same value for all devices.

<device_name>: Value based on a parameter in the settings file (section: general, name: name). It is converted to lowercase, all characters except letters and numbers are cut off, spaces are replaced with underscores.

Input topics

Topic: <root_topic>/<device_name>/cmd

Execute the specified command on the device.

Command Parameters Description Example payload
get_image filename (string) Save the image to the specified file (JPEG, 640x360). { "action": "get_image", "filename": "/mnt/mmc/image.jpg" }
set_volume value (integer) Set volume level for speaker (0-100). { "action": "set_volume", "value": 100 }
play_media filename (string), type (string, optional), volume (integer, optional) Play the specified media file. Two types are supported: "pcm" (WAV, 8000 hz, 16-bit, mono) and "g711" (A-Law, 8000 hz, 16-bit, mono). { "action": "play_media", "filename": "/mnt/mmc/media.wav", "type": "pcm", "volume": 75 }
stop_media Stop current playback. { "action": "stop_media" }
system command (string) Execute the system (shell) command. { "action": "system", "command": "poweroff -f" }
restart Restart the main thread of mjsxj02hl application { "action": "restart" }
reboot Reboot the device. { "action": "reboot" }

Output topics

Topic: <root_topic>/<device_name>/status

This is a topic where availability status of the device is published (online or offline).

Topic: <root_topic>/<device_name>/info

This is a topic where general device state is published.

Field Description
fw_version Version of the firmware.
ip_address IP address of the device.
hw_temp Temperature from chip's internal sensor.
total_ram The total size of RAM.
free_ram The size of the free RAM.
total_sdmem The total size of SD-card.
free_sdmem The size of free space on the SD-card.
total_configs Total size of the configs partition.
free_configs The size of free space on the configs partition.
volume_level Current volume level of the speaker.
media_status Playback status (0 = stopped, 1 = playing, 2 = stopping).
image_url URL address of the JPEG image from the camera.

Topic: <root_topic>/<device_name>/alarm

This is a topic where motion detection events is published.

Field Description
motion Motion detection state.
humanoid Humanoid detection state.

Topic: <root_topic>/<device_name>/night

This is a topic where the state of night mode is published.

Field Description
state Night mode state.
gray Grayscale state.

Third-party libraries

mjsxj02hl_application's People

Contributors

kasitoru avatar smoogly avatar madagaga avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.