Comments (30)
Hey everyone, the discussion on introducing peripheral support is of interest to me. Has there been any work done to this repo (or maybe another repo) to add peripheral support for React Native?
from react-native-ble.
As some of you might know, I have been doing a lot of work to add the extra functionality on my fork, updates
branch. I am not ready to submit a PR, but I am actively working on it since I am currently using it on this big project that involves using BLE. I expect to have the rest of the functionality completely done and conforming to the noble API more or less in the coming weeks.
from react-native-ble.
Yep, noble abstraction is way to go, as for cordova, theres really nothing to port from thin abstractions like this sadly.
No good reason, I just havent needed any more than this for my work yet. PRs welcome
from react-native-ble.
This is exciting! sadly the projectim on still hasn't moved to react native.
from react-native-ble.
@rclai Good job man. I still havent gotten around to getting back to this project or looking at your code. A big goal of mine is keeping the noble files as untouched as possible and pushing any needed changes upstream to @sandeepmistry eventually deduping them in our repo or merging into his domain. Whatever works.
from react-native-ble.
@rclai I don't see an updates branch in your fork, could you link us?
from react-native-ble.
You're looking at the wrong fork. It's here.
Also, keep in mind that I'm not a super expert on Objective-C, so if any of you know of more efficient ways to juggle the data back and forth via better data types, feel free to pitch in. However, I do share the goal of being able to keep the Noble layer untouched and only modify the custom bindings.
Also, I have a big feeling that I can literally do away with all the JS files that were copied from Noble, and literally use noble
as an NPM dependency. I'm going to try that soon.
from react-native-ble.
I managed to get rid of all the copies of Noble files and directly depend on the noble
NPM package itself. You can check it out here. Right now if you test it you'll get a binding
variable not found error, but that has been fixed, we just need to wait for NPM package to get bumped up to reflect the fix.
from react-native-ble.
@rclai noble v1.5.0 has been published with your fix :)
from react-native-ble.
Thanks.
from react-native-ble.
@rclai just made a huge pr with what looks like all this. I published as 1.0.0 beta1 while I look at it myself.
Check it out everyone and give any feedback here
npm install [email protected]
from react-native-ble.
Looks like you just npm install [email protected] actually
from react-native-ble.
@rclai Im still losing the initial getState in order to use the typical noble pattern of only scanning once we get a poweredOn state. Are you catching it with current code? Care to share a gist of your index.ios.js?
from react-native-ble.
I know that the BlueTooth state gets lost sometimes, but in my experience it's not all the time. In an effort to make it more reliable, I moved the iOS setup
code into the init
function, which I believe is a more appropriate and reliable place to put and we should be guaranteed to have an initial BlueTooth state. Try it now.
Edit: even with this change, I still get an initial state of unknown
but once in a blue moon and I end up having to disable and enable the BlueTooth to make it come alive.
from react-native-ble.
Here's my test gist: https://gist.github.com/rclai/104ffcd953ecfe6bad18b21fc0536f1b
from react-native-ble.
Why does NPM still show the library as 0.0.7? https://www.npmjs.com/package/react-native-ble
from react-native-ble.
FYI, I just rebased my PR and organized my commits in a more comprehensive way that is not an eye-sore. Thankfully and surprisingly using git rebase -i
was a very nice, intuitive learning process that wasn't painful at all.
from react-native-ble.
Its a beta release, you have to ask for it by name to get it. I THOUGHT you had to ask with the beta version but apparently not?
from react-native-ble.
Oh okay. So were you able to test my new change with the Bluetooth state?
from react-native-ble.
Ive was fighting NPM. Your new code is released as
npm i [email protected]
Im not sure what changed as it was overwritten, but note in you're not using the typical noble pattern of waiting for a state event, you're forcing it by checking the noble.state and scanning based on that -- because were still losing the state
https://gist.github.com/rclai/104ffcd953ecfe6bad18b21fc0536f1b#file-react-native-ble-test-index-ios-js-L36
from react-native-ble.
There's no way of guaranteeing that the Bluetooth state is poweredOn
even though my iPhone says that Bluetooth is on, that's why I'm doing that. I believe this is an iOS bug and the only way to fix it is to toggle the Bluetooth button, and let the stateChange
event take care of it. I check the state on the init
function in order to always have the state, especially during Live Reload mode. Also, when you say we're still losing the state, are you implying that you had the state and then all of a sudden it gets lost later? How does that happen?
How would you suggest I handle this?
from react-native-ble.
Agreed. Thats why the noble pattern is to just wait until you get that
first onstatechange event
Heres my patched branch, this hack is what will have to do.
https://github.com/jacobrosenthal/react-native-ble/blob/1.0.3/bindings.ios.js#L137
I also pulled out the peripheral stuff. We should start a
react-native-bleno for that in order to stay true to node
On Wed, Apr 27, 2016 at 10:50 PM, Richard Lai [email protected]
wrote:
There's no way of guaranteeing that the Bluetooth state is poweredOn even
though my iPhone says that Bluetooth is on, that's why I'm doing that. I
check the state on the init function in order to always have the state,
especially during Live Reload mode.—
You are receiving this because you commented.
Reply to this email directly or view it on GitHub
#4 (comment)
from react-native-ble.
Oh yeah, I was about to take out the peripheral stuff after noticing that since I'm depending on noble
, that stuff was going to break. I'm actually working on removing that stuff from my PR.
from react-native-ble.
Okay I updated my PR and the peripheral stuff is no longer there.
from react-native-ble.
Is it necessary to put a setTimeout
to getState
? I think the issue of the state being unknown
may still arise. I'm sure I've tried that and the only way to fix it was to just toggle the Bluetooth button, go figure.
from react-native-ble.
Were trying to be like noble, and I dont believe noble guarantees has a known state on startup. It asks you to wait for an onchange event. Our problem has been were always missing that event, hence my final terrible hack.
You dont have to update, Ill used my patched fork, itll maintain all your authorship.
from react-native-ble.
Cool, I see you updated your example. Did it all work?
from react-native-ble.
Yep. Havent used it super thoroughly but looks good. Nobody else tested
anything yet?
On Thu, Apr 28, 2016 at 8:11 AM, Richard Lai [email protected]
wrote:
Cool, I see you update your example. Did it all work?
—
You are receiving this because you commented.
Reply to this email directly or view it on GitHub
#4 (comment)
from react-native-ble.
Well with no other feedback the few tests Ive run work well. Good job and thanks @rclai . Published it as 1.0.3 (.3 because of my previous fighting with npm--dont ask)
from react-native-ble.
I'm also interested in peripheral support for react native
from react-native-ble.
Related Issues (20)
- noble.state is `unsupported` on evey other launch (iOS) HOT 2
- Build Fail with RN v .0.40.0 'sendDeviceEventWithName:body:' is deprecated
- ios simulator app crashing with react-native-ble library installed HOT 2
- Error with running App with react-native-ble on Android in debug mode HOT 3
- Unable to resolve module 'url' HOT 6
- Evaluate react-native-ble-plx native code HOT 4
- noble.on is not a function HOT 2
- sendDeviceEventWithName:body is deprecated
- noble characteristic write error : 'Invalid parameter not satisfying: data != nil'
- Cannot subscribe to multiple characteristics HOT 3
- Cannot read property 'getState' of undefined HOT 2
- discoverIncludedServices not implemented for Android
- Can't read descriptor value
- Can't get characteristics list of a service HOT 3
- Crash on iOS HOT 4
- Eddystone protocol
- Different UUID format when running in my RN app and directly from noble/example/advertisement.js HOT 5
- List of characteristics are empty in service HOT 1
- Use Polidea's BLE for android and iOS under the hood
- How to advertise?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-native-ble.