+

CN104780580B - A kind of Wi-Fi mobile networking methods of energy consumption balance - Google Patents

A kind of Wi-Fi mobile networking methods of energy consumption balance Download PDF

Info

Publication number
CN104780580B
CN104780580B CN201510120173.1A CN201510120173A CN104780580B CN 104780580 B CN104780580 B CN 104780580B CN 201510120173 A CN201510120173 A CN 201510120173A CN 104780580 B CN104780580 B CN 104780580B
Authority
CN
China
Prior art keywords
mobile
file
hotspot
mobile equipment
equipment
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Expired - Fee Related
Application number
CN201510120173.1A
Other languages
Chinese (zh)
Other versions
CN104780580A (en
Inventor
朱嘉钢
冯宗越
成燕华
邹哲
张福键
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
JIANGSU HILLSUN INFORMATION INDUSTRY Co Ltd
Original Assignee
JIANGSU HILLSUN INFORMATION INDUSTRY Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by JIANGSU HILLSUN INFORMATION INDUSTRY Co Ltd filed Critical JIANGSU HILLSUN INFORMATION INDUSTRY Co Ltd
Priority to CN201510120173.1A priority Critical patent/CN104780580B/en
Publication of CN104780580A publication Critical patent/CN104780580A/en
Application granted granted Critical
Publication of CN104780580B publication Critical patent/CN104780580B/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04WWIRELESS COMMUNICATION NETWORKS
    • H04W36/00Hand-off or reselection arrangements
    • H04W36/16Performing reselection for specific purposes
    • H04W36/22Performing reselection for specific purposes for handling the traffic
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04WWIRELESS COMMUNICATION NETWORKS
    • H04W52/00Power management, e.g. Transmission Power Control [TPC] or power classes
    • H04W52/04Transmission power control [TPC]
    • H04W52/30Transmission power control [TPC] using constraints in the total amount of available transmission power
    • H04W52/34TPC management, i.e. sharing limited amount of power among users or channels or data types, e.g. cell loading
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D30/00Reducing energy consumption in communication networks
    • Y02D30/70Reducing energy consumption in communication networks in wireless communication networks

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Mobile Radio Communication Systems (AREA)

Abstract

本发明涉及Wi‑Fi应用技术领域,具体为一种能耗均衡的Wi‑Fi移动组网方法,移动设备通过Wi‑Fi连接开启AP热点模式的移动设备形成移动组网后,定时收集每个移动设备进行电池剩余电量百分比、单位时间耗电量,依据对各个移动设备能耗率的计算结果,选出最优开启AP热点模式的移动设备,并自动选择该移动设备开启AP热点模式,实现当作为AP热点的移动设备电量低于均衡电量时能够将AP功能自动切换至局域网中的其它节点,保证已建立的网络能耗均衡,同时文件传输的数据不丢失,切换过程对用户全透明。

The present invention relates to the field of Wi-Fi application technology, and specifically relates to a Wi-Fi mobile networking method with balanced energy consumption. After a mobile device connects to a mobile device with an AP hotspot mode enabled through Wi-Fi to form a mobile network, it regularly collects each According to the calculation results of the energy consumption rate of each mobile device, select the mobile device with the best AP hotspot mode enabled, and automatically select the mobile device to enable the AP hotspot mode to achieve When the power of the mobile device as the AP hotspot is lower than the balanced power, the AP function can be automatically switched to other nodes in the LAN to ensure the energy balance of the established network, and at the same time, the data of the file transmission will not be lost, and the switching process is completely transparent to the user.

Description

一种能耗均衡的Wi-Fi移动组网方法A Wi-Fi mobile networking method with balanced energy consumption

技术领域technical field

本发明涉及Wi-Fi应用技术领域,具体为一种能耗均衡的Wi-Fi移动组网方法。The invention relates to the field of Wi-Fi application technology, in particular to a Wi-Fi mobile networking method with balanced energy consumption.

背景技术Background technique

现在智能手机以其越来越强大的运算能力而越来越普及,使之完全也可以作为一个智能的移动互联网终端,其拓展的功能也早已经超越了人们的想象。Nowadays, smart phones are becoming more and more popular due to their increasingly powerful computing power, so that they can also be used as an intelligent mobile Internet terminal, and their expanded functions have already surpassed people's imagination.

Wi-Fi技术,是可以将个人电脑,手机,iPAD等终端以无线方式互联的技术。随着Wi-Fi技术的成熟和广泛应用,目前几乎所有的移动设备都具备了Wi-Fi连接的功能,同时几乎所有的移动设备都支持基于Wi-Fi技术的开启AP热点功能。通过上述Wi-Fi技术便可以将大量的移动设备组成的一个小型无线局域网进行通信。Wi-Fi technology is a technology that can connect terminals such as personal computers, mobile phones, and iPADs wirelessly. With the maturity and wide application of Wi-Fi technology, almost all mobile devices now have the function of Wi-Fi connection, and almost all mobile devices support the function of opening AP hotspots based on Wi-Fi technology. Through the aforementioned Wi-Fi technology, a small wireless local area network composed of a large number of mobile devices can be used for communication.

移动设备有携带方便,使用灵活等特点。但移动设备通常难以得到固定电源的充电,而移动电源又电量有限。当一个作为AP热点的移动设备发生电量不足时,现有建立起来的小型移动局域网络诸节点间的通信则会断开,需要重新进行设置。在此过程中,所传文件的数据或者丢失或者需要在通信重启后重头传输,给用户带来诸多不便,尤其在文件较大时更是如此。Mobile devices are easy to carry and flexible to use. However, it is usually difficult for mobile devices to be charged by a fixed power source, and the mobile power source has limited power. When a mobile device serving as an AP hotspot is short of power, the communication between the nodes of the existing small mobile local area network will be disconnected, and it needs to be reset. During this process, the data of the transmitted file is either lost or needs to be retransmitted after the communication is restarted, which brings a lot of inconvenience to the user, especially when the file is large.

发明内容Contents of the invention

为了解决上述问题,本发明提供了一种能耗均衡的Wi-Fi移动组网方法,其能够实现当作为AP热点的移动设备电量低于均衡电量时能够将AP功能自动切换至局域网中的其它节点,保证已建立的网络能耗均衡,切换过程中文件传输的数据不丢失,切换过程对用户全透明。In order to solve the above problems, the present invention provides a Wi-Fi mobile networking method with balanced energy consumption, which can automatically switch the AP function to other devices in the local area network when the power of the mobile device as the AP hotspot is lower than the balanced power. Node, to ensure that the energy consumption of the established network is balanced, the data transmitted by the file will not be lost during the switching process, and the switching process is completely transparent to the user.

其技术方案是这样的:一种能耗均衡的Wi-Fi移动组网方法,其特征在于,其包括以下步骤:Its technical solution is as follows: a Wi-Fi mobile networking method with balanced energy consumption, characterized in that it includes the following steps:

(1)选择至少两个具有Wi-Fi连接、开启AP热点和数据处理功能的移动设备;(1) Select at least two mobile devices with Wi-Fi connection, AP hotspot and data processing functions;

(2)使其中一个移动设备开启AP热点模式,其余移动设备通过Wi-Fi连接到所述开启AP热点模式的移动设备,形成Wi-Fi移动局域网;(2) Make one of the mobile devices turn on the AP hotspot mode, and the other mobile devices connect to the mobile device with the AP hotspot mode turned on through Wi-Fi to form a Wi-Fi mobile local area network;

(3)移动局域网内进行文件传输时,接收文件的移动设备为每个正在接收的文件配备一个ID号并建立一个相应的日志文件,在每接收到某个接收文件的一个数据块并写入文件后,更新相应的日志文件,记录下已经接收到的字节数信息;(3) When transferring files in the mobile local area network, the mobile device receiving the file is equipped with an ID number for each file being received and creates a corresponding log file, and writes it to the After the file, update the corresponding log file and record the number of bytes received;

(4)开启AP热点模式的移动设备定时收集每个移动设备的电池剩余电量百分比、单位时间耗电量,并依据对各个移动设备的单位耗电率,选出最适合开启AP热点模式的移动设备;(4) Mobile devices with AP hotspot mode enabled regularly collect the percentage of remaining battery power and power consumption per unit time of each mobile device, and select the most suitable mobile device for enabling AP hotspot mode based on the unit power consumption rate of each mobile device. equipment;

(5)若最适合开启AP热点模式的移动设备为已经开启AP热点模式的移动设备,则已有的网络继续其连接方式和状态;若最适合开启AP热点模式的移动设备不是已经开启AP热点模式的移动设备,则已经开启AP热点模式的移动设备向最适合开启AP热点模式的移动设备发出AP热点切换信号,并关闭自身的AP热点模式、开启Wi-Fi连接,最优开启AP热点模式的移动设备关闭Wi-Fi连接、开启AP热点模式,其余移动设备通过Wi-Fi连接新开启AP热点模式的移动设备,重新建立Wi-Fi网络;Wi-Fi网络重建后,各设备依据各自已建立的日志文件,从数据传输中断处继续数据传输,维持网络正常运行。(5) If the mobile device that is most suitable for enabling the AP hotspot mode is a mobile device that has already enabled the AP hotspot mode, the existing network will continue its connection mode and status; if the mobile device that is most suitable for enabling the AP hotspot mode is not already enabled for the AP hotspot mode, the mobile device that has turned on the AP hotspot mode sends an AP hotspot switching signal to the mobile device that is most suitable for turning on the AP hotspot mode, and closes its own AP hotspot mode, opens the Wi-Fi connection, and optimally turns on the AP hotspot mode Close the Wi-Fi connection of the mobile device and enable the AP hotspot mode, and the other mobile devices connect to the mobile device with the newly enabled AP hotspot mode through Wi-Fi, and re-establish the Wi-Fi network; after the Wi-Fi network is rebuilt, each device Created log files, continue data transmission from the point where data transmission is interrupted, and maintain the normal operation of the network.

其进一步特征在于,移动组网内移动设备之间的Wi-Fi连接使用固定的SSID和密码,并设置对其他设备不可见。It is further characterized in that the Wi-Fi connection between mobile devices in the mobile network uses a fixed SSID and password, and is set to be invisible to other devices.

使用本发明的方案后,移动设备通过Wi-Fi连接开启AP热点模式的移动设备形成移动组网后,定时收集每个移动设备进行电池剩余电量百分比、单位时间耗电量,依据对各个移动设备能耗率的计算结果,选出最优开启AP热点模式的移动设备,并自动选择该移动设备开启AP热点模式,实现当作为AP热点的移动设备电量低于均衡电量时能够将AP功能自动切换至局域网中的其它节点,保证已建立的网络能耗均衡,同时文件传输的数据不丢失,切换过程对用户全透明。After using the solution of the present invention, after the mobile device is connected to the mobile device with the AP hotspot mode enabled through Wi-Fi to form a mobile network, the remaining battery power percentage and the power consumption per unit time of each mobile device are collected regularly, based on the analysis of each mobile device Based on the calculation results of the energy consumption rate, the mobile device with the best AP hotspot mode enabled is selected, and the mobile device is automatically selected to enable the AP hotspot mode, so that the AP function can be automatically switched when the power of the mobile device serving as the AP hotspot is lower than the balance power. To other nodes in the local area network, to ensure the energy balance of the established network, and at the same time, the data of the file transfer will not be lost, and the switching process is completely transparent to the user.

附图说明Description of drawings

图1为AP热点切换流程图 ;Figure 1 is a flow chart of AP hotspot switching;

图2 为文件传送流程图。Figure 2 is a flow chart of file transfer.

具体实施方式Detailed ways

以两个移动设备为例。移动设备可以是智能手机、IPAD、笔记本电脑等,一种能耗均衡的Wi-Fi移动组网方法,能量均衡计算及AP点切换工作由两款软件经启动后自动完成:其一是能耗均衡管理软件app1,其二是文件传输软件app2。所述能耗均衡的Wi-Fi移动组网方法包括以下步骤,见图1,图2所示:Take two mobile devices as an example. Mobile devices can be smartphones, IPADs, laptops, etc. It is a Wi-Fi mobile networking method with energy balance. Energy balance calculation and AP point switching are automatically completed by two softwares after startup: one is energy consumption The balance management software app1, and the second is the file transfer software app2. The Wi-Fi mobile networking method with balanced energy consumption includes the following steps, as shown in Fig. 1 and Fig. 2:

(1)人工选择两个具有Wi-Fi连接、开启AP热点和数据处理功能的移动设备,开启这两台设备,同时开启它们的能耗均衡管理软件app1,该软件运行形成进程T1;随机将其中一个移动设备开启AP热点模式,另一个移动设备通过Wi-Fi连接开启AP热点模式的移动设备形成Wi-Fi移动局域网;(1) Manually select two mobile devices with Wi-Fi connection, AP hotspot and data processing functions, turn on these two devices, and start their energy balance management software app1 at the same time, the software runs to form a process T1; One of the mobile devices turns on the AP hotspot mode, and the other mobile device connects to the mobile device that turns on the AP hotspot mode through Wi-Fi to form a Wi-Fi mobile local area network;

下面的步骤(2)由对应的程序运行中自动完成:The following step (2) is automatically completed by the corresponding program running:

(2)进程T1执行以下流程:(2) Process T1 executes the following flow:

(2.1)设置接收通信端口i,发送通信端口j;检查所在设备是否是开启AP热点的设备,是则将标志IsAP置1否则IsAP置0,将AP热点切换标志Switch置0;(2.1) Set the receiving communication port i and the sending communication port j; check whether the device you are on is a device with AP hotspot enabled, if so, set the flag IsAP to 1, otherwise set IsAP to 0, and set the AP hotspot switching flag Switch to 0;

(2.2)监听所述端口,并定时采集所在移动设备的电池剩余电量百分比、单位时间耗电量数据,计算单位耗电率;(2.2) Monitor the port, and regularly collect the remaining battery power percentage and power consumption data per unit time of the mobile device, and calculate the unit power consumption rate;

(2.3)若标志IsAP为1则执行以下流程:(2.3) If the flag IsAP is 1, execute the following process:

(2.3.1)若名为pcr的文件尚未建立则建立该文件,记录来自端口i的“设备ID-单位耗电率”信息,更新pcr文件,同时也用所在设备的“设备ID-单位耗电率”信息更新pcr文件;(2.3.1) If the file named pcr has not been created, create the file, record the information of "device ID-unit power consumption rate" from port i, update the pcr file, and use the "device ID-unit power consumption rate" information of the device at the same time "Electric rate" information to update the pcr file;

(2.3.2)用pcr文件数据,根据能耗均衡准则选出最适合开启AP热点模式的移动设备,本实施例中暂定为电池剩余电量与单位时间耗电量比值最高的移动设备;(2.3.2) Use the pcr file data to select the mobile device that is most suitable for enabling the AP hotspot mode according to the energy balance criterion. In this embodiment, it is tentatively determined to be the mobile device with the highest ratio of remaining battery power to power consumption per unit time;

(2.3.3)若最适合开启AP热点模式的移动设备就是当前开启AP热点设备,则转步骤(2.3.1);(2.3.3) If the mobile device most suitable for enabling the AP hotspot mode is the currently enabled AP hotspot device, then go to step (2.3.1);

(2.3.4)否则标志Switch置1,通过端口j向所有连接到所在设备的其余设备发送AP切换命令;(2.3.4) Otherwise, the flag Switch is set to 1, and the AP switching command is sent to all other devices connected to the device through port j;

(2.3.5)在接收到来自通信端口i的所述设备的确认回复后,关闭所在设备的AP热点,开启Wi-Fi,并连接到新的开启AP热点的设备;(2.3.5) After receiving the confirmation reply from the device on the communication port i, turn off the AP hotspot of the device, turn on Wi-Fi, and connect to the new device that turns on the AP hotspot;

(2.3.6)标志IsAP置0,标志Switch置0,转到步骤(2.2);(2.3.6) The flag IsAP is set to 0, the flag Switch is set to 0, go to step (2.2);

(2.4)若标志IsAP为0则执行以下流程:(2.4) If the flag IsAP is 0, execute the following process:

(2.4.1)通过通信端口j 向AP发送所在设备的“设备ID-单位耗电率”信息;(2.4.1) Send the "device ID-unit power consumption rate" information of the device to the AP through the communication port j;

(2.4.2)监听端口i是否收到切换AP的命令,若未有切换AP的命令,转步骤(2.2);(2.4.2) Whether the monitoring port i receives the command to switch AP, if there is no command to switch AP, go to step (2.2);

(2.4.3)标志Switch置1,通过端口j向当前的AP热点设备发送“设备ID-确认”回复;(2.4.3) Set the flag Switch to 1, and send a "device ID-confirmation" reply to the current AP hotspot device through port j;

(2.4.4)若所在设备为将须开启AP热点的设备,则关闭Wi-Fi连接,开启AP热点,标志Switch置0,标志IsAP置1,转步骤(2.2);(2.4.4) If the device you are on is a device that will need to turn on the AP hotspot, turn off the Wi-Fi connection, turn on the AP hotspot, set the flag Switch to 0, set the flag IsAP to 1, and go to step (2.2);

(2.4.5)否则连接新开启AP热点的设备,标志Switch置0,转步骤(2.2);(2.4.5) Otherwise, connect to the newly opened AP hotspot device, set the flag Switch to 0, and go to step (2.2);

(3)如需在AP热点设备和其它设备间传送文件,则在需传送文件的设备上人工启动文件传输软件app2,告知app2所在设备是文件的发送还是接收方,app2运行后形成进程T2;(3) If you need to transfer files between the AP hotspot device and other devices, manually start the file transfer software app2 on the device that needs to transfer files, and tell app2 whether the device where the file is located is the sender or receiver of the file, and app2 will form a process T2 after running;

下面的步骤(4)由对应的程序运行中自动完成:The following step (4) is automatically completed by the corresponding program running:

(4)进程T2执行以下流程:(4) Process T2 executes the following flow:

(4.1)判断所在设备是文件的发送方还是接收方;(4.1) Determine whether the device is the sender or receiver of the file;

(4.2)若是发送方则执行以下流程:(4.2) If it is the sender, perform the following process:

(4.2.1)若标志Switch为1则转步骤(4.2.1)等待;(4.2.1) If the flag Switch is 1, go to step (4.2.1) and wait;

(4.2.2)接收文件接收方发送来的源文件名和已接收字节数,若源文件未被打开则打开源文件;(4.2.2) Receive the source file name and the number of received bytes sent by the receiver of the file, and open the source file if the source file has not been opened;

(4.2.3)根据已接收字节数定位指定文件数据块;(4.2.3) Locate the specified file data block according to the number of received bytes;

(4.2.4)从文件读入并向网络端口发送一个数据块;(4.2.4) read in from the file and send a block of data to the network port;

(4.2.5)若源文件已发送完毕则关闭源文件,转步骤(4.4)否则转步骤(4.2.1);(4.2.5) If the source file has been sent, close the source file, go to step (4.4), otherwise go to step (4.2.1);

(4.3)若是接收方则执行以下流程:(4.3) If it is the recipient, the following process is performed:

(4.3.1)若标志Switch为1则转步骤(4.3.1)等待;(4.3.1) If the flag Switch is 1, go to step (4.3.1) and wait;

(4.3.2)若未生成日志文件则生成日志文件,从日志文件中读出要传输的文件的ID号和已接收的字节数;由文件的ID号确定要传送的文件名;(4.3.2) If no log file is generated, generate a log file, read the ID number of the file to be transmitted and the number of bytes received from the log file; determine the file name to be transmitted by the ID number of the file;

(4.3.3)向文件发送方发送要传送的文件名、已接收的字节数;(4.3.3) Send the file name to be transmitted and the number of bytes received to the file sender;

(4.3.4)接收一个数据块,若目标文件未建立则建立并打开目标文件,将已接收的数据块写入目标文件,已接收字节数增量,更新日志文件中已接收字节数;(4.3.4) Receive a data block, if the target file is not created, create and open the target file, write the received data block into the target file, increment the number of received bytes, and update the number of received bytes in the log file ;

(4.3.5)若文件接收未结束则转步骤(4.3.1)否则关闭目标文件,转步骤(4.4);(4.3.5) If the file reception is not over, go to step (4.3.1), otherwise close the target file, go to step (4.4);

(4.4)进程T2结束。(4.4) Process T2 ends.

本发明中整个移动组网内的所有移动设备都具有数据处理的能力,但是在网络的运行过程中,只能有一个移动设备可以从其他的设备中获取所需参数并且进行数据处理的能力。在整个网络工作过程中,作为AP热点的设备具有参数数据处理能力并且对网络的控制权; 网络中AP热点的切换信号由当前的作为AP热点的设备发出,切换后激活新的开启AP热点的移动设备获取参数和数据处理能力。In the present invention, all mobile devices in the entire mobile network have data processing capabilities, but only one mobile device can obtain required parameters from other devices and perform data processing capabilities during network operation. During the entire network working process, the device as the AP hotspot has the parameter data processing capability and the control right to the network; the switching signal of the AP hotspot in the network is sent by the current device as the AP hotspot, and the new AP hotspot is activated after switching. The mobile device acquires parameters and data processing capabilities.

下面再具体给出在两部安卓手机上的实现实例:The following is a specific implementation example on two Android phones:

一种能耗均衡的Wi-Fi移动组网方法,能量均衡计算及AP点切换工作由两款软件经启动后自动完成:其一是能耗均衡管理软件app1,其二是文件传输软件app2。所述能耗均衡的Wi-Fi移动组网方法包括以下步骤:A Wi-Fi mobile networking method with balanced energy consumption. The energy balance calculation and AP point switching work are automatically completed by two softwares after startup: one is the energy consumption balance management software app1, and the other is the file transfer software app2. The Wi-Fi mobile networking method of described energy consumption balance comprises the following steps:

(1)人工选择两个具有Wi-Fi连接、开启AP热点和数据处理功能的安卓手机,开启这两台安卓手机,同时开启它们的能耗均衡管理软件app1,该软件运行形成进程T1;随机将其中一个安卓手机开启AP热点模式,另一个安卓手机开启Wi-Fi连接开启AP热点模式的安卓手机形成Wi-Fi移动局域网;(1) Manually select two Android phones with Wi-Fi connection, AP hotspot and data processing functions, turn on these two Android phones, and open their energy balance management software app1 at the same time, and the software runs to form a process T1; random Turn on AP hotspot mode on one of the Android phones, and turn on Wi-Fi on the other Android phone to connect to the Android phone with AP hotspot mode on to form a Wi-Fi mobile LAN;

(2)进程T1执行以下流程:(2) Process T1 executes the following flow:

(2.1)使用Socket类设置参数获取和发送的通信端口为6565,使用WifiManager类的isWifiEnabled()方法检查所在安卓手机是否是开启AP热点手机,是则将变量IsAP置1,将AP热点切换变量Switch置0;(2.1) Use the Socket class to set the communication port for parameter acquisition and sending to 6565, and use the isWifiEnabled() method of the WifiManager class to check whether the Android phone is an AP hotspot phone, and if so, set the variable IsAP to 1, and switch the AP hotspot to the variable Switch set to 0;

(2.2)生成一个Socket类,用来监听6565端口,并使用Intent类的ACTION_BATTERY_CHANGED行为定时采集所在移动设备的电池剩余电量百分比、单位时间耗电量数据,计算单位耗电率;(2.2) Generate a Socket class to monitor port 6565, and use the ACTION_BATTERY_CHANGED behavior of the Intent class to periodically collect the remaining battery power percentage and power consumption data per unit time of the mobile device, and calculate the unit power consumption rate;

(2.3)判断变量IsAP的值,若变量为1则执行以下流程:(2.3) Determine the value of the variable IsAP, if the variable is 1, execute the following process:

(2.3.1)使用File类的exists()方法判断名为pcr的文件是否存在,若尚未建立则使用File类建立该文件,该文件用来记录来自端口6565的“设备ID-单位耗电率”信息,通过创建一个Thread线程,在线程内的Runnable类的run()方法内调用RandomAccessFile类的wirte()方法将获取的信息更新到pcr文件,同时也用所在安卓手机的“设备ID-单位耗电率”信息更新pcr文件;(2.3.1) Use the exists() method of the File class to determine whether the file named pcr exists. If it has not been created, use the File class to create the file. This file is used to record the "device ID-unit power consumption rate" from port 6565 "Information, by creating a Thread thread, call the write() method of the RandomAccessFile class in the run() method of the Runnable class in the thread to update the obtained information to the pcr file, and also use the "device ID-unit" of the Android phone Power consumption rate" information to update the pcr file;

(2.3.2)用pcr文件数据,根据能耗均衡准则选出最适合开启AP热点模式的安卓手机,本具体实施例中暂定为电池剩余电量与单位时间耗电量比值最高的移动设备;(2.3.2) Use the pcr file data to select the Android mobile phone that is most suitable for opening the AP hotspot mode according to the energy balance criterion. In this specific embodiment, it is tentatively determined to be the mobile device with the highest ratio of battery remaining power to power consumption per unit time;

(2.3.3)若最适合开启AP热点模式的安卓手机就是当前开启AP热点手机,则转步骤(2.3.1);(2.3.3) If the most suitable Android phone to enable the AP hotspot mode is the currently enabled AP hotspot phone, go to step (2.3.1);

(2.3.4)否则变量Switch置1,使用Android的BroadcastReceiver广播机制把变量Switch广播出去,同时使用Socket类的getOutputStream()方法向端口6565向另一台安卓手机发送AP切换命令;(2.3.4) Otherwise, set the variable Switch to 1, use the BroadcastReceiver broadcast mechanism of Android to broadcast the variable Switch, and use the getOutputStream() method of the Socket class to send an AP switching command to another Android phone through port 6565;

(2.3.5)使用Socket类的getInputStream()方法在接收到来自另一台安卓手机确认回复后,使用WifiManager类的setWifiEnabled()方法关闭手机的AP热点,使用WifiManager类的setWifiEnabled ()方法开启Wi-Fi,并使用WifiManager类的addNetwork()方法和enableNetwork()方法连接到新的开启AP热点的手机;(2.3.5) Use the getInputStream() method of the Socket class to receive a confirmation reply from another Android phone, use the setWifiEnabled() method of the WifiManager class to turn off the AP hotspot of the mobile phone, and use the setWifiEnabled () method of the WifiManager class to turn on the Wifi -Fi, and use the addNetwork() method and enableNetwork() method of the WifiManager class to connect to the new mobile phone with the AP hotspot enabled;

(2.3.6)变量IsAP置0,变量Switch置0,并通过BroadcastReceiver广播机制把变量Switch广播出去,转到步骤(2.2);(2.3.6) The variable IsAP is set to 0, the variable Switch is set to 0, and the variable Switch is broadcast through the BroadcastReceiver broadcast mechanism, and then go to step (2.2);

(2.4)若变量IsAP为0则执行以下流程:(2.4) If the variable IsAP is 0, execute the following process:

(2.4.1)使用Socket类的getOutputStream.write()方法向开启AP热点手机的6565端口发送“设备ID-单位耗电率”信息;(2.4.1) Use the getOutputStream.write() method of the Socket class to send the "device ID-unit power consumption rate" information to the 6565 port of the mobile phone with the AP hotspot enabled;

(2.4.2)使用Socket类监听端口6565是否收到AP的切换命令,若未有切换AP的命令,转步骤(2.2);(2.4.2) Use the Socket class to monitor whether the port 6565 has received the switch command of the AP. If there is no command to switch the AP, go to step (2.2);

(2.4.3)变量Switch置1,使用Socket类的getOutputStream.write()方法向AP热点手机发送“设备ID-确认”回复;(2.4.3) Set the variable Switch to 1, and use the getOutputStream.write() method of the Socket class to send a "device ID-confirmation" reply to the AP hotspot mobile phone;

(2.4.4)若所在手机为将须开启AP热点的设备,则调用WifiManager类的setWifiEnable()方法关闭Wi-Fi,同时使用WifiConfiguration类配置AP热点属性调用Method类的invoke()方法开启AP热点,变量Switch置0,变量IsAP置1,转步骤(2.2);(2.4.4) If the mobile phone is a device that needs to turn on the AP hotspot, call the setWifiEnable() method of the WifiManager class to turn off Wi-Fi, and use the WifiConfiguration class to configure the AP hotspot attribute and call the invoke() method of the Method class to turn on the AP hotspot , the variable Switch is set to 0, the variable IsAP is set to 1, and then go to step (2.2);

(2.4.5)否则连接新开启AP热点的安卓手机,变量Switch置0,转步骤(2.2);(2.4.5) Otherwise, connect to an Android phone with newly enabled AP hotspot, set the variable Switch to 0, and go to step (2.2);

(3)如需在两台手机设备上传送文件,则在需传送文件的安卓手机上人工启动文件传输软件app2,告知app2所在安卓手机是文件的发送还是接收方,app2运行后形成进程T2;(3) If you need to transfer files on two mobile devices, manually start the file transfer software app2 on the Android phone that needs to transfer files, and tell app2 whether the Android phone where app2 is located is the sender or receiver of the file, and app2 will form process T2 after running;

(4)进程T2执行以下流程:(4) Process T2 executes the following flow:

(4.1)使用变量IsSend判断所在安卓手机是文件的发送方还是接收方;(4.1) Use the variable IsSend to determine whether the Android phone is the sender or receiver of the file;

(4.2)若变量IsSend为1则为发送方执行以下流程:(4.2) If the variable IsSend is 1, the following process will be executed for the sender:

(4.2.1)通过BroadcastReceiver接收读取变量Switch,若变量Switch为1表示AP热点正在切换则转步骤(4.2.1)继续等待;(4.2.1) Receive and read the variable Switch through BroadcastReceiver. If the variable Switch is 1, it means that the AP hotspot is switching, then go to step (4.2.1) and continue to wait;

(4.2.2)创建Socket类监听6789端口,使用PushbackInputStream类捕获由Socket类的getInputStream()方法所获取到数据流;通过PushbackInputStream类的read()方法读出数据流并解析出由接收文件的接收方发送来的源文件名和已接收字节数,若源文件未被打开则使用File类的open()方法打开源文件;(4.2.2) Create a Socket class to monitor port 6789, use the PushbackInputStream class to capture the data stream obtained by the getInputStream() method of the Socket class; read the data stream through the read() method of the PushbackInputStream class and parse out the received file received The name of the source file sent by the party and the number of bytes received. If the source file has not been opened, use the open() method of the File class to open the source file;

(4.2.3)根据解析出的数据内包含的已接收字节数,使用FileOutputStream类的seek()方法定位到指定文件数据块;(4.2.3) According to the number of received bytes contained in the parsed data, use the seek() method of the FileOutputStream class to locate the specified file data block;

(4.2.4)使用FileOutputStream类的read()方法从文件中将指定数据块读入到一个字节数组buf中,并使用Socket类的getOutputStream.write()方法向网络6789端口发送此数据块;(4.2.4) Use the read() method of the FileOutputStream class to read the specified data block from the file into a byte array buf, and use the getOutputStream.write() method of the Socket class to send this data block to the network port 6789;

(4.2.5)若已接收到的数据块的最后字符为EOF表示文件已发送完毕则调用File类的close()方法关闭源文件,转步骤(4.4)否则转步骤(4.2.1);(4.2.5) If the last character of the received data block is EOF, indicating that the file has been sent, call the close() method of the File class to close the source file, and go to step (4.4); otherwise, go to step (4.2.1);

(4.3)若是接收方则执行以下流程:(4.3) If it is the recipient, the following process is performed:

(4.3.1)通过BroadcastReceiver接收读取变量Switch,若变量Switch为1则转步骤(4.3.1)等待;(4.3.1) Receive and read the variable Switch through BroadcastReceiver, if the variable Switch is 1, go to step (4.3.1) and wait;

(4.3.2)使用File类的exists()方法判断日志文件是否生成,若未生成日志文件则生成日志文件,使用File类的read()方法从日志文件中读出要传输的文件的ID号和已接收的字节数;由文件的ID号确定要传送的文件名;(4.3.2) Use the exists() method of the File class to determine whether the log file is generated. If no log file is generated, generate a log file, and use the read() method of the File class to read the ID number of the file to be transferred from the log file and the number of bytes received; the file name to be transferred is determined by the ID number of the file;

(4.3.3)使用Socket类的getOutputStream.write()方法向文件发送方发送要传送的文件名、已接收的字节数;(4.3.3) Use the getOutputStream.write() method of the Socket class to send the file name to be transmitted and the number of bytes received to the file sender;

(4.3.4)使用PushbackInputStream类捕获由Socket类的getInputStream()方法获取的数据块,使用File类的exitst()方法判断目标文件是否建立,若未建立则建立并打开目标文件,使用FileOutputStream类的write()方法将已接收的数据块写入目标文件,已接收字节数增量,更新日志文件中已接收字节数;(4.3.4) Use the PushbackInputStream class to capture the data block obtained by the getInputStream() method of the Socket class, use the exitst() method of the File class to determine whether the target file is established, if not, create and open the target file, and use the FileOutputStream class The write() method writes the received data block into the target file, increments the number of bytes received, and updates the number of bytes received in the log file;

(4.3.5)若接收的数据块的最后字符不是EOF表示文件接收未结束则转步骤(4.3.1)否则调用File类的close()方法关闭目标文件,转步骤(4.4);(4.3.5) If the last character of the received data block is not EOF, it means that the file reception is not over, then go to step (4.3.1), otherwise call the close() method of File class to close the target file, go to step (4.4);

(4.4)进程T2结束。(4.4) Process T2 ends.

以上所述仅为本发明的较佳实施例而已,并不用以限制本发明,凡在本发明的精神和原则之内所做的任何修改、等同替换和改进等,均应包含在本发明的保护范围之内。The above descriptions are only preferred embodiments of the present invention, and are not intended to limit the present invention. Any modifications, equivalent replacements and improvements made within the spirit and principles of the present invention should be included in the scope of the present invention. within the scope of protection.

Claims (1)

1. a kind of Wi-Fi mobile networking methods of energy consumption balance, which is characterized in that it includes the following steps:
(1)Selection at least two has Wi-Fi connection, the mobile equipment for opening AP hot spots and data processing function;
(2)Make one of mobile opening of device AP hotspot patterns, remaining movement equipment passes through Wi-Fi connection to the unlatching AP The mobile equipment of hotspot pattern forms Wi-Fi mobile LANs;
(3)When file transmission is carried out in mobile LAN, the mobile equipment for receiving file is equipped with for each file received One ID number simultaneously establishes a corresponding journal file, is often receiving a data block of some reception file and file is written Afterwards, corresponding journal file is updated, records the byte number information having been received by;
(4)The mobile equipment timed collection for opening AP hotspot patterns each moves the battery dump energy percentage of equipment, unit Time power consumption, and according to the unit power consumption rate to each mobile equipment, select the movement for being most suitable for opening AP hotspot patterns and set It is standby;
(5)If the mobile equipment for being most suitable for opening AP hotspot patterns is to have been switched on the mobile equipment of AP hotspot patterns, have Network continue its connection mode and state;If the mobile equipment for being most suitable for opening AP hotspot patterns is not to have been switched on AP hot spots The mobile equipment of pattern then has been switched on the mobile equipment of AP hotspot patterns to the mobile equipment of most suitable unlatching AP hotspot patterns AP hot spot switching signals are sent out, and closes the AP hotspot patterns of itself, open Wi-Fi connection, optimal unlatching AP hotspot patterns Mobile equipment closes Wi-Fi connection, opens AP hotspot patterns, remaining movement equipment newly opens AP hot spot moulds by Wi-Fi connection The mobile equipment of formula, re-establishes Wi-Fi network;After Wi-Fi network is rebuild, each equipment is according to respectively established daily record text Part continues data transmission at data-transmission interruptions, maintains network normal operation;
Wi-Fi connection in mobile networking between mobile equipment is set to other equipment not using fixed SSID and password It can be seen that.
CN201510120173.1A 2015-03-19 2015-03-19 A kind of Wi-Fi mobile networking methods of energy consumption balance Expired - Fee Related CN104780580B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201510120173.1A CN104780580B (en) 2015-03-19 2015-03-19 A kind of Wi-Fi mobile networking methods of energy consumption balance

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201510120173.1A CN104780580B (en) 2015-03-19 2015-03-19 A kind of Wi-Fi mobile networking methods of energy consumption balance

Publications (2)

Publication Number Publication Date
CN104780580A CN104780580A (en) 2015-07-15
CN104780580B true CN104780580B (en) 2018-06-12

Family

ID=53621733

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201510120173.1A Expired - Fee Related CN104780580B (en) 2015-03-19 2015-03-19 A kind of Wi-Fi mobile networking methods of energy consumption balance

Country Status (1)

Country Link
CN (1) CN104780580B (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US11758487B2 (en) 2020-02-20 2023-09-12 Boe Technology Group Co., Ltd. Electric power balance processing method and apparatus, system, device and storage medium

Families Citing this family (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105376724B (en) * 2015-11-17 2019-04-16 北京小鸟听听科技有限公司 Communication processing method and equipment
CN106793157B (en) * 2016-11-28 2020-10-16 崇友智能技术有限责任公司 Method for processing communication between terminals and related equipment
CN112188592B (en) * 2020-09-29 2023-03-31 维沃移动通信有限公司 Wireless hotspot connection control method and device and electronic equipment
CN114980237A (en) * 2021-02-23 2022-08-30 中兴通讯股份有限公司 A wireless networking method, wireless device and storage medium
CN113141582B (en) * 2021-04-25 2022-09-20 深圳市元征科技股份有限公司 Log export method and device, computer equipment and storage medium
CN113507515B (en) * 2021-07-05 2024-07-19 维沃移动通信有限公司 Data transmission method, device, electronic equipment and storage medium

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101800575A (en) * 2009-11-19 2010-08-11 中南大学 Method and device for reducing document transmission energy consumption of bluetooth equipment
CN102970728A (en) * 2012-11-02 2013-03-13 北京小米科技有限责任公司 Message notification method and device
CN103648180A (en) * 2013-12-04 2014-03-19 北京奇虎科技有限公司 Method and device for sharing files between terminal devices
CN103888891A (en) * 2014-04-09 2014-06-25 北京安奇智联科技有限公司 Method and system for achieving data resource sharing on mobile terminal

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101800575A (en) * 2009-11-19 2010-08-11 中南大学 Method and device for reducing document transmission energy consumption of bluetooth equipment
CN102970728A (en) * 2012-11-02 2013-03-13 北京小米科技有限责任公司 Message notification method and device
CN103648180A (en) * 2013-12-04 2014-03-19 北京奇虎科技有限公司 Method and device for sharing files between terminal devices
CN103888891A (en) * 2014-04-09 2014-06-25 北京安奇智联科技有限公司 Method and system for achieving data resource sharing on mobile terminal

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US11758487B2 (en) 2020-02-20 2023-09-12 Boe Technology Group Co., Ltd. Electric power balance processing method and apparatus, system, device and storage medium

Also Published As

Publication number Publication date
CN104780580A (en) 2015-07-15

Similar Documents

Publication Publication Date Title
CN104780580B (en) A kind of Wi-Fi mobile networking methods of energy consumption balance
KR102083349B1 (en) Communication method, communication system and relevant device of wearable device
CN107079393B (en) The power consumption control method and wearable device of wearable device
CN104767768A (en) A method for sending/receiving network access configuration information for home appliances and home appliances
WO2018227494A1 (en) Measurement gap configuration method, apparatus, device, terminal and system
CN104754674B (en) Method and system for intelligent mobile terminal to simultaneously access Wi-Fi accessory equipment and 3G/4G network
CN109379734A (en) Real-time control method, equipment, storage medium and the device of narrowband internet of things equipment
CN110635957B (en) Method and device for network distribution of Internet of things equipment and mobile terminal
CN105553808A (en) Wireless network bridging method, smart home device and router
CN106413032A (en) Hotspot establishing method and terminal equipment
JP2021514130A (en) Handover method between wireless access technologies
CN109076405A (en) The method and device of different standard handover between cells
CN204206482U (en) Radio reception device and system
WO2018019058A1 (en) Wireless access point switching method and apparatus, and terminal
CN105099836A (en) BLE intelligent node control method and system
US10356666B2 (en) Communication device and communication control method
EP3735024B1 (en) Data transmission method and device and computer storage medium
KR20190095488A (en) Handover method, core network device, access network device, and terminal device
CN106792434A (en) A hotspot establishment method and terminal equipment
CN106358318A (en) A hotspot establishment method and terminal equipment
CN106559767A (en) Based on the double card double standby mobile phone terminal call method and device that call forwarding is realized
CN205883594U (en) A single modem dual card login system that provides dynamic download numbers
US20200351819A1 (en) Method and apparatus for reporting information by terminal, and computer storage medium
WO2022252716A1 (en) Method for acquiring timer parameters, terminal device, and storage medium
CN108702663A (en) By single packet data network for data transmission with network resource administration

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
EXSB Decision made by sipo to initiate substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
CF01 Termination of patent right due to non-payment of annual fee
CF01 Termination of patent right due to non-payment of annual fee

Granted publication date: 20180612

点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载