Files
AI-on-the-edge-device-docs/REST-API/index.html
2023-03-02 13:45:07 +00:00

488 lines
20 KiB
HTML

<!DOCTYPE html>
<html class="writer-html5" lang="en" >
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /><link rel="canonical" href="https://jomjol.github.io/AI-on-the-edge-device-docs/REST-API/" />
<link rel="shortcut icon" href="../img/favicon.ico" />
<title>REST API - AI on the Edge Device</title>
<link rel="stylesheet" href="../css/theme.css" />
<link rel="stylesheet" href="../css/theme_extra.css" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.5.0/styles/github.min.css" />
<script>
// Current page data
var mkdocs_page_name = "REST API";
var mkdocs_page_input_path = "REST-API.md";
var mkdocs_page_url = "/AI-on-the-edge-device-docs/REST-API/";
</script>
<script src="../js/jquery-3.6.0.min.js" defer></script>
<!--[if lt IE 9]>
<script src="../js/html5shiv.min.js"></script>
<![endif]-->
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.5.0/highlight.min.js"></script>
<script>hljs.initHighlightingOnLoad();</script>
</head>
<body class="wy-body-for-nav" role="document">
<div class="wy-grid-for-nav">
<nav data-toggle="wy-nav-shift" class="wy-nav-side stickynav">
<div class="wy-side-scroll">
<div class="wy-side-nav-search">
<img src=https://jomjol.github.io/AI-on-the-edge-device-docs//img/logo.png>
<a href=".." class="icon icon-home"> AI on the Edge Device
</a><div role="search">
<form id ="rtd-search-form" class="wy-form" action="../search.html" method="get">
<input type="text" name="q" placeholder="Search docs" title="Type search term here" />
</form>
</div>
</div>
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu">
<p class="caption"><span class="caption-text">Getting Started</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="..">Welcome</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../Installation/">Installation</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../initial-setup/">Initial Setup</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../Hardware-Compatibility/">Hardware Compatibility</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../Best-Practice/">Best Practice</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../FAQs/">Frequently Asked Questions</a>
</li>
</ul>
<p class="caption"><span class="caption-text">External Links</span></p>
<ul>
<li class="toctree-l1"><a class="" href="https://github.com/jomjol/AI-on-the-edge-device/releases">Releases</a>
</li>
<li class="toctree-l1"><a class="" href="https://jomjol.github.io/AI-on-the-edge-device/index.html">Web Installer/Console</a>
</li>
<li class="toctree-l1"><a class="" href="https://github.com/jomjol/AI-on-the-edge-device/issues">Place an Issue</a>
</li>
<li class="toctree-l1"><a class="" href="https://github.com/jomjol/AI-on-the-edge-device/discussions">Join a Discussion</a>
</li>
</ul>
<p class="caption"><span class="caption-text">Configuration</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../Reference-Image/">Reference Image</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../Alignment/">Alignment References</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../ROI-Configuration/">ROIs (Regions of Interest)</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../Configuration/">Graphical Configuration</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../Choosing-the-Model/">Model Selection</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../ota/">Over-The-Air (OTA) Update</a>
</li>
</ul>
<p class="caption"><span class="caption-text">Advanced</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../Parameters/">Parameters</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../Integration-Home-Assistant/">Integration into Home Assistant</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../External-LED/">External LED</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../data-logging/">Data Logging</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../rolling-installation/">Living on the Edge</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../Watermeter-specific-analog---digital-transition/">Analog/Digital Transition on Water Meters</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../collect-new-images/">Collect images to improve the models</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../Learn-models-with-your-own-images/">Learn a model with your own images</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../Correction%20Algorithm/">Correction Algorithm</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../Neural-Network-Types/">Neural Network Types</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../Additional-Information/">Additional Information</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../New-Releases-Notification/">Notification about new Releases</a>
</li>
</ul>
<p class="caption"><span class="caption-text">Troubleshooting</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../Error-Codes/">Error Codes</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../Error-Debugging/">Error Debugging</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../Frequent-Reboots/">Frequent Reboots</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../Demo-Mode/">Demo Mode</a>
</li>
</ul>
<p class="caption"><span class="caption-text">API's</span></p>
<ul class="current">
<li class="toctree-l1 current"><a class="reference internal current" href="./">REST API</a>
<ul class="current">
<li class="toctree-l2"><a class="reference internal" href="#control">Control</a>
<ul>
<li class="toctree-l3"><a class="reference internal" href="#flow_start">flow_start</a>
</li>
<li class="toctree-l3"><a class="reference internal" href="#set-pre-value">Set Pre Value</a>
</li>
<li class="toctree-l3"><a class="reference internal" href="#gpio">GPIO</a>
</li>
<li class="toctree-l3"><a class="reference internal" href="#ota">ota</a>
</li>
<li class="toctree-l3"><a class="reference internal" href="#ota_pagehtml">ota_page.html</a>
</li>
<li class="toctree-l3"><a class="reference internal" href="#reboot">reboot</a>
</li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="#results">Results</a>
<ul>
<li class="toctree-l3"><a class="reference internal" href="#json">json</a>
</li>
<li class="toctree-l3"><a class="reference internal" href="#value">value</a>
</li>
<li class="toctree-l3"><a class="reference internal" href="#img_tmprawjpg">img_tmp/raw.jpg</a>
</li>
<li class="toctree-l3"><a class="reference internal" href="#img_tmpalgjpg">img_tmp/alg.jpg</a>
</li>
<li class="toctree-l3"><a class="reference internal" href="#img_tmpalg_roijpg">img_tmp/alg_roi.jpg</a>
</li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="#status">Status</a>
<ul>
<li class="toctree-l3"><a class="reference internal" href="#statusflow">statusflow</a>
</li>
<li class="toctree-l3"><a class="reference internal" href="#rssi">rssi</a>
</li>
<li class="toctree-l3"><a class="reference internal" href="#cpu_temperature">cpu_temperature</a>
</li>
<li class="toctree-l3"><a class="reference internal" href="#sysinfo">sysinfo</a>
</li>
<li class="toctree-l3"><a class="reference internal" href="#starttime">starttime</a>
</li>
<li class="toctree-l3"><a class="reference internal" href="#uptime">uptime</a>
</li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="#camera">Camera</a>
<ul>
<li class="toctree-l3"><a class="reference internal" href="#lighton">lighton</a>
</li>
<li class="toctree-l3"><a class="reference internal" href="#lightoff">lightoff</a>
</li>
<li class="toctree-l3"><a class="reference internal" href="#capture">capture</a>
</li>
<li class="toctree-l3"><a class="reference internal" href="#capture_with_flashlight">capture_with_flashlight</a>
</li>
<li class="toctree-l3"><a class="reference internal" href="#save">save</a>
</li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="#logs">Logs</a>
<ul>
<li class="toctree-l3"><a class="reference internal" href="#log">log</a>
</li>
<li class="toctree-l3"><a class="reference internal" href="#logfileact">logfileact</a>
</li>
<li class="toctree-l3"><a class="reference internal" href="#loghtml">log.html</a>
</li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="#diagnostics">Diagnostics</a>
<ul>
<li class="toctree-l3"><a class="reference internal" href="#heap">heap</a>
</li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../MQTT-API/">MQTT API</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../Influx-DB/">Influx DB</a>
</li>
</ul>
<p class="caption"><span class="caption-text">Development</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../Build-Instructions/">Build the Project</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../Upload-files-by-script/">Scripted File Upload</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../Testing/">Testing</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../Release-creation/">Preparing for Release</a>
</li>
</ul>
<p class="caption"><span class="caption-text">Old Pages (no longer maintained)</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../outdated--Integrated-Functions/">Integrated Functions</a>
</li>
</ul>
<p class="caption"><span class="caption-text">Assorted Pages</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../StatusLED_BlinkCodes/">StatusLED BlinkCodes</a>
</li>
</ul>
</div>
</div>
</nav>
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
<nav class="wy-nav-top" role="navigation" aria-label="Mobile navigation menu">
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="..">AI on the Edge Device</a>
</nav>
<div class="wy-nav-content">
<div class="rst-content"><div role="navigation" aria-label="breadcrumbs navigation">
<ul class="wy-breadcrumbs">
<li><a href=".." class="icon icon-home" alt="Docs"></a> &raquo;</li>
<li>API's &raquo;</li>
<li>REST API</li>
<li class="wy-breadcrumbs-aside">
<a href="https://github.com/jomjol/AI-on-the-edge-device-docs/edit/main/docs/REST-API.md" class="icon icon-github"> Edit on GitHub</a>
</li>
</ul>
<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div class="section" itemprop="articleBody">
<h1 id="rest-api">REST API</h1>
<p>Various information is directly accessible over specific REST calls.</p>
<p>To use it, just append them to the IP, separated with a <code>/</code>, e.g. <code>http://192.168.1.1/json</code></p>
<p>Note: For more detailed information to the REST handler, have a look to the code in the repository: <a href="https://github.com/jomjol/AI-on-the-edge-device/search?q=camuri.uri">registered handlers</a></p>
<h2 id="control">Control</h2>
<ul>
<li>
<h3 id="flow_start">flow_start</h3>
<p>Trigger a flow start (if not running)</p>
</li>
<li>
<h3 id="set-pre-value">Set Pre Value</h3>
<p>Set the Previous Value</p>
</li>
</ul>
<p><code>/setPreValue?value=1234&amp;numbers=main</code> where <code>1234</code> is the new value and <code>main</code> the name of the number to be adjusted.</p>
<ul>
<li>
<h3 id="gpio">GPIO</h3>
</li>
<li>
<p>Control a GPIO output</p>
<ul>
<li>The <code>GPIO</code> entrypoint also support parameters:</li>
<li><code>/GPIO?GPIO={PinNumber}&amp;Status=high</code></li>
<li><code>/GPIO?GPIO={PinNumber}&amp;Status=low</code></li>
<li>Example: <code>/GPIO?GPIO=12&amp;Status=high</code></li>
</ul>
</li>
<li>
<p>Read a GPIO input </p>
<ul>
<li>The <code>GPIO</code> entrypoint also support parameters:</li>
<li><code>/GPIO?GPIO={PinNumber}</code></li>
<li>Example: <code>/GPIO?GPIO=12</code></li>
</ul>
</li>
<li>
<h3 id="ota">ota</h3>
</li>
<li>
<h3 id="ota_pagehtml">ota_page.html</h3>
<p>Opens the Over-The-Air update html page</p>
</li>
<li>
<h3 id="reboot">reboot</h3>
<p>Trigger a reboot of the device</p>
</li>
</ul>
<h2 id="results">Results</h2>
<ul>
<li>
<h3 id="json">json</h3>
Show result in JSON syntax</li>
<li>
<p>Example:
<code>{
"main":
{
"value": "521.17108",
"raw": "521.17108",
"pre": "521.17108",
"error": "no error",
"rate": "0.023780",
"timestamp": "2023-01-13T16:00:42+0100"
}
}</code></p>
</li>
<li>
<h3 id="value">value</h3>
<p>Show single result values</p>
</li>
<li>The <code>value</code> entrypoint also support parameters:</li>
<li><code>http://&lt;IP&gt;/value?all=true&amp;type=value</code></li>
<li><code>http://&lt;IP&gt;/value?all=true&amp;type=raw</code></li>
<li><code>http://&lt;IP&gt;/value?all=true&amp;type=error</code></li>
<li>
<p><code>http://&lt;IP&gt;/value?all=true&amp;type=prevalue</code></p>
</li>
<li>
<h3 id="img_tmprawjpg">img_tmp/raw.jpg</h3>
<p>Capture and show a new raw image</p>
</li>
<li>
<h3 id="img_tmpalgjpg">img_tmp/alg.jpg</h3>
<p>Show last aligned image</p>
</li>
<li>
<h3 id="img_tmpalg_roijpg">img_tmp/alg_roi.jpg</h3>
<p>Show last aligned image including ROI overlay</p>
</li>
</ul>
<h2 id="status">Status</h2>
<ul>
<li>
<h3 id="statusflow">statusflow</h3>
Show the actual step of the flow incl. timestamp</li>
<li>
<p>Example: <code>Take Image (15:56:34)</code></p>
</li>
<li>
<h3 id="rssi">rssi</h3>
<p>Show the WIFI signal strength (Unit: dBm)</p>
</li>
<li>
<p>Example: <code>-51</code></p>
</li>
<li>
<h3 id="cpu_temperature">cpu_temperature</h3>
<p>Show the CPU temperature (Unit: °C)</p>
</li>
<li>
<p>Example: <code>38</code></p>
</li>
<li>
<h3 id="sysinfo">sysinfo</h3>
<p>Show system infos in JSON syntax</p>
</li>
<li>
<p>Example: <code>[{"firmware": "","buildtime": "2023-01-25 12:41","gitbranch": "HEAD","gittag": "","gitrevision": "af13c68+","html": "Development-Branch: HEAD (Commit: af13c68+)","cputemp": "64","hostname": "WaterMeterTest","IPv4": "192.168.xxx.xxx","freeHeapMem": "2818330"}]</code></p>
</li>
<li>
<h3 id="starttime">starttime</h3>
<p>Show starttime</p>
</li>
<li>
<p>Example: <code>20230113-154634</code></p>
</li>
<li>
<h3 id="uptime">uptime</h3>
<p>Show uptime</p>
</li>
<li>Example: <code>0d 00h 15m 50s</code></li>
</ul>
<h2 id="camera">Camera</h2>
<ul>
<li>
<h3 id="lighton">lighton</h3>
<p>Switch the camera flashlight on </p>
</li>
<li>
<h3 id="lightoff">lightoff</h3>
<p>Switch the camera flashlight off</p>
</li>
<li>
<h3 id="capture">capture</h3>
<p>Capture a new image (without flashlight)</p>
</li>
<li>
<h3 id="capture_with_flashlight">capture_with_flashlight</h3>
<p>Capture a new image with flashlight</p>
</li>
<li>
<h3 id="save">save</h3>
<p>Save a new image to SD card</p>
</li>
<li>The <code>save</code> entrypoint also support parameters:</li>
<li><code>http://&lt;IP&gt;/save?filename=test.jpg&amp;delay=1</code></li>
</ul>
<h2 id="logs">Logs</h2>
<ul>
<li>
<h3 id="log">log</h3>
<p>Last part of todays log (last 80 kBytes))</p>
</li>
<li>
<h3 id="logfileact">logfileact</h3>
<p>Full log of today</p>
</li>
<li>
<h3 id="loghtml">log.html</h3>
<p>Opens the log html page</p>
</li>
</ul>
<h2 id="diagnostics">Diagnostics</h2>
<ul>
<li>
<h3 id="heap">heap</h3>
print relevant memory (heap) information</li>
<li>Example: <code>Heap info: Heap Total: 1888926 | SPI Free: 1827431 | SPI Larg Block: 1802240 | SPI Min Free: 758155 | Int Free: 61495 | Int Larg Block: 55296 | Int Min Free: 36427</code></li>
</ul>
</div>
</div><footer>
<div class="rst-footer-buttons" role="navigation" aria-label="Footer Navigation">
<a href="../Demo-Mode/" class="btn btn-neutral float-left" title="Demo Mode"><span class="icon icon-circle-arrow-left"></span> Previous</a>
<a href="../MQTT-API/" class="btn btn-neutral float-right" title="MQTT API">Next <span class="icon icon-circle-arrow-right"></span></a>
</div>
<hr/>
<div role="contentinfo">
<!-- Copyright etc -->
</div>
Built with <a href="https://www.mkdocs.org/">MkDocs</a> using a <a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.
</footer>
</div>
</div>
</section>
</div>
<div class="rst-versions" role="note" aria-label="Versions">
<span class="rst-current-version" data-toggle="rst-current-version">
<span>
<a href="https://github.com/jomjol/AI-on-the-edge-device-docs" class="fa fa-github" style="color: #fcfcfc"> GitHub</a>
</span>
<span><a href="../Demo-Mode/" style="color: #fcfcfc">&laquo; Previous</a></span>
<span><a href="../MQTT-API/" style="color: #fcfcfc">Next &raquo;</a></span>
</span>
</div>
<script>var base_url = '..';</script>
<script src="../js/theme_extra.js" defer></script>
<script src="../js/theme.js" defer></script>
<script src="../search/main.js" defer></script>
<script defer>
window.onload = function () {
SphinxRtdTheme.Navigation.enable(true);
};
</script>
</body>
</html>