diff --git a/source/vicharak_sbcs/axon/axon-video/video-input/mipi.rst b/source/vicharak_sbcs/axon/axon-video/video-input/mipi.rst index ee2c6606..91910e20 100644 --- a/source/vicharak_sbcs/axon/axon-video/video-input/mipi.rst +++ b/source/vicharak_sbcs/axon/axon-video/video-input/mipi.rst @@ -38,7 +38,6 @@ Pre-Requisites 2. Ensure your axon is powred off before connecting the camera How to Attach Camera to Axon ----------------------------- 1. First, Connect Vicharak Flex Cable To Vicharak CAM PCB Connector. @@ -80,7 +79,6 @@ How to Attach Camera to Axon :width: 40% Camera Interface PCBs ---------------------- 2 Lane Alpha PCB ( Rpi compatible ) ==================================== @@ -89,7 +87,6 @@ Camera Interface PCBs :width: 30% Enable Overlays In Axon ------------------------- **Here, you can find which overlay should be turned on for each MIPI Connector.** @@ -169,7 +166,6 @@ Enable Overlays In Axon Make sure that whenever you are going to connect Camera, Device should be power off. Verify Camera Connection and Detection: ---------------------------------------- 1. Open a terminal by clicking ctrl+alt+t @@ -216,14 +212,13 @@ Verify Camera Connection and Detection: 5. If you got the device name and number then it confirms that axon has detected the Camera. If it is not visible, check the connection and pins again. To use the camera(s): ------------------------------------------------------------------------ .. Tip:: Connect a monitor to axon to see the captured feed. Run Camera Using qV4l2 (GUI tool) -================================== +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ **Step 1: Install the GUI tool (qv4l2) on RX Axon** @@ -261,7 +256,7 @@ Click on start capturing Run camera live feed using ffmpeg -================================= +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1. Install ffmpeg using ``sudo apt install ffmpeg`` 2. Find the camera device number and substitute in the below command @@ -269,7 +264,7 @@ Run camera live feed using ffmpeg 4. In case of multiple camera open a new terminal and run the same command with different device number Run Camera Using V4l2 Utility -=============================== +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1. Use v4l2-ctl to capture camera frame data @@ -313,7 +308,7 @@ Run Camera Using V4l2 Utility Run Camera Using Python Script -============================== +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. note:: @@ -338,7 +333,6 @@ for Debian-based systems (like Ubuntu): pip install opencv-python Setup ------- 1. Open a terminal window(``Ctrl+Alt+T``). @@ -423,7 +417,7 @@ If you have multiple versions of Python installed, ensure you use ``python3`` to - If you encounter any errors related to missing modules or libraries, ensure that Python and OpenCV are properly installed on your system. - If the camera frame does not open or the program does not behave as expected, check for any - errors in the terminal output and review your program for potential issues. + errors in the terminal output and review your program for potential issues. - Check Camera I2C address is detected or not. .. note:: @@ -431,3 +425,88 @@ If you have multiple versions of Python installed, ensure you use ``python3`` to I2C Bus number is mentioned in Camera DTS node in device tree file +.. _run-camera-live-stream-over-rtsp: + +Run Camera Live Stream over RTSP +================================ + +This section demonstrates how to stream a camera feed over the network using GStreamer and MediaMTX. Make sure you have the WiFi antenna connected to your board. + +Prerequisites +^^^^^^^^^^^^^ + +Install the required packages: + +.. code-block:: bash + + sudo apt update + + sudo apt install \ + gstreamer1.0-tools \ + gstreamer1.0-plugins-base \ + gstreamer1.0-plugins-good \ + gstreamer1.0-plugins-bad \ + gstreamer1.0-plugins-ugly \ + gstreamer1.0-libav \ + v4l-utils \ + ffmpeg + +Verify that the required GStreamer plugins are available: + +.. code-block:: bash + + gst-inspect-1.0 mpph264enc + gst-inspect-1.0 rtspclientsink + +Install MediaMTX +^^^^^^^^^^^^^^^^ + +Download the latest `Mediamtx relase `__ for Linux ARM64: + +.. code-block:: bash + + wget https://github.com/bluenviron/mediamtx/releases/download//mediamtx__linux_arm64.tar.gz + + tar -xzf mediamtx_linux_arm64v8.tar.gz + +Start MediaMTX: + +.. code-block:: bash + + ./mediamtx & + +By default, MediaMTX listens on: + + +Publish Camera Stream +^^^^^^^^^^^^^^^^^^^^^ + +Replace ```` with your camera device number. + +Examples: + + +Run: + +.. code-block:: bash + + gst-launch-1.0 -e \ + v4l2src device=/dev/video io-mode=mmap ! \ + videoscale ! \ + video/x-raw,width=1280,height=720 ! \ + mpph264enc bps=2000000 gop=15 ! \ + h264parse config-interval=-1 ! \ + rtspclientsink protocols=tcp location=rtsp://127.0.0.1:8554/cam + +View Stream Using FFplay +^^^^^^^^^^^^^^^^^^^^^^^^ + +From another machine on the same network, replace ```` with the IP address of the AXON board: + +.. code-block:: bash + + ffplay \ + -fflags nobuffer \ + -flags low_delay \ + -rtsp_transport tcp \ + rtsp://:8554/cam diff --git a/source/vicharak_sbcs/axon/connectivity/index.rst b/source/vicharak_sbcs/axon/connectivity/index.rst index bd54fb55..a6678e8d 100644 --- a/source/vicharak_sbcs/axon/connectivity/index.rst +++ b/source/vicharak_sbcs/axon/connectivity/index.rst @@ -10,3 +10,4 @@ Axon offers a range of connectivity options to ensure seamless integration with Bluetooth 5.2 Ethernet WiFi 6 + WiFi Direct (P2P) diff --git a/source/vicharak_sbcs/axon/connectivity/p2p.rst b/source/vicharak_sbcs/axon/connectivity/p2p.rst new file mode 100644 index 00000000..8318e960 --- /dev/null +++ b/source/vicharak_sbcs/axon/connectivity/p2p.rst @@ -0,0 +1,351 @@ +######################################### +Peer-to-peer networking via WiFi Direct +######################################### + +Sometimes you may encounter situations where you need to connect a cluster of Axons/other devices to share data over a short distance. While this is relatively trivial using wired methods, wirelessly doing so requires some extra setup steps. This page gives step-by-step instructions for setting up WiFi Direct on the Axon board, as well as similar devices. + +Workflow +========= + +A typical Wi-Fi network consists of multiple devices communicating through a central Access Point (AP). The AP is responsible for receiving and forwarding traffic, as well as handling routing, filtering, and other network functions. WiFi Direct removes the need for such an external device, and devices can negotiate amongst themselves. +In this guide, we will be setting up a connection between two Axons. The process will look roughly like so: + +.. image:: /_static/images/rk3588-axon/p2p_diagram.webp + :width: 70% + :alt: P2P WiFi Direct Connection Workflow + +#. Discovery - Devices locate one another using probe requests. + +#. GO Negotiation - Devices negotiate which device will become the Group Owner (GO). + +#. Group Formation - Once the GO has been selected, it creates a P2P group and advertises its SSID. + +#. WPS Authentication - This guide uses ``wps_pbc`` for authentication, although other methods are available. During this stage, devices authenticate and join the group. + +#. Data Transfer - Once connected, devices can communicate using standard networking tools and protocols. + +WiFi P2P Setup +============== + +This guide establishes a direct WiFi P2P connection between two Axon boards. Make sure that you have the WiFi antenna connected to each board. + +.. note:: + + **Axon 1** acts as the Group Owner (GO). + + **Axon 2** acts as the Station (Client). + +Configure P2P +============= + +.. grid:: 2 + :gutter: 3 + + .. grid-item-card:: Axon 1 + + .. code-block:: bash + + sudo vim /etc/wpa_supplicant/p2p.conf + + .. code-block:: ini + + ctrl_interface=/var/run/wpa_supplicant + update_config=1 + country=IN + + device_name=AXON_1 + + p2p_go_intent=15 + p2p_go_ht40=1 + + .. grid-item-card:: Axon 2 + + .. code-block:: bash + + sudo vim /etc/wpa_supplicant/p2p.conf + + .. code-block:: ini + + ctrl_interface=/var/run/wpa_supplicant + update_config=1 + country=IN + + device_name=AXON_2 + + p2p_go_intent=1 + p2p_go_ht40=1 + + +Kill Existing Instances +======================= + +.. grid:: 2 + :gutter: 3 + + .. grid-item-card:: Axon 1 + + .. code-block:: bash + + sudo pkill wpa_supplicant + + Verify: + + .. code-block:: bash + + ps -ef | grep wpa_supplicant + + .. grid-item-card:: Axon 2 + + .. code-block:: bash + + sudo pkill wpa_supplicant + + Verify: + + .. code-block:: bash + + ps -ef | grep wpa_supplicant + +Only the grep process should remain. + + +Start wpa_supplicant +==================== + +.. grid:: 2 + :gutter: 3 + + .. grid-item-card:: Axon 1 + + .. code-block:: bash + + sudo wpa_supplicant \ + -Dnl80211 \ + -i wlan0 \ + -c /etc/wpa_supplicant/p2p.conf \ + -B + + .. grid-item-card:: Axon 2 + + .. code-block:: bash + + sudo wpa_supplicant \ + -Dnl80211 \ + -i wlan0 \ + -c /etc/wpa_supplicant/p2p.conf \ + -B + + +Open Control Interface +====================== + +.. grid:: 2 + :gutter: 3 + + .. grid-item-card:: Axon 1 + + .. code-block:: bash + + sudo wpa_cli + + .. grid-item-card:: Axon 2 + + .. code-block:: bash + + sudo wpa_cli + +Keep both terminals open. + + +Create the P2P Group +==================== + +.. grid:: 2 + :gutter: 3 + + .. grid-item-card:: Axon 1 + + Inside ``wpa_cli``: + + .. code-block:: text + + p2p_group_add + + Expected: + + .. code-block:: text + + P2P-GROUP-STARTED wlan0 GO + + .. grid-item-card:: Axon 2 + + No action required. + + +Enable WPS Push Button +====================== + +.. grid:: 2 + :gutter: 3 + + .. grid-item-card:: Axon 1 + + Inside ``wpa_cli``: + + .. code-block:: text + + wps_pbc + + Expected: + + .. code-block:: text + + WPS-PBC-ACTIVE + + .. grid-item-card:: Axon 2 + + No action required. + + +Discover the Group Owner +======================== + +.. grid:: 2 + :gutter: 3 + + .. grid-item-card:: Axon 1 + + No action required. + + .. grid-item-card:: Axon 2 + + Inside ``wpa_cli``: + + .. code-block:: text + + p2p_find + + Expected: + + .. code-block:: text + + P2P-DEVICE-FOUND + + Make a note of the Group Owner's MAC address. + + +Connect +======= + +.. grid:: 2 + :gutter: 3 + + .. grid-item-card:: Axon 1 + + No action required. + + .. grid-item-card:: Axon 2 + + .. code-block:: text + + p2p_connect pbc join + + Replace ```` with the MAC address of the Group Owner. + + +Verify Success +============== + +.. grid:: 2 + :gutter: 3 + + .. grid-item-card:: Axon 1 + + Inside ``wpa_cli``: + + .. code-block:: text + + status + + Expected: + + .. code-block:: text + + mode=P2P_GO + wpa_state=COMPLETED + + .. grid-item-card:: Axon 2 + + Inside ``wpa_cli``: + + .. code-block:: text + + status + + Expected: + + .. code-block:: text + + mode=station + wpa_state=COMPLETED + ssid=DIRECT-* + + +Assign IP Addresses +=================== + +P2P creates the wireless link but does not automatically assign IPv4 addresses. + +.. grid:: 2 + :gutter: 3 + + .. grid-item-card:: Axon 1 + + Exit ``wpa_cli`` and run: + + .. code-block:: bash + + sudo ip addr add 192.168.50.1/24 dev wlan0 + + .. grid-item-card:: Axon 2 + + Exit ``wpa_cli`` and run: + + .. code-block:: bash + + sudo ip addr add 192.168.50.2/24 dev wlan0 + + +Test Connectivity +================= + +.. grid:: 2 + :gutter: 3 + + .. grid-item-card:: Axon 1 + + .. code-block:: bash + + ping 192.168.50.2 + + .. grid-item-card:: Axon 2 + + .. code-block:: bash + + ping 192.168.50.1 + +Expected output: + +.. code-block:: text + + 64 bytes from 192.168.50.X: icmp_seq=1 ttl=64 time= + + +Project Ideas +============= + + +Once peer-to-peer connectivity has been established, the connection can be +used for low-latency camera streaming between two Axon boards. + +See :ref:`run-camera-live-stream-over-rtsp`.