"STM32. Net MF Development Board Learning-17" WiFi Remote control Smart Car

Source: Internet
Author: User
Tags socket

Just before a PDA with wifi features, so instead of using a PC to control the Smart car via ZigBee, it's more convenient to control it with a PDA, but since the. NET MF Development Board does not directly support WiFi, we have to control it indirectly, that is, PDA control pc, PC through ZigBee control intelligent car.

For our developers, WiFi is the same as the normal cable interface, is the socket programming. We only need to build a simple TCP client on the PDA, the PC to build a TCP server side, the PDA to send the relevant instructions, the PC received through the ZigBee forward to the smart car.

PDA ===> Wifi (TCP/IP) ===> PC ===> Zigbee (serial 232/ttl) ===> intelligent car

PC through ZigBee control intelligent car, in my last blog "ZigBee Remote control intelligent car" has been introduced, so here is skipped.

We first develop the program on the PDA (operating system Windows Mobile 5.0), the development language we choose C #, the relevant code is as follows:

Public Frmmain ()
{
InitializeComponent ();
Connect ("192.168.1.2", 7722);
}
public void Connect (string server,int port)
{
Sock = new Socket (AddressFamily.InterNetwork, SocketType.Stream, protocoltype.tcp);
if (ipendpoint!= null) sock. Connect (Getendpoint (server, port));
}
private void Btnforward_click (object sender, EventArgs e)
{
if (sock!= null) sock. Send (New byte[] {48});
}
private void Btnleft_click (object sender, EventArgs e)
{
if (sock!= null) sock. Send (New byte[] {49});
}
private void Btnright_click (object sender, EventArgs e)
{
if (sock!= null) sock. Send (New byte[] {50});
}
private void Btnback_click (object sender, EventArgs e)
{
if (sock!= null) sock. Send (New byte[] {51});
}
private void Btnstop_click (object sender, EventArgs e)
{
if (sock!= null) sock. Send (new byte[] {52});
}

The results of the compilation run are as follows:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.