Home Web Front-end JS Tutorial WeChat applet Bluetooth device code and error sorting

WeChat applet Bluetooth device code and error sorting

Feb 03, 2018 pm 02:58 PM
code Applets mistake

The WeChat applet is generally very good. The Bluetooth interface is indeed a "hole". The programmers on the "network side" do the "hardware interface". This article mainly shares with you the WeChat applet Bluetooth device code and error sorting. I hope it can Help everyone.

Some troublesome things

Many Bluetooth devices will jam the phone. The company can scan 200+ devices and directly jam the WeChat of iPhone 5S.

There must be a delay between each hardware operation, 100ms is recommended, such as between "turn on Bluetooth" and "start scanning", "connection successful" and "get service", etc. Failure to use delay may cause inexplicable errors, which are more common on the Android side.

Pay attention to the asynchronous and concurrency characteristics of JS, especially the characteristics under polling service. The mini program does not yet support async and await (these two keywords are included in the code completion, but they cannot be compiled).

Bluetooth data reading and writing, advertisesData type is ArrayBuffer, (note when quoting the applet: vConsole cannot print out ArrayBuffer type data). Guys, please understand binary arrays and hexadecimal strings first. There are conversion methods in the code (copied from github).

Initialize the Bluetooth adapter (wx.openBluetoothAdapter(OBJECT)) and obtain the status of the local Bluetooth adapter (wx.getBluetoothAdapterState(OBJECT)). It is difficult to say which of these two functions should be called first. You can play it yourself. See the instructions below. .

Some BUG

1. During the Bluetooth scanning process, obtain the local Bluetooth adapter status (wx.getBluetoothAdapterState(OBJECT)). (Exclusive to Android, Huawei Honor 8, VIVO 7plus, 6.5.13)

available\Boolean\Whether the Bluetooth adapter is available, the value is true.

discovering\Boolean\Whether the device is being searched for, the value is false.

https://github.com/FFiot/WX_Bluetooth/issues/1

2. During the Bluetooth scanning process, start scanning again wx.startBluetoothDevicesDiscovery(OBJECT): fail, errCode=10008 . (Exclusive to Android, Huawei Honor 8, VIVO 7plus, 6.5.13) BUG: Query Bluetooth status during Bluetooth scanning · Issue #1 · FFiot/WX_Bluetoothgithub.com During Bluetooth scanning, start scanning again wx.startBluetoothDevicesDiscovery(OBJECT): fail,errCode=10008. (Exclusive to Android, Huawei Honor 8, VIVO 7plus, 6.5.13)

https://github.com/FFiot/WX_Bluetooth/issues/2

errorCode is mixed with errMsg. (Exclusive to IOS, IPHONE5s, WeChat 6.5.15)

https://github.com/FFiot/WX_Bluetooth/issues/3

3. When Bluetooth is scanning characters under service, if If there are multiple services, only the character under the first service can be obtained normally. The chara obtained by other services is the same as that of the first service. (Unique to IOS, IPHONE5s, WeChat 6.5.15)

There are two states for mobile device Bluetooth to be turned on and off, triggering the wx.onBluetoothAdapterStateChange callback

1, wx.getBluetoothAdapterState(OBJECT)

Close status returns: drrCode:10000,errMsg:"getBluetoothAdapterState:fail". Turn on Bluetooth at this time: wx.onBluetoothAdapterStateChange(CALLBACK) has no callback.

Open status returns: drrCode:10000,errMsg:"getBluetoothAdapterState:fail". Turn off Bluetooth at this time: wx.onBluetoothAdapterStateChange(CALLBACK) has no callback.

2. wx.getBluetoothAdapterState(OBJECT)

Close status returns: drrCode:10001,errMsg:"openBluetoothAdapter:fail". Turn on Bluetooth at this time: wx.onBluetoothAdapterStateChange(CALLBACK) has a callback.

Open status returns: errMsg: "openBluetoothAdapter:ok". Turn on Bluetooth at this time: wx.onBluetoothAdapterStateChange(CALLBACK) has a callback.

Related recommendations:

Code for WeChat applet to implement Bluetooth link

##Example sharing of how WeChat applet implements Bluetooth

WeChat Mini Program--Ble Bluetooth

The above is the detailed content of WeChat applet Bluetooth device code and error sorting. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Unable to complete operation (Error 0x0000771) Printer error Unable to complete operation (Error 0x0000771) Printer error Mar 16, 2024 pm 03:50 PM

If you encounter an error message when using your printer, such as the operation could not be completed (error 0x00000771), it may be because the printer has been disconnected. In this case, you can solve the problem through the following methods. In this article, we will discuss how to fix this issue on Windows 11/10 PC. The entire error message says: The operation could not be completed (error 0x0000771). The specified printer has been deleted. Fix 0x00000771 Printer Error on Windows PC To fix Printer Error the operation could not be completed (Error 0x0000771), the specified printer has been deleted on Windows 11/10 PC, follow this solution: Restart Print Spool

Solution to Windows Update prompt Error 0x8024401c error Solution to Windows Update prompt Error 0x8024401c error Jun 08, 2024 pm 12:18 PM

Table of Contents Solution 1 Solution 21. Delete the temporary files of Windows update 2. Repair damaged system files 3. View and modify registry entries 4. Turn off the network card IPv6 5. Run the WindowsUpdateTroubleshooter tool to repair 6. Turn off the firewall and other related anti-virus software. 7. Close the WidowsUpdate service. Solution 3 Solution 4 "0x8024401c" error occurs during Windows update on Huawei computers Symptom Problem Cause Solution Still not solved? Recently, the web server needs to be updated due to system vulnerabilities. After logging in to the server, the update prompts error code 0x8024401c. Solution 1

What to do if the blue screen code 0x0000001 occurs What to do if the blue screen code 0x0000001 occurs Feb 23, 2024 am 08:09 AM

What to do with blue screen code 0x0000001? The blue screen error is a warning mechanism when there is a problem with the computer system or hardware. Code 0x0000001 usually indicates a hardware or driver failure. When users suddenly encounter a blue screen error while using their computer, they may feel panicked and at a loss. Fortunately, most blue screen errors can be troubleshooted and dealt with with a few simple steps. This article will introduce readers to some methods to solve the blue screen error code 0x0000001. First, when encountering a blue screen error, we can try to restart

Interpreting Oracle error 3114: causes and solutions Interpreting Oracle error 3114: causes and solutions Mar 08, 2024 pm 03:42 PM

Title: Analysis of Oracle Error 3114: Causes and Solutions When using Oracle database, you often encounter various error codes, among which error 3114 is a relatively common one. This error generally involves database link problems, which may cause exceptions when accessing the database. This article will interpret Oracle error 3114, discuss its causes, and give specific methods to solve the error and related code examples. 1. Definition of error 3114 Oracle error 3114 pass

Why does the Xiangxiangfuzhai app display an error? Why does the Xiangxiangfuzhai app display an error? Mar 19, 2024 am 08:04 AM

The display error is a problem that may occur in the Xiangxiang Fuzhai app. Some users are not sure why the Xiangxiang Fuzhai app displays errors. It may be due to network connection problems, too many background programs, incorrect registration information, etc. Next, This is the editor’s introduction to how to solve app display errors for users. Interested users should come and take a look! Why does the Xiangxiang Fuzhai app display an error answer: network connection problem, too many background programs, incorrect registration information, etc. Details: 1. [Network problem] Solution: Check the device connection network status, reconnect or choose another network connection to use. Can. 2. [Too many background programs] Solution: Close other running programs and release the system, which can speed up the running of the software. 3. [Incorrect registration information

GE universal remote codes program on any device GE universal remote codes program on any device Mar 02, 2024 pm 01:58 PM

If you need to program any device remotely, this article will help you. We will share the top GE universal remote codes for programming any device. What is a GE remote control? GEUniversalRemote is a remote control that can be used to control multiple devices such as smart TVs, LG, Vizio, Sony, Blu-ray, DVD, DVR, Roku, AppleTV, streaming media players and more. GEUniversal remote controls come in various models with different features and functions. GEUniversalRemote can control up to four devices. Top Universal Remote Codes to Program on Any Device GE remotes come with a set of codes that allow them to work with different devices. you may

Linux Oops: Detailed explanation of what this error means Linux Oops: Detailed explanation of what this error means Mar 21, 2024 am 09:06 AM

LinuxOops: Detailed explanation of the meaning of this error, need specific code examples What is LinuxOops? In Linux systems, "Oops" refers to a situation where a serious error in the kernel causes the system to crash. Oops is actually a kernel crash mechanism that stops the system when a fatal error occurs and prints out relevant error information so that developers can diagnose and fix the problem. Oops usually occur in kernel space and have nothing to do with user space applications. When the kernel encounters

How to use Copilot to generate code How to use Copilot to generate code Mar 23, 2024 am 10:41 AM

As a programmer, I get excited about tools that simplify the coding experience. With the help of artificial intelligence tools, we can generate demo code and make necessary modifications as per the requirement. The newly introduced Copilot tool in Visual Studio Code allows us to create AI-generated code with natural language chat interactions. By explaining functionality, we can better understand the meaning of existing code. How to use Copilot to generate code? To get started, we first need to get the latest PowerPlatformTools extension. To achieve this, you need to go to the extension page, search for "PowerPlatformTool" and click the Install button

See all articles