Difference between revisions of "3 WiFI wireless programming"

From Banana Pi Wiki
Jump to: navigation, search
(WebDAV HTTP file system service)
(hostname local domain name service)
Line 65: Line 65:
  
 
::[[File:Wifi_cfg.png]]
 
::[[File:Wifi_cfg.png]]
 +
 +
As shown in figure bit3D6D, the access method and test method are as follows.:
 +
 +
::[[File:Hostname.png]]

Revision as of 02:20, 21 February 2019

Understanding wireless programming

The way using wired connection board is the characteristic of last century, so we in the later development process, is to support, and as far as possible to the wireless control the direction of, for all kinds of simple things networking equipment is not a cable interface specially reserved for you connected to the computer control, for example, a intelligent control of light.

So at this time the wireless is put to use, you can see, in the board connected to the Internet, we can need not be inserted into the computer to help the board directly online (mobile phone distribution network model in the previous section), so this is the wireless programming basis, through a simple way to make the board into your network, you can control it.

remote to connect BPI:bit

The MicroPython interface USES the Python REPL, which means that it is itself an operating system environment that can be re-used. Unlike previous Linux systems, it is characterized by its simplicity and ease of use

REPL is a commonly used interactive interface when wired, while on wireless, WebREPL is introduced, which, as the name implies, is a cloud REPL, as shown in the figure below:

Webrepl (1).png

You can see that it can directly operate the board, like the past wired connection, response speed is very fast, and wired feeling is not much different.

However, this is obviously not enough, because this editor can only be used, but it is not easy to use, so I specially adapted webrepl in mpfshell. That is to say, the mpfshell-based pycharm plug-in also supports wireless programming, so all the functions that are thought to be useful are used, as shown in the following figure.

Pycharm.png

Running the program is fine and responsive faster (after all, it has been specially fixed for this purpose), but it's important to note that the paths are not quite the same.

  • The webrepl standard path is ws://192.168.30.116:8266.
  • The path of mpfshell is ws:192.168.30.116 and 1234, the difference being that the latter allows passcode to be bypassed, thus eliminating connection authentication.

At this point, you can use it just like you used to with wired, and if anything goes wrong during this time, just restart the board, which will automatically power up the network and open the Webrepl support service

In the future, it will be powered by batteries, without computer power, so you can completely control it without wires. Please note that you need to lower the frequency to 80Mhz when necessary, or the power will be out soon.

Remote management BPI:bit

While we can use REPL to programmatically control the board, we need some additional network support services to make our board more enjoyable. I'm going to talk a little bit about them here

FTP standard file system operation service

Start with the following code:

import ftptiny
ftptiny.FtpTiny().start()
Ftp.png

WebDAV HTTP file system service

Start by using the following code

import webdav
webdav.start()
Webdav.png

It is different from FTP in that it use port 80 and use HTTP instead of FTP

Webdav index.png


hostname local domain name service

This requires specific routing service support, such as openwrt(Linux).

It allows you to access the boards using hostname.lan (or directly hostname) instead of IP.

So instead of memorizing IP addresses, you define your own board names.

The hostname is saved in the wifi_cfg.py file below.

Wifi cfg.png

As shown in figure bit3D6D, the access method and test method are as follows.:

Hostname.png