Coder Social home page Coder Social logo

Comments (16)

fhackenb avatar fhackenb commented on May 27, 2024 2

Returning true seemed to allow the rest of the plugin to work normally

from ble.

diginikkari avatar diginikkari commented on May 27, 2024 1

I think your idea is good. I just tried also with simple cordova app, and I'm getting the same undefined there also.

from ble.

EddyVerbruggen avatar EddyVerbruggen commented on May 27, 2024 1

@dbenninger You're right. I intended to do that but somehow screwed it up. Will now be part of the soon-to-be-released 2.0.0 version.

from ble.

EddyVerbruggen avatar EddyVerbruggen commented on May 27, 2024 1

Depends on how much time I can spend in my IDE vs responding to Github issues šŸ˜˜

from ble.

EddyVerbruggen avatar EddyVerbruggen commented on May 27, 2024

Strange.. it's this line: https://github.com/EddyVerbruggen/nativescript-bluetooth/blob/1907f7643e3f8c781dc68080ca0559db7b1358b5/bluetooth.ios.js#L311

Perhaps you can console.log the actual state on that device?

from ble.

fhackenb avatar fhackenb commented on May 27, 2024

It's being logged as undefined. Could this be an older iOS version thing?

from ble.

EddyVerbruggen avatar EddyVerbruggen commented on May 27, 2024

Hmm, older versions should be better than newer actually, because CBCentralManagerStatePoweredOn seems to be deprecated now.

I'll have to investigate and change the implementation I'm afraid. Perhaps it's best to not rely too much on that method for now..

from ble.

fhackenb avatar fhackenb commented on May 27, 2024

Ok. I can just have it return true for now and see if that lets me connect

from ble.

diginikkari avatar diginikkari commented on May 27, 2024

This seems to be issue also with latest ios for ipod touch 5th generation. Any idea how this could be fixed? Iā€™m now also returning true always, but that not actual fix.

from ble.

EddyVerbruggen avatar EddyVerbruggen commented on May 27, 2024

It would be very useful to know if changing this bit in bluetooth.ios.js:

https://github.com/EddyVerbruggen/nativescript-bluetooth/blob/25ccc7067f22f2fe19a1a241900e24fb9ed5982d/bluetooth.ios.js#L340-L342

to

Bluetooth._isEnabled = function () {
  return Bluetooth._state.manager.state === CBManagerState.PoweredOn;
};

would fix the problem. Can anyone try that perhaps?

from ble.

diginikkari avatar diginikkari commented on May 27, 2024

Both CBCentralManagerStatePoweredOn and CBManagerStatePoweredOn (without dot) are returning number 5.

The issue is that for one reason Bluetooth._state.manager.state is undefined.

from ble.

EddyVerbruggen avatar EddyVerbruggen commented on May 27, 2024

Ah, I see. Could be it's a timing issue. Can you check that method again a few seconds after you checked it the first time?

from ble.

diginikkari avatar diginikkari commented on May 27, 2024

Same, still undefined.

from ble.

EddyVerbruggen avatar EddyVerbruggen commented on May 27, 2024

Hmm if it still works when undefined on your device then I may need to return true when undefined or state equals PoweredOn.. the latter seems to work for most devices, and the former is a fallback. I have no clue how to approach this in any other way.

from ble.

dbenninger avatar dbenninger commented on May 27, 2024

This change somehow didn't make it into the 1.3.1 release. The function is still:
Bluetooth._isEnabled = function () {
return Bluetooth._state.manager.state === CBCentralManagerStatePoweredOn;
};

from ble.

dbenninger avatar dbenninger commented on May 27, 2024

Thanks, how soon?

from ble.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    šŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. šŸ“ŠšŸ“ˆšŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ā¤ļø Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.