V
V
Vadimm10012018-08-26 19:55:59
Microcontrollers
Vadimm1001, 2018-08-26 19:55:59

Controlling a microcontroller over the Internet?

How to organize communication with the microcontroller via the Internet, that is, via telnet only on which android? That is, through android, I send a command to the web server, the web server, having read it, sends the command to the micro, which is connected (via w5500, for example) to the router. But after all usually the web server produces only html page. Organize I think it's in php. Am I presenting everything correctly?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
V
Vladislav Kadun, 2018-08-26
@ZXZs

The web server issues not only html pages. The HTTP protocol can even transfer files.
It is better to find an application on Android that can issue arbitrary POST requests.
If found, then deploy a program on the server that will wait for a POST request, in which there will be a line with the command name. Like this:

<?php
if ( ! isset ( $_POST['command'] ) ){
    return;
}
else
{
    if $_POST['command'] == 'имя_команды'
    {
        // здесь обрабатываем команду
    }
}
?>

Next, the server analyzes it, realizes what command it should send, and here is the most difficult thing.
There is an option for the MK to also act as a server. We put it on listening to some free port and then our PHP code, after analyzing the command, sends it a POST request so that the MK reacts and does what is required. Example:
$url = 'http://localhost:1337/';
$data = array('command' => 'имя_команды');
$options = array(
    'http' => array(
        'header'  => "Content-type: application/x-www-form-urlencoded\r\n",
        'method'  => 'POST',
        'content' => http_build_query($data)
    )
);
$context  = stream_context_create($options);
$result = file_get_contents($url, false, $context); // это необязательно. но можно с помощью этого проверить, выполнил ли МК задачу.
if ($result === FALSE) { /* обрабатываем ошибку, если будет */ }
var_dump($result);

Here I can be wildly mistaken, because I do not understand microcontrollers.
Well, in general, here's an idea for you - to organize communication through POST requests.

D
Dmitry Shitskov, 2018-08-26
@Zarom

If you have a web server, you can display a button in the browser on Android.
Or you can pass a special key parameter to the web server in a GET request. But telnet won't help here, you'll have to use curl https://w3bsit3-dns.com/forum/index.php?showtopic=728747

A
Alexander, 2018-08-27
@UPSA

Am I presenting everything correctly?

Not )
Hard case to explain who understands very little)))
Pay attention to the link www.litsovet.ru/index.php/material.read?material_i... .
w5500 is just.... a small chip in a huge system. It helps to reduce the programming costs of the entire system.

M
Maxim, 2018-09-19
@pokk-pokk

Why do you need PHP? If the task is to purely connect the computer and the controller, i.e. transfer data from the processor (or to it), then you just need to configure wiznet so that it listens to the UDP port. and responded accordingly to his requests.
https://github.com/Wiznet/ioLibrary_Driver/tree/ma...
See sendto, recvfrom and initialization commands.
PS. I did such a thing for debugging using a terminal program NetCat sent a request to turn on the logs, and winzet spat them all into the terminal.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question