-
Notifications
You must be signed in to change notification settings - Fork 94
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
onDataReceived not woking ! #154
Comments
First of all, you should take a look at the documentation and the sample application. You don't need Yes, it's in the doc: And the sample application: You're doing a lot of extra addition of subscriptions. The only code you really nead:
You may want to play with this function based on the documentation and sample app (above). |
If you get things working and you find bugs, please re-open the ticket providing all the information that I've requested in the template:
Good luck. |
this.onReceivedData is still not getting called when device send the data, I can see Received 417 bytes from device is been log but no JS method get called. Can You please suggest me the process i waking with function components, examples r in class based. |
All I can do is reference your code to the sample application code and compare it, which you can also do (I've provided the links). Unless you can provide debugging information (either JS or Native, whichever you believe the problem to be) there isn't much I can do. If you want to post your full repository I can try (at some point, but not any time soon - like really not any time soon) to clone and reproduce the issue.
You really need to provide substantially more information if you want any form of assistance. |
` static async connectDevice(id: string) {
} static onReceivedData = (data: any) => {
I can see
After that noting being loge; |
If you're seeing the log, the next step is to start debugging it on that line and see what happens when it attempts to send data. |
Is their any other way around to directly send the data to JS method
// I can see my data here want to directly emit and event to custom event listener?
` |
There are two ways to receive data:
There are no other ways. If you're doing one of those and you're not getting data, then until you can show me otherwise I assume your data is invalid:
or you're attempting to do both manual and listener reads and that will just mess things up. You cannot add any other custom listeners, you can only add the |
The line you want to debug is
If this doesn't return data, then it won't send anything to the Javascript side.
Now I admit, it's not done in the best way, the delimited messsages should be put into a QUEUE based on the incoming messages and that queue should be read from, instead of performing the buffer read each time. But regardless of that you should be able to read data. |
AS you can see the log "DATA mBuffer " + mBuffer.toString()); It is giving me Object that i am expecting data,, |
That's good, you're getting a String representation of a JSON object. The default delimiter is
If your JSON data does not end with a Can you confirm that you:
|
Just Now i Comminted
AND directly send the data And i {data , device, timestamp} SO do i need to do this way? |
I don't think you understand what a delimiter is. The point of
which will return 2 messages to the application:
Do you see how the messages are delimited by the What you're doing is bipassing the delimiter and just sending the full message. The problem with this, is based on your messaging it is possible that a message is bigger than the amount of data read. This means that you might get partial messages in your application. At this point in time there is no logic to handle EMPTY/NULL delimiters, which might be a handy option? I don't know. You have two options:
Your call, but the library is working as it's intended too and this isn't a bug (per say). |
As You suggested i made the changes? Yet not
Not working |
Like I said, you need to debug the Android code to see why the Your latest change look good in terms of:
But I cannot debug the |
Can you please point out some of the cases in which in my case i can send the new message with as if now |
You cant read the code for yourself to find that out? The line will be null when there is no delimiter found in the buffer. It's pretty straight forward. You need to send a delimiter so it knows when a full message has been sent. That's how that works. You can write your own device connection to do what you want. I wrote it to be generic and extendable. I'm not sure why the \n is breaking your json parsing, but why not just remove it before json parsing? I chose to keep it in there because I needed the delimiter. If you don't, remove it in the listener. But it must be in the data from the device. I don't know. What to tell you at this point. |
Actually. Looking at the ios code it looks like the delimiter isn't included. So ya, this could be a bug on Android, but again most of the time a \n delimiter shouldn't break that much. I'll fix 5he issue when I get a chance with #152 Regardless. You should send in the \n to make it work. Then chop it off before calling JSON.parse() on the react side. |
my Point is i can Send data with **Really appreciate your support Bro a big thanks for your replies ** |
You don't need to send (react native to device) the \n delimiter. As long as it know how to handle the messages. If you don't control the device code, and cannot add the delimiter, then you cannot use the Delimited String connection (as that's the whole point). This means you have a few options.
What device is this that you use? I need more info before I make a change that I feel is not right. I see both pros and cons for a null/blank delimiter. |
This plugin is used with ionic angular communication with same device-- https://www.npmjs.com/package/cordova-plugin-bluetooth-serial |
The code you posted doesnt' make any sense. There has to be a delimiter or else Why can't I ass the delimiter? I don't understand your question? |
you asked me this two question. What device is this that you use? -- IT's a Biomatric device which sends the data attendance data using Bluetooth in a string OBJECT
IN that case how i am able to receive all data which device is sending... without any issue ?? For Connection with device -------------------------
For Receiving data from device
can see the full code |
I have no idea how you're reading data, I can only read the library code that you posted and it's doing exactly the same thing that this is doing. If there is no delimiter found then it will return a I'm looking at the full code: The original method you posted requires a
When the read happens it:
Looking at the options:
What exactly are you providing in the Cordova app as a string delimiter?
However arguments work in Cordova, it's the first argument. |
Oh I see,
which seems like an odd way to do things. I've created a branch if you take the code from
I will pull it and release it. |
Sure Bro I am doing it now ... a special thanks to you ones more...👍 |
it will be count |
2021-12-02 21:04:08.734 20475-20587/com.reactnativeultimatestarter D/DelimitedStringDeviceConnectionImpl: Received 423 bytes from device AC:67:B2:40:48:E2 yet
not gating called |
and working with adding this |
Using the delimiter of With the changes made, and using this code:
Does it not send the full content? |
It also won't work with the latest change where I'm dropping the delimiter.
Which is now matching IOS but would blow up what you are doing. |
Yes Your are write.. i just did this for testing.. and check its work or not.. so that i will be sure about the issue.. Send regular (delimiter) I've created a branch task/blank-delimiter-messages which I don't have time to test. if you take the code from DelimitedStringDeviceConnectionImpl and put it into your local file and:` IF you can make this working it will add more user to use this plugin without any knowledge of delimiter. |
Yes, but the point is device can sent data with or without any delimiter and code should work in both the case |
I would fully agree, if the logic wasn't contained in something called I'm not against having an EMPTY delimiter (now that we've discussed it more), since it's something you'd have to configure manually during the connection process, and shouldn't affect anyone who is already using the library with an actual delimiter. |
I won't be adding the same functionality of
as that makes no sense to me. But what I will try to get working is:
Since it will require the developer to be cognizant that their device does NOT send a delimiter and they are aware that they need to handle the data themselves:
I think this will work for all parties. |
Last byte of data gating lost. |
Sorry, your messages don't make much sense (language barrier I'm sure). You're connecting with:
The device is sending:
And you're only receiving:
Or are you still using the |
Yes But latest bulid its seemas to be solved.. i got full JSON object . |
Ya, that makes sense..
Let me update it so that it checks that |
|
Dammit, brackets!! Sorry, I'm making these changes while trying to get something else working. |
Its total fine Bro... still gating this one --- |
Ugh, I'm thinking |
|
Yes, already updated
|
GOOD NEWS 😊 Now working as expected... Thanks Bro!.. will this changes will be available on main branch as will ? after some time ? |
If you can do me a favor and just check that the original functionality works. If you do that for me, I'll merge and publish it now. I really have to find time to write some unit tests. |
I have just tested it with |
Welp, here's hoping. Merged and publishing to NPM. Hopefully this doesn't break a bunch of peoples work! |
onDataReceived how to Received data from device, can help me i want to received data in my serve file.
I able to connect to device, also write to device but not able to received data from device.
Current code IS ====
The text was updated successfully, but these errors were encountered: