LogoLogo
  • Ruuvi Developer Documentation
  • Ruuvi Hardware
    • RuuviTag B
    • RuuviTag Pro
    • Ruuvi Gateway
    • Ruuvi DevShield
    • Ruuvi Connector Kit
    • TMP 117 External Sensor
  • Ruuvi Connector System
    • Introduction
    • Expansion boards
    • Cables
    • Connectors
  • Ruuvi Sensor Firmware
    • 1.2.12
    • 2.5.9
    • 3.X
      • 3.x Sensors
      • 3.x Heartbeat
    • Device Firmware Update (DFU)
  • Ruuvi Gateway Firmware
    • GW Getting Started
    • GW Web-UI
      • Greeting window
      • Internet connection settings
        • Connection via Wi-Fi
        • Connection via Ethernet
      • Software update
      • Automatic configuration download
      • Automatic updates
      • Access Settings from LAN
      • Cloud Options
        • Backend: HTTP(s)
        • Backend: MQTT(s)
        • Backend: Statistics
      • Time Synchronisation Options
      • Bluetooth Scanning Settings
      • Configuration completion
      • Authentication when accessing from LAN
    • GW Install custom firmware
    • GW nRF52811 Firmware
      • GW nRF52811 selftest
      • GW nRF52811 scanning
      • GW nRF52811 repeating
      • GW nRF52811 UART communication
  • GW ESP32 Firmware
    • GW ESP32 WiFi Hotspot
    • GW ESP32 Button
    • GW ESP32 LED
    • GW ESP32 HTTP Client
    • GW ESP32 MQTT client
  • GW Data formats
    • HTTP: Time-stamped data from Bluetooth-sensors
    • HTTP: Data from Bluetooth-sensors without timestamps
    • MQTT: Time-stamped data from Bluetooth-sensors
    • MQTT: Data from Bluetooth-sensors without timestamps
    • HTTP GET /history (with timestamps) and decoding
    • HTTP: Gateway status
    • Gateway configuration
  • GW Examples
    • Polling mode
    • Poll endpoint "/metrics"
    • Configuration update via API
    • Firmware update via API
    • Configuration download from a remote server via API
    • MQTT examples
    • Home Assistant
    • MQTT+AWS IoT Core
  • Communicate with RuuviTag devices via Bluetooth
    • Bluetooth advertisements
      • Data format 3 (RAWv1)
      • Data format 4 (URL)
      • Data format 5 (RAWv2)
      • Data format C5 (Cut-RAWv2)
      • Data format 8 (Encrypted environmental)
    • Bluetooth connection
      • DIS (Device Information Service)
      • NUS (Nordic UART Service)
        • Heartbeat transmissions
        • Read logged history
    • Real Time Transfer (RTT)
  • Communicate with Ruuvi Cloud
    • Ruuvi Cloud
      • User API
      • Gateway API
      • Internal API
      • Alerts
      • Cloud stored app settings
  • Ruuvi Community projects
    • Integrations
Powered by GitBook
On this page
Edit on GitHub
  1. GW Examples

Configuration update via API

PreviousPoll endpoint "/metrics"NextFirmware update via API

Last updated 1 year ago

If your Gateway is password protected, you can configure the Gateway to allow you to update the configuration on it programmatically using bearer authentication.

On the "Access Settings" page, enable full access using bearer authentication and set the API-key:

If your Gateway is password protected and bearer authentication is not configured, you can still access the Gateway by using the 'RUUVISESSION' cookie from your browser. Open the configuration wizard in your browser and authenticate with the password, then open 'Developer Tools' in your browser, then open URL 'http://<RUUVI_GW_IP>/ruuvi.json'. In 'Developer Tools', open the 'Network' tab, select the 'Headers' sub-tab and locate the "RUUVISESSION" cookie:

Please note that you can only access the Gateway using the cookie from the same PC as the browser used for authentication.

Examples

Getting configuration from the Gateway

In the following examples, the gateway configuration is stored in the 'ruuvi.json' file.

  • The Gateway is remotely configurable without a password:

curl -v http://<RUUVI_GW_IP>/ruuvi.json --output ruuvi.json
  • The Gateway is remotely configurable using a bearer token:

curl -v http://<RUUVI_GW_IP>/ruuvi.json 
  -H "Authorization: Bearer 1SDrQH1FkH+pON0GsSjt2gYeMSP02uYqfuu7LWdaBvY=" 
  --output ruuvi.json
  • Using a cookie from the browser to access the Gateway:

curl -v http://<RUUVI_GW_IP>/ruuvi.json 
    --cookie "RUUVISESSION=SEUFTNJMCZASBWUO" 
    --output ruuvi.json

Uploading configuration to the Gateway

To upload the configuration from the "./ruuvi.json" file:

  • The Gateway is remotely configurable without a password:

curl -v http://<RUUVI_GW_IP>/ruuvi.json 
  -H "Content-Type: application/json" 
  -d @./ruuvi.json 
  • The Gateway is remotely configurable using a bearer token:

curl -v http://<RUUVI_GW_IP>/ruuvi.json 
  -H "Content-Type: application/json" 
  -H "Authorization: Bearer 1SDrQH1FkH+pON0GsSjt2gYeMSP02uYqfuu7LWdaBvY=" 
  -d @./ruuvi.json 
  • Using a cookie from the browser to access the Gateway:

curl -v http://<RUUVI_GW_IP>/ruuvi.json 
  -H "Content-Type: application/json" 
  --cookie "RUUVISESSION=SEUFTNJMCZASBWUO" 
  -d @./ruuvi.json 

Disabling all data relay interfaces

These examples show how to disable relaying data to the Ruuvi cloud, custom HTTP(S) server and MQTT.

  • The Gateway is remotely configurable without a password:

curl -v -X POST http://ruuvigateway9c2c.local/ruuvi.json 
    -H "Content-Type: application/json" 
    -d '{"use_http_ruuvi":false, "use_http":false, "use_mqtt":false}'
  • The Gateway is remotely configurable using a bearer token:

curl -v -X POST http://ruuvigateway9c2c.local/ruuvi.json 
    -H "Content-Type: application/json" 
    -H "Authorization: Bearer 1SDrQH1FkH+pON0GsSjt2gYeMSP02uYqfuu7LWdaBvY=" 
    -d '{"use_http_ruuvi":false, "use_http":false, "use_mqtt":false}'
  • Using a cookie from the browser to access the Gateway:

curl -v -X POST http://ruuvigateway9c2c.local/ruuvi.json 
    -H "Content-Type: application/json" 
    --cookie "RUUVISESSION=SEUFTNJMCZASBWUO" 
    -d '{"use_http_ruuvi":false, "use_http":false, "use_mqtt":false}'

Uploading network configuration

Note: The network settings must be uploaded separately from the main Gateway configuration.

Example of "ruuvi.json" with the network settings (See Gateway configuration):

{
  "wifi_sta_config": {
    "ssid": "",
    "password": ""
  },
  "wifi_ap_config": {
    "password": "",
    "channel": 1
  },
  "use_eth": true,
  "eth_dhcp": true,
  "eth_static_ip": "",
  "eth_netmask": "",
  "eth_gw": "",
  "eth_dns1": "",
  "eth_dns2": ""
}

The network configuration must contain the use_eth key and the main Gateway configuration must not.