Announcement

Collapse
No announcement yet.

HTTP API (Thieye T5e)

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • HTTP API (Thieye T5e)

    Hi Everyone,
    I would like some help in making, if possible, a simple HTTP API to interface remotely via wifi.
    • Idealy it would be with some scripts,utilities loaded onto the stock firmware
    • the camera would
      • accept commands which represent the button presses (short, long, very-long if applicable)
      • need to expose the current "screen" we are in, or current status, or some sort of feedback to be able to define what a button press would do.

    Something along the lines of https://github.com/KonradIT/gopro-control ,

    On the Thread "Script Ideas for A12 Cams" , Nutsey presents using 't app key <key>' command, within an autoexec.ash script the possibility to perform virtual keys to "presses" to define a automatic initial setup. But I currently have not managed to use the "t"AmbaShell Test Command outside the domain of the autoexec.ash script, for example through a telnet session.

    I have however managed to from within a telnet session to the camera :
    • change the camera mode (Video/Photo)
      Code:
       ~ # /usr/bin/SendToRTOS record
    • Trigger the shutter (Photo or Start/Stop the recording)
      Code:
      ~ # /usr/bin/SendToRTOS photo
    A tipical use of this API would be as follows
    1. provide Power through microUSB. The camera starts up automatically
    2. Connect to the camera via wifi
    3. HTTP API : Read Current Settings or Current Screen revelant information
    4. HTTP API : Navigate through the different settings / Screens
    5. HTTP API : Change settings if needed through button presses
    6. HTTP API: Start Recording (Button press or not)
    7. HTTP API: Stop Recording (Button press of not)
    8. Download the files on the SD card through ftp server or http server, actually the cameras http server accesses the SD card already
    9. HTTP API: Turn Off the Camera
    10. The power provided through the microUSB would be disconnected.
    In my specific case I have a ThiEye T5e camera
    I have stock firmware I believe it is TI/UN5-170112-V5.0 ,
    I have attached a generated info file of my camera
    Generated by ambainfo.sh [by petesimon] from within a telnet session ThieyeT5e_info.txt
    Generated by autoexec.ash [by Nutsey] (getinfo_script) on the root SD card ThieyeT5e_log.txt

    Any input would be greatly apreciated, Thanks!
    paucoma
    Junior Member
    Last edited by paucoma; 07-08-2017, 09:50 PM. Reason: Edited ThieyeT5e_info.txt link

  • #2
    Hi Everyone,
    So I have progressed quite a bit with this.

    Point 1. The Camera starts up automatically when external power is applied
    Point 2. PENDING, I have an old f/w version (170112) where apparently the modified settings are not saved, so setting wifi to ON is forgotten once the camera is turned off.
    - Will need to upgarde the firmware to (170228) where this is fixed
    - Alternatively an autoexec.ash script could also do the trick probably
    Points 3-7. Satisfied with the JSON communications protocol on port 7878, detailed below. Will just need to program a "front_end" to the localhost Web Administration page.
    Point 8. PENDING Investigation.
    - a WGET through the already integrated HTTP server should be fine, will need to see transfer speeds and so on.
    - There apparently is a way to do this through the command interface too. will need to investigate.
    Point 9-10. The camera turns off automatically when external power is removed

    After Sniffing the Thieye App on the phone with [Packet Capture](https://play.google.com/store/apps/d...lcapture&hl=en) I noticed traffic to 192.168.42.1 on ports UDP 6971, 6970 TCP 554,8787,7878

    UDP 6971, 6970 sends some mixed text,binary data but there are no responses
    TCP 554 is the rtsp feed, this I can open in VLC to view the stream @ "rtsp://192.168.42.1/live/"
    TCP 8787 Only recieves data, what data this is I am not sure.. I am guessing images such as thumbnails...
    TCP 7878 Appears to be for the command interface

    The message exchange appears to be in JSON format, after googling a bit I stumbled across [a forum post](https://dashcamtalk.com/forum/thread...lin-mac.11206/) linking to the Github project [Xiaomi Yi Camera: GUI Control & Configure from PC (Win/Lin/Mac)](https://github.com/deltaflyer4747/Xiaomi_Yi) typically know in the forums as C&C by deltaflyer4747 from dashcamtalk also known as Andy_S. This and the resources mentioned helped me a be decipher the communications protocol.

    Additional Resources:
    - [Reverse engineering](http://copter.sovgvd.info/a/Xiaomi-Y...remote-control)
    - [AmbaCommandHelper.java from APK 1.5](http://pastebin.com/yKvXyyp8)
    - [Untitled](https://pastebin.com/nHA0WDsh)
    - [QBIC - API Reverse engineering](https://github.com/vogloblinsky/elmo...engineering.md)

    So I opened up a telnet session on port 7878 to 192.168.42.1 with putty and started playing around:

    First: you need to send a *token request message* with token = 0

    SEND {"msg_id":257,"token":0}
    RECV {"rval":0,"msg_id":257,"param":1}

    - param hold the token number with which we need to tag all our messages from here onwards in the format
    + {"msg_id":<msg_id>,"token":<token>}
    - Messages that are successful have a retrun value *"rval":0*
    - unsucessful commands have several negative return values which I have not decifered yet

    | Action | msg_id | type | param | reply |
    |-----------------------|--------|-------|-------|-------|
    | Get Token | 257 | - | - | "param":<valid token> |
    | Take Photo | 769 | - | - | "param":"C:\\AMBA\\170625000\\18101900.JPG" |
    | Start Recording | 513 | - | - | - |
    | Get Record time | 515 | - | - | "param":<seconds> |
    | Stop Recording | 514 | - | - | "param":"C:\\AMBA\\170625000\\181631AA.MP4" |
    | Check Battery | 13 | - | - | "type":[adapter/battery],"param":[1-5]<level> |
    | Check Card Space | 5 |"total"| - | "param":<kBytes> |
    | Check Card Space | 5 | "free"| - | "param":<kBytes> |
    | Get Cam Config | 3 | - | - | "param":[{key:value},...] |
    | Enter Settings Mode | 260 | - | - | - |
    | Get Parameter Options | 9 | - | <key> | "param":<key>,"options":[<Accepted values>]} |
    | Change Setting | 2 |"<key>"| "<newVal>" | "type":<keyModified> |
    | Exit Settings Mode | 259 | - | "none_force" | - |
    | List Directory | 1282 | - | "\/tmp\/SD0\/AMBA\/ -D -S" | "listing":[ {"<file_dir name>":"<size> bytes|<date-time>"},..]} |


    Return Values encountered:
    | Value | Description |
    |-------|-------------------|
    | 0 | Success |
    | -1 | Failed ? |
    | -4 | Bad Syntax ? |
    | -14 | Not Available ? |
    | -23 | Not Implemented ? |

    Examples attached in file. port7878cmd_examples.txt

    Any feedback/ideas are more than welcome.

    Cheers,
    Pau

    Comment


    • AussieKev
      AussieKev
      Member
      AussieKev commented
      Editing a comment
      * Point 1. The Camera starts up automatically when external power is applied
      * Point 2. PENDING, I have an old f/w version (170112) where apparently the modified settings are not saved, so setting wifi to ON is forgotten once the camera is turned off.

      This is annoying as there is no official ThiEYE charger for batteries, only modded sjcam type chargers. Do not want cam ON when plugged into a damn charger.

      My T5e was fine (170112v1.0), settings saved OK, until I bumped USB cable loose while watching a vid on Laptop. Settings were "frozen" on boot to FHD60, EIS ON, Sceensaver 30 secs etc. and locked the f/w on boot to this.
      If NOT corrupted (reset on boot) you can upgrade with SDcard using BIN file but if corrupted you have to use PC upgrade version ELF file. I can't as the UP button is broken. No long press UP Button function.

    • AussieKev
      AussieKev
      Member
      AussieKev commented
      Editing a comment
      * | Take Photo | 769 | - | - | "param":"C:\\AMBA\\170625000\\18101900.JPG" |

      Shouldn't the 2nd date range for JPG be 181019000 (9 digits) ?

    • paucoma
      paucoma
      Junior Member
      paucoma commented
      Editing a comment
      Thanks for the feedback on the fw and the settings... I will try to update my firmware soon and give feedback.
      Regarding enumeration which you call "date range" for JPG I believe is some 8 character based hexadecimal ennumeration. The file name corresponds to the created one after taking the photo.

    • petesimon
      petesimon
      Member
      petesimon commented
      Editing a comment
      ThieyeT5e_info.txt file from ambainfo.sh script link is https://www.goprawn.com/filedata/fet...7&d=1498203417
      Code:
      https://www.goprawn.com/filedata/fetch?id=4857&d=1498203417

    • AussieKev
      AussieKev
      Member
      AussieKev commented
      Editing a comment
      Thought they were using the date, then 00 - FF (0000 - 1111) after first 6 characters, "00" for JPG and "AA" for MP4 but obviously not.

  • #3
    How do you like your T5e so far? I just ordered one and am now playing the waiting game for it to show up so I can try it out. I researched the action cams and seems the T5e is one of the lowest priced cams that actually does 4k video and has decent components with the sony imx117 sensor and ambarella A12 processor.

    Comment


    • #4
      Originally posted by oldrockfan View Post
      How do you like your T5e so far? I just ordered one and am now playing the waiting game for it to show up so I can try it out. I researched the action cams and seems the T5e is one of the lowest priced cams that actually does 4k video and has decent components with the sony imx117 sensor and ambarella A12 processor.
      Hi, sorry for the late reply,
      I'm very pleased with the image quality although I must confessed I've only used it at 4k 30fps,
      Battery life is pretty good aswell
      The only complaint I have till now is that it gets really hot.

      Comment


      • #5
        Glad it is working well for you. I am still waiting for mine but intend to do a full test on it soon as it shows up. I am already thinking about swapping the fisheye lens for one with about 90 degree angle to eliminate the distortion around the edges. Any chance you can post up a pic of yours so we can see how it does stock?

        Comment


        • #6
          Originally posted by oldrockfan View Post
          Glad it is working well for you. I am still waiting for mine but intend to do a full test on it soon as it shows up. I am already thinking about swapping the fisheye lens for one with about 90 degree angle to eliminate the distortion around the edges. Any chance you can post up a pic of yours so we can see how it does stock?
          Here are a couple photos and snapshots of a video of my gate with a simple drawing explaining the setup and a couple measurements.

          http://imgur.com/a/QGiG3

          Cheers

          Comment


          • #7
            Thanks for posting up the pics. Other than the fisheye distortion, looks like it does a very good job. Nice detail and balanced colors across picture. I'm looking forward to getting mine in and once I change out the lens to one with a tighter fov, I think it will work great for what I intend to use it for.

            Comment


            • #8
              Code:
              AMBA_BOSS_RESETVF = 0x103
              AMBA_CANCEL_GET_FILE = 0x507
              AMBA_CD = 0x503
              AMBA_CHANGE_BITRATE = 0x10
              AMBA_CONTINUE_CAPTURE_STOP = 0x302
              AMBA_DEL_FILE = 0x501
              AMBA_DIGITAL_ZOOM = 0xe
              AMBA_DIGITAL_ZOOM_INFO = 0xf
              AMBA_FORMAT = 0x4
              AMBA_GET_ALL_CURRENT_SETTINGS = 0x3
              AMBA_GET_BATTERY_LEVEL = 0xd
              AMBA_GET_FILE = 0x505
              AMBA_GET_MEDIAINFO = 0x402
              AMBA_GET_RECORD_TIME = 0x203
              AMBA_GET_SETTING = 0x1
              AMBA_GET_SINGLE_SETTING_OPTIONS = 0x9
              AMBA_GET_SPACE = 0x5
              AMBA_GET_THUMB = 0x401
              AMBA_LS = 0x502
              AMBA_NOTIFICATION = 0x7
              AMBA_QUERY_SESSION_HOLDER = 0x701
              AMBA_RECORD_START = 0x201
              AMBA_RECORD_STOP = 0x202
              AMBA_SD_SPEED = 0x1000002
              AMBA_SD_TYPE = 0x1000001
              AMBA_SET_SETTING = 0x2
              AMBA_START_SESSION = 0x101
              AMBA_STOP_SESSION = 0x102
              AMBA_STOP_VF = 0x104
              AMBA_TAKE_PHOTO = 0x301
              AMBA_UNKNOW = 0x5000001
              Donate here if you want to support my efforts and this site.

              Email me if you have any offers, requests or ideas.

              Comment


              • #9
                Hye, I am planning to buy a ThiEye E7 but only if it allows me to control it via HTTP API. Does anyone here has tried this with the E7?

                Comment


                • #10
                  Seems this document might be usefull as it describes requests and responses in details
                  Foream_Wireless_Remote_Control_API.pdf
                  Originated from here
                  http://www.driftlife.co/download/For...ontrol_API.pdf
                  Attached Files

                  Comment


                  • #11
                    nutsey
                    _m_o0_m_
                    nutsey
                    paucoma
                    Junior Member
                    paucoma having a bit of trouble getting the command format correct. The examples file is no longer available. Would you mind posting the examples again (or just the format of the HTTP command). Cheers.

                    Comment


                    • #12
                      Hi everybody, could this work on the T5 edge, which is on iCatch V50 instead of Ambarella chipset?

                      Originally posted by v_max View Post
                      Seems this document might be usefull as it describes requests and responses in details
                      Foream_Wireless_Remote_Control_API.pdf
                      Originated from here
                      http://www.driftlife.co/download/For...ontrol_API.pdf

                      Comment


                      • #13
                        Quick update: received my T5 edge (icatch v50) camera today. Connected to the wifi with a windows 10 laptop, it generated an IP 192.168.1.10 for the laptop and shown no gateway. Pinging 192.168.1.1 gave a response but couldn't establish a telnet connection.

                        Comment

                        Working...
                        X