• Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Register
  • Login
ModalAI Forum
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
    • Register
    • Login

    How to set up a static IP in RB5

    Qualcomm Flight RB5 5G Drone
    4
    17
    1.8k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • R
      Roberto @Eric Katzfey
      last edited by 9 Mar 2022, 22:46

      @Eric-Katzfey
      Thank you for help, what would you suggest? Perhaps a delay in the script or something similar?
      how do you suggest to do the startup log? and how could this sequence be organized correctly?
      Do you have a RB5 to test? Thank you for any help

      Roberto Calvi

      1 Reply Last reply Reply Quote 0
      • T
        tom admin
        last edited by 9 Mar 2022, 23:04

        @Roberto The "dumb" way to do it is to just put a sleep at the start of mystatic-ip.sh and gradually decrease the length to find the quickest sleep that works.

        Otherwise you'd have to reference another service in an "After" section to tell the service to start after the stated one

        Example:

        [Unit]
        Description=My static IP
        After=wlan_daemon.service 
        

        I know on VOXL wlan_daemon.service can be referenced, not positive whether it is on RB5 as well

        R 2 Replies Last reply 10 Mar 2022, 14:38 Reply Quote 0
        • R
          Roberto @tom
          last edited by Roberto 10 Mar 2022, 14:40 10 Mar 2022, 14:38

          RESOLVED: Thanks to @Eric-Katzfey & @tom

          1. First create a script:
          vi /etc/sudoers.d/mystatic-ip.sh
          

          Content of mystatic-ip.sh script:

          #!/bin/bash
          sudo ifconfig wlan0 192.168.178.201 netmask 255.255.255.0
          sudo route add default gw 192.168.178.1 wlan0
          
          1. Create a service:
          vi /etc/systemd/system/mystatic-ip.service
          

          Content of mystatic-ip.service file (that starts after wlan daemon):

          [Unit]
          Description=My static IP
          After=wlan_daemon.service
          
          [Service]
          ExecStart=/etc/sudoers.d/mystatic-ip.sh start
          
          [Install]
          WantedBy=multi-user.target
          

          To enable this service when the RB5 boots:

          systemctl enable mystatic-ip
          

          Reboot and you will have a static IP!

          Roberto Calvi

          R 1 Reply Last reply 10 Mar 2022, 15:37 Reply Quote 0
          • R
            Roberto @Roberto
            last edited by Roberto 10 Mar 2022, 15:38 10 Mar 2022, 15:37

            NOT RESOLVED 😖 @Eric-Katzfey & @tom

            Works on Reboot but not if I turn RB5 OFF wait a wile and afterwards I turn it ON

            Sometimes work and sometimes doesn't

            Somebody could please help me?

            Roberto Calvi

            1 Reply Last reply Reply Quote 0
            • R
              Roberto @tom
              last edited by 10 Mar 2022, 17:03

              @tom & @Eric-Katzfey

              List of services: (command to show active services)

              systemctl list-units --type=service
              

              Screenshot 2022-03-10 alle 17.56.18.png

              Some services are down like:
              ● dnsmasq.service loaded failed failed dnsmasq - A lightweight DHCP and caching DNS server
              ● lunch-make-scripts.service loaded failed failed lunch make scripts
              ● mystatic-ip.service loaded failed failed My static IP

              Somebody could please help me?

              Roberto Calvi

              E 1 Reply Last reply 11 Mar 2022, 17:05 Reply Quote 0
              • E
                Eric Katzfey ModalAI Team @Roberto
                last edited by 11 Mar 2022, 17:05

                @Roberto We will take a look and see if we can put together a solution over the next few days.

                1 Reply Last reply Reply Quote 0
                • T
                  tom admin
                  last edited by 11 Mar 2022, 18:00

                  @Roberto This combo consistently works for me:

                  sh-4.4# cat /usr/bin/rb5-wifi-static-ip.sh 
                  #!/bin/bash
                  
                  # wait for wlan0 to get it's initial IP from router
                  rb5-net-check wlan0 192.168
                  
                  # set new IP
                  sudo ifconfig wlan0 192.168.1.150 netmask 255.255.255.0
                  sudo route add default gw 192.168.1.1 wlan0
                  
                  sh-4.4# cat /etc/systemd/system/rb5-wifi-static-ip.service 
                  [Unit]
                  Description=WLAN0 Static IP Service
                  After=wlan_daemon.service
                  
                  [Service]
                  ExecStart=/usr/bin/rb5-wifi-static-ip.sh
                  
                  [Install]
                  WantedBy=multi-user.target
                  

                  Basically adding the rb5-net-check call which waits for wlan0 to get an initial valid IP before proceeding.

                  1 Reply Last reply Reply Quote 0
                  • T
                    tom admin
                    last edited by 11 Mar 2022, 18:40

                    @Roberto Or a slightly cleaner solution would be to keep your same script and just have the service depend on the rb5-net-check.service that is already enabled by default if you're running PX4:

                    sh-4.4# cat /etc/systemd/system/rb5-wifi-static-ip.service 
                    [Unit]
                    Description=WLAN0 Static IP Service
                    After=rb5-net-check.service
                    
                    [Service]
                    ExecStart=/usr/bin/rb5-wifi-static-ip.sh
                    
                    [Install]
                    WantedBy=multi-user.target
                    
                    R 1 Reply Last reply 12 Mar 2022, 14:15 Reply Quote 0
                    • R
                      Roberto @tom
                      last edited by Roberto 12 Mar 2022, 14:21 12 Mar 2022, 14:15

                      FINALLY SOLVED: Thanks to @tom
                      (added chmod and complete procedure for other users)

                      1. First create a script:
                      vi /usr/bin/rb5-wifi-static-ip.sh 
                      

                      Content of rb5-wifi-static-ip.sh script (with sample IP):

                      #!/bin/bash
                      
                      rb5_net='192.168'
                      drone_IP='192.168.178.201'
                      router_IP='192.168.178.1'
                      netmask_IP='255.255.255.0'
                      network_interface='wlan0'
                      
                      # wait for wlan to get it's initial IP from router
                      rb5-net-check $network_interface $rb5_net
                      
                      # set new IP
                      sudo ifconfig $network_interface $drone_IP netmask $netmask_IP
                      sudo route add default gw $router_IP $network_interface
                      
                      1. Give permission to script (if not, will give you message "Permission denied"):
                      chmod u+x /usr/bin/rb5-wifi-static-ip.sh
                      
                      1. Create a service:
                      vi /etc/systemd/system/rb5-wifi-static-ip.service
                      

                      Content of rb5-wifi-static-ip.service file:

                      [Unit]
                      Description=WLAN0 Static IP Service
                      After=wlan_daemon.service
                      
                      [Service]
                      ExecStart=/usr/bin/rb5-wifi-static-ip.sh
                      
                      [Install]
                      WantedBy=multi-user.target
                      
                      1. Enable this service when RB5 boots:
                      systemctl enable rb5-wifi-static-ip.service
                      

                      Restart RB5 and you will have a static IP!

                      Roberto Calvi

                      1 Reply Last reply Reply Quote 0
                      • T
                        tom admin
                        last edited by 14 Mar 2022, 17:00

                        @Roberto Thanks for your patience with this, I will make sure this script / service makes it into our next SDK release as well.

                        1 Reply Last reply Reply Quote 0
                        • M
                          mrawding
                          last edited by 30 Mar 2022, 15:48

                          If anyone else is interested - I found a way to enable static ip's for ethernet and wlan interfaces.

                          You'll need to install a file like below under /etc/systemd/systetem/ and run the following commands:

                          systemctl enable ipconfig.service
                          systemctl disable dhcpcd.service
                          
                          [Unit]
                          Description=A description for your custom service goes here
                          Requires=systemd-networkd.service
                          After=systemd-networkd-wait-online.service
                          
                          [Service]
                          Type=simple
                          ExecStartPre=/bin/sleep 10
                          ExecStart=/bin/systemctl restart systemd-networkd.service
                          
                          
                          [Install]
                          WantedBy=multi-user.target
                          

                          You'll also need to add this file under /etc/systemd/network/wlan0.network

                          [Match]
                          Name=wlan0
                          
                          [Network]
                          Address=192.168.0.169/24
                          #DHCP=yes
                          

                          Simply installing this service will allow most routers to keep the rb5 address the same when assigning IPs for a lease. Just comment #Address and uncomment DHCP to use dhcp.

                          You will also need to make sure to add the gatway to the routing table:

                          route add default gw $router_IP $network_interface

                          this is best to be configured as a oneshot service where the service has the field Requires=ipconfig.service

                          1 Reply Last reply Reply Quote 0
                          • First post
                            Last post
                          Powered by NodeBB | Contributors