[go: up one dir, main page]
More Web Proxy on the site http://driver.im/

CN114996187B - OTG function control method and device, computer equipment and storage medium - Google Patents

OTG function control method and device, computer equipment and storage medium Download PDF

Info

Publication number
CN114996187B
CN114996187B CN202210486552.2A CN202210486552A CN114996187B CN 114996187 B CN114996187 B CN 114996187B CN 202210486552 A CN202210486552 A CN 202210486552A CN 114996187 B CN114996187 B CN 114996187B
Authority
CN
China
Prior art keywords
data interface
magnetic field
state
usb data
usb
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.)
Active
Application number
CN202210486552.2A
Other languages
Chinese (zh)
Other versions
CN114996187A (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.)
Dongguan Bubugao Education Software Co ltd
Original Assignee
Dongguan Bubugao Education Software 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 Dongguan Bubugao Education Software Co ltd filed Critical Dongguan Bubugao Education Software Co ltd
Priority to CN202210486552.2A priority Critical patent/CN114996187B/en
Publication of CN114996187A publication Critical patent/CN114996187A/en
Application granted granted Critical
Publication of CN114996187B publication Critical patent/CN114996187B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F13/00Interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
    • G06F13/38Information transfer, e.g. on bus
    • G06F13/40Bus structure
    • G06F13/4063Device-to-bus coupling
    • G06F13/4068Electrical coupling
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F1/00Details not covered by groups G06F3/00 - G06F13/00 and G06F21/00
    • G06F1/16Constructional details or arrangements
    • G06F1/1613Constructional details or arrangements for portable computers
    • G06F1/163Wearable computers, e.g. on a belt
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F1/00Details not covered by groups G06F3/00 - G06F13/00 and G06F21/00
    • G06F1/16Constructional details or arrangements
    • G06F1/1613Constructional details or arrangements for portable computers
    • G06F1/1633Constructional details or arrangements of portable computers not specific to the type of enclosures covered by groups G06F1/1615 - G06F1/1626
    • G06F1/1684Constructional details or arrangements related to integrated I/O peripherals not covered by groups G06F1/1635 - G06F1/1675
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2213/00Indexing scheme relating to interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
    • G06F2213/0042Universal serial bus [USB]
    • 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
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Hardware Design (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Human Computer Interaction (AREA)
  • Telephone Function (AREA)
  • Electric Clocks (AREA)

Abstract

The embodiment of the invention discloses a control method of an OTG function, which utilizes the characteristics of a Hall sensor and a USB connector with magnetic characteristics, and comprises the following steps: acquiring the target magnetic field intensity detected by the Hall sensor, and confirming that the USB connector with the magnetic characteristic is close when the target magnetic field intensity meets a preset magnetic field threshold value; acquiring the change condition of the access state of the USB data interface, when the USB connector with the magnetic characteristic is confirmed to be inserted into the USB data interface of the intelligent watch according to the change condition, sending a starting trigger signal to the Hall sensor, pulling down the ID pin of the USB data interface through the starting trigger signal, detecting the pulled down ID pin by the portable small intelligent device, and starting the OTG function. The invention realizes the hardware design which is not completely dependent on the USB data interface end and the USB connector of the equipment, and directly realizes the control of the OTG function on software. The user experience of the portable small intelligent device for transmitting data is better.

Description

OTG function control method and device, computer equipment and storage medium
Technical Field
The present invention relates to the field of communications technologies, and in particular, to a method and apparatus for controlling an OTG function, a computer device, and a storage medium.
Background
With the development of the age, the requirements of users on the data transmission of portable small intelligent devices are increasing. In the prior art, the data transmission of the portable small intelligent device is based on the OTG technology, and when the specific portable small intelligent device is connected with other devices through a USB connecting wire, the ID pin of the USB data interface end is pulled down, so that the OTG function is correspondingly controlled.
However, the method realizes the control of the OTG function completely through hardware design, and if the USB connector or the USB data interface is damaged, the control of the OTG by the equipment is easy to be out of control. For example, the long-time use of the portable small intelligent device by the user causes a great amount of fine dust particles in the USB data interface of the portable small intelligent device or pin abrasion of the USB connector, which can cause inaccuracy or even incapability of controlling the OTG function, so that the user experience is poor.
Therefore, it is necessary to provide a method for implementing OTG function control without completely relying on hardware design.
Disclosure of Invention
In view of the foregoing, it is necessary to provide a method and apparatus for controlling OTG functions, a computer device, and a storage medium.
In a first aspect, the present invention provides a method for controlling an OTG function, the method being applied to a smart watch configured with a hall sensor and a USB data interface, an interrupt pin of the hall sensor being connected to an ID pin of the USB data interface;
the method comprises the following steps:
Acquiring the target magnetic field intensity detected by a Hall sensor and acquiring the change condition of the access state of the USB data interface, wherein the access state is the accessed state of the accessed USB data interface or the unaccessed state of the unaccessed USB data interface;
and determining whether to start an OTG function of the intelligent watch according to the target magnetic field intensity and the change condition of the access state of the USB data interface.
Optionally, the acquiring the target magnetic field strength detected by the hall sensor and acquiring the change condition of the access state of the USB data interface further includes:
when the magnetic field intensity detected by the Hall sensor is detected to be greater than or equal to a preset magnetic field threshold value, determining whether the interface state of the USB data interface is an unaccessed state;
When the interface state is a non-access state, continuing to execute the steps of acquiring the magnetic field intensity detected by the Hall sensor and acquiring the change condition of the access state of the USB data interface;
When the interface state is an accessed state, then the OTG function cannot be triggered.
Optionally, the determining whether to turn on the OTG function of the smart watch according to the target magnetic field strength and the change condition of the access state includes:
Acquiring the target magnetic field intensity detected by the Hall sensor and the change condition of the access state of the USB data interface at the same moment in real time;
when the target magnetic field intensity is greater than or equal to the preset magnetic field threshold value at the same moment and the interface state of the USB data interface is not changed, continuously returning to execute the step of acquiring the target magnetic field intensity detected by the Hall sensor in real time and the change condition of the access state of the USB data interface at the same moment;
when the target magnetic field intensity is greater than or equal to the preset magnetic field threshold value at the same moment and the interface state of the USB data interface is changed into an accessed state, the USB connector is a magnetic USB connector, a starting trigger signal is sent to the Hall sensor, and an ID pin of the USB data interface is pulled down through the starting trigger signal so as to start an OTG function of the intelligent watch;
and stopping controlling the OTG function when the target magnetic field intensity is smaller than the preset magnetic field threshold at the same time.
Optionally, before the determining to turn on the OTG function of the smart watch, the method includes:
displaying a message for determining/canceling to start OTG function;
If the selection determination is detected to be started, the OTG function is determined to be started;
And if the selection cancellation is detected, determining that the OTG function is not started.
Optionally, after the OTG function of the smart watch is turned on, the method further includes:
detecting the change condition of the access state of the USB data interface;
if the access state of the USB data interface is detected to be changed from the accessed state to the unaccessed state, monitoring the access state of the USB data interface;
If the state of the USB data interface is changed from the unaccessed state to the accessed state within the preset time period, the starting of the USB function is determined.
Optionally, the method further comprises:
Recording a first parameter of the USB connector;
And determining to start the USB function, including:
And acquiring a second parameter of the currently inserted USB connector, and if the second parameter is the same as the first parameter, determining to start the USB function.
Optionally, after the OTG function of the smart watch is turned on, the method further includes:
The display interface displays a floating identification window corresponding to the OTG function;
When the clicking operation on the floating identification window is detected, displaying a switching interface of an OTG function and a USB function;
And if the switching operation is detected, switching to the USB function.
In a second aspect, an embodiment of the present application provides an OTG function control device, the device including:
the acquisition module is used for acquiring the target magnetic field intensity detected by the Hall sensor and acquiring the change condition of the access state of the USB data interface, wherein the access state is the accessed state of the accessed USB data interface or the unaccessed state of the unaccessed USB data interface;
And the determining and starting module is used for determining whether to start the OTG function of the intelligent watch according to the target magnetic field intensity and the change condition of the access state of the USB data interface.
In a third aspect, embodiments of the present application provide a computer readable storage medium storing a computer program which, when executed by a processor, causes the processor to perform the steps of:
Acquiring the target magnetic field intensity detected by a Hall sensor and acquiring the change condition of the access state of the USB data interface, wherein the access state is the accessed state of the accessed USB data interface or the unaccessed state of the unaccessed USB data interface;
and determining whether to start an OTG function of the intelligent watch according to the target magnetic field intensity and the change condition of the access state of the USB data interface.
In a fourth aspect, an embodiment of the present application provides a computer device comprising a memory and a processor, the memory storing a computer program which, when executed by the processor, causes the processor to perform the steps of:
Acquiring the target magnetic field intensity detected by a Hall sensor and acquiring the change condition of the access state of the USB data interface, wherein the access state is the accessed state of the accessed USB data interface or the unaccessed state of the unaccessed USB data interface;
and determining whether to start an OTG function of the intelligent watch according to the target magnetic field intensity and the change condition of the access state of the USB data interface.
The embodiment of the invention has the following beneficial effects:
The application provides a control method of OTG function, which uses the characteristics of a Hall sensor and a USB connector with magnetic characteristics, and comprises the following steps: acquiring the target magnetic field intensity detected by the Hall sensor, and confirming that the USB connector with the magnetic characteristic is close when the target magnetic field intensity meets a preset magnetic field threshold value; acquiring the change condition of the access state of the USB data interface, when the USB connector with the magnetic characteristic is confirmed to be inserted into the USB data interface of the intelligent watch according to the change condition, sending a starting trigger signal to the Hall sensor, pulling down the ID pin of the USB data interface through the starting trigger signal, detecting the pulled down ID pin by the portable small intelligent device, and starting the OTG function. The application realizes the control of OTG function on software directly through the magnetic field intensity and the change condition of the access state of the USB data interface without completely depending on the hardware design of the USB data interface end and the USB connector of the device. The user experience of the portable small intelligent device for transmitting data is better.
Drawings
In order to more clearly illustrate the embodiments of the invention or the technical solutions in the prior art, the drawings that are required in the embodiments or the description of the prior art will be briefly described, it being obvious that the drawings in the following description are only some embodiments of the invention, and that other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
Wherein:
FIG. 1 is a schematic flow chart of an OTG function control method in an embodiment of the application;
FIG. 2 is a flow chart of a method for switching OTG functions and USB functions in an embodiment of the application;
fig. 3 is a schematic structural diagram of an OTG function control device according to an embodiment of the present application;
Fig. 4 is a block diagram of a smart watch in one embodiment.
Detailed Description
The following description of the embodiments of the present invention will be made clearly and completely with reference to the accompanying drawings, in which it is apparent that the embodiments described are only some embodiments of the present invention, but not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
OTG refers to (On-The-Go), a technology for transmitting data, mainly applied to directly transmit data between different devices or mobile devices without a host.
As devices are designed more and more compact, such as smartwatches, smartbracelets, walkman, etc., users have increased the need for these portable small smart devices to transmit data.
There is a USB connector that the connector of USB connecting wire is the USB connector that has magnetic property, and this USB connector aim at is in the same place firmly through the USB data interface end of magnetic property with equipment and USB connector when charging, has avoided electric leakage and other bad condition of contact. And if the USB connector with magnetic property has an OTG function, the USB connector has 5 pins (Vbus, D+, D-, ID, GND).
The inventor creatively discovers that the magnetic property and OTG function of the USB connector can be utilized to realize the control of the OTG function with an intelligent equipment instrument with a Hall sensor.
Based on this, the application provides a control method of OTG function, which can be applied to various portable small intelligent devices with hall sensors, such as smart watches, smart bracelets, etc., and herein, the smart watches are exemplified, the hall sensors are integrated in the original hardware configuration of the smart watches, the hall sensors are magnetic field sensors made according to the hall effect, when magnetic objects approach and get away, certain magnetic field changes are generated, and the hall sensors can detect the magnetic field changes.
The technical scheme of the application is realized by combining the characteristics of the Hall sensor and the USB connector with magnetic characteristics: when the USB connector with the magnetic characteristic is close to the intelligent watch, the Hall sensor detects a certain magnetic field intensity, and the USB connector with the magnetic characteristic is confirmed to be close; and detecting whether the USB connector with the magnetic characteristic is inserted into the USB data interface of the intelligent watch or not, when the USB connector with the magnetic characteristic is detected to be inserted into the USB data interface of the intelligent watch, sending a starting trigger signal to the Hall sensor, pulling down an ID pin of the USB data interface through the starting trigger signal, detecting the pulled down ID pin by the intelligent watch, and correspondingly starting an OTG function.
Specifically, please refer to fig. 1, which is a schematic flow chart of an OTG function control method in an embodiment of the present application, the method specifically includes the following steps:
Step 101, obtaining the target magnetic field intensity detected by the Hall sensor and obtaining the change condition of the access state of the USB data interface.
Step 102, determining whether to start the OTG function of the intelligent watch according to the target magnetic field intensity and the change condition of the access state of the USB data interface.
When an object with magnetic characteristics is close to the intelligent watch, the Hall sensor can detect certain magnetic field intensity, the detected magnetic field intensity is used as target magnetic field intensity, and the target magnetic field intensity is used for determining whether the object with magnetic characteristics close to the intelligent watch is a USB connector with magnetic characteristics; the access state of the USB data interface comprises an accessed state in which the USB connector is inserted and an unaccessed state in which the USB connector is not inserted. Further, the changing conditions of the access state include: the USB connector is inserted into the USB data interface of the intelligent watch from the unaccessed state to the accessed state, or the USB connector is pulled out of the USB data interface of the intelligent watch from the accessed state to the unaccessed state, and whether the USB connector is inserted into the USB data interface of the intelligent watch can be determined by analyzing the change condition of the access state of the USB data interface.
It can be understood that when an object with magnetic characteristics approaches the smart watch, if the access state is changed from the unaccessed state to the accessed state, it can be determined that the object with magnetic characteristics is a USB connector with magnetic characteristics at this time, under the scene, a start trigger signal can be sent to the hall sensor, the ID pin of the USB data interface is pulled down by the start trigger signal, at this time, the smart watch detects the pulled-down ID pin, and the OTG function is controlled to be started.
In a possible implementation manner, the obtaining the target magnetic field strength detected by the hall sensor in step 101 and the obtaining the change condition of the access state of the USB data interface are obtained in real time, and based on this, step 101 and step 102 specifically include the following steps:
a. Acquiring the target magnetic field intensity detected by the Hall sensor and the change condition of the access state of the USB data interface at the same time in real time;
b. when the target magnetic field intensity is larger than or equal to the preset magnetic field threshold value at the same moment and the interface state of the USB data interface is unchanged, continuing to return to the execution step a;
c. When the target magnetic field intensity is greater than or equal to a preset magnetic field threshold value at the same moment and the interface state of the USB data interface is changed into an accessed state, the USB connector is a magnetic USB connector, a starting trigger signal is sent to the Hall sensor, and an ID pin of the USB data interface is pulled down through the starting trigger signal so as to start the OTG function of the intelligent watch;
d. and stopping controlling the OTG function when the target magnetic field intensity at the same moment is smaller than the preset magnetic field threshold value.
The preset magnetic field threshold value is a preset magnetic field critical value, and the USB connector with magnetic characteristics is determined to be close to the intelligent watch only when the magnetic field strength detected by the Hall sensor in real time is greater than or equal to the critical value, so that the change condition of the access state of the USB data interface is continuously detected.
It can be understood that in step b, when the obtained target magnetic field strength is greater than or equal to the preset magnetic field threshold at a certain moment, and meanwhile, the interface state of the USB data interface is not changed, it is determined that the object with magnetic characteristics close to the smart watch is a USB connector with magnetic characteristics, but the USB connector is not inserted into the USB data interface, so that the step a is continuously executed, and the step a is re-obtained; in step c, when the acquired target magnetic field intensity is greater than or equal to a preset magnetic field threshold at a certain moment, and meanwhile, the interface state of the USB data interface is changed from a non-accessed state to an accessed state, it is determined that an object with magnetic characteristics close to the intelligent watch is a USB connector with magnetic characteristics, and the USB connector is inserted into the USB data interface of the intelligent watch, at the moment, a starting trigger signal is sent to the Hall sensor, an ID pin of the USB data interface is pulled down through the starting trigger signal, at the moment, the intelligent watch detects the pulled down ID pin, and the intelligent watch starts an OTG function; in step d, when the obtained target magnetic field strength is smaller than the preset magnetic field threshold at a certain moment, it is determined that the object with magnetic characteristics close to the smart watch is not the USB connector with magnetic characteristics, or the USB connector with magnetic characteristics is far away from the smart watch, at this time, control of the OTG function is stopped no matter how the interface state of the USB data interface changes.
In the embodiment of the application, the triggering condition of the Hall sensor is more strict by setting the preset magnetic field threshold value, so that other objects with magnetic characteristics but not meeting the magnetic field strength requirement are prevented from being touched by mistake. And the target magnetic field intensity detected by the Hall sensor and the change condition of the access state of the USB data interface at the same time are obtained in real time, so that the intelligent watch can control the OTG function more accurately.
In a possible implementation manner, before determining to turn on the OTG function of the smart watch in step c, the method may further include selecting and displaying a man-machine interaction interface. Specifically, before the smart watch determines to start the OTG function, a display interface of the smart watch pops up a human-computer interaction interface, and a selection frame is displayed, where the selection frame includes: displaying a selection message for selecting and determining to start the OTG function, or displaying a selection message for selecting and canceling to start the OTG function, and determining to start the OTG function if the user selection is detected to determine to start the OTG function; if the user selects to cancel the starting, the OTG function is not started.
In the embodiment of the application, the experience of the user is further optimized by setting the display interface of man-machine interaction.
It should be noted that, in order to implement the above technical solution, it is necessary to ensure that the initial state of the USB data interface is a non-access state in advance, that is, no other device is inserted in the initial state of the USB data interface. The method specifically comprises the following steps:
Before step 101, the magnetic field intensity detected by the hall sensor is monitored, if the magnetic field intensity detected by the hall sensor is detected to be greater than or equal to a preset magnetic field threshold value, it is determined that an object with magnetic characteristics close to the smart watch is a USB connector with magnetic characteristics, and the interface state of the USB data interface at the same moment is continuously detected. When the interface state is the unaccessed state, determining that the initial state of the USB data interface is the unaccessed state, i.e. no other device is inserted in the initial state of the USB data interface, and at this time, further data acquisition can be started, i.e. the steps 101 and 102 are executed; when the interface state is the accessed state, it is determined that other devices are inserted in the initial state of the USB data interface, and step 101 and step 102 are not needed to be executed again, so that the OTG function cannot be triggered.
In the embodiment of the application, by detecting the initial state of the USB data interface in advance, the situation that other equipment is connected to the USB data interface is avoided, corresponding steps are executed to control the OTG function, unnecessary resource waste is caused, and the control is more accurate.
Further, after determining to start the OTG function of the smart watch in the step c, the present application may also implement switching between the OTG function and the USB function, and referring to fig. 2, a flowchart of a method for switching between the OTG function and the USB function in the embodiment of the present application includes:
step 201, detecting a change condition of an access state of the USB data interface.
Step 202, when detecting that the access state of the USB data interface is changed from the accessed state to the unaccessed state, monitoring the access state of the USB data interface.
Step 203, when it is monitored that the access state of the USB data interface is changed from the unaccessed state to the accessed state within the preset time period, it is determined to turn on the USB function.
It can be appreciated that the method proposed in fig. 2 is based on a secondary plug to implement the OTG function and USB function switching. In step 202, when it is detected that the access state of the USB data interface is changed from the accessed state to the unaccessed state, it is indicated that the USB connector is pulled out from the USB data interface of the smart watch, and the access state of the USB data interface is continuously monitored; detecting that the access state of the USB data interface is changed from the unaccessed state to the accessed state again within the preset time length, indicating that the USB connector is secondarily inserted into the USB data interface of the intelligent watch, and determining that the user needs the USB function at the moment, so that the USB function is started; and stopping controlling the USB function when detecting that the access state of the USB data interface is unchanged within the preset time.
The preset duration may be a very short time threshold, for example, 5s, and the time threshold may be set according to specific needs in practical applications, which is not limited herein.
In a feasible implementation manner, the implementation main body of determining the secondary plugging accurately is the same USB connector, and the specific steps include:
i, recording a first parameter of the USB connector.
Ii obtaining a second parameter of the USB connector.
Iii determining to turn on the USB function when the second parameter is the same as the first parameter.
It can be understood that the first parameter of the USB connector is a relevant parameter of the USB connector when the first detection of the accessed state of the USB data interface is the accessed state, and the specific first detection of the accessed state is in the foregoing step c: when the target magnetic field intensity is greater than or equal to a preset magnetic field threshold value at the same moment and the interface state of the USB data interface is changed into an accessed state, the USB connector is a magnetic USB connector, the OTG function of the intelligent watch is determined to be started, and relevant parameters of the USB connector at the moment are recorded as first parameters; the second parameter of the USB connector is a related parameter of the USB connector when the access state of the USB data interface is detected to be the accessed state within the preset time period, specifically, in step 203: the method comprises the steps of monitoring that the access state of a USB data interface is changed from a non-access state to an accessed state within a preset time period, and recording relevant parameters of a USB connector at the moment as second parameters; comparing the second parameter with the first parameter, if the second parameter and the first parameter are the same, it can be determined that the same USB connector is plugged and unplugged for the second time, and at the moment, the USB function is determined to be started.
Wherein, the related parameters include, but are not limited to, data that can identify the USB connector.
The embodiment aims to provide a more accurate method for realizing switching between an OTG function and a USB function.
The embodiment of the application also provides a method for realizing switching between the OTG function and the USB function besides the secondary plugging method, wherein the method comprises a man-machine interaction interface, and a user can perform real-time manual operation control, and the method is specific: and c, after the OTG function of the intelligent watch is determined to be started, displaying a floating identification window corresponding to the OTG function by the intelligent watch, detecting clicking operation of a user on the floating identification window, if the user is determined to click the floating identification window, further displaying a switching interface of the OTG function and the USB function for the user to select to start the OTG function or the USB function, and switching to the function selected by the user after detecting the switching operation of the user.
For example: the OTG function is selected to be used by a user, so that the OTG function is started; and if the user selects to use the USB function, the starting of the USB function is realized. The aim of the embodiment is to make the experience of the user better.
Referring to fig. 3, a schematic structural diagram of an OTG function control device according to an embodiment of the present application includes:
the acquiring module 301 is configured to acquire a target magnetic field strength detected by the hall sensor, and acquire a change condition of an access state of the USB data interface, where the access state is an accessed state of the accessed USB data interface or an unaccessed state of the unaccessed USB data interface;
The determining opening module 302 is configured to determine whether to open the OTG function of the smart watch according to the target magnetic field strength and the change condition of the access state of the USB data interface.
In the embodiment of the present application, the content related to the acquiring module 301 and the determining opening module 302 may refer to the content in the embodiment shown in fig. 1 and fig. 2, which is not described herein.
In the embodiment of the application, the change condition of the target magnetic field intensity detected by the Hall sensor and the access state of the USB data interface is acquired at the same time in real time, so that the application can realize the control of the OTG function by software without completely depending on the hardware design of the USB data interface end and the USB connector of the device. The user experience of the portable small intelligent device for transmitting data is better.
Fig. 4 shows an internal structural view of the smart watch in one embodiment. The intelligent watch can be a terminal or a server. As shown in fig. 4, the smart watch includes a processor, a memory, and a network interface connected by a system bus. The memory includes a nonvolatile storage medium and an internal memory. The non-volatile storage medium of the smart watch stores an operating system and may also store a computer program that, when executed by a processor, causes the processor to implement a method of controlling OTG functions. The internal memory may also store a computer program which, when executed by the processor, causes the processor to perform the control method of the OTG function. It will be appreciated by those skilled in the art that the structure shown in fig. 4 is merely a block diagram of a portion of the structure associated with the present inventive arrangements and is not limiting of the smart watch to which the present inventive arrangements are applied, and that a particular smart watch may include more or fewer components than shown, or may combine some of the components, or have a different arrangement of components.
In one embodiment, a computer-readable storage medium is provided, storing a computer program which, when executed by a processor, causes the processor to perform the steps of:
acquiring the target magnetic field intensity detected by a Hall sensor and acquiring the change condition of the access state of the USB data interface, wherein the access state is the accessed state of the accessed USB data interface or the unaccessed state of the unaccessed USB data interface;
And determining whether to start the OTG function of the intelligent watch according to the target magnetic field intensity and the change condition of the access state of the USB data interface.
Those skilled in the art will appreciate that all or part of the processes in the methods of the above embodiments may be implemented by a computer program for instructing relevant hardware, where the program may be stored in a non-volatile computer readable storage medium, and where the program, when executed, may include processes in the embodiments of the methods described above. Any reference to memory, storage, database, or other medium used in embodiments provided herein may include non-volatile and/or volatile memory. The nonvolatile memory can include Read Only Memory (ROM), programmable ROM (PROM), electrically Programmable ROM (EPROM), electrically Erasable Programmable ROM (EEPROM), or flash memory. Volatile memory can include Random Access Memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in a variety of forms such as Static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double Data Rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (SYNCHLINK) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), among others.
The technical features of the above embodiments may be arbitrarily combined, and all possible combinations of the technical features in the above embodiments are not described for brevity of description, however, as long as there is no contradiction between the combinations of the technical features, they should be considered as the scope of the description.
The foregoing examples illustrate only a few embodiments of the application and are described in detail herein without thereby limiting the scope of the application. It should be noted that it will be apparent to those skilled in the art that several variations and modifications can be made without departing from the spirit of the application, which are all within the scope of the application. Accordingly, the scope of protection of the present application is to be determined by the appended claims.

Claims (10)

1. The control method of the OTG function is characterized in that the method is applied to a smart watch provided with a Hall sensor and a USB data interface, wherein an interrupt pin of the Hall sensor is connected to an ID pin of the USB data interface;
the method comprises the following steps:
Acquiring the target magnetic field intensity detected by a Hall sensor and acquiring the change condition of the access state of the USB data interface, wherein the access state is the accessed state of the accessed USB data interface or the unaccessed state of the unaccessed USB data interface;
determining whether to start an OTG function of the intelligent watch according to the target magnetic field intensity and the change condition of the access state of the USB data interface;
the determining whether to start the OTG function of the smart watch according to the target magnetic field strength and the change condition of the access state of the USB data interface specifically includes:
When the target magnetic field intensity at the same time is smaller than a preset magnetic field threshold value, or when the target magnetic field intensity at the same time is larger than or equal to the preset magnetic field threshold value and the access state of the USB data interface is unchanged, the OTG function of the intelligent watch is not started;
And when the target magnetic field intensity is larger than or equal to the preset magnetic field threshold value at the same moment and the access state of the USB data interface is changed into the accessed state, starting an OTG function of the intelligent watch.
2. The method according to claim 1, wherein the acquiring the target magnetic field strength detected by the hall sensor and the acquiring the change condition of the access state of the USB data interface further includes:
when the magnetic field intensity detected by the Hall sensor is detected to be greater than or equal to a preset magnetic field threshold value, determining whether the interface state of the USB data interface is an unaccessed state;
When the interface state is a non-access state, continuing to execute the steps of acquiring the magnetic field intensity detected by the Hall sensor and acquiring the change condition of the access state of the USB data interface;
When the interface state is an accessed state, then the OTG function cannot be triggered.
3. The method of claim 2, wherein the determining whether to turn on the OTG function of the smart watch according to the target magnetic field strength and the change condition of the access state comprises:
Acquiring the target magnetic field intensity detected by the Hall sensor and the change condition of the access state of the USB data interface at the same moment in real time;
when the target magnetic field intensity is greater than or equal to the preset magnetic field threshold value at the same moment and the interface state of the USB data interface is not changed, continuously returning to execute the step of acquiring the target magnetic field intensity detected by the Hall sensor in real time and the change condition of the access state of the USB data interface at the same moment;
When the target magnetic field intensity is greater than or equal to the preset magnetic field threshold value at the same moment and the interface state of the USB data interface is changed into an accessed state, the USB connector is a magnetic USB connector, a starting trigger signal is sent to the Hall sensor, and an ID pin of the USB data interface is pulled down by the starting trigger signal so as to start an OTG function of the intelligent watch;
and stopping controlling the OTG function when the target magnetic field intensity is smaller than the preset magnetic field threshold at the same time.
4. The method of claim 3, wherein the determining to turn on the OTG function of the smart watch comprises, prior to:
displaying a message for determining/canceling to start OTG function;
If the selection determination is detected to be started, the OTG function is determined to be started;
And if the selection cancellation is detected, determining that the OTG function is not started.
5. The method of claim 3, further comprising, after turning on the OTG function of the smart watch:
detecting the change condition of the access state of the USB data interface;
if the access state of the USB data interface is detected to be changed from the accessed state to the unaccessed state, monitoring the access state of the USB data interface;
If the state of the USB data interface is changed from the unaccessed state to the accessed state within the preset time period, the starting of the USB function is determined.
6. The method of claim 5, wherein the method further comprises:
Recording a first parameter of the USB connector, wherein the first parameter is a related parameter of the USB connector when the access state of the USB data interface is detected to be the accessed state for the first time;
And determining to start the USB function, including:
acquiring a second parameter of the currently inserted USB connector, wherein the second parameter is a related parameter of the USB connector when the access state of the USB data interface is detected to be the accessed state again within a preset time length;
And if the second parameter is the same as the first parameter, determining to start the USB function.
7. The method of claim 3, further comprising, after turning on the OTG function of the smart watch:
The display interface displays a floating identification window corresponding to the OTG function;
When the clicking operation on the floating identification window is detected, displaying a switching interface of an OTG function and a USB function;
And if the switching operation is detected, switching to the USB function.
8. An OTG function control device, the device comprising:
The acquisition module is used for acquiring the target magnetic field intensity detected by the Hall sensor and acquiring the change condition of the access state of the USB data interface, wherein the access state is the accessed state of the accessed USB data interface or the unaccessed state of the unaccessed USB data interface;
the starting module is used for determining whether to start the OTG function of the intelligent watch according to the target magnetic field intensity and the change condition of the access state of the USB data interface;
the determining and starting module is further configured to not start an OTG function of the smart watch when the target magnetic field strength is smaller than a preset magnetic field threshold at the same time, or when the target magnetic field strength is greater than or equal to the preset magnetic field threshold at the same time and the access state of the USB data interface is unchanged;
And when the target magnetic field intensity is larger than or equal to the preset magnetic field threshold value at the same moment and the access state of the USB data interface is changed into the accessed state, starting an OTG function of the intelligent watch.
9. A computer readable storage medium storing a computer program which, when executed by a processor, causes the processor to perform the steps of the method of any one of claims 1 to 7.
10. A computer device comprising a memory and a processor, the memory storing a computer program that, when executed by the processor, causes the processor to perform the steps of the method of any of claims 1 to 7.
CN202210486552.2A 2022-05-06 2022-05-06 OTG function control method and device, computer equipment and storage medium Active CN114996187B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210486552.2A CN114996187B (en) 2022-05-06 2022-05-06 OTG function control method and device, computer equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210486552.2A CN114996187B (en) 2022-05-06 2022-05-06 OTG function control method and device, computer equipment and storage medium

Publications (2)

Publication Number Publication Date
CN114996187A CN114996187A (en) 2022-09-02
CN114996187B true CN114996187B (en) 2024-07-26

Family

ID=83024475

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210486552.2A Active CN114996187B (en) 2022-05-06 2022-05-06 OTG function control method and device, computer equipment and storage medium

Country Status (1)

Country Link
CN (1) CN114996187B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117041145B (en) * 2023-06-29 2024-09-06 荣耀终端有限公司 Router, detection method thereof and intelligent home system

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2018217508A1 (en) * 2017-05-24 2018-11-29 Qualcomm Incorporated Universal serial bus (usb) type-c and power delivery port with scalable power architecture
WO2019129108A1 (en) * 2017-12-29 2019-07-04 捷开通讯(深圳)有限公司 Mobile terminal, otg control and configuration method, and storage medium

Family Cites Families (22)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
DE102004057756B4 (en) * 2004-11-30 2009-08-06 Advanced Micro Devices Inc., Sunnyvale USB control device with OTG control unit
US20060106962A1 (en) * 2004-11-17 2006-05-18 Woodbridge Nancy G USB On-The-Go implementation
US20070070308A1 (en) * 2005-09-23 2007-03-29 Topseed Technology Corp. Projector having built-in portable universal serial bus on the go
JP2007148930A (en) * 2005-11-29 2007-06-14 Canon Inc Electronic device, control method for electronic device, and computer program
US7214089B1 (en) * 2006-01-13 2007-05-08 I/O Interconnect Inc. Universal serial bus On-The-Go apparatus
KR101792503B1 (en) * 2010-10-19 2017-11-02 엘지전자 주식회사 Computer system and method for controlling thereof
US8683097B2 (en) * 2012-06-30 2014-03-25 Intel Corporation Device connect detection
CN102841877B (en) * 2012-07-05 2015-05-06 深圳芯邦科技股份有限公司 Detecting method and automatic detecting circuit of working mode
CN103904715A (en) * 2012-12-30 2014-07-02 青岛海尔软件有限公司 Wall-in intelligent USB charging socket
KR101259488B1 (en) * 2013-02-21 2013-05-07 (주)에스와이씨 Wireless data storage device
US20170116146A1 (en) * 2015-10-26 2017-04-27 Le Holdings (Beijing) Co., Ltd. Control method and control device for a mobile terminal
KR20170081379A (en) * 2016-01-04 2017-07-12 삼성전자주식회사 Universial serial bus on-the-go device
CN106940670A (en) * 2016-01-05 2017-07-11 中兴通讯股份有限公司 Access state checking method, device and terminal
CN106648857B (en) * 2016-11-29 2019-11-01 维沃移动通信有限公司 A kind of open method and mobile terminal of the OTG function of mobile terminal
CN108475245B (en) * 2016-12-20 2020-12-22 华为技术有限公司 Plug and play device identification method and electronic device
CN107643998B (en) * 2017-09-07 2020-04-10 上海移远通信技术股份有限公司 System for realizing OTG and charging dual functions based on intelligent module
CN110121015A (en) * 2019-04-01 2019-08-13 珠海奔图电子有限公司 The control method and device of image forming apparatus option and installment
CN110442539B (en) * 2019-06-17 2021-08-31 荣耀终端有限公司 Mobile phone OTG switching method and device
CN112394845B (en) * 2019-08-19 2024-03-01 北京小米移动软件有限公司 Distance sensor module, display device, electronic equipment and distance detection method
CN112449258A (en) * 2019-08-29 2021-03-05 Oppo广东移动通信有限公司 In-cartridge detection method, charging cartridge, electronic apparatus, and storage medium and system
CN113741634B (en) * 2021-08-30 2024-06-11 海信视像科技股份有限公司 State control method based on wearable device and wearable device
CN216352062U (en) * 2021-12-16 2022-04-19 深圳市谦视智能科技有限责任公司 Mobile intelligent terminal, USB device and electronic equipment system

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2018217508A1 (en) * 2017-05-24 2018-11-29 Qualcomm Incorporated Universal serial bus (usb) type-c and power delivery port with scalable power architecture
WO2019129108A1 (en) * 2017-12-29 2019-07-04 捷开通讯(深圳)有限公司 Mobile terminal, otg control and configuration method, and storage medium

Also Published As

Publication number Publication date
CN114996187A (en) 2022-09-02

Similar Documents

Publication Publication Date Title
CN106507445B (en) Wireless fidelity Wi-Fi scanning method and mobile terminal
CN109947496B (en) Application program preloading method and device, storage medium and mobile terminal
CN109033247B (en) Application program management method and device, storage medium and terminal
CN105676993A (en) Method and device for saving electric quantity and electronic equipment
CN104811546A (en) Terminal
CN104811547A (en) Terminal control method
CN109408465B (en) File attribution information recording method, device, storage medium and terminal
CN112906568B (en) Dynamic threshold management method, system, electronic device and medium
CN114996187B (en) OTG function control method and device, computer equipment and storage medium
CN105512033A (en) Automated testing method and device of mobile terminal and mobile terminal
CN105159548A (en) List interface operating method and electronic terminal
CN107402625B (en) Touch screen scanning method and device, terminal and computer readable storage medium
CN113077834A (en) Storage device testing method and device, television and storage medium
CN109167420B (en) Charging control circuit, charging circuit and charging control method
CN105678141A (en) Information exhibiting method and device and terminal
CN110889116B (en) Advertisement interception method and device and electronic equipment
CN113791725A (en) Touch pen operation identification method, intelligent terminal and computer readable storage medium
CN106468943A (en) Application control method and device and terminal
CN102708032B (en) Method and device for detecting hot plug of secure digital card
CN109634484A (en) A kind of application icon display methods and terminal, storage medium
CN112448447B (en) Charging method, charging device, electronic equipment and storage medium
CN107277906B (en) Mode selecting method, device, terminal and computer readable storage medium
CN109725816A (en) A kind of footmark sweep-out method and terminal, storage medium
CN104268231B (en) A kind of file access method, device and Intelligent File System
CN110109529B (en) SD card power supply control method and device, storage medium and electronic equipment

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant