quiet / QuietModemKit

iOS framework for the Quiet Modem (data over sound)
BSD 3-Clause "New" or "Revised" License
451 stars 50 forks source link

Library not working? #5

Closed arctouch-pedrocosta closed 7 years ago

arctouch-pedrocosta commented 7 years ago

Hello, I tried to create a small project with this library, I did setup two versions of the app one for receiver and another for the transmitter. I installed in two devices running iOS 10 and I never got a callback in the receiver end even though no crashes or errors were reported in the transmitter app.

Can you help?

brian-armstrong commented 7 years ago

Hi @arctouch-pedrocosta,

Which profile are you using? Approximately how far apart are the phones?

arctouch-pedrocosta commented 7 years ago

Hello @brian-armstrong the phones are almost touching each other.

I'm using the sample code you provided so I imagine the profile is the standard one.

brian-armstrong commented 7 years ago

That profile should be the best one, but it is hard to hear. I'd recommend temporarily switching to the "audible" profile and making sure that you can hear the transmitter. Once you have let me know and I'll think of other possibilities

arctouch-pedrocosta commented 7 years ago

ok, testing "audible" I get a EXC_BAD_ACCESS at line 84 on the encoder.c file.

arctouch-pedrocosta commented 7 years ago

I think it's important to mention that I'm using latest Xcode and Swift

brian-armstrong commented 7 years ago

I'll take a look when I get home later. When you get that error it's because it can't find the profile with that name. I will retest my code with that profile name. Also if you get a chance to share your project that would be helpful for me to reproduce the error

arctouch-pedrocosta commented 7 years ago

Hello @brian-armstrong I uploaded the code here (personal account): https://github.com/pedrovanrooij/UltrasonicConversation let me know if you find any mistakes in my code.

One thing I noticed is that in the TransmitterViewController in line 21 I do have a configuration, but once I access the init for the transmitter the configuration is nil.

arctouch-pedrocosta commented 7 years ago

Hello @brian-armstrong any progress on this issue? Thank you

brian-armstrong commented 7 years ago

I haven't had a chance to look yet, was planning on looking tonight.

I'm quite surprised that switching to audible gives an error. Do any of the other keys (in quiet-profiles.json) give the same error?

arctouch-pedrocosta commented 7 years ago

yes, I tried "audible-7k-channel-0" and "audible" and both break at the same line in the encoder.c file.

Thank you for looking into it, let me know if you need any help solving the issue, I'm not an expert with this type of build but I could try to help anywhere I can.

brian-armstrong commented 7 years ago

Hi @arctouch-pedrocosta,

Thanks for sharing your project. I went ahead and cloned it. I'm running Xcode 8 and I'm able to change TransmitterViewController line 21 from "ultrasonic-experimental" to "audible" without a crash. Now I'm wondering if I shouldn't try updating and see if something fails. Still, I know roughly what causes the error you're seeing, and I know it happens in the C library QuietModemKit uses - which should be well below whatever Xcode/Swift could affect. So I'll be quite curious to see what is failing there.

There is for sure one bug here, which is that quiet doesn't fail gracefully if it doesn't like the profile name you give it, and you get the failure you're seeing. So at the very least I need to make it emit a more helpful error message when that happens.

And finally to address your original question, I tried your app with one copy running in the sim on a "6S" and the other running on my 5S. It works both ways, even from a few feet away. One thing I did run into was that I forgot to turn the mute switch to having sound on on my phone at first. With ultrasonic this is hard to notice, so just a heads up :)

Sorry that I couldn't reproduce your issue. I might try upgrading to Xcode 10 this weekend and see if anything notable breaks. Otherwise it looks like I should make the profile failure more explicit.

arctouch-pedrocosta commented 7 years ago

Hello @brian-armstrong thank you for looking into it.

I was able to make the project work with audible and ultrasonic, that was a mistake of mine since I didn't quite understand the concept of "key". I'm really sorry.

Given that, I was able to test the app but this type of communication seems to be very unreliable, I want to confirm with you your testing environment. In my case I test in a office with some background noise and for some reason some messages go through and most of them don't.

Digging a little deeper I saw that the method quiet_frame_receiver_callback inside your QMFrameReceiver gets called frequently and it's very hard for that execution to go past the line 31 which is [NSData dataWithBytes:d->recvBuffer length:written];. When it goes past that it calls the callback implemented by me.

My question here is more if it is indeed unreliable or there might be something wrong with my code. My ratio of message sent and received successfully is like 10%, I'm sending very small messages, smaller than "Hello, World". I hope this brings a interesting conversation, or if not, a fix to my current code.

PS: I updated the repo with the latest version of the framework.

Thank you,

Pedro

brian-armstrong commented 7 years ago

Glad you got some of it working!

I'd recommend trying the ultrasonic-experimental profile again if you haven't tested with it yet. It's slow, but it's by far the most reliable. It's also pretty high frequency which should put it out of the range of common ambient noise

arctouch-pedrocosta commented 7 years ago

I will give it a try this weekend. Thank you so much Brian! I'm closing this issue

brian-armstrong commented 7 years ago

Cool, let me know how it goes. Don't be afraid to open another issue if something goes wrong - there's still plenty that can be fixed with this library

brian-armstrong commented 7 years ago

@arctouch-pedrocosta Did you have better luck with it? Would love to know how your experience with Quiet was either way :)

arctouch-pedrocosta commented 7 years ago

Hello @brian-armstrong I did play a little bit more with it, in a open environment with people talking around me the success rate wasn't that great, I tested it using the "ultrasonic-experimental" profile.

One thing I did notice is that if I'm a very quiet environment I can actually hear the sound coming from the speakers once I send a message out, is this expected? I was wondering if it should indeed be ultrasonic. Lets keep talking, I find this topic very interesting.