validation left and coap
This commit is contained in:
parent
6391537519
commit
662744558d
@ -13,6 +13,8 @@
|
|||||||
2) validate the data
|
2) validate the data
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
const { isNumber } = require("./functions/validateData");
|
||||||
|
|
||||||
function generateRandomData() {
|
function generateRandomData() {
|
||||||
const psiData = getRandomValue(0, 500);
|
const psiData = getRandomValue(0, 500);
|
||||||
const humidityData = getRandomValue(0, 100);
|
const humidityData = getRandomValue(0, 100);
|
||||||
@ -36,7 +38,7 @@ function generateRandomData() {
|
|||||||
windspeed: windspeedData.toFixed(0) + "km/h",
|
windspeed: windspeedData.toFixed(0) + "km/h",
|
||||||
time: currentTime,
|
time: currentTime,
|
||||||
};
|
};
|
||||||
|
/*
|
||||||
console.log(json.psi);
|
console.log(json.psi);
|
||||||
console.log(json.humidity);
|
console.log(json.humidity);
|
||||||
console.log(json.o3);
|
console.log(json.o3);
|
||||||
@ -45,11 +47,17 @@ function generateRandomData() {
|
|||||||
console.log(json.temperature);
|
console.log(json.temperature);
|
||||||
console.log(json.windspeed);
|
console.log(json.windspeed);
|
||||||
console.log(json.time);
|
console.log(json.time);
|
||||||
|
*/
|
||||||
|
return json;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getRandomValue(min, max) {
|
function getRandomValue(min, max) {
|
||||||
return Math.random() * (max - min) + min;
|
return Math.random() * (max - min) + min;
|
||||||
}
|
}
|
||||||
|
|
||||||
//every 5 minutes
|
//5 minutes
|
||||||
setInterval(generateRandomData, 300000);
|
setInterval(() => {
|
||||||
|
var json = generateRandomData();
|
||||||
|
isNumber(json);
|
||||||
|
}, 300000);
|
||||||
|
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
var validator = require('validator');
|
var validator = require('validator');
|
||||||
|
|
||||||
function isNumber(data) {
|
function isNumber(data) {
|
||||||
return !is
|
console.log("isNumber");
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = { isNumber}
|
module.exports = { isNumber }
|
Loading…
x
Reference in New Issue
Block a user