简体   繁体   English

如何发送和接收数据从Android应用程序到硬件(microcotroller)?

[英]How to send and receive data from an android app to a hardware(microcotroller)?

I am developing a project which communicates over wifi. 我正在开发一个通过wifi进行通信的项目。 My project is about motor control with ARM CORTEX M0 processor. 我的项目是使用ARM CORTEX M0处理器进行电机控制。 I want to send data from my mobile(android app) to the processor to increase or decrease the speed with the +/- symbol or to blink a LED or something like that and I need to receive data(for eg I programmed the processor to send the speed from controller or the motor is on or off) from processor and that need to be displayed in android app. 我想将数据从移动设备(android app)发送到处理器,以使用+/-符号增加或降低速度,或者使LED闪烁或类似的信号,并且我需要接收数据(例如,我将处理器编程为从控制器发送速度,或者从处理器发送电机开或关),并且需要在android应用中显示。

We are using Qualcomm Longsys GT1216 module attached to the processor and that creates the wifi connection to the mobiles. 我们正在使用连接到处理器的Qualcomm Longsys GT1216模块,该模块可创建与手机的wifi连接。 I want to develop an app that connects with that wifi to send and receive data to and from the controller. 我想开发一个与该wifi连接的应用程序,以向控制器发送数据和从控制器接收数据。 Is there any source code available to develop an app such like that. 是否有任何源代码可用于开发这样的应用程序。

i can only suggest that for that purpose you can use websockets + json or yaml. 我只能建议为此目的,您可以使用websockets + json或yaml。 It is full-duplex communication channels over a single TCP connection. 它是通过单个TCP连接的全双工通信通道。 You should strongly prefer wss:// protocol over the insecure ws:// transport. 与不安全的ws://传输相比,您应该更倾向于wss://协议。 Like HTTPS, WSS (WebSockets over SSL/TLS) is encrypted. 与HTTPS一样,WSS(基于SSL / TLS的WebSockets)也被加密。 For transport i am using https://libwebsockets.org/ for linux but there are also version for android. 为了进行传输,我在Linux上使用https://libwebsockets.org/ ,但也有适用于android的版本。 I have made one little project (IP relay) based on this technology. 我基于此技术做了一个小项目(IP中继)。 Linux system on one side and cortex M0 + board with LAN and TCP/IP stack on other side. 一侧是Linux系统,另一侧是带有LAN和TCP / IP堆栈的cortex M0 +板。 You should to know that it is big job. 您应该知道这是一项艰巨的任务。 1. You can start with standard socket TCP connections. 1.您可以从标准套接字TCP连接开始。 2. Implement client and server appl. 2.实施客户端和服务器应用程序。 3. Implement json or yaml parser and then switch to websockets. 3.实现json或yaml解析器,然后切换到websockets。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM