Giter Site home page Giter Site logo

ezefranca / fsk-arduino-ios Goto Github PK

View Code? Open in Web Editor NEW
81.0 9.0 14.0 468 KB

〰️ FSK Library for iOS interface with Arduino Development

License: MIT License

Objective-C 52.06% C++ 29.05% Objective-C++ 17.51% Ruby 0.83% Arduino 0.55%
fsk fsk-arduino-ios arduino-library ios waveform cocoapods pod

fsk-arduino-ios's Introduction

FSK-Arduino-iOS

Build Status Badge w/ Version Badge w/ Platform wercker status

Dependencies for iOS Development, using Sofmodem Arduino library, with FSK communication.

imagem

=====

How to use

This libraries have a propouse work with an Arduino using a Sofmodem Shield* to communicate with iOS using FSK. Currently, the source code of the SoftModem is not made as a framework. If you want to use SoftModem in your project, you have two ways:

Adding FSK-Arduino-iOS to your project

CocoaPods

CocoaPods is the recommended way to add FSK-Arduino-iOS to your project.

  1. Add a pod entry for FSK-Arduino-iOS to your Podfile pod 'FSK-Arduino-iOS', '~> 0.0.2'
  2. Install the pod(s) by running pod install.

Source files

Alternatively you can directly adding source files to your project.

  1. Download the latest code version or add the repository as a git submodule to your git-tracked project.
  2. The Folder /FSK must be copied from the source code of your project. The following is the list of source code related to FSK. Please copy these to the project source code.
* AudioQueueObject.h
* AudioQueueObject.m
* AudioSignalAnalyzer.h
* AudioSignalAnalyzer.m
* AudioSignalGenerator.h
* AudioSignalGenerator.m
* CharReceiver.h
* FSKModemConfig.h
* FSKByteQueue.h
* FSKRecognizer.h
* FSKRecognizer.mm
* FSKSerialGenerator.h
* FSKSerialGenerator.m
* lockfree.h
* MultiDelegate.h
* MultiDelegate.m
* PatternRecognizer.h

SoftModem uses the following two framework for audio input and output. Please add them to your project.

Image

* AudioToolbox.framework
* AVFoundation.framework

Initialization

First, set the category of application with AVAudioSession class. To do voice recording and playback, AVAudioSessionCategoryPlayAndRecord need to be set.

AVAudioSession *session = [AVAudioSession sharedInstance];   
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(interruption:) name:
AVAudioSessionInterruptionNotification object:nil];

[session setCategory:AVAudioSessionCategoryPlayAndRecord error:nil];
[session setCategory:AVAudioSessionCategoryPlayback error:nil];
[session setActive:YES error:nil];

interruption selector method

- (void) interruption:(NSNotification*)notification
{
    NSDictionary *interuptionDict = notification.userInfo;
    NSUInteger interuptionType = (NSUInteger)[interuptionDict valueForKey:AVAudioSessionInterruptionTypeKey];
    
    if (interuptionType == AVAudioSessionInterruptionTypeBegan)
        [self beginInterruption];
# if __CC_PLATFORM_IOS >= 40000
    else if (interuptionType == AVAudioSessionInterruptionTypeEnded)
        [self endInterruptionWithFlags:(NSUInteger)[interuptionDict valueForKey:AVAudioSessionInterruptionOptionKey]];
# else
    else if (interuptionType == AVAudioSessionInterruptionTypeEnded)
        [self endInterruption];
# endif
}

Next, for analysis of the voice, make instance of class AudioSignalAnalyzer, FSKRecognizer and AudioSignalAnalyzer parses the input waveform from the microphone to detect the falling and rising edge of the waveform. FSKRecognizer restores the data bits based on the results of the analysis of AudioSignalAnalyzer.

        recognizer = [[FSKRecognizer alloc] init];     
        [recognizer addReceiver:self];
        analyzer = [[AudioSignalAnalyzer alloc] init]; 
        [analyzer addRecognizer:recognizer];

Then create an instance of a class FSKSerialGenerator for sound output. FSKSerialGenerator converts the data bits to audio signal and output.

        generator = [[FSKSerialGenerator alloc] init]; 
        [generator play];

Receiving

Register the class that implements the CharReceiver protocol to the FSKRecognizer class, and AVAudioSessionDelegate.

@interface YourClass : NSObject <AVAudioSessionDelegate, CharReceiver>

Register FSKRecognizer class at initialization.

YourClass *yourClassInstance;
[recognizer addReceiver: yourClassInstance];

receivedChar: method is called when one byte of data is received.

- (void) receivedChar: (char) input
{
     // Receive handling
}

Sending

Sending data is much easier than receiving data. FSKSerialGenerator class's writeByte: method to sends a single byte.

[generator writeByte: 0xff];

Links and Credits

arms22 - Creator of Softmodem hardware, libraries for Arduino and ARC version lib for iOS.

Arduino Libraries

iOS 4/5 ARC version

FSK Wikipedia

FSK Explanation

License

This code is distributed under the terms and conditions of the MIT license.

fsk-arduino-ios's People

Contributors

bryant1410 avatar ezefranca avatar readmecritic avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fsk-arduino-ios's Issues

[MultiDelegate receivedChar:]: unrecognized selector sent to instance

When I try to use this fsk library sometimes I got this error message. FSKRecognizer.mm file has this function. I don't understand what is the problem. In my project I did not use microphone yet. Just install this library for future. But sometimes it crashes with this message. Can you help me?

Change delegate method

Possible [receivedChar:input] should be changed to receivedData with whole piece of input data
This will significantly increase performance on big data chunks

I can not receive data.

Hi Ezequiel,

I'm sorry to disturb you.

I can send data(I can hear the sound).

But, the data can not be received. I have no idea if I do something wrong.

Could you help me to check what is going on?

Thank you so much.

Generator stops working when minimizing app

Thanks a lot for sharing this project – it's the basis of an iOS app I've written for my research project:

http://spin.media.mit.edu/

I have noticed that the audio generation is inconsistent. Specifically, if someone returns to the homescreen and then re-opens the app, it seems like the audio generation doesn't work. Do you have any ideas about how to fix this?

Please add "[analyzer record]" to README.

Thank you for the grate library!
However, I have a trouble when I catch the signals in iPhone.

[analyzer record]
is a key command to start catching the signals.
Please write this command in README for a beginner like me.

CocoaPods error

I'm using CocoaPods 0.39.0.rc.1
Now, when i try to build installed FSK packet, Xcode (7.0) gives me an error.
Undefined symbols for architecture arm64:
"OBJC_CLASS$_FSKRecognizer", referenced from:
type metadata accessor for ObjectiveC.FSKRecognizer in FSKDataManager.o
"OBJC_CLASS$_FSKSerialGenerator", referenced from:
type metadata accessor for ObjectiveC.FSKSerialGenerator in FSKDataManager.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I've checked build phases list.
Necessary sources are missed.
I guess they should be added, and probably minor refactoring (names) should be done too.

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.