User Tools

Site Tools


doc:appunti:hardware:sjcam-8pro-ambarella-wifi-api

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
doc:appunti:hardware:sjcam-8pro-ambarella-wifi-api [2022/05/07 09:11] – [Executing API commands at bootstrap] niccolodoc:appunti:hardware:sjcam-8pro-ambarella-wifi-api [2023/06/16 10:18] (current) – [SJCAM SJ8 Pro WiFi Ambarella API] niccolo
Line 5: Line 5:
 The server on the camera accepts **only one client at a time**. When the camera is connected to a WiFi client on the controlling port 7878/TCP it will **ignore the Auto Power Off** setting and it remains active. The server on the camera accepts **only one client at a time**. When the camera is connected to a WiFi client on the controlling port 7878/TCP it will **ignore the Auto Power Off** setting and it remains active.
  
-The protocol was at least partially **reversed engineered**. To analyze the protocol I used **tcpdump**; having a rooted Android phone it is possibile to install the **[[https://termux.com/|Termux]]** app to have a command line terminal, install the **tcpdump** tool and, as root, sniff all the TCP traffic from the host smartphone and the SJCAM camera while using the SJCAM Zone app.+The protocol was at least partially **reversed engineered**. Having a rooted Android phoneit was possibile to run the **tcpdump** tool to analyze the TCP traffic (''tcpdump'' is installed from the command line of the **[[https://termux.com/|Termux]]** app). As root I started tcpdump to capture the traffic exchanged from the smartphone and the SJCAM camerawhile using the SJCAM Zone app.
  
-See my other page about the SJCAM SJ8 Pro action camera: **[[sjcam-8pro]]****[[sjcam-8pro-ambarella-firmware-modding]]** and **[[sjcam-8pro-custom-firmware]]**.+See my other page about the SJCAM SJ8 Pro action camera: 
 + 
 +  * **[[sjcam-8pro]]** 
 +  * **[[sjcam-8pro-ambarella-firmware-modding]]** 
 +  * **[[sjcam-8pro-custom-firmware]]**
  
 ===== JSON Messages ===== ===== JSON Messages =====
Line 128: Line 132:
 == AMBA_GET_SINGLE_SETTING_OPTIONS == == AMBA_GET_SINGLE_SETTING_OPTIONS ==
  
-Enumerate all the possible values for one setting:+Enumerate all the possible values for LCD Off Time setting:
  
 <code> <code>
Line 134: Line 138:
 RECV: {"rval":0,"msg_id":9,"permission":"settable","param":"LCD Off Time", RECV: {"rval":0,"msg_id":9,"permission":"settable","param":"LCD Off Time",
        "options":["Off","30 Seconds","1 Minute","3 Minutes","5 Minutes"]}        "options":["Off","30 Seconds","1 Minute","3 Minutes","5 Minutes"]}
 +</code>
 +
 +Enumerate all the possible values for Resolution setting:
 +
 +<code>
 +SEND: {"msg_id":9, "param": "Resolution", "token":1}
 +RECV: {"rval":0,"msg_id":9,"permission":"settable","param":"Resolution","options":[
 +       "4K (3840x2160) 24FPS","4K (3840x2160) 25FPS","4K (3840x2160) 30FPS",
 +       "4K (3840x2160) 50FPS","4K (3840x2160) 60FPS",
 +       "4K UItra (3840X21 60) 24FPS","4K UItra (3840X2160) 30FPS",
 +       "2.7K (2720x1520) 24FPS","2.7K (2720x1520) 25FPS","2.7K (2720x1520) 30FPS",
 +       "2.7K (2720x1520) 50FPS","2.7K (2720x1520) 60FPS",
 +       "1440 (2560x1440) 24FPS","1440 (2560x1440) 25FPS","1440 (2560x1440) 30FPS",
 +       "1440 (2560x1440) 50FPS","1440 (2560x1440) 60FPS",
 +       "1080(1920x1080) 24FPS","1080(1920x1080) 25FPS","1080(1920x1080) 30FPS",
 +       "1080(1920x1080) 50FPS","1080(1920x1080) 60FPS","1080(1920x1080) 120FPS",
 +       "1080 Ultra(1920X1080) 30FPS","1080 Ultra(1920X1080) 60FPS",
 +       "720(1280x720) 240FPS"]}
 </code> </code>
  
Line 150: Line 172:
 SEND: {"msg_id":2,"type":"camera_clock","param":"2022-05-06 17:02:43","token":2} SEND: {"msg_id":2,"type":"camera_clock","param":"2022-05-06 17:02:43","token":2}
 RECV: {"rval":0,"msg_id":2,"type":"camera_clock"} RECV: {"rval":0,"msg_id":2,"type":"camera_clock"}
 +</code>
 +
 +Set the video mode:
 +
 +<code>
 +SEND: {"msg_id": 2, "type": "Resolution", "param": "1080(1920x1080) 30FPS", "token":1}
 +RECV: {"rval":0,"msg_id":2,"type":"camera_mode"}
 +</code>
 +
 +Set the camera mode to normal record:
 +
 +<code>
 +SEND: {"msg_id": 2, "type": "camera_mode", "param": "normal_record", "token":1}
 +RECV: {"rval":0,"msg_id":2,"type":"camera_mode"}{"msg_id":7,"type":"normal_record"}
 </code> </code>
  
Line 254: Line 290:
 ===== Using Python to call the API ===== ===== Using Python to call the API =====
  
 +{{.:sjcam:sjcam-termux-shortcuts.png?direct&200 |Termux Widgets to start SJCAM scripts}}
 {{ .:sjcam:sj8pro-wifi-api-python-termux.png?220|Termux screen on Android smartphone}} {{ .:sjcam:sj8pro-wifi-api-python-termux.png?220|Termux screen on Android smartphone}}
 I wrote same **Python scripts** to execute simple actions, like **start** and **stop recording**, turning off the **front LCD** and **LEDs**. Python is very flexible: I can run the same scripts from my **GNU/Linux** PC or from the **Android** smartphone (once I installed the **[[https://termux.com/|Termux]]** app). Here it is a screenshot of the script launched from an icon on my Android device: I wrote same **Python scripts** to execute simple actions, like **start** and **stop recording**, turning off the **front LCD** and **LEDs**. Python is very flexible: I can run the same scripts from my **GNU/Linux** PC or from the **Android** smartphone (once I installed the **[[https://termux.com/|Termux]]** app). Here it is a screenshot of the script launched from an icon on my Android device:
  
 +On Android I installed also the **Termux:Widget** app which allows to add shortcut icons over the desktop which will launch the scripts. I have scripts to start and stop recording, to change white balance, to turn ON and OFF the front display and to power OFF the camera. Each launcher was customized with its own **icon** (se the screenshot to the left). When a script is launched, the output is printed into the text console; to have a more visible feedback I used the **figlet** program to print large ASCII-art messages (se the screenshot to the right).
 +
 +In this **[[https://github.com/RigacciOrg/ambarella-api-pytools|GitHub repository]]** you can find a Python module which contains basic functions to send and receive the JSON messages, plus some handy scripts to do basic operations, like **REC Start**, **REC Stop**, set **White Balance**, etc.
  
  
doc/appunti/hardware/sjcam-8pro-ambarella-wifi-api.1651914697.txt.gz · Last modified: 2022/05/07 09:11 by niccolo