README
IoT Platform
Lynxari MySQL Application
Install
Lynxari Server App for inserting sensor data into MySQL DB
<script type="module">
import agilatechLynxariMysqlApplication from 'https://cdn.skypack.dev/@agilatech/lynxari-mysql-application';
</script>
IoT Platform
gt; npm install @agilatech/lynxari-mysql-application
Install in the same directory in which lynxari is installed. Create a config.json file to suit.
The purpose of this application is to store device data outputs to MySQL databases. It queries the system for device data properties and streams, and responds whenever data appears. Using the configuration to guide its behavior, it writes the results to a database table.
This application runs on the Agilatech® Lynxari IoT platform. As such, it is not applicable for other environments.
To use it with Lynxari, simply insert its object definition as an element in the apps array in the applist.json file. On startup, the Lynxari server reads applist.json and starts all applications found there.
A config.json configuration file must be present in the module's main directory. For this module, that will be within the Lynxari home directory in node_modules/@agilatech/lynxari-mysql-application/config.json
The config.json file defines two arrays, the devices and the connections. The devices array defines the devices and their values to be saved. Each device definition is an object with the following elements:
There is no limit to the number of device objects which may appear in the devices array.
The connections array defines the databases on which the device tables are stored. There may be any number of connections, but all connections are mirrors of one another -- in other words, there is currently no way to store only certain device values on certain databases for certain connections. Each connection may contain the following parameters:
The config.json file must be valid JSON.
A sample config file:
{
"devices":[
{
"name":"MOCK",
"database":"lynxari",
"table":"mock",
"insertDelay":0,
"uniqueId":{"serial": 24562571},
"values":["value"],
"columns":["value"]
},
{
"name":"WIND",
"database":"wxstation",
"table":"wind",
"insertDelay":1000,
"storeType":"update",
"values":["speed_mps", "direction_deg"],
"columns":["speed", "direction"]
}
],
"connections":[
{
"user":"agt",
"password":"aC7ch6ppig6v4cqi49mx",
"socketPath":"/opt/local/var/run/mariadb/mysqld.sock"
},
{
"host":"mysql.example.com",
"user":"billybob",
"password":"7fjH4Uh6F83JUtE2xGWq"
}
]
}
Copyright © 2018-2020 Agilatech®. All Rights Reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.