Andlua+ implements WakeUpOnline remote boot

1. The final effect

Remote boot app download:

Download link: https://wwp.lanzoup.com/iDR330ml4l2b

Extract code: dxcg

Note: Please follow the steps in 2.1 to set up the computer before use"

mac address: fill in your own mac address

Host address: fill in your own public network ip, Baidu search ip

Mapped port: the mapped port configured in the second preparation

2. Preparation

2.1. Enable the wol remote wakeup function of bios

  • Common Assembled Motherboards
motherboard brandstart button
Intel motherboardF12
onda motherboardF11
Topstar MotherboardF11 or F12
Foxconn MotherboardESC or F12
Champions League Main BoardF11 or F12
Guanming motherboardF9
ASRock MotherboardF11
asus motherboardF8
Gigabyte MotherboardF12
Jiewei MotherboardESC or F8
Jetway motherboardESC
Elite MotherboardESC or F11
Soyo MotherboardE5C or F12
MAXSUN MotherboardESC
For example, the main boardESC
Colorful MotherboardESC or F11
Dual Sensitive MotherboardESC
Spartan Card MotherboardESC
msi motherboardF11
ASL MotherboardF10
Yeston Main BoardF8
Playback motherboardF9
Zhiming MotherboardF12
Zhiying MotherboardESC

Common Notebook Brands

notebook brandstart button
eMachines NotebookF12
Gateway NotebookF12
IBM notebookF12
toshiba notebookF12
Founder notebookF12
haier notebookF12
Acer notebookF12
asus notebookESC
patient notebookF9
gigabyte notebookF12
cutle notebookF12
Lenovo ThinkpadF12
lenovo notebookF12
benq notebookF9
apple notebookLong press the "option" key
Tsinghua Tongfang NotebookF12
samsung notebookF12
shenzhou notebookF12
Stonetone NotebookF12
suni notebookESC
msi notebookF11
  • desktop brand
desktop brandstart button
Founder desktopF12
haier desktopF12
Acer DesktopF12
asus desktopF8
Huisha desktopF12
Cel desktopESC
lenovo desktopF12
benq desktopF8
Tsinghua Tongfang DesktopF12
Shenzhou desktopF12

Note: For other brands, please Baidu or try the above buttons

After entering the BIOS, check whether there are options related to Wake On LAN, remote wake-up, WOL, etc., find and enable them.

If you still don’t know how to set it up, Baidu search for “mainboard model + remote wake-up”

  1. set up router

The TP Link router settings are as follows, and other router settings are similar, please Baidu by yourself.

  • Set IP and MAC Binding

  • Set up port mapping

Note that the intranet IP is consistent with the IP of the computer, which is the IP address when the MAC was bound just now, the port can be selected arbitrarily, and the protocol type is ALL or UDP.

  • set up computer

Click "This PC->Device Manager->Network Adapter" to enable Wake Magic Packet.

2.2. Download Andlua+ software

Software download link, follow [product manager is not manager] gzh, reply [andlua+] to download.

3. Realize the code

3.1. Open the software and create a new project. The creation steps are as follows:

  1. Click on the "+" sign

  1. Select a template, here we choose a blank template.

  1. Fill in the project name and package name. Fill in the project name as you like, and the package name is similar to com.xx.xx, just fill in whatever you want.

  1. The generated template code is as follows:

3.2. Write code:

  • The main.lua code is as follows:
require "import"
import "android.app.*"
import "android.os.*"
import "android.widget.*"
import "android.view.*"
import "layout"
import "socket"

activity.setTheme(R.Theme_Blue)
activity.setTitle("remote boot")
activity.setContentView(loadlayout(layout))

-- Convert the hexadecimal represented by a set of two strings to a hexadecimal string
-- 'ff'(66 66) -> 0xff -> '.'(255)
function to(str)
  ret = ''
  for i = 1, string.len(str), 2 do
    byte = ('0x' .. string.sub(str, 0 + i, 1 + i))
    a = tonumber(byte)
    ret = ret .. string.char(a)
  end
  return ret
end

function wakeUp(mac,bip,port)
  -- to target host MAC address
  -- router broadcast address
  -- mapped port
  mac=string.gsub(mac,":","")
  head = 'FFFFFFFFFFFF' -- header
  head = to(head)
  mac = to(mac)
  for i = 1, 16 do
    head = head .. mac
  end
  u = socket.udp()
  u:sendto(head,bip,port) 
  u:close()
  toast("Magic packet sent successfully")
end

-- Determine whether it is empty
function isEmpty(s)
  local flag=false
  if s==nil or s=="" then
    flag=true
  end
  return flag
end

-- customize toast
function toast(msg,activity,duration)
  local activity=activity or this
  local msg=msg or ""
  local duration=duration or Toast.LENGTH_SHORT
  Toast.makeText(activity, msg,duration).show()
end


btn.onClick=function()
  mac=tostring(macAddr.getText())
  host1=tostring(host.getText())
  port1=tostring(port.getText())
  if isEmpty(mac) or isEmpty(host1) or isEmpty(port1) then
    toast("mac The address, host address, and port cannot be empty")
    return
  end
  wakeUp(mac,host1,port1)
end
  • The layout.aly code is as follows:
{
  LinearLayout;
  orientation="vertical";
  layout_height="wrap_content";
  layout_width="match_parent";
  backgroundColor="0xffc4d7d6";
  {
    LinearLayout;
    layout_marginTop="20dp";
    layout_width="match_parent";
    {
      TextView;
      textSize="16sp";
      layout_marginLeft="10dp";
      layout_width="wrap_content";
      layout_height="wrap_content";
      textColor="0xff000000";
      text="mac address:";
    };
    {
      EditText;
      text="04:7C:16:01:21:85";
      layout_width="match_parent";
      id="macAddr";
      layout_marginRight="10dp";
    };
  };
  {
    LinearLayout;
    layout_width="match_parent";
    layout_height="wrap_content";
    {
      TextView;
      textSize="16sp";
      textColor="0xff000000";
      layout_marginLeft="10dp";
      text="Host address:";
    };
    {
      EditText;
      text="123.145.8.199";
      layout_width="match_parent";
      id="host";
      layout_marginRight="10dp";
    };
  };
  {
    LinearLayout;
    layout_width="match_parent";
    {
      TextView;
      textSize="16sp";
      textColor="0xff000000";
      layout_marginLeft="10dp";
      text="Mapped port:";
    };
    {
      EditText;
      layout_marginRight="10dp";
      layout_width="match_parent";
      id="port";
      text="9";
    };
  };
  {
    Button;
    layout_marginLeft="15dp";
    id="btn";
    text="One key boot";
    layout_marginTop="20dp";
    backgroundColor="0xff10aec2";
    textColor="0xffffffff";
    layout_height="wrap_content";
    layout_width="match_parent";
    layout_marginRight="15dp";
  };
};
  • init.lua uses template code, no changes.
  • After the modification is complete, click the triangle symbol to preview

3.2. Package app:

  • Click Properties to set project properties.

Uncheck the debug mode, and we only need to have full network access permissions for the permissions required by the app. After the settings are complete, click the tick in the upper right corner to save.

  • Click Package, after the package is complete, it will prompt to install, just click Install.

3. Summary

The andlua+ software provides a wealth of functions, allowing us to program and quickly generate our own applications on the mobile phone. More complex applications need to be explored by ourselves.

This article was released simultaneously by [product manager is not a manager] gzh, welcome to pay attention

Tags: lua

Posted by white99 on Sun, 05 Feb 2023 15:27:45 +0530