Code Monkey home page Code Monkey logo

Comments (3)

omersiar avatar omersiar commented on August 21, 2024

Hi @prassaschr ,

ESP-RFID self sufficient project. Implementing MySQL support is easy but this will require specific solution for each MySQL setup, instead you can query ESP-RFID with a Node.js application (using WebSocket client) or any other tool for record keeping. Node.js and MySQL + WebSocket packages is just enough for the task.

Kind regards.

from esp-rfid.

prassaschr avatar prassaschr commented on August 21, 2024

This sounds interesting! Could you guide me by posting an example URL? I am not familiar with Node.js and Websocket client.
Thank you once more.
Kind Regards

from esp-rfid.

omersiar avatar omersiar commented on August 21, 2024

For example this is a simple Node.js script that is Websocket Server and a MySQL client. Websocket server listens for queries and executes a search query on MySQL server, then sends back results to Websocket client.

var mysql = require('mysql');
var connection = mysql.createConnection({
  host: 'localhost',
  user: 'admin',
  password: '1',
  database: 'tek_servis'
});

const WebSocket = require('ws');
const wss = new WebSocket.Server({
  port: 8080
});

wss.broadcast = function broadcast(data) {
  wss.clients.forEach(function each(client) {
    if (client.readyState === WebSocket.OPEN) {
      client.send(data);
    }
  });
};

function sorgula(data) {
  connection.query("select c.hesapkodu, c.cariadi, c.tipi, c.cinsi, c.marka, c.model, c.tamadi, c.sfiyat, c.afiyat, c.ptipi, c.barkod, (case when 1=1 then(SELECT sum(coalesce(d.miktar,0)*m.gc) FROM stokgcm m, stokgcd d WHERE m.gcsno=d.gcsno and m.aktif=1 and d.hesapkodu=c.hesapkodu) else 0 end) as Kalan from cariler c where c.hesapkodu like '153%' and c.bayino=1 and c.aktif=1 and (c.barkod='" + data + "') or (c.tamadi like '%" + data + "%')", function(error, results, fields) {
    if (error) throw error;
    wss.broadcast(JSON.stringify(results));
  });
}

wss.on('connection', function connection(ws) {
  ws.on('message', function incoming(message) {
    var obj = JSON.parse(message);
    if (obj.type === "sorgu") {
      sorgula(obj.data);
    }
  });
});

from esp-rfid.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.