21.9 C
Canberra
Tuesday, April 7, 2026

bluetooth lowenergy – Why does my BLE peripheral disappear from my app’s scanning menu after first scanning on iOS?


I am attempting to develop a customized app utilizing Svelte Native (the cross-platform improvement instrument primarily based round Svelte) and the NativeScript Group BLE library. This app is designed to connect with an STM32WB-based microcontroller board. Once I construct it for Android, all the pieces works completely, and the app is ready to constantly connect with the system. This scanner, in the intervening time, is simply designed to scan for any Bluetooth gadgets that may be seen, not essentially filtering for our system. Attributable to this, many miscellaneous gadgets present up, and do not disappear after the primary couple scans, even on iOS.

Nevertheless, once I construct the app for iOS, the STM32 board exhibits up on the primary one or two scans, however then isn’t seen once more. Any concept what is perhaps taking place right here? I feel it is perhaps some sort of caching challenge, however I am not likely certain.

I’ve tried restarting the iOS gadgets (I used an iPhone and iPad), uninstalling and rebuilding the app, resetting community settings, and renaming the peripheral from the board’s perspective. It does not appear to be an iOS challenge, because the ST BLE Toolbox app is ready to see it and connect with it simply, so it must be one thing with the app. Here is the present code for the Bluetooth scanning, if that is useful.

const bluetooth = new Bluetooth();
// different code exists
async operate toggleScan() {
        if (isScanning) return;
        const allowed = await requestBluetoothPermissions();
        if (!allowed) return;
        isScanning = true;
        gadgets = []; // Clear listing
        attempt { await bluetooth.stopScanning(); } catch(e) {console.err(e)}
        await new Promise(resolve => setTimeout(resolve, 500));
        // that is simply in case it's by some means already scanning, which could trigger issues

        await bluetooth.startScanning({
            seconds: 4, // Give it a number of time
            onDiscovered: (system) => {
                gadgets = [...devices, device];
            },
            avoidDuplicates: true
        }).then(() => {
            isScanning = false;
        }).catch((err) => {
            console.log("SCAN ERROR:", err);
        });
    }

I’ve additionally tried this code with avoidDuplicates set to false , which did not appear to do something helpful.

Any assist could be a lot appreciated.

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

[td_block_social_counter facebook="tagdiv" twitter="tagdivofficial" youtube="tagdiv" style="style8 td-social-boxed td-social-font-icons" tdc_css="eyJhbGwiOnsibWFyZ2luLWJvdHRvbSI6IjM4IiwiZGlzcGxheSI6IiJ9LCJwb3J0cmFpdCI6eyJtYXJnaW4tYm90dG9tIjoiMzAiLCJkaXNwbGF5IjoiIn0sInBvcnRyYWl0X21heF93aWR0aCI6MTAxOCwicG9ydHJhaXRfbWluX3dpZHRoIjo3Njh9" custom_title="Stay Connected" block_template_id="td_block_template_8" f_header_font_family="712" f_header_font_transform="uppercase" f_header_font_weight="500" f_header_font_size="17" border_color="#dd3333"]
- Advertisement -spot_img

Latest Articles