TestsTested | ✗ |
LangLanguage | Obj-CObjective C |
License | MIT |
ReleasedLast Release | Dec 2014 |
Maintained by Ezequiel Franca.
Dependencies for iOS Development Non-ARC, using Sofmodem Arduino library, with FSK communication.
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, the source code related to the SoftModem must be copied from the source code of the SoftModemTerminal. The following is the list of source code related to SoftModem. 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.
* AudioToolbox.framework
* AVFoundation.framework
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];
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 data is much easier than receiving data. FSKSerialGenerator class's writeByte: method to sends a single byte.
[generator writeByte: 0xff];
arms22 - creator of Softmodem hardware, libraries for Arduino and ARC version lib for iOS.