CN114996187A - 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
CN114996187A
CN114996187A CN202210486552.2A CN202210486552A CN114996187A CN 114996187 A CN114996187 A CN 114996187A CN 202210486552 A CN202210486552 A CN 202210486552A CN 114996187 A CN114996187 A CN 114996187A
Authority
CN
China
Prior art keywords
data interface
state
usb data
magnetic field
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.)
Pending
Application number
CN202210486552.2A
Other languages
Chinese (zh)
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/CN114996187A/en
Publication of CN114996187A publication Critical patent/CN114996187A/en
Pending legal-status Critical Current

Links

Images

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)

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 a target magnetic field intensity detected by a Hall sensor, and confirming that a USB connector with magnetic characteristics approaches when the target magnetic field intensity meets a preset magnetic field threshold; the method comprises the steps of obtaining the change condition of the access state of a USB data interface, when the USB connector with the magnetic characteristic is confirmed to be inserted into the USB data interface of the smart watch according to the change condition, sending a starting trigger signal to a 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 portable small intelligent device, and starting the OTG function. The invention realizes the hardware design which does not depend on the USB data interface end and the USB connector of the device, and directly realizes the control of the OTG function on software. The user can experience better data transmission of the portable small intelligent device.

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 an apparatus for controlling an OTG function, a computer device, and a storage medium.
Background
With the development of the times, the requirements of users on the data transmission of portable small intelligent equipment are higher and higher. The data transmission of realizing portable small-size intelligent equipment among the prior art is based on the OTG technique, and when specific portable small-size intelligent equipment passes through the USB connecting wire and is connected with other equipment, when the ID pin of USB data interface end was pulled down, the control of corresponding realization OTG function.
However, the method completely realizes the control of the OTG function through hardware design, and if the USB connector or the USB data interface is damaged, the control of the OTG by the equipment is easily out of control. For example, a user uses the portable small-sized smart device for a long time to cause a large amount of fine dust particles in a USB data interface of the portable small-sized smart device or cause pin abrasion of a USB connector, which causes inaccuracy or even incapability of implementing OTG function control, and causes poor user experience.
Therefore, it is necessary to provide a method for implementing OTG function control without relying solely on hardware design.
Disclosure of Invention
In view of the foregoing, it is necessary to provide a method and an apparatus for controlling an OTG function, 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, 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 intensity of a target magnetic field 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.
Optionally, the obtaining of the target magnetic field strength detected by the hall sensor and the obtaining of the change condition of the access state of the USB data interface further include:
when the magnetic field intensity detected by the Hall sensor is monitored to be larger 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, continuously executing 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, the OTG function cannot be triggered.
Optionally, the determining, according to the target magnetic field strength and the change of the access state, whether to start an OTG function of the smart watch includes:
acquiring the intensity of a target magnetic field 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 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 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 at the same moment and the interface state of the USB data interface is changed into the connected state, the USB connector is a magnetic USB connector, a starting trigger signal is sent to the Hall sensor, and the 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;
and when the target magnetic field strength is smaller than the preset magnetic field threshold value at the same moment, stopping controlling the OTG function.
Optionally, before determining to start the OTG function of the smart watch, the method includes:
displaying a message for determining/canceling the OTG function;
if the selection is determined to be started, determining to start the OTG function;
and if the selection cancellation is detected, determining not to start the OTG function.
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;
monitoring 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;
and if the state of the USB data interface is changed from the non-accessed state to the accessed state within the preset time length, determining to start the USB function.
Optionally, the method further includes:
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 determining to start the USB function if the second parameter is the same as the first parameter.
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 the OTG function and the 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 a control apparatus for an OTG function, where the apparatus includes:
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, an embodiment of the present application provides a computer-readable storage medium storing a computer program, which when executed by a processor, causes the processor to perform the following steps:
acquiring the intensity of a target magnetic field 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.
In a fourth aspect, an embodiment of the present application provides a computer device, including a memory and a processor, the memory storing a computer program, and the computer program, when executed by the processor, causes the processor to perform the following steps:
acquiring the intensity of a target magnetic field 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.
By adopting the embodiment of the invention, the following beneficial effects are achieved:
the application provides a control method of OTG function, has utilized the characteristic that hall sensor and USB connector that has magnetic property have, includes: acquiring a target magnetic field intensity detected by a Hall sensor, and confirming that a USB connector with magnetic characteristics approaches when the target magnetic field intensity meets a preset magnetic field threshold; the method comprises the steps of obtaining the change condition of the access state of a USB data interface, when the USB connector with the magnetic characteristic is confirmed to be inserted into the USB data interface of the smart watch according to the change condition, sending a starting trigger signal to a 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 portable small intelligent device, and starting the OTG function. The invention realizes the control of the 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 can experience better data transmission of the portable small intelligent device.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts.
Wherein:
fig. 1 is a schematic flow chart of an OTG function control method in an embodiment of the present application;
fig. 2 is a flowchart of a method for switching between an OTG function and a USB function in the embodiment of the present application;
fig. 3 is a schematic structural diagram of a control device of the OTG function in the embodiment of the present application;
fig. 4 is a block diagram of a smart watch in an embodiment.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
OTG refers to (On-The-Go), which is a technology for transmitting data, and is mainly applied to directly transmit data between different devices or mobile devices without a host.
As devices are designed to be smaller and more delicate, such as smartwatches, smartbands, walkmans, and the like, users have higher and higher requirements for transmitting data of these portable small-sized smart devices.
The connector of the USB connecting line is a USB connector with magnetic characteristics, and the USB connector aims to firmly attract the USB data interface end of the device and the USB connector together through the magnetic characteristics during charging, so that the situations of electric leakage and other poor contacts are avoided. And if the USB connector with magnetic property has OTG function, the USB connector has 5 pins (Vbus, D +, D-, ID, GND).
The inventor creatively discovers that the magnetic property and the OTG function of the USB connector can be used for realizing the control of the OTG function with a smart device instrument with a Hall sensor.
Based on this, the present application provides a control method of an OTG function, which may be applied to various portable small-sized smart devices having hall sensors, such as a smart watch, a smart bracelet, and the like, where the smart watch is taken as an example for explanation, the hall sensor is integrated in an original hardware configuration of the smart watch, the hall sensor is a magnetic field sensor manufactured according to a hall effect, and when a magnetic object approaches or leaves, a certain magnetic field change may be generated, and the hall sensor may detect the magnetic field change.
Combine hall sensor and the characteristic that the USB connector that has magnetic property has, realize the technical scheme in this application: when the USB connector with the magnetic property is close to the intelligent watch, the Hall sensor detects a certain magnetic field intensity, and the fact that the USB connector with the magnetic property is close to the intelligent watch is confirmed; and detecting whether the USB connector with the magnetic characteristic is inserted into the USB data interface of the intelligent watch, sending a starting trigger signal to the Hall sensor when detecting that the USB connector with the magnetic characteristic is inserted into the USB data interface of the intelligent watch, pulling down the ID pin of the USB data interface by the starting trigger signal, detecting the pulled down ID pin by the intelligent watch, and correspondingly starting the 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, and the method specifically includes the following steps:
step 101, 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.
And step 102, determining whether to start the OTG function of the smart 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 the magnetic property approaches the intelligent watch, the Hall sensor detects a certain magnetic field intensity, the detected magnetic field intensity is used as a target magnetic field intensity, and the target magnetic field intensity is used for determining whether the object with the magnetic property approaching the intelligent watch is a USB connector with the magnetic property or not; the access state of the USB data interface comprises an accessed state in which the USB connector is inserted and a non-accessed state in which the USB connector is not inserted. Further, the change of the access state includes: the state is changed from the non-access state to the access state, the USB connector is inserted into the USB data interface of the smart watch, or the state is changed from the access state to the non-access state, the USB connector is pulled out of the USB data interface of the smart watch, and whether the USB connector is inserted into the USB data interface of the smart watch or not can be determined through analysis of the change situation of the access state of the USB data interface.
It can be understood that when an object with magnetic characteristics is close to the smart watch, if the access state is changed from an unaccessed state to an accessed state, it can be determined that the object with magnetic characteristics is a USB connector with magnetic characteristics at this time, in this kind of 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, the ID pin pulled down is detected by the smart watch at this time, the OTG function is controlled to be opened, the technical scheme in the application is to utilize the principle to realize the control of the OTG function.
In a feasible implementation manner, the step 101 of 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 are acquired in real time, and based on this, the steps 101 and 102 specifically include the following steps:
a. acquiring the intensity of a target magnetic field detected by a Hall sensor and the change condition of the access state of a USB data interface at the same moment 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 not changed, continuing to return to execute the step a;
c. when the target magnetic field intensity is larger 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 the 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 when the target magnetic field intensity is smaller than the preset magnetic field threshold value at the same moment, stopping controlling the OTG function.
The preset magnetic field threshold value is a preset magnetic field critical value, and only when the magnetic field intensity detected by the Hall sensor in real time is greater than or equal to the critical value, the USB connector with the magnetic characteristic is determined to be close to the smart watch, so that the change condition of the access state of the USB data interface is continuously detected.
It can be understood that, in the step b, when the acquired 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 an object with magnetic characteristics, which is 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 to perform the step a for reacquiring; in the step c, when the acquired target magnetic field intensity is larger than or equal to a preset magnetic field threshold value at a certain moment, and meanwhile, the interface state of the USB data interface is changed from an unaccessed state to an accessed state, it is determined that an object with magnetic characteristics close to the smart watch is a USB connector with magnetic characteristics, the USB connector is inserted into the USB data interface of the smart watch, at the moment, a starting trigger signal is sent to the Hall sensor, the ID pin of the USB data interface is pulled down through the starting trigger signal, at the moment, the smart watch detects the pulled-down ID pin, and the smart watch starts the OTG function; in the step d, when the obtained target magnetic field intensity is smaller than the preset magnetic field threshold value at a certain moment, it is determined that the object with the magnetic property close to the smart watch is not the USB connector with the magnetic property, or the USB connector with the magnetic property is far away from the smart watch, and at this time, the 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 preset magnetic field threshold is set, so that the triggering condition of the Hall sensor is more rigorous, and the mistaken touch of other objects which have magnetic characteristics but do not meet the requirement of the magnetic field strength is avoided. 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 acquired in real time, so that the intelligent watch can control the OTG function more accurately.
In a possible implementation manner, before determining to start the OTG function of the smart watch in step c, a selection display of the human-computer interaction interface may be further included. Specifically, before the OTG function was opened in the intelligence wrist-watch affirmation, the man-machine interface was popped out to the display interface of intelligence wrist-watch, shows the select box, and the select box 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 detecting that a user selects and determines to start; and if the user is detected to select to cancel the starting, not starting the OTG function.
In the embodiment of the application, the experience of the user is further optimized by setting the display interface of human-computer 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 an unaccessed 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 monitored to be greater than or equal to a preset magnetic field threshold value, it is determined that an object with magnetic characteristics, which is 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 an unaccessed state, determining that the initial state of the USB data interface is an unaccessed state, that is, no other device is inserted in the initial state of the USB data interface, and then starting to further acquire data, that is, executing the foregoing step 101 and step 102; when the interface state is the accessed state, it is determined that other devices have been inserted in the initial state of the USB data interface, and at this time, it is not necessary to continue to execute step 101 and step 102, so the OTG function cannot be triggered.
In the embodiment of the application, by detecting the initial state of the USB data interface in advance, it is avoided that corresponding steps are executed to control the OTG function when other devices access the USB data interface, which causes unnecessary resource waste, and also makes the control more accurate.
Further, after determining to start the OTG function of the smart watch in step c, the application may further implement switching between the OTG function and the USB function, please refer to fig. 2, which is a flowchart of a method for switching between the OTG function and the USB function in the embodiment of the application, and includes:
step 201, detecting the change condition of the access state of the USB data interface.
Step 202, when it is detected that the access state of the USB data interface changes from the accessed state to the unaccessed state, the access state of the USB data interface is monitored.
Step 203, when it is monitored that the access state of the USB data interface changes from the unaccessed state to the accessed state within the preset time, it is determined to start the USB function.
It can be understood that the method proposed in fig. 2 is based on the second plugging to implement the switching between the OTG function and the USB function. In step 202, when it is detected that the access state of the USB data interface changes from the accessed state to the unaccessed state, indicating that the USB connector is pulled out from the USB data interface of the smart watch, continuously monitoring the access state of the USB data interface; within the preset time, detecting that the access state of the USB data interface is changed from the non-access state to the access state again, indicating that the USB connector is inserted into the USB data interface of the smart watch for the second time, and determining that the user needs the USB function at the moment so as to start the USB function; and within the preset time, stopping controlling the USB function when detecting that the access state of the USB data interface is not changed.
The preset time duration may be a short time threshold, for example, 5s, and the time threshold may be set based on specific needs in practical applications, which is not limited herein.
In a feasible implementation, the main body of the implementation that needs to be accurately determined to be plugged for the second time is the same USB connector, and the specific steps include:
and i, recording a first parameter of the USB connector.
ii obtaining a second parameter of the USB connector.
And iii, when the second parameter is the same as the first parameter, determining to start the USB function.
It can be understood that the first parameter of the USB connector is a related parameter of the USB connector when the first time it is detected that the access state of the USB data interface is the accessed state, and the specific first time it is detected that the accessed state is in the foregoing step c: when the target magnetic field intensity at the same moment is greater than or equal to a preset magnetic field threshold value 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 the related parameters of the current USB connector 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 as the accessed state again within the preset time duration, specifically, in step 203: monitoring that the access state of the USB data interface is changed from an unaccessed state to an accessed state within a preset time length, and recording related parameters of the USB connector at the moment as second parameters; and comparing the second parameter with the first parameter, if the second parameter is the same as the first parameter, determining that the same USB connector is plugged for the second time, and determining to start the USB function at the moment.
The related parameters include, but are not limited to, data that can identify the USB connector.
The embodiment aims to provide a method for more accurately realizing switching between an OTG function and a USB function.
The embodiment of the application also provides a method for realizing the switching of the OTG function and the USB function besides a secondary plugging method, the method comprises a man-machine interaction interface, and a user can manually operate and control in real time, specifically: similarly, after the OTG function of the smart watch is determined to be started in step c, the smart watch displays a floating identification window corresponding to the OTG function, at this time, a click operation of the user on the floating identification window is detected, if it is determined that the user clicks the floating identification window, a switching interface between the OTG function and the USB function is further displayed, so that the user can select to start the OTG function or the USB function, and after the switching operation of the user is detected, the switching is switched to the function selected by the user.
For example: the user selects to use the OTG function, and then the OTG function is started; and if the user selects to use the USB function, the USB function is started. The purpose of the embodiment is to make the user experience better.
Please refer to fig. 3, which is a schematic structural diagram of a control device for an OTG function in an embodiment of the present application, the device 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 in which the USB data interface is accessed or an unaccessed state in which the USB data interface is not accessed;
and a determining and starting module 302, configured to determine whether to start an OTG function of the smart watch according to the change of the target magnetic field strength and the access state of the USB data interface.
In the embodiment of the present application, the content of the obtaining module 301 and the content of the determining and starting module 302 may refer to the content in the embodiment shown in fig. 1 and fig. 2, which is not described herein again.
In the embodiment of the application, the target magnetic field intensity detected by the Hall sensor is acquired in real time, and the change condition of the access state of the USB data interface is acquired at the same time, so that the invention 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 can experience better data transmission of the portable small intelligent device.
Fig. 4 shows an internal structural diagram of the smart watch in one embodiment. The smart watch may 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. Wherein the memory includes a non-volatile storage medium and an internal memory. The nonvolatile storage medium of the smart watch stores an operating system and also stores a computer program, and when the computer program is executed by a processor, the processor can realize the control method of the OTG function. The internal memory may also store a computer program that, when executed by the processor, causes the processor to perform a method of controlling an OTG function. Those skilled in the art will appreciate that the configuration shown in fig. 4 is a block diagram of only a portion of the configuration associated with the present application and does not constitute a limitation on the smart watch to which the present application may be applied, and that a particular smart watch may include more or fewer components than those shown, or may combine certain components, or have a different arrangement of components.
In one embodiment, a computer-readable storage medium is proposed, in which a computer program is stored which, when executed by a processor, causes the processor to carry out the steps of:
acquiring the intensity of a target magnetic field detected by a Hall sensor and acquiring the change condition of the access state of a 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 change conditions of the target magnetic field intensity and the access state of the USB data interface.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by a computer program, which can be stored in a non-volatile computer-readable storage medium, and can include the processes of the embodiments of the methods described above when the program is executed. Any reference to memory, storage, database, or other medium used in the embodiments provided herein may include non-volatile and/or volatile memory, among others. Non-volatile 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 DRAM (SLDRAM), Rambus Direct RAM (RDRAM), direct bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
All possible combinations of the technical features in the above embodiments may not be described for the sake of brevity, but should be considered as being within the scope of the present disclosure as long as there is no contradiction between the combinations of the technical features.
The above-mentioned embodiments only express several embodiments of the present application, and the description thereof is more specific and detailed, but not construed as limiting the scope of the present application. It should be noted that, for a person skilled in the art, several variations and modifications can be made without departing from the concept of the present application, which falls within the scope of protection of the present application. Therefore, the protection scope of the present patent application shall be subject to 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 intensity of a target magnetic field 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 or not according to the target magnetic field intensity and the change condition of the access state of the USB data interface.
2. The method of claim 1, wherein the obtaining of the target magnetic field strength detected by the hall sensor and the obtaining of the change of the access state of the USB data interface further comprise:
when the magnetic field intensity detected by the Hall sensor is monitored to be larger 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, the OTG function cannot be triggered.
3. The method according to 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 of the access state comprises:
acquiring the intensity of a target magnetic field 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 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 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 the connected state, the USB connector is a magnetic USB connector, a starting trigger signal is sent to the Hall sensor, and the ID pin of the USB data interface is pulled down through the starting trigger signal so as to start the OTG function of the smart watch;
and when the target magnetic field strength is smaller than the preset magnetic field threshold value at the same moment, stopping controlling the OTG function.
4. The method according to claim 3, wherein before the determining to turn on the OTG function of the smart watch, the method comprises:
displaying a message for determining/canceling the OTG function;
if the selection is determined to be started, determining to start the OTG function;
and if the selection cancellation is detected, determining not to start the OTG function.
5. The method according to claim 3, further comprising, after the OTG function of the smart watch is turned on:
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;
and if the state of the USB data interface is changed from the non-accessed state to the accessed state within the preset time length, determining to start the USB function.
6. The method of claim 5, further comprising:
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 determining to start the USB function if the second parameter is the same as the first parameter.
7. The method according to claim 3, further comprising, after the OTG function of the smart watch is turned on:
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 the OTG function and the USB function;
and if the switching operation is detected, switching to the USB function.
8. An OTG-function control apparatus, characterized in that the apparatus comprises:
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.
9. A computer-readable storage medium, storing a computer program which, when executed by a processor, causes the processor to carry out the steps of the method according to 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 according to any one of claims 1 to 7.
CN202210486552.2A 2022-05-06 2022-05-06 OTG function control method and device, computer equipment and storage medium Pending CN114996187A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210486552.2A CN114996187A (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 CN114996187A (en) 2022-05-06 2022-05-06 OTG function control method and device, computer equipment and storage medium

Publications (1)

Publication Number Publication Date
CN114996187A true CN114996187A (en) 2022-09-02

Family

ID=83024475

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210486552.2A Pending CN114996187A (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) CN114996187A (en)

Citations (24)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20060095642A1 (en) * 2004-10-29 2006-05-04 Advanced Micro Devices, Inc. USB on-the-go controller
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
CN2938223Y (en) * 2006-01-13 2007-08-22 链达电子工业股份有限公司 OTG device of USB
KR20120040354A (en) * 2010-10-19 2012-04-27 엘지전자 주식회사 Computer system and method for controlling thereof
CN102841877A (en) * 2012-07-05 2012-12-26 深圳芯邦科技股份有限公司 Detecting method and automatic detecting circuit of working mode
KR101259488B1 (en) * 2013-02-21 2013-05-07 (주)에스와이씨 Wireless data storage device
CN103904715A (en) * 2012-12-30 2014-07-02 青岛海尔软件有限公司 Wall-in intelligent USB charging socket
CN104321757A (en) * 2012-06-30 2015-01-28 英特尔公司 Device connect detection
US20170116146A1 (en) * 2015-10-26 2017-04-27 Le Holdings (Beijing) Co., Ltd. Control method and control device for a mobile terminal
CN106648857A (en) * 2016-11-29 2017-05-10 维沃移动通信有限公司 Method for starting OTG function of mobile terminal and mobile terminal
US20170194747A1 (en) * 2016-01-04 2017-07-06 Samsung Electronics Co., Ltd. Universal serial bus (usb) on-the-go (otg) device
CN106940670A (en) * 2016-01-05 2017-07-11 中兴通讯股份有限公司 Access state checking method, device and terminal
CN107643998A (en) * 2017-09-07 2018-01-30 上海移远通信技术股份有限公司 OTG and the difunctional system that charges are realized based on intelligent object
WO2018113128A1 (en) * 2016-12-20 2018-06-28 华为技术有限公司 Method for recognizing plug-and-play device, and electronic device
US20180341309A1 (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
CN110121015A (en) * 2019-04-01 2019-08-13 珠海奔图电子有限公司 The control method and device of image forming apparatus option and installment
CN110442539A (en) * 2019-06-17 2019-11-12 华为技术有限公司 Mobile phone OTG switching method and apparatus
EP3783389A1 (en) * 2019-08-19 2021-02-24 Beijing Xiaomi Mobile Software Co., Ltd. Distance sensor module, display device, electronic device 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
CN113741634A (en) * 2021-08-30 2021-12-03 海信视像科技股份有限公司 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 (26)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20060095642A1 (en) * 2004-10-29 2006-05-04 Advanced Micro Devices, Inc. USB on-the-go controller
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
CN2938223Y (en) * 2006-01-13 2007-08-22 链达电子工业股份有限公司 OTG device of USB
KR20120040354A (en) * 2010-10-19 2012-04-27 엘지전자 주식회사 Computer system and method for controlling thereof
CN104321757A (en) * 2012-06-30 2015-01-28 英特尔公司 Device connect detection
CN102841877A (en) * 2012-07-05 2012-12-26 深圳芯邦科技股份有限公司 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
US20170194747A1 (en) * 2016-01-04 2017-07-06 Samsung Electronics Co., Ltd. Universal serial bus (usb) on-the-go (otg) device
CN106940670A (en) * 2016-01-05 2017-07-11 中兴通讯股份有限公司 Access state checking method, device and terminal
CN106648857A (en) * 2016-11-29 2017-05-10 维沃移动通信有限公司 Method for starting OTG function of mobile terminal and mobile terminal
CN108475245A (en) * 2016-12-20 2018-08-31 华为技术有限公司 The recognition methods of PnP device and electronic equipment
WO2018113128A1 (en) * 2016-12-20 2018-06-28 华为技术有限公司 Method for recognizing plug-and-play device, and electronic device
WO2018217508A1 (en) * 2017-05-24 2018-11-29 Qualcomm Incorporated Universal serial bus (usb) type-c and power delivery port with scalable power architecture
US20180341309A1 (en) * 2017-05-24 2018-11-29 Qualcomm Incorporated Universal serial bus (usb) type-c and power delivery port with scalable power architecture
CN107643998A (en) * 2017-09-07 2018-01-30 上海移远通信技术股份有限公司 OTG and the difunctional system that charges are realized based on intelligent object
WO2019129108A1 (en) * 2017-12-29 2019-07-04 捷开通讯(深圳)有限公司 Mobile terminal, otg control and configuration method, and storage medium
CN110121015A (en) * 2019-04-01 2019-08-13 珠海奔图电子有限公司 The control method and device of image forming apparatus option and installment
CN110442539A (en) * 2019-06-17 2019-11-12 华为技术有限公司 Mobile phone OTG switching method and apparatus
EP3783389A1 (en) * 2019-08-19 2021-02-24 Beijing Xiaomi Mobile Software Co., Ltd. Distance sensor module, display device, electronic device 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
CN113741634A (en) * 2021-08-30 2021-12-03 海信视像科技股份有限公司 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

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
单长武: "低功耗USB2.0 OTG电路的设计", 信息科技辑 *
陆荣;晏芳;章琦;: "USB-OTG技术在便携式数码设备中的应用", 信息化研究, no. 05, pages 53 - 55 *

Similar Documents

Publication Publication Date Title
CN106202472B (en) Application icon processing method and device
CN106507445B (en) Wireless fidelity Wi-Fi scanning method and mobile terminal
CN109033247B (en) Application program management method and device, storage medium and terminal
CN104811547A (en) Terminal control method
CN104811546A (en) Terminal
CN103607822B (en) A kind of method of overheat protector of photoflash lamp of terminal and device
CN105094936A (en) Background application program cleaning method and device applied to mobile terminal
CN106412293B (en) Foreign matter detection method and device and terminal equipment
CN109408465B (en) File attribution information recording method, device, storage medium and terminal
US9634517B2 (en) Battery charging mode selection
WO2016023520A1 (en) Method and device for recognizing application causing temperature rise of terminal, and terminal
CN108445475B (en) Data processing method and device and related medium product
CN110830644A (en) Display screen control method and device, electronic equipment and storage medium
CN105528171A (en) Method and system for quickly starting application of intelligent terminal, and intelligent terminal
CN110768332B (en) Charging cartridge, charging control method thereof, and readable storage medium
CN109167420B (en) Charging control circuit, charging circuit and charging control method
CN102708032B (en) Method and device for detecting hot plug of secure digital card
CN104503674A (en) Screenshot picture generating method
CN114996187A (en) OTG function control method and device, computer equipment and storage medium
CN107277906B (en) Mode selecting method, device, terminal and computer readable storage medium
CN102710816A (en) Mobile terminal, memory cassette and write protection method for memory card in mobile terminal
CN110971219A (en) Pressure sensor, switch circuit thereof, clock control method and clock control device
CN115219930B (en) Vehicle storage battery aging early warning method and device, electronic equipment and storage medium
CN109634484A (en) A kind of application icon display methods and terminal, storage medium
CN113885380A (en) Control method and control device, and computer storage medium

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