├── Project.xcconfig ├── IRKit ├── IRKit.bundle │ ├── _CodeSignature │ │ ├── CodeSignature │ │ ├── CodeDirectory │ │ ├── CodeRequirements │ │ └── CodeRequirements-1 │ ├── Info.plist │ ├── IREditCell.nib │ ├── anime_01@2x.png │ ├── anime_02@2x.png │ ├── anime_03@2x.png │ ├── anime_04@2x.png │ ├── anime_05@2x.png │ ├── anime_06@2x.png │ ├── anime_07@2x.png │ ├── anime_08@2x.png │ ├── anime_09@2x.png │ ├── anime_10@2x.png │ ├── anime_11@2x.png │ ├── anime_12@2x.png │ ├── anime_13@2x.png │ ├── anime_14@2x.png │ ├── anime_15@2x.png │ ├── anime_16@2x.png │ ├── anime_17@2x.png │ ├── anime_18@2x.png │ ├── anime_19@2x.png │ ├── anime_20@2x.png │ ├── icn_signal.png │ ├── IRProgressView.nib │ ├── bg_progress@2x.png │ ├── icn_arrow@2x.png │ ├── icn_check2@2x.png │ ├── icn_device@2x.png │ ├── icn_signal@2x.png │ ├── img_remote3@2x.png │ ├── IRPeripheralCell.nib │ ├── icn_chart_01@2x.png │ ├── icn_chart_02@2x.png │ ├── img_powerup3@2x.png │ ├── IRFAQViewController.nib │ ├── icn_navibar_add@2x.png │ ├── icn_navibar_back@2x.png │ ├── icn_navibar_menu@2x.png │ ├── img_connect_01@2x.png │ ├── img_connect_02@2x.png │ ├── icn_navibar_camera@2x.png │ ├── icn_navibar_cancel@2x.png │ ├── img_connect_01_jp@2x.png │ ├── img_connect_02_jp@2x.png │ ├── en.lproj │ │ └── Localizable.strings │ ├── ja.lproj │ │ ├── Localizable.strings │ │ ├── IRGuideWifiViewController.nib │ │ ├── IRNewSignalScene1ViewController.nib │ │ ├── IRWifiEditViewController.strings │ │ ├── IRPeripheralNameEditViewController.strings │ │ ├── IRSignalNameEditViewController.strings │ │ └── IRGuidePowerViewController.strings │ ├── IRWifiSecuritySelectViewController.nib │ └── Base.lproj │ │ ├── IRGuideWifiViewController.nib │ │ ├── IRWifiEditViewController.nib │ │ ├── IRGuidePowerViewController.nib │ │ ├── IRSignalNameEditViewController.nib │ │ ├── IRNewSignalScene1ViewController.nib │ │ └── IRPeripheralNameEditViewController.nib ├── IRKitTests │ ├── en.lproj │ │ └── InfoPlist.strings │ ├── IRKitTests.h │ ├── IRKitTests-Prefix.pch │ ├── XCTestCase+Async.h │ ├── IRKitTests-Info.plist │ ├── IRKitTests.m │ ├── IRSignalTests.m │ ├── XCTestCase+Async.m │ ├── IRReachabilityTests.m │ ├── IRSignalsTests.m │ └── IRSignalSequenceTests.m ├── IRKitViewSamples │ ├── en.lproj │ │ └── InfoPlist.strings │ ├── ja.lproj │ │ ├── InfoPlist.strings │ │ └── MainStoryboard.strings │ ├── Default.png │ ├── Default@2x.png │ ├── Default-568h@2x.png │ ├── IRSamplesTableViewController.h │ ├── IRAppDelegate.h │ ├── main.m │ ├── IRKitViewSamples-Prefix.pch │ ├── IRKitViewSamples-Info.plist │ └── IRAppDelegate.m ├── IRKitResources │ ├── icn_add.png │ ├── anime_01@2x.png │ ├── anime_02@2x.png │ ├── anime_03@2x.png │ ├── anime_04@2x.png │ ├── anime_05@2x.png │ ├── anime_06@2x.png │ ├── anime_07@2x.png │ ├── anime_08@2x.png │ ├── anime_09@2x.png │ ├── anime_10@2x.png │ ├── anime_11@2x.png │ ├── anime_12@2x.png │ ├── anime_13@2x.png │ ├── anime_14@2x.png │ ├── anime_15@2x.png │ ├── anime_16@2x.png │ ├── anime_17@2x.png │ ├── anime_18@2x.png │ ├── anime_19@2x.png │ ├── anime_20@2x.png │ ├── icn_add@2x.png │ ├── icn_arrow@2x.png │ ├── icn_signal.png │ ├── bg_progress@2x.png │ ├── icn_check2@2x.png │ ├── icn_device@2x.png │ ├── icn_signal@2x.png │ ├── img_remote3@2x.png │ ├── icn_chart_01@2x.png │ ├── icn_chart_02@2x.png │ ├── img_connect_01@2x.png │ ├── img_connect_02@2x.png │ ├── img_powerup3@2x.png │ ├── icn_navibar_add@2x.png │ ├── icn_navibar_back@2x.png │ ├── icn_navibar_menu@2x.png │ ├── icn_tabbar_album@2x.png │ ├── icn_tabbar_icon@2x.png │ ├── icn_navibar_camera@2x.png │ ├── icn_navibar_cancel@2x.png │ ├── icn_tabbar_album_on@2x.png │ ├── icn_tabbar_icon_on@2x.png │ ├── img_connect_01_jp@2x.png │ ├── img_connect_02_jp@2x.png │ ├── en.lproj │ │ └── Localizable.strings │ ├── ja.lproj │ │ ├── Localizable.strings │ │ ├── IRWifiEditViewController.strings │ │ ├── IRSignalNameEditViewController.strings │ │ ├── IRPeripheralNameEditViewController.strings │ │ └── IRGuidePowerViewController.strings │ ├── IRFAQViewController.xib │ ├── IRKitResources-Info.plist │ ├── IRWifiSecuritySelectViewController.xib │ ├── IREditCell.xib │ ├── IRProgressView.xib │ └── IRPeripheralCell.xib └── IRKit │ ├── CRC8.h │ ├── IRKit-Prefix.pch │ ├── IREditCell.h │ ├── IRSignalSendOperationQueue.h │ ├── IRHTTPJSONOperation.h │ ├── IRKit+Internal.m │ ├── IRHTTPOperationQueue.h │ ├── IRSignalSendOperation.h │ ├── IREditCell.m │ ├── Log.m │ ├── IRReachability.h │ ├── IRUserDefaultsStore.h │ ├── IRHTTPClient+UIKit.h │ ├── IRPeripheralCell.h │ ├── IRKit+Internal.h │ ├── IRHelper.h │ ├── IRPersistentStore.h │ ├── IRSignalSequence.h │ ├── IRFAQViewController.h │ ├── IRViewHelper.h │ ├── IRGuidePowerViewController.h │ ├── IRProgressView.h │ ├── CRC8.m │ ├── IRPeripherals+UIKit.h │ ├── IRHTTPOperationQueue.m │ ├── IRNewSignalScene1ViewController.h │ ├── Log.h │ ├── IRSignalNameEditViewController.h │ ├── IRWifiSecuritySelectViewController.h │ ├── IRViewCustomizer.h │ ├── IRHTTPJSONOperation.m │ ├── IRNewSignalViewController.h │ ├── IRPeripheralNameEditViewController.h │ ├── IRWifiEditViewController.h │ ├── IRKit.h │ ├── IRKeys.h │ ├── IRSearcher.h │ ├── IRSignals.h │ ├── IRPeripherals.h │ ├── IRNewPeripheralViewController.h │ ├── IRGuideWifiViewController.h │ ├── IRHTTPClient+UIKit.m │ ├── IRPeripheral.h │ ├── IRUserDefaultsStore.m │ ├── IRSignalSendOperation.m │ ├── IRPeripherals+UIKit.m │ ├── IRConst.h │ ├── IRHTTPClient.h │ ├── IRSignalSendOperationQueue.m │ ├── IRFAQViewController.m │ ├── IRViewHelper.m │ ├── IRSignal.h │ ├── IRPeripheralCell.m │ ├── IRSignals.m │ ├── IRNewSignalViewController.m │ ├── IRHelper.m │ ├── IRNewSignalScene1ViewController.m │ ├── IRSignalNameEditViewController.m │ ├── IRGuidePowerViewController.m │ ├── IRPeripheralNameEditViewController.m │ ├── IRWifiSecuritySelectViewController.m │ ├── IRProgressView.m │ ├── IRKit.m │ ├── IRSignal.m │ ├── IRPeripherals.m │ ├── IRReachability.m │ └── IRSignalSequence.m ├── spec ├── .DS_Store └── diagrams │ ├── connect.png │ ├── send-ir-signal.png │ ├── README │ ├── learn-ir-signal.png │ ├── one-create-icon.png │ ├── Makefile │ ├── learn-ir-signal.msc │ ├── one-create-icon.msc │ ├── send-ir-signal.msc │ └── connect.msc ├── Minimal └── Minimal │ ├── en.lproj │ └── InfoPlist.strings │ ├── ja.lproj │ ├── InfoPlist.strings │ └── MainStoryboard.storyboard │ ├── Default.png │ ├── Default@2x.png │ ├── Default-568h@2x.png │ ├── Resources │ ├── icn_actionbar_menu.png │ └── icn_actionbar_menu@2x.png │ ├── MMAppDelegate.h │ ├── MMViewController.h │ ├── main.m │ ├── Log.m │ ├── MMSignalsDataSource.h │ ├── Minimal-Prefix.pch │ ├── Log.h │ ├── MMSignalsDataSource.m │ ├── Minimal-Info.plist │ ├── MMAppDelegate.m │ ├── MMViewController.m │ └── Base.lproj │ └── MainStoryboard.storyboard ├── .gitignore ├── IRKit.xcworkspace └── contents.xcworkspacedata ├── Podfile.lock ├── Contributing.md ├── podfile ├── LICENSE ├── IRKit.podspec └── README.md /Project.xcconfig: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /IRKit/IRKit.bundle/_CodeSignature/CodeSignature: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /spec/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/irkit/ios-sdk/HEAD/spec/.DS_Store -------------------------------------------------------------------------------- /IRKit/IRKitTests/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /Minimal/Minimal/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /Minimal/Minimal/ja.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /IRKit/IRKitViewSamples/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /IRKit/IRKitViewSamples/ja.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /Minimal/Minimal/Default.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/irkit/ios-sdk/HEAD/Minimal/Minimal/Default.png -------------------------------------------------------------------------------- /spec/diagrams/connect.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/irkit/ios-sdk/HEAD/spec/diagrams/connect.png -------------------------------------------------------------------------------- /IRKit/IRKit.bundle/Info.plist: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/irkit/ios-sdk/HEAD/IRKit/IRKit.bundle/Info.plist -------------------------------------------------------------------------------- /IRKit/IRKitResources/icn_add.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/irkit/ios-sdk/HEAD/IRKit/IRKitResources/icn_add.png -------------------------------------------------------------------------------- /Minimal/Minimal/Default@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/irkit/ios-sdk/HEAD/Minimal/Minimal/Default@2x.png -------------------------------------------------------------------------------- /spec/diagrams/send-ir-signal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/irkit/ios-sdk/HEAD/spec/diagrams/send-ir-signal.png -------------------------------------------------------------------------------- /IRKit/IRKit.bundle/IREditCell.nib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/irkit/ios-sdk/HEAD/IRKit/IRKit.bundle/IREditCell.nib -------------------------------------------------------------------------------- /IRKit/IRKit.bundle/anime_01@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/irkit/ios-sdk/HEAD/IRKit/IRKit.bundle/anime_01@2x.png -------------------------------------------------------------------------------- /IRKit/IRKit.bundle/anime_02@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/irkit/ios-sdk/HEAD/IRKit/IRKit.bundle/anime_02@2x.png -------------------------------------------------------------------------------- /IRKit/IRKit.bundle/anime_03@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/irkit/ios-sdk/HEAD/IRKit/IRKit.bundle/anime_03@2x.png -------------------------------------------------------------------------------- /IRKit/IRKit.bundle/anime_04@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/irkit/ios-sdk/HEAD/IRKit/IRKit.bundle/anime_04@2x.png -------------------------------------------------------------------------------- /IRKit/IRKit.bundle/anime_05@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/irkit/ios-sdk/HEAD/IRKit/IRKit.bundle/anime_05@2x.png -------------------------------------------------------------------------------- /IRKit/IRKit.bundle/anime_06@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/irkit/ios-sdk/HEAD/IRKit/IRKit.bundle/anime_06@2x.png -------------------------------------------------------------------------------- /IRKit/IRKit.bundle/anime_07@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/irkit/ios-sdk/HEAD/IRKit/IRKit.bundle/anime_07@2x.png -------------------------------------------------------------------------------- /IRKit/IRKit.bundle/anime_08@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/irkit/ios-sdk/HEAD/IRKit/IRKit.bundle/anime_08@2x.png -------------------------------------------------------------------------------- /IRKit/IRKit.bundle/anime_09@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/irkit/ios-sdk/HEAD/IRKit/IRKit.bundle/anime_09@2x.png -------------------------------------------------------------------------------- /IRKit/IRKit.bundle/anime_10@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/irkit/ios-sdk/HEAD/IRKit/IRKit.bundle/anime_10@2x.png -------------------------------------------------------------------------------- /IRKit/IRKit.bundle/anime_11@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/irkit/ios-sdk/HEAD/IRKit/IRKit.bundle/anime_11@2x.png -------------------------------------------------------------------------------- /IRKit/IRKit.bundle/anime_12@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/irkit/ios-sdk/HEAD/IRKit/IRKit.bundle/anime_12@2x.png -------------------------------------------------------------------------------- /IRKit/IRKit.bundle/anime_13@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/irkit/ios-sdk/HEAD/IRKit/IRKit.bundle/anime_13@2x.png -------------------------------------------------------------------------------- /IRKit/IRKit.bundle/anime_14@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/irkit/ios-sdk/HEAD/IRKit/IRKit.bundle/anime_14@2x.png -------------------------------------------------------------------------------- /IRKit/IRKit.bundle/anime_15@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/irkit/ios-sdk/HEAD/IRKit/IRKit.bundle/anime_15@2x.png -------------------------------------------------------------------------------- /IRKit/IRKit.bundle/anime_16@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/irkit/ios-sdk/HEAD/IRKit/IRKit.bundle/anime_16@2x.png -------------------------------------------------------------------------------- /IRKit/IRKit.bundle/anime_17@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/irkit/ios-sdk/HEAD/IRKit/IRKit.bundle/anime_17@2x.png -------------------------------------------------------------------------------- /IRKit/IRKit.bundle/anime_18@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/irkit/ios-sdk/HEAD/IRKit/IRKit.bundle/anime_18@2x.png -------------------------------------------------------------------------------- /IRKit/IRKit.bundle/anime_19@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/irkit/ios-sdk/HEAD/IRKit/IRKit.bundle/anime_19@2x.png -------------------------------------------------------------------------------- /IRKit/IRKit.bundle/anime_20@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/irkit/ios-sdk/HEAD/IRKit/IRKit.bundle/anime_20@2x.png -------------------------------------------------------------------------------- /IRKit/IRKit.bundle/icn_signal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/irkit/ios-sdk/HEAD/IRKit/IRKit.bundle/icn_signal.png -------------------------------------------------------------------------------- /IRKit/IRKitViewSamples/Default.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/irkit/ios-sdk/HEAD/IRKit/IRKitViewSamples/Default.png -------------------------------------------------------------------------------- /spec/diagrams/README: -------------------------------------------------------------------------------- 1 | use mscgen 2 | http://www.mcternan.me.uk/mscgen/index.html 3 | 4 | mscgen -T png -i *.msc 5 | -------------------------------------------------------------------------------- /spec/diagrams/learn-ir-signal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/irkit/ios-sdk/HEAD/spec/diagrams/learn-ir-signal.png -------------------------------------------------------------------------------- /spec/diagrams/one-create-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/irkit/ios-sdk/HEAD/spec/diagrams/one-create-icon.png -------------------------------------------------------------------------------- /IRKit/IRKit.bundle/IRProgressView.nib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/irkit/ios-sdk/HEAD/IRKit/IRKit.bundle/IRProgressView.nib -------------------------------------------------------------------------------- /IRKit/IRKit.bundle/bg_progress@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/irkit/ios-sdk/HEAD/IRKit/IRKit.bundle/bg_progress@2x.png -------------------------------------------------------------------------------- /IRKit/IRKit.bundle/icn_arrow@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/irkit/ios-sdk/HEAD/IRKit/IRKit.bundle/icn_arrow@2x.png -------------------------------------------------------------------------------- /IRKit/IRKit.bundle/icn_check2@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/irkit/ios-sdk/HEAD/IRKit/IRKit.bundle/icn_check2@2x.png -------------------------------------------------------------------------------- /IRKit/IRKit.bundle/icn_device@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/irkit/ios-sdk/HEAD/IRKit/IRKit.bundle/icn_device@2x.png -------------------------------------------------------------------------------- /IRKit/IRKit.bundle/icn_signal@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/irkit/ios-sdk/HEAD/IRKit/IRKit.bundle/icn_signal@2x.png -------------------------------------------------------------------------------- /IRKit/IRKit.bundle/img_remote3@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/irkit/ios-sdk/HEAD/IRKit/IRKit.bundle/img_remote3@2x.png -------------------------------------------------------------------------------- /IRKit/IRKitResources/anime_01@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/irkit/ios-sdk/HEAD/IRKit/IRKitResources/anime_01@2x.png -------------------------------------------------------------------------------- /IRKit/IRKitResources/anime_02@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/irkit/ios-sdk/HEAD/IRKit/IRKitResources/anime_02@2x.png -------------------------------------------------------------------------------- /IRKit/IRKitResources/anime_03@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/irkit/ios-sdk/HEAD/IRKit/IRKitResources/anime_03@2x.png -------------------------------------------------------------------------------- /IRKit/IRKitResources/anime_04@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/irkit/ios-sdk/HEAD/IRKit/IRKitResources/anime_04@2x.png -------------------------------------------------------------------------------- /IRKit/IRKitResources/anime_05@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/irkit/ios-sdk/HEAD/IRKit/IRKitResources/anime_05@2x.png -------------------------------------------------------------------------------- /IRKit/IRKitResources/anime_06@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/irkit/ios-sdk/HEAD/IRKit/IRKitResources/anime_06@2x.png -------------------------------------------------------------------------------- /IRKit/IRKitResources/anime_07@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/irkit/ios-sdk/HEAD/IRKit/IRKitResources/anime_07@2x.png -------------------------------------------------------------------------------- /IRKit/IRKitResources/anime_08@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/irkit/ios-sdk/HEAD/IRKit/IRKitResources/anime_08@2x.png -------------------------------------------------------------------------------- /IRKit/IRKitResources/anime_09@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/irkit/ios-sdk/HEAD/IRKit/IRKitResources/anime_09@2x.png -------------------------------------------------------------------------------- /IRKit/IRKitResources/anime_10@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/irkit/ios-sdk/HEAD/IRKit/IRKitResources/anime_10@2x.png -------------------------------------------------------------------------------- /IRKit/IRKitResources/anime_11@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/irkit/ios-sdk/HEAD/IRKit/IRKitResources/anime_11@2x.png -------------------------------------------------------------------------------- /IRKit/IRKitResources/anime_12@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/irkit/ios-sdk/HEAD/IRKit/IRKitResources/anime_12@2x.png -------------------------------------------------------------------------------- /IRKit/IRKitResources/anime_13@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/irkit/ios-sdk/HEAD/IRKit/IRKitResources/anime_13@2x.png -------------------------------------------------------------------------------- /IRKit/IRKitResources/anime_14@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/irkit/ios-sdk/HEAD/IRKit/IRKitResources/anime_14@2x.png -------------------------------------------------------------------------------- /IRKit/IRKitResources/anime_15@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/irkit/ios-sdk/HEAD/IRKit/IRKitResources/anime_15@2x.png -------------------------------------------------------------------------------- /IRKit/IRKitResources/anime_16@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/irkit/ios-sdk/HEAD/IRKit/IRKitResources/anime_16@2x.png -------------------------------------------------------------------------------- /IRKit/IRKitResources/anime_17@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/irkit/ios-sdk/HEAD/IRKit/IRKitResources/anime_17@2x.png -------------------------------------------------------------------------------- /IRKit/IRKitResources/anime_18@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/irkit/ios-sdk/HEAD/IRKit/IRKitResources/anime_18@2x.png -------------------------------------------------------------------------------- /IRKit/IRKitResources/anime_19@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/irkit/ios-sdk/HEAD/IRKit/IRKitResources/anime_19@2x.png -------------------------------------------------------------------------------- /IRKit/IRKitResources/anime_20@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/irkit/ios-sdk/HEAD/IRKit/IRKitResources/anime_20@2x.png -------------------------------------------------------------------------------- /IRKit/IRKitResources/icn_add@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/irkit/ios-sdk/HEAD/IRKit/IRKitResources/icn_add@2x.png -------------------------------------------------------------------------------- /IRKit/IRKitResources/icn_arrow@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/irkit/ios-sdk/HEAD/IRKit/IRKitResources/icn_arrow@2x.png -------------------------------------------------------------------------------- /IRKit/IRKitResources/icn_signal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/irkit/ios-sdk/HEAD/IRKit/IRKitResources/icn_signal.png -------------------------------------------------------------------------------- /IRKit/IRKitViewSamples/Default@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/irkit/ios-sdk/HEAD/IRKit/IRKitViewSamples/Default@2x.png -------------------------------------------------------------------------------- /Minimal/Minimal/Default-568h@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/irkit/ios-sdk/HEAD/Minimal/Minimal/Default-568h@2x.png -------------------------------------------------------------------------------- /IRKit/IRKit.bundle/IRPeripheralCell.nib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/irkit/ios-sdk/HEAD/IRKit/IRKit.bundle/IRPeripheralCell.nib -------------------------------------------------------------------------------- /IRKit/IRKit.bundle/icn_chart_01@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/irkit/ios-sdk/HEAD/IRKit/IRKit.bundle/icn_chart_01@2x.png -------------------------------------------------------------------------------- /IRKit/IRKit.bundle/icn_chart_02@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/irkit/ios-sdk/HEAD/IRKit/IRKit.bundle/icn_chart_02@2x.png -------------------------------------------------------------------------------- /IRKit/IRKit.bundle/img_powerup3@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/irkit/ios-sdk/HEAD/IRKit/IRKit.bundle/img_powerup3@2x.png -------------------------------------------------------------------------------- /IRKit/IRKit/CRC8.h: -------------------------------------------------------------------------------- 1 | @interface CRC8 : NSObject 2 | 3 | + (uint8_t)crc8:(uint8_t *)data size: (uint16_t)size; 4 | 5 | @end 6 | -------------------------------------------------------------------------------- /IRKit/IRKitResources/bg_progress@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/irkit/ios-sdk/HEAD/IRKit/IRKitResources/bg_progress@2x.png -------------------------------------------------------------------------------- /IRKit/IRKitResources/icn_check2@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/irkit/ios-sdk/HEAD/IRKit/IRKitResources/icn_check2@2x.png -------------------------------------------------------------------------------- /IRKit/IRKitResources/icn_device@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/irkit/ios-sdk/HEAD/IRKit/IRKitResources/icn_device@2x.png -------------------------------------------------------------------------------- /IRKit/IRKitResources/icn_signal@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/irkit/ios-sdk/HEAD/IRKit/IRKitResources/icn_signal@2x.png -------------------------------------------------------------------------------- /IRKit/IRKitResources/img_remote3@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/irkit/ios-sdk/HEAD/IRKit/IRKitResources/img_remote3@2x.png -------------------------------------------------------------------------------- /IRKit/IRKit.bundle/IRFAQViewController.nib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/irkit/ios-sdk/HEAD/IRKit/IRKit.bundle/IRFAQViewController.nib -------------------------------------------------------------------------------- /IRKit/IRKit.bundle/icn_navibar_add@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/irkit/ios-sdk/HEAD/IRKit/IRKit.bundle/icn_navibar_add@2x.png -------------------------------------------------------------------------------- /IRKit/IRKit.bundle/icn_navibar_back@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/irkit/ios-sdk/HEAD/IRKit/IRKit.bundle/icn_navibar_back@2x.png -------------------------------------------------------------------------------- /IRKit/IRKit.bundle/icn_navibar_menu@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/irkit/ios-sdk/HEAD/IRKit/IRKit.bundle/icn_navibar_menu@2x.png -------------------------------------------------------------------------------- /IRKit/IRKit.bundle/img_connect_01@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/irkit/ios-sdk/HEAD/IRKit/IRKit.bundle/img_connect_01@2x.png -------------------------------------------------------------------------------- /IRKit/IRKit.bundle/img_connect_02@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/irkit/ios-sdk/HEAD/IRKit/IRKit.bundle/img_connect_02@2x.png -------------------------------------------------------------------------------- /IRKit/IRKitResources/icn_chart_01@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/irkit/ios-sdk/HEAD/IRKit/IRKitResources/icn_chart_01@2x.png -------------------------------------------------------------------------------- /IRKit/IRKitResources/icn_chart_02@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/irkit/ios-sdk/HEAD/IRKit/IRKitResources/icn_chart_02@2x.png -------------------------------------------------------------------------------- /IRKit/IRKitResources/img_connect_01@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/irkit/ios-sdk/HEAD/IRKit/IRKitResources/img_connect_01@2x.png -------------------------------------------------------------------------------- /IRKit/IRKitResources/img_connect_02@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/irkit/ios-sdk/HEAD/IRKit/IRKitResources/img_connect_02@2x.png -------------------------------------------------------------------------------- /IRKit/IRKitResources/img_powerup3@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/irkit/ios-sdk/HEAD/IRKit/IRKitResources/img_powerup3@2x.png -------------------------------------------------------------------------------- /IRKit/IRKitViewSamples/Default-568h@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/irkit/ios-sdk/HEAD/IRKit/IRKitViewSamples/Default-568h@2x.png -------------------------------------------------------------------------------- /IRKit/IRKit.bundle/icn_navibar_camera@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/irkit/ios-sdk/HEAD/IRKit/IRKit.bundle/icn_navibar_camera@2x.png -------------------------------------------------------------------------------- /IRKit/IRKit.bundle/icn_navibar_cancel@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/irkit/ios-sdk/HEAD/IRKit/IRKit.bundle/icn_navibar_cancel@2x.png -------------------------------------------------------------------------------- /IRKit/IRKit.bundle/img_connect_01_jp@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/irkit/ios-sdk/HEAD/IRKit/IRKit.bundle/img_connect_01_jp@2x.png -------------------------------------------------------------------------------- /IRKit/IRKit.bundle/img_connect_02_jp@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/irkit/ios-sdk/HEAD/IRKit/IRKit.bundle/img_connect_02_jp@2x.png -------------------------------------------------------------------------------- /IRKit/IRKitResources/icn_navibar_add@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/irkit/ios-sdk/HEAD/IRKit/IRKitResources/icn_navibar_add@2x.png -------------------------------------------------------------------------------- /IRKit/IRKitResources/icn_navibar_back@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/irkit/ios-sdk/HEAD/IRKit/IRKitResources/icn_navibar_back@2x.png -------------------------------------------------------------------------------- /IRKit/IRKitResources/icn_navibar_menu@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/irkit/ios-sdk/HEAD/IRKit/IRKitResources/icn_navibar_menu@2x.png -------------------------------------------------------------------------------- /IRKit/IRKitResources/icn_tabbar_album@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/irkit/ios-sdk/HEAD/IRKit/IRKitResources/icn_tabbar_album@2x.png -------------------------------------------------------------------------------- /IRKit/IRKitResources/icn_tabbar_icon@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/irkit/ios-sdk/HEAD/IRKit/IRKitResources/icn_tabbar_icon@2x.png -------------------------------------------------------------------------------- /IRKit/IRKit.bundle/_CodeSignature/CodeDirectory: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/irkit/ios-sdk/HEAD/IRKit/IRKit.bundle/_CodeSignature/CodeDirectory -------------------------------------------------------------------------------- /IRKit/IRKit.bundle/en.lproj/Localizable.strings: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/irkit/ios-sdk/HEAD/IRKit/IRKit.bundle/en.lproj/Localizable.strings -------------------------------------------------------------------------------- /IRKit/IRKit.bundle/ja.lproj/Localizable.strings: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/irkit/ios-sdk/HEAD/IRKit/IRKit.bundle/ja.lproj/Localizable.strings -------------------------------------------------------------------------------- /IRKit/IRKitResources/icn_navibar_camera@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/irkit/ios-sdk/HEAD/IRKit/IRKitResources/icn_navibar_camera@2x.png -------------------------------------------------------------------------------- /IRKit/IRKitResources/icn_navibar_cancel@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/irkit/ios-sdk/HEAD/IRKit/IRKitResources/icn_navibar_cancel@2x.png -------------------------------------------------------------------------------- /IRKit/IRKitResources/icn_tabbar_album_on@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/irkit/ios-sdk/HEAD/IRKit/IRKitResources/icn_tabbar_album_on@2x.png -------------------------------------------------------------------------------- /IRKit/IRKitResources/icn_tabbar_icon_on@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/irkit/ios-sdk/HEAD/IRKit/IRKitResources/icn_tabbar_icon_on@2x.png -------------------------------------------------------------------------------- /IRKit/IRKitResources/img_connect_01_jp@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/irkit/ios-sdk/HEAD/IRKit/IRKitResources/img_connect_01_jp@2x.png -------------------------------------------------------------------------------- /IRKit/IRKitResources/img_connect_02_jp@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/irkit/ios-sdk/HEAD/IRKit/IRKitResources/img_connect_02_jp@2x.png -------------------------------------------------------------------------------- /IRKit/IRKitResources/en.lproj/Localizable.strings: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/irkit/ios-sdk/HEAD/IRKit/IRKitResources/en.lproj/Localizable.strings -------------------------------------------------------------------------------- /IRKit/IRKitResources/ja.lproj/Localizable.strings: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/irkit/ios-sdk/HEAD/IRKit/IRKitResources/ja.lproj/Localizable.strings -------------------------------------------------------------------------------- /Minimal/Minimal/Resources/icn_actionbar_menu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/irkit/ios-sdk/HEAD/Minimal/Minimal/Resources/icn_actionbar_menu.png -------------------------------------------------------------------------------- /IRKit/IRKit.bundle/_CodeSignature/CodeRequirements: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/irkit/ios-sdk/HEAD/IRKit/IRKit.bundle/_CodeSignature/CodeRequirements -------------------------------------------------------------------------------- /IRKit/IRKit.bundle/_CodeSignature/CodeRequirements-1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/irkit/ios-sdk/HEAD/IRKit/IRKit.bundle/_CodeSignature/CodeRequirements-1 -------------------------------------------------------------------------------- /Minimal/Minimal/Resources/icn_actionbar_menu@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/irkit/ios-sdk/HEAD/Minimal/Minimal/Resources/icn_actionbar_menu@2x.png -------------------------------------------------------------------------------- /IRKit/IRKitViewSamples/ja.lproj/MainStoryboard.strings: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/irkit/ios-sdk/HEAD/IRKit/IRKitViewSamples/ja.lproj/MainStoryboard.strings -------------------------------------------------------------------------------- /IRKit/IRKit.bundle/IRWifiSecuritySelectViewController.nib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/irkit/ios-sdk/HEAD/IRKit/IRKit.bundle/IRWifiSecuritySelectViewController.nib -------------------------------------------------------------------------------- /IRKit/IRKit.bundle/ja.lproj/IRGuideWifiViewController.nib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/irkit/ios-sdk/HEAD/IRKit/IRKit.bundle/ja.lproj/IRGuideWifiViewController.nib -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | *.xcworkspace/xcuserdata 3 | *.xcworkspace/xcshareddata 4 | */*.xcodeproj/project.xcworkspace 5 | xcuserdata 6 | Pods 7 | Secret.xcconfig 8 | -------------------------------------------------------------------------------- /IRKit/IRKit.bundle/Base.lproj/IRGuideWifiViewController.nib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/irkit/ios-sdk/HEAD/IRKit/IRKit.bundle/Base.lproj/IRGuideWifiViewController.nib -------------------------------------------------------------------------------- /IRKit/IRKit.bundle/Base.lproj/IRWifiEditViewController.nib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/irkit/ios-sdk/HEAD/IRKit/IRKit.bundle/Base.lproj/IRWifiEditViewController.nib -------------------------------------------------------------------------------- /IRKit/IRKitViewSamples/IRSamplesTableViewController.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface IRSamplesTableViewController : UITableViewController 4 | 5 | @end 6 | -------------------------------------------------------------------------------- /IRKit/IRKit.bundle/Base.lproj/IRGuidePowerViewController.nib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/irkit/ios-sdk/HEAD/IRKit/IRKit.bundle/Base.lproj/IRGuidePowerViewController.nib -------------------------------------------------------------------------------- /IRKit/IRKit.bundle/Base.lproj/IRSignalNameEditViewController.nib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/irkit/ios-sdk/HEAD/IRKit/IRKit.bundle/Base.lproj/IRSignalNameEditViewController.nib -------------------------------------------------------------------------------- /IRKit/IRKit.bundle/ja.lproj/IRNewSignalScene1ViewController.nib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/irkit/ios-sdk/HEAD/IRKit/IRKit.bundle/ja.lproj/IRNewSignalScene1ViewController.nib -------------------------------------------------------------------------------- /IRKit/IRKit.bundle/Base.lproj/IRNewSignalScene1ViewController.nib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/irkit/ios-sdk/HEAD/IRKit/IRKit.bundle/Base.lproj/IRNewSignalScene1ViewController.nib -------------------------------------------------------------------------------- /IRKit/IRKit.bundle/Base.lproj/IRPeripheralNameEditViewController.nib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/irkit/ios-sdk/HEAD/IRKit/IRKit.bundle/Base.lproj/IRPeripheralNameEditViewController.nib -------------------------------------------------------------------------------- /IRKit/IRKitTests/IRKitTests.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface IRKitTests : NSObject 4 | 5 | + (IRSignal*)makeTestSignal; 6 | + (IRPeripheral*)makeTestPeripheral; 7 | 8 | @end -------------------------------------------------------------------------------- /Minimal/Minimal/MMAppDelegate.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface MMAppDelegate : UIResponder 4 | 5 | @property (strong, nonatomic) UIWindow *window; 6 | 7 | @end 8 | -------------------------------------------------------------------------------- /IRKit/IRKit.bundle/ja.lproj/IRWifiEditViewController.strings: -------------------------------------------------------------------------------- 1 | 2 | /* Class = "IBUILabel"; text = "Enter your home Wi-Fi information"; ObjectID = "REr-lY-lZo"; */ 3 | "REr-lY-lZo.text" = "家のWi-Fiの情報を入力してください"; 4 | -------------------------------------------------------------------------------- /IRKit/IRKitViewSamples/IRAppDelegate.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface IRAppDelegate : UIResponder 4 | 5 | @property (strong, nonatomic) UIWindow *window; 6 | 7 | @end 8 | -------------------------------------------------------------------------------- /spec/diagrams/Makefile: -------------------------------------------------------------------------------- 1 | 2 | OUT = connect.png learn-ir-signal.png send-ir-signal.png one-create-icon.png 3 | 4 | all: $(OUT) 5 | 6 | .SUFFIXES: .msc .png 7 | 8 | .msc.png: 9 | mscgen -T png -i $< 10 | -------------------------------------------------------------------------------- /IRKit/IRKitResources/ja.lproj/IRWifiEditViewController.strings: -------------------------------------------------------------------------------- 1 | 2 | /* Class = "IBUILabel"; text = "Enter your home Wi-Fi information"; ObjectID = "REr-lY-lZo"; */ 3 | "REr-lY-lZo.text" = "家のWi-Fiの情報を入力してください"; 4 | -------------------------------------------------------------------------------- /IRKit/IRKit/IRKit-Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'IRKit' target in the 'IRKit' project 3 | // 4 | 5 | #ifdef __OBJC__ 6 | #import 7 | 8 | #endif // __OBJC__ 9 | -------------------------------------------------------------------------------- /Minimal/Minimal/MMViewController.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | 4 | @interface MMViewController : UITableViewController 5 | 6 | @end 7 | -------------------------------------------------------------------------------- /IRKit/IRKit/IREditCell.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface IREditCell : UITableViewCell 4 | 5 | @property (weak, nonatomic) IBOutlet UILabel *titleLabel; 6 | @property (weak, nonatomic) IBOutlet UITextField *editTextField; 7 | 8 | @end 9 | -------------------------------------------------------------------------------- /IRKit.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /IRKit/IRKit/IRSignalSendOperationQueue.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface IRSignalSendOperationQueue : NSOperationQueue 4 | 5 | @property (nonatomic, copy) void (^completion)(NSError *error); 6 | @property (nonatomic) NSError *error; 7 | 8 | @end 9 | -------------------------------------------------------------------------------- /IRKit/IRKit/IRHTTPJSONOperation.h: -------------------------------------------------------------------------------- 1 | // 2 | // IRHTTPJSONOperation.h 3 | // IRKit 4 | // 5 | // Created by Masakazu Ohtsuka on 2013/12/02. 6 | // 7 | // 8 | 9 | @import ISHTTPOperation; 10 | 11 | @interface IRHTTPJSONOperation : ISHTTPOperation 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /Minimal/Minimal/main.m: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | #import "MMAppDelegate.h" 4 | 5 | int main(int argc, char *argv[]) 6 | { 7 | @autoreleasepool { 8 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([MMAppDelegate class])); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /IRKit/IRKitViewSamples/main.m: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | #import "IRAppDelegate.h" 4 | 5 | int main(int argc, char *argv[]) 6 | { 7 | @autoreleasepool { 8 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([IRAppDelegate class])); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Minimal/Minimal/Log.m: -------------------------------------------------------------------------------- 1 | #import "Log.h" 2 | 3 | NSString *sp(NSString *format, ...) 4 | { 5 | va_list args; 6 | va_start(args, format); 7 | NSString *str = [[NSString alloc] initWithFormat:format arguments:args]; // ARC 8 | va_end(args); 9 | return str; 10 | } 11 | -------------------------------------------------------------------------------- /IRKit/IRKit/IRKit+Internal.m: -------------------------------------------------------------------------------- 1 | // 2 | // IRKit+Internal.m 3 | // IRKit 4 | // 5 | // Created by Masakazu Ohtsuka on 2014/04/04. 6 | // 7 | // 8 | 9 | #import "IRKit+Internal.h" 10 | 11 | @implementation IRKit (Internal) 12 | 13 | @dynamic apikey, clientkey, store; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /IRKit/IRKitTests/IRKitTests-Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header 3 | // 4 | // The contents of this file are implicitly included at the beginning of every source file. 5 | // 6 | 7 | #ifdef __OBJC__ 8 | #import 9 | #import 10 | #endif 11 | -------------------------------------------------------------------------------- /Minimal/Minimal/MMSignalsDataSource.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | 4 | @interface MMSignalsDataSource : NSObject 5 | 6 | - (void)addSignalsObject: (IRSignal*) signal; 7 | - (IRSignal*)objectAtIndex: (NSUInteger) index; 8 | 9 | @end 10 | -------------------------------------------------------------------------------- /IRKit/IRKit.bundle/ja.lproj/IRPeripheralNameEditViewController.strings: -------------------------------------------------------------------------------- 1 | 2 | /* Class = "IBUILabel"; text = "Give IRKit a name"; ObjectID = "175"; */ 3 | "175.text" = "IRKitに名前をつけてください"; 4 | 5 | /* Class = "IBUITextField"; placeholder = "ex: Living, Bedroom, ..."; ObjectID = "414"; */ 6 | "414.placeholder" = "ex: リビング,寝室, ..."; 7 | -------------------------------------------------------------------------------- /IRKit/IRKit.bundle/ja.lproj/IRSignalNameEditViewController.strings: -------------------------------------------------------------------------------- 1 | 2 | /* Class = "IBUILabel"; text = "Give signal a name"; ObjectID = "327"; */ 3 | "327.text" = "ボタンに名前をつけてください"; 4 | 5 | /* Class = "IBUITextField"; placeholder = "ex: Living, Bedroom, ..."; ObjectID = "338"; */ 6 | "338.placeholder" = "ex: 電源オン,音量UP, ..."; 7 | -------------------------------------------------------------------------------- /IRKit/IRKit/IRHTTPOperationQueue.h: -------------------------------------------------------------------------------- 1 | // 2 | // IRHTTPOperationQueue.h 3 | // IRKit 4 | // 5 | // Created by Masakazu Ohtsuka on 2013/12/18. 6 | // 7 | // 8 | 9 | #import "ISHTTPOperationQueue.h" 10 | 11 | @interface IRHTTPOperationQueue : ISHTTPOperationQueue 12 | 13 | + (instancetype)localQueue; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /IRKit/IRKitResources/ja.lproj/IRSignalNameEditViewController.strings: -------------------------------------------------------------------------------- 1 | 2 | /* Class = "IBUILabel"; text = "Give signal a name"; ObjectID = "327"; */ 3 | "327.text" = "ボタンに名前をつけてください"; 4 | 5 | /* Class = "IBUITextField"; placeholder = "ex: Living, Bedroom, ..."; ObjectID = "338"; */ 6 | "338.placeholder" = "ex: 電源オン,音量UP, ..."; 7 | -------------------------------------------------------------------------------- /IRKit/IRKitResources/ja.lproj/IRPeripheralNameEditViewController.strings: -------------------------------------------------------------------------------- 1 | 2 | /* Class = "IBUILabel"; text = "Give IRKit a name"; ObjectID = "175"; */ 3 | "175.text" = "IRKitに名前をつけてください"; 4 | 5 | /* Class = "IBUITextField"; placeholder = "ex: Living, Bedroom, ..."; ObjectID = "414"; */ 6 | "414.placeholder" = "ex: リビング,寝室, ..."; 7 | -------------------------------------------------------------------------------- /IRKit/IRKit/IRSignalSendOperation.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import "IRSignal.h" 3 | 4 | @interface IRSignalSendOperation : NSOperation 5 | 6 | @property (nonatomic) IRSignal *signal; 7 | 8 | - (id)initWithSignal:(IRSignal *)signal 9 | completion:(void(^) (NSError * error))completion; 10 | 11 | @end 12 | -------------------------------------------------------------------------------- /IRKit/IRKit/IREditCell.m: -------------------------------------------------------------------------------- 1 | #import "Log.h" 2 | #import "IREditCell.h" 3 | 4 | @interface IREditCell () 5 | 6 | @end 7 | 8 | @implementation IREditCell 9 | 10 | - (void)awakeFromNib { 11 | LOG_CURRENT_METHOD; 12 | [super awakeFromNib]; 13 | } 14 | 15 | - (void)dealloc { 16 | LOG_CURRENT_METHOD; 17 | } 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /IRKit/IRKit/Log.m: -------------------------------------------------------------------------------- 1 | #import "Log.h" 2 | 3 | NSString * _IRLog(NSString *format, ...) { 4 | va_list args; 5 | 6 | va_start(args, format); 7 | NSString *str = [[NSString alloc] initWithFormat: format arguments: args]; 8 | va_end(args); 9 | return str; 10 | } 11 | 12 | void IRKitLog(NSString *msg) { 13 | NSLog(@"[IRKit]%@", msg); 14 | } -------------------------------------------------------------------------------- /IRKit/IRKitTests/XCTestCase+Async.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface XCTestCase (Async) 4 | 5 | @property (nonatomic, getter = isWaiting) BOOL waiting; 6 | 7 | - (void)startWaiting; 8 | - (void)startWaitingForInterval:(NSTimeInterval)interval; 9 | - (void)stopWaiting; 10 | 11 | - (void)waitUntilSatisfyingCondition:(BOOL (^)(void))conditionBlock; 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /IRKit/IRKit/IRReachability.h: -------------------------------------------------------------------------------- 1 | // 2 | // IRReachability.h 3 | // IRKit 4 | // 5 | // Created by Masakazu Ohtsuka on 2014/03/17. 6 | // 7 | // 8 | 9 | #import 10 | 11 | @interface IRReachability : NSObject 12 | 13 | + (instancetype) reachabilityWithHostname: (NSString*)hostname; 14 | - (BOOL)isReachableViaWiFi; 15 | - (BOOL)isReachableViaWiFiAndDirect; 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /IRKit/IRKit/IRUserDefaultsStore.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import "IRPersistentStore.h" 3 | 4 | @interface IRUserDefaultsStore : NSObject 5 | 6 | - (void)storeObject:(id)object forKey:(NSString *)key; 7 | - (void)storePeripherals:(NSDictionary*)object; 8 | - (id)objectForKey:(NSString *)key; 9 | - (NSDictionary*)loadPeripherals; 10 | - (void)synchronize; 11 | 12 | @end 13 | -------------------------------------------------------------------------------- /Minimal/Minimal/Minimal-Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'Minimal' target in the 'Minimal' project 3 | // 4 | 5 | #import 6 | 7 | #ifndef __IPHONE_5_0 8 | #warning "This project uses features only available in iOS SDK 5.0 and later." 9 | #endif 10 | 11 | #ifdef __OBJC__ 12 | #import 13 | #import 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /IRKit/IRKit/IRHTTPClient+UIKit.h: -------------------------------------------------------------------------------- 1 | // 2 | // IRHTTPClient+UIKit.h 3 | // IRKit 4 | // 5 | // Created by Masakazu Ohtsuka on 2014/04/02. 6 | // 7 | // 8 | 9 | #import "IRHTTPClient.h" 10 | #import 11 | 12 | @interface IRHTTPClient (UIKit) 13 | 14 | + (void)loadImage:(NSString *)url completionHandler:(void (^) (NSHTTPURLResponse * response, UIImage * image, NSError * error))handler; 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - ISHTTPOperation (1.2.0) 3 | - OHHTTPStubs (3.0.4) 4 | 5 | DEPENDENCIES: 6 | - ISHTTPOperation (~> 1.2.0) 7 | - OHHTTPStubs (~> 3.0.4) 8 | 9 | SPEC CHECKSUMS: 10 | ISHTTPOperation: dfe4b6b2b3d7803688b22df2c46ea9827081e723 11 | OHHTTPStubs: 32947621778de87d82590d57db44bbf79b5d9168 12 | 13 | PODFILE CHECKSUM: 0b65b405710d033759c13425b1322a97bb83f6f8 14 | 15 | COCOAPODS: 1.0.0 16 | -------------------------------------------------------------------------------- /IRKit/IRKit/IRPeripheralCell.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import "IRPeripheral.h" 3 | 4 | @interface IRPeripheralCell : UITableViewCell 5 | 6 | + (CGFloat)height; 7 | 8 | @property (nonatomic, strong) IRPeripheral *peripheral; 9 | 10 | @property (weak, nonatomic) IBOutlet UILabel *nameLabel; 11 | @property (weak, nonatomic) IBOutlet UILabel *detailLabel; 12 | @property (weak, nonatomic) IBOutlet UIImageView *iconView; 13 | 14 | @end 15 | -------------------------------------------------------------------------------- /IRKit/IRKit/IRKit+Internal.h: -------------------------------------------------------------------------------- 1 | // 2 | // IRKit+Internal.h 3 | // IRKit 4 | // 5 | // Created by Masakazu Ohtsuka on 2014/04/04. 6 | // 7 | // 8 | 9 | #import "IRKit.h" 10 | 11 | /// publicize some properties for internal access 12 | @interface IRKit (Internal) 13 | 14 | @property (nonatomic, copy) NSString *apikey; 15 | @property (nonatomic, copy) NSString *clientkey; 16 | @property (nonatomic) id store; 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /IRKit/IRKitViewSamples/IRKitViewSamples-Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'IRKitViewSamples' target in the 'IRKitViewSamples' project 3 | // 4 | 5 | #import 6 | 7 | #ifndef __IPHONE_5_0 8 | #warning "This project uses features only available in iOS SDK 5.0 and later." 9 | #endif 10 | 11 | #ifdef __OBJC__ 12 | #import 13 | #import 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /IRKit/IRKit/IRHelper.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | extern NSString * IRLocalizedString(NSString *key, NSString *comment); 4 | 5 | @interface IRHelper : NSObject 6 | 7 | + (NSArray *)mapObjects:(NSArray *)array usingBlock:(id (^) (id obj, NSUInteger idx))block; 8 | + (NSBundle *)resources; 9 | + (NSString *)localIPAddress; 10 | #if TARGET_OS_IPHONE 11 | + (NSString *)currentWifiSSID; 12 | #endif // TARGET_OS_IPHONE 13 | 14 | @end 15 | -------------------------------------------------------------------------------- /IRKit/IRKit/IRPersistentStore.h: -------------------------------------------------------------------------------- 1 | // 2 | // IRPersistentStore.h 3 | // IRKit 4 | // 5 | // Created by Masakazu Ohtsuka on 2014/04/04. 6 | // 7 | // 8 | 9 | #import 10 | 11 | @protocol IRPersistentStore 12 | 13 | @required 14 | - (void)storeObject:(id)object forKey:(NSString *)key; 15 | - (void)storePeripherals:(NSDictionary *)object; 16 | - (id)objectForKey:(NSString *)key; 17 | - (NSDictionary*)loadPeripherals; 18 | - (void)synchronize; 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /IRKit/IRKit.bundle/ja.lproj/IRGuidePowerViewController.strings: -------------------------------------------------------------------------------- 1 | 2 | /* Class = "IBUILabel"; text = "Power Up your 3 | IRKit"; ObjectID = "12"; */ 4 | "12.text" = "IRKitの電源を 5 | 入れましょう"; 6 | 7 | /* Class = "IBUILabel"; text = "Connect 8 | USB Micro-B"; ObjectID = "N0I-xf-e06"; */ 9 | "N0I-xf-e06.text" = "USB Micro-B 10 | ケーブルを 11 | つないでください"; 12 | 13 | /* Class = "IBUIButton"; normalTitle = " Buy IRKit on Amazon"; ObjectID = "nUU-7e-4ed"; */ 14 | "nUU-7e-4ed.normalTitle" = "AmazonでIRKitを買う"; 15 | -------------------------------------------------------------------------------- /IRKit/IRKit/IRSignalSequence.h: -------------------------------------------------------------------------------- 1 | // 2 | // IRSignalSequence.h 3 | // IRKit 4 | // 5 | // Created by Masakazu Ohtsuka on 2014/02/20. 6 | // 7 | // 8 | 9 | #import 10 | #import "IRSignal.h" 11 | 12 | @interface IRSignalSequence : NSObject 13 | 14 | @property (nonatomic, copy) NSString *name; 15 | @property (nonatomic) NSDictionary *custom; 16 | 17 | - (instancetype)initWithSignals:(NSArray*)signals andIntervals:(NSArray*)intervals; 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /IRKit/IRKitResources/ja.lproj/IRGuidePowerViewController.strings: -------------------------------------------------------------------------------- 1 | 2 | /* Class = "IBUILabel"; text = "Power Up your 3 | IRKit"; ObjectID = "12"; */ 4 | "12.text" = "IRKitの電源を 5 | 入れましょう"; 6 | 7 | /* Class = "IBUILabel"; text = "Connect 8 | USB Micro-B"; ObjectID = "N0I-xf-e06"; */ 9 | "N0I-xf-e06.text" = "USB Micro-B 10 | ケーブルを 11 | つないでください"; 12 | 13 | /* Class = "IBUIButton"; normalTitle = " Buy IRKit on Amazon"; ObjectID = "nUU-7e-4ed"; */ 14 | "nUU-7e-4ed.normalTitle" = "AmazonでIRKitを買う"; 15 | -------------------------------------------------------------------------------- /Contributing.md: -------------------------------------------------------------------------------- 1 | Contributing 2 | ============ 3 | 4 | I love receiving a pull request. 5 | Here's a quick guide. 6 | 7 | 1. Fork the repo. 8 | 1. Create a branch from master with a descriptive name. 9 | 1. Push. 10 | 1. Send a pull request! 11 | 12 | If you've contributed more than a few lines of code, use [Uncrustify](http://uncrustify.sourceforge.net/) with this configuration file [.uncrustifyconfig](.uncrustifyconfig). 13 | I recommend using [BBUncrustifyPlugin-Xcode](https://github.com/benoitsan/BBUncrustifyPlugin-Xcode) 14 | -------------------------------------------------------------------------------- /IRKit/IRKit/IRFAQViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // IRFAQViewController.h 3 | // IRKit 4 | // 5 | // Created by Masakazu Ohtsuka on 2014/04/10. 6 | // 7 | // 8 | 9 | #import 10 | 11 | @protocol IRFAQViewControllerDelegate; 12 | 13 | @interface IRFAQViewController : UIViewController 14 | 15 | @property (weak, nonatomic) id delegate; 16 | 17 | @end 18 | 19 | @protocol IRFAQViewControllerDelegate 20 | 21 | - (void)faqViewControllerDidFinish:(IRFAQViewController*)controller; 22 | 23 | @end -------------------------------------------------------------------------------- /IRKit/IRKit/IRViewHelper.h: -------------------------------------------------------------------------------- 1 | // 2 | // IRViewHelper.h 3 | // IRKit 4 | // 5 | // Created by Masakazu Ohtsuka on 2014/04/01. 6 | // 7 | // 8 | 9 | #import 10 | #import 11 | 12 | @interface IRViewHelper : NSObject 13 | 14 | + (void)enumerateSubviewsOfRootView:(UIView *)view usingBlock:(void (^) (id obj, NSUInteger idx, BOOL * stop))block; 15 | + (UIFont *)fontWithSize:(CGFloat)size; 16 | + (UIImage *)imageWithColor:(UIColor *)color; 17 | + (UIImage *)imageInResourceNamed:(NSString *)name; 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /podfile: -------------------------------------------------------------------------------- 1 | source 'https://github.com/CocoaPods/Specs.git' 2 | use_frameworks! 3 | 4 | platform :ios, "7.0" 5 | workspace 'IRKit' 6 | project 'IRKit/IRKit.xcodeproj' 7 | 8 | pod 'ISHTTPOperation', '~> 1.2.0' 9 | 10 | target 'Minimal' do 11 | project 'Minimal/Minimal.xcodeproj' 12 | end 13 | 14 | target 'IRKit' do 15 | project 'IRKit/IRKit.xcodeproj' 16 | end 17 | 18 | target 'IRKitViewSamples' do 19 | project 'IRKit/IRKit.xcodeproj' 20 | end 21 | 22 | target 'IRKitTests' do 23 | pod 'OHHTTPStubs', '~> 3.0.4' 24 | project 'IRKit/IRKit.xcodeproj' 25 | end 26 | -------------------------------------------------------------------------------- /IRKit/IRKit/IRGuidePowerViewController.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @protocol IRGuidePowerViewControllerDelegate; 4 | 5 | @interface IRGuidePowerViewController : UIViewController 6 | 7 | @property (nonatomic, weak) id delegate; 8 | 9 | @end 10 | 11 | @protocol IRGuidePowerViewControllerDelegate 12 | @required 13 | 14 | // Your implementation of this method should dismiss view controller. 15 | - (void)scene1ViewController:(IRGuidePowerViewController *)viewController didFinishWithInfo:(NSDictionary *)info; 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /IRKit/IRKit/IRProgressView.h: -------------------------------------------------------------------------------- 1 | // 2 | // IRProgressView.h 3 | // IRKit 4 | // 5 | // Created by Masakazu Ohtsuka on 2014/03/16. 6 | // 7 | // 8 | 9 | #import 10 | 11 | @interface IRProgressView : UIView 12 | 13 | @property (nonatomic) IBOutlet UIActivityIndicatorView *indicatorView; 14 | @property (nonatomic) IBOutlet UIImageView *checkmarkImageView; 15 | @property (nonatomic) IBOutlet UIImageView *circleBackgroundImageView; 16 | 17 | + (instancetype)showHUDAddedTo:(UIView*)view; 18 | + (BOOL)hideHUDForView:(UIView*)view afterDelay:(NSTimeInterval)delay; 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /IRKit/IRKit/CRC8.m: -------------------------------------------------------------------------------- 1 | #include "CRC8.h" 2 | 3 | #define CRC8INIT 0x00 4 | #define CRC8POLY 0x31 // = X^8+X^5+X^4+X^0 5 | 6 | @implementation CRC8 7 | 8 | + (uint8_t)crc8:(uint8_t *)data size: (uint16_t)size { 9 | uint8_t crc, i; 10 | 11 | crc = CRC8INIT; 12 | 13 | while (size--) { 14 | crc ^= *data++; 15 | 16 | for (i = 0; i < 8; i++) { 17 | if (crc & 0x80) { 18 | crc = (crc << 1) ^ CRC8POLY; 19 | } 20 | else { 21 | crc <<= 1; 22 | } 23 | } 24 | } 25 | 26 | return crc; 27 | } 28 | 29 | @end 30 | -------------------------------------------------------------------------------- /Minimal/Minimal/Log.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | NSString *sp(NSString *format, ...); 4 | 5 | #ifdef FORCE_LOG 6 | # define LOG_CURRENT_METHOD NSLog(@"%s#%d", __PRETTY_FUNCTION__, __LINE__) 7 | # define LOG(...) NSLog(@"%s#%d %@", __PRETTY_FUNCTION__, __LINE__, sp(__VA_ARGS__)) 8 | # 9 | #elif defined DEBUG 10 | # define LOG_CURRENT_METHOD NSLog(@"%s#%d", __PRETTY_FUNCTION__, __LINE__) 11 | # define LOG(...) NSLog(@"%s#%d %@", __PRETTY_FUNCTION__, __LINE__, sp(__VA_ARGS__)) 12 | # 13 | #else 14 | # define LOG(...) 15 | # define LOG_CURRENT_METHOD 16 | # 17 | #endif 18 | -------------------------------------------------------------------------------- /IRKit/IRKit/IRPeripherals+UIKit.h: -------------------------------------------------------------------------------- 1 | // 2 | // IRPeripherals+UITableView.h 3 | // IRKit 4 | // 5 | // Created by Masakazu Ohtsuka on 2014/04/01. 6 | // 7 | // 8 | 9 | #import "IRPeripherals.h" 10 | #import 11 | 12 | @interface IRPeripherals (UITableView) 13 | 14 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath; 15 | - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section; 16 | - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath; 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /IRKit/IRKit/IRHTTPOperationQueue.m: -------------------------------------------------------------------------------- 1 | // 2 | // IRHTTPOperationQueue.m 3 | // IRKit 4 | // 5 | // Created by Masakazu Ohtsuka on 2013/12/18. 6 | // 7 | // 8 | 9 | #import "IRHTTPOperationQueue.h" 10 | 11 | @implementation IRHTTPOperationQueue 12 | 13 | + (instancetype)localQueue { 14 | static IRHTTPOperationQueue *queue = nil; 15 | static dispatch_once_t onceToken; 16 | 17 | dispatch_once(&onceToken, ^{ 18 | queue = [[IRHTTPOperationQueue alloc] init]; 19 | }); 20 | // no multiple concurrent requests agains device 21 | queue.maxConcurrentOperationCount = 1; 22 | 23 | return queue; 24 | } 25 | 26 | @end 27 | -------------------------------------------------------------------------------- /IRKit/IRKit/IRNewSignalScene1ViewController.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | // pre definition for delegate 4 | @protocol IRNewSignalScene1ViewControllerDelegate; 5 | 6 | @interface IRNewSignalScene1ViewController : UIViewController 7 | 8 | @property (nonatomic, weak) id delegate; 9 | 10 | @end 11 | 12 | @protocol IRNewSignalScene1ViewControllerDelegate 13 | 14 | @required 15 | 16 | // Your implementation of this method should dismiss view controller. 17 | - (void)scene1ViewController:(IRNewSignalScene1ViewController *)viewController didFinishWithInfo:(NSDictionary *)info; 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /IRKit/IRKit/Log.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | NSString * _IRLog(NSString *format, ...); 4 | void IRKitLog(NSString *msg); 5 | 6 | // '#define LOG_DISABLED 1' before '#import "Log.h"' in .m file to disable logging only in that file 7 | #ifndef LOG_DISABLED 8 | # define LOG_DISABLED 0 9 | #endif 10 | 11 | #if (defined(IRKIT_DEBUG) && !LOG_DISABLED) 12 | # define LOG_CURRENT_METHOD NSLog(@ "%s#%d", __PRETTY_FUNCTION__, __LINE__) 13 | # define LOG(...) NSLog(@ "%s#%d %@", __PRETTY_FUNCTION__, __LINE__, _IRLog(__VA_ARGS__)) 14 | # 15 | #else 16 | # define LOG_CURRENT_METHOD 17 | # define LOG(...) 18 | # 19 | #endif 20 | 21 | #ifdef IRKIT_DEBUG 22 | # define ASSERT(A, B) NSAssert(A, B) 23 | #else 24 | # define ASSERT(A, B) 25 | #endif 26 | -------------------------------------------------------------------------------- /IRKit/IRKit/IRSignalNameEditViewController.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import "IRSignal.h" 3 | 4 | @protocol IRSignalNameEditViewControllerDelegate; 5 | 6 | @interface IRSignalNameEditViewController : UIViewController 7 | 8 | @property (nonatomic, weak) id delegate; 9 | @property (weak, nonatomic) IBOutlet UITextField *textField; 10 | @property (nonatomic) IRSignal *signal; 11 | 12 | @end 13 | 14 | @protocol IRSignalNameEditViewControllerDelegate 15 | @required 16 | 17 | // Your implementation of this method should dismiss view controller. 18 | - (void)signalNameEditViewController:(IRSignalNameEditViewController *)viewController didFinishWithInfo:(NSDictionary *)info; 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /IRKit/IRKit/IRWifiSecuritySelectViewController.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import "IRKeys.h" 3 | 4 | @protocol IRWifiSecuritySelectViewControllerDelegate; 5 | 6 | @interface IRWifiSecuritySelectViewController : UIViewController 7 | 8 | @property (nonatomic, weak) id delegate; 9 | @property (weak, nonatomic) IBOutlet UITableView *tableView; 10 | @property (nonatomic, assign) IRSecurityType selectedSecurityType; 11 | 12 | @end 13 | 14 | @protocol IRWifiSecuritySelectViewControllerDelegate 15 | @required 16 | 17 | - (void)securitySelectviewController:(IRWifiSecuritySelectViewController *)viewController didFinishWithSecurityType:(IRSecurityType)securityType; 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /IRKit/IRKit/IRViewCustomizer.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | 4 | @interface IRViewCustomizer : NSObject 5 | 6 | // if set, viewDidLoad block will be called 7 | // after any IRKit origin UIViewController's viewDidLoad: 8 | // Set this callback if you want full control over 9 | // IRKit's viewcontrollers appearance 10 | // Otherwise you'll see IRKit's default appearance 11 | @property (nonatomic, copy) void (^viewDidLoad)(UIViewController *viewController); 12 | 13 | + (instancetype)sharedInstance; 14 | 15 | + (UIColor *)keyColor; 16 | + (UIColor *)textColor; 17 | + (UIColor *)activeFontColor; 18 | + (UIColor *)inactiveFontColor; 19 | + (UIColor *)defaultViewBackgroundColor; 20 | + (void)customizeNavigationBar:(UINavigationBar *)bar; 21 | 22 | @end 23 | -------------------------------------------------------------------------------- /IRKit/IRKitTests/IRKitTests-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundlePackageType 14 | BNDL 15 | CFBundleShortVersionString 16 | 1.0 17 | CFBundleSignature 18 | ???? 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /IRKit/IRKit/IRHTTPJSONOperation.m: -------------------------------------------------------------------------------- 1 | // 2 | // IRHTTPJSONOperation.m 3 | // IRKit 4 | // 5 | // Created by Masakazu Ohtsuka on 2013/12/02. 6 | // 7 | // 8 | 9 | #import "IRHTTPJSONOperation.h" 10 | #import "Log.h" 11 | 12 | @implementation IRHTTPJSONOperation 13 | 14 | - (id)processData:(NSData *)data { 15 | NSError *error = nil; 16 | id object = nil; 17 | 18 | // don't try to parse empty string 19 | if (data.length) { 20 | object = [NSJSONSerialization JSONObjectWithData: data 21 | options: NSJSONReadingAllowFragments 22 | error: &error]; 23 | if (error) { 24 | LOG(@"JSON error: %@", error); 25 | } 26 | } 27 | return object; 28 | } 29 | 30 | @end 31 | -------------------------------------------------------------------------------- /IRKit/IRKit/IRNewSignalViewController.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import "IRNewSignalScene1ViewController.h" 3 | #import "IRSignalNameEditViewController.h" 4 | 5 | // pre definition for delegate 6 | @protocol IRNewSignalViewControllerDelegate; 7 | 8 | @interface IRNewSignalViewController : UIViewController 9 | 10 | @property (nonatomic) UINavigationController *navController; 11 | @property (nonatomic, weak) id delegate; 12 | 13 | @end 14 | 15 | @protocol IRNewSignalViewControllerDelegate 16 | 17 | @required 18 | 19 | // Your implementation of this method should dismiss view controller. 20 | - (void)newSignalViewController:(IRNewSignalViewController *)viewController didFinishWithSignal:(IRSignal *)signal; 21 | 22 | @end 23 | -------------------------------------------------------------------------------- /IRKit/IRKit/IRPeripheralNameEditViewController.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import "IRPeripheral.h" 3 | 4 | @protocol IRPeripheralNameEditViewControllerDelegate; 5 | 6 | @interface IRPeripheralNameEditViewController : UIViewController 7 | 8 | @property (nonatomic, weak) id delegate; 9 | @property (nonatomic) IRPeripheral *peripheral; 10 | @property (weak, nonatomic) IBOutlet UITextField *textField; 11 | @property (weak, nonatomic) IBOutlet UIImageView *iconView; 12 | 13 | @end 14 | 15 | @protocol IRPeripheralNameEditViewControllerDelegate 16 | @required 17 | 18 | // Your implementation of this method should dismiss view controller. 19 | - (void)nameEditViewController:(IRPeripheralNameEditViewController *)viewController didFinishWithInfo:(NSDictionary *)info; 20 | 21 | @end 22 | -------------------------------------------------------------------------------- /IRKit/IRKit/IRWifiEditViewController.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import "IRWifiSecuritySelectViewController.h" 3 | 4 | @protocol IRWifiEditViewControllerDelegate; 5 | 6 | @interface IRWifiEditViewController : UIViewController 7 | 8 | @property (nonatomic, weak) id delegate; 9 | @property (weak, nonatomic) IBOutlet UITableView *tableView; 10 | @property (weak, nonatomic) IBOutlet UIImageView *iconView; 11 | 12 | @property (nonatomic) IRKeys *keys; 13 | 14 | @end 15 | 16 | @protocol IRWifiEditViewControllerDelegate 17 | @required 18 | 19 | // Your implementation of this method should dismiss view controller. 20 | - (void)wifiEditViewController:(IRWifiEditViewController *)viewController didFinishWithInfo:(NSDictionary *)info; 21 | 22 | @end 23 | -------------------------------------------------------------------------------- /IRKit/IRKitTests/IRKitTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // IRKitTests.m 3 | // IRKitTests 4 | // 5 | // Created by Masakazu Ohtsuka on 2014/02/17. 6 | // 7 | // 8 | 9 | #import "IRSignal.h" 10 | #import "IRPeripherals.h" 11 | #import "IRUserDefaultsStore.h" 12 | 13 | @interface IRKitTests : NSObject 14 | 15 | @end 16 | 17 | @implementation IRKitTests 18 | 19 | + (IRSignal*)makeTestSignal { 20 | NSDictionary *signalInfo = @{ 21 | @"data": @[ @100,@100,@100,@100,@100,@100,@100,@100,@100,@100 ], 22 | @"format": @"raw", 23 | @"freq": @38, 24 | @"type": @"single", 25 | }; 26 | return [[IRSignal alloc] initWithDictionary: signalInfo]; 27 | } 28 | 29 | + (IRPeripheral*)makeTestPeripheral { 30 | IRUserDefaultsStore *store = [[IRUserDefaultsStore alloc] init]; 31 | IRPeripherals *peripherals = [[IRPeripherals alloc] initWithPersistentStore: store]; 32 | return [peripherals savePeripheralWithName: @"IRKitTEST" deviceid: @"xxx"]; 33 | } 34 | 35 | @end 36 | -------------------------------------------------------------------------------- /IRKit/IRKit/IRKit.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import "IRConst.h" 3 | #import "IRPeripherals.h" 4 | #import "IRHelper.h" 5 | #import "IRSignals.h" 6 | #import "IRSignalSequence.h" 7 | #import "IRPersistentStore.h" 8 | #if TARGET_OS_IPHONE 9 | # import "IRPeripheralCell.h" 10 | # import "IRPeripherals+UIKit.h" 11 | # import "IRNewPeripheralViewController.h" 12 | # import "IRNewSignalViewController.h" 13 | # import "IRViewCustomizer.h" 14 | #endif 15 | 16 | @interface IRKit : NSObject 17 | 18 | + (instancetype)sharedInstance; 19 | + (void)startWithAPIKey:(NSString *)apikey; 20 | 21 | /// call before startWithAPIKey, 22 | /// to save clientkey and peripherals information into somewhere else than NSUserDefaults. 23 | /// IRKit will have a strong reference to this. 24 | + (void)setPersistentStore:(id)store; 25 | 26 | - (void)save; 27 | 28 | @property (nonatomic, readonly) NSUInteger countOfReadyPeripherals; 29 | @property (nonatomic, readonly) IRPeripherals *peripherals; 30 | 31 | @end 32 | -------------------------------------------------------------------------------- /IRKit/IRKit/IRKeys.h: -------------------------------------------------------------------------------- 1 | // 2 | // IRKeys.h 3 | // IRKit 4 | // 5 | // Created by Masakazu Ohtsuka on 2013/11/07. 6 | // 7 | // 8 | 9 | #import 10 | 11 | typedef NS_ENUM(uint8_t, IRSecurityType) { 12 | IRSecurityTypeNone = 0, 13 | IRSecurityTypeWEP = 2, 14 | IRSecurityTypeWPA2 = 8, 15 | }; 16 | 17 | @interface IRKeys : NSObject 18 | 19 | @property (nonatomic, copy) NSString *ssid; 20 | @property (nonatomic, copy) NSString *password; 21 | @property (nonatomic) IRSecurityType security; 22 | @property (nonatomic, copy) NSString *deviceid; 23 | @property (nonatomic, copy) NSString *devicekey; // send this to IRKit using morse 24 | 25 | - (NSString *)securityTypeString; 26 | + (NSString *)securityTypeStringOf:(IRSecurityType)security; 27 | + (BOOL)isPassword:(NSString *)password validForSecurityType:(IRSecurityType)securityType; 28 | - (NSString *)morseStringRepresentation; 29 | - (void)setKeys:(NSDictionary *)keys; 30 | - (BOOL)keysAreSet; 31 | - (NSString *)regdomain; 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /IRKit/IRKit/IRSearcher.h: -------------------------------------------------------------------------------- 1 | // 2 | // IRSearcher.h 3 | // IRKit 4 | // 5 | // Created by Masakazu Ohtsuka on 2013/11/22. 6 | // 7 | // 8 | 9 | #import 10 | 11 | @protocol IRSearcherDelegate; 12 | 13 | @interface IRSearcher : NSObject 14 | 15 | @property (nonatomic, weak) id delegate; 16 | @property (nonatomic, readonly) BOOL searching; 17 | 18 | + (instancetype)sharedInstance; 19 | - (void)startSearching; 20 | - (void)startSearchingForTimeInterval:(NSTimeInterval)interval; 21 | - (void)startSearchingAfterTimeInterval:(NSTimeInterval)waitInterval forTimeInterval:(NSTimeInterval)interval; 22 | - (void)stop; 23 | 24 | @end 25 | 26 | @protocol IRSearcherDelegate 27 | 28 | @required 29 | - (void)searcher:(IRSearcher *)searcher didResolveService:(NSNetService *)service; 30 | 31 | @optional 32 | - (void)searcherWillStartSearching:(IRSearcher*)searcher; 33 | - (void)searcherDidTimeout:(IRSearcher *)searcher; 34 | 35 | @end 36 | -------------------------------------------------------------------------------- /spec/diagrams/learn-ir-signal.msc: -------------------------------------------------------------------------------- 1 | msc { 2 | # entities 3 | user, peripheral, central; 4 | 5 | # space 6 | |||; 7 | 8 | user note central [label = "Successfully authenticated"]; 9 | 10 | |||; 11 | 12 | peripheral note central [label = "Always connected when app is active in foreground.\nOnly learns signals when app is in foreground."]; 13 | 14 | |||; 15 | 16 | user -> peripheral [label = "Send IR signal"]; 17 | 18 | peripheral -> central [label = "Notify \"IR Unread Status\""]; 19 | 20 | peripheral <= central [label = "Read 'IR Data' c12c"]; 21 | peripheral >> central [label = "IR data"]; 22 | peripheral <= central [label = "Read 'IR Data' c12c"]; 23 | peripheral >> central [label = "IR data"]; 24 | peripheral <= central [label = "Read 'IR Data' c12c"]; 25 | peripheral >> central [label = "IR data"]; 26 | 27 | peripheral note central [label = "Stay connected while app is active"]; 28 | 29 | peripheral <- central [label = "Disconnect when app goes inactive"]; 30 | } 31 | -------------------------------------------------------------------------------- /IRKit/IRKitTests/IRSignalTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // IRSignalTests.m 3 | // IRKit 4 | // 5 | // Created by Masakazu Ohtsuka on 2014/02/17. 6 | // 7 | // 8 | 9 | #import 10 | #import "IRKit.h" 11 | 12 | @interface IRSignalTests : XCTestCase 13 | 14 | @end 15 | 16 | @implementation IRSignalTests 17 | 18 | - (void)setUp { 19 | [super setUp]; 20 | // Put setup code here; it will be run once, before the first test case. 21 | } 22 | 23 | - (void)tearDown { 24 | // Put teardown code here; it will be run once, after the last test case. 25 | [super tearDown]; 26 | } 27 | 28 | - (void)testRound { 29 | NSDictionary *signalInfo = @{ 30 | @"data": @[ @100,@100,@100,@100,@100,@100,@100,@100,@100,@100 ], 31 | @"format": @"raw", 32 | @"freq": @38, 33 | @"type": @"single", 34 | }; 35 | IRSignal *signal = [[IRSignal alloc] initWithDictionary: signalInfo]; 36 | XCTAssertNotNil(signal); 37 | 38 | NSDictionary *signalInfo2 = signal.asPublicDictionary; 39 | XCTAssertEqualObjects(signalInfo, signalInfo2); 40 | } 41 | 42 | @end 43 | -------------------------------------------------------------------------------- /IRKit/IRKit/IRSignals.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import "IRSignal.h" 3 | 4 | /// Collection of id 5 | /// IRSignals can contain IRSignal or IRSignalSequence 6 | @interface IRSignals : NSObject 7 | 8 | - (NSData *)data; 9 | - (void)loadFromData:(NSData *)data; 10 | 11 | - (void)loadFromStandardUserDefaultsKey:(NSString *)key; 12 | - (void)saveToStandardUserDefaultsWithKey:(NSString *)key; 13 | - (void)saveToUserDefaults:(NSUserDefaults*) defaults withKey:(NSString *)key; 14 | 15 | - (id)objectAtIndex:(NSUInteger)index; 16 | - (NSUInteger)indexOfSignal:(id)signal; 17 | 18 | #pragma mark - Key Value Coding - Mutable Ordered To-Many Accessors 19 | 20 | // Getter Indexed Accessors 21 | - (NSArray *)signals; 22 | - (NSUInteger)countOfSignals; 23 | - (id)objectInSignalsAtIndex:(NSUInteger)index; 24 | 25 | // Mutable Indexed Accessors 26 | - (void)insertObject:(id)object inSignalsAtIndex:(NSUInteger)index; 27 | - (void)removeObjectFromSignalsAtIndex:(NSUInteger)index; 28 | 29 | - (void)addSignalsObject:(id)object; 30 | 31 | @end 32 | -------------------------------------------------------------------------------- /IRKit/IRKit/IRPeripherals.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import "IRPeripheral.h" 3 | #import "IRPersistentStore.h" 4 | 5 | @interface IRPeripherals : NSObject 6 | 7 | - (instancetype)initWithPersistentStore:(id)store; 8 | - (id)objectAtIndex:(NSUInteger)index; 9 | - (NSUInteger)indexOfObject:(id)object; 10 | - (IRPeripheral *)peripheralWithName:(NSString *)name; 11 | - (void)save; 12 | - (void)saveToStore:(id)store; 13 | - (NSUInteger)countOfReadyPeripherals; 14 | - (BOOL)isKnownName:(NSString *)hostname; 15 | - (IRPeripheral *)registerPeripheralWithName:(NSString *)hostname; 16 | - (IRPeripheral *)savePeripheralWithName:(NSString *)hostname deviceid:(NSString *)deviceid; 17 | - (void)clearPeripherals; 18 | 19 | #pragma mark - Key Value Coding - Mutable Unordered Accessors 20 | 21 | - (NSArray *)peripherals; 22 | - (NSUInteger)countOfPeripherals; 23 | - (NSEnumerator *)enumeratorOfPeripherals; 24 | - (void)addPeripheralsObject:(IRPeripheral *)peripheral; 25 | - (void)removePeripheralsObject:(IRPeripheral *)peripheral; 26 | - (IRPeripheral *)memberOfPeripherals:(IRPeripheral *)object; 27 | 28 | @end 29 | -------------------------------------------------------------------------------- /IRKit/IRKit/IRNewPeripheralViewController.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import "IRGuidePowerViewController.h" 3 | #import "IRWifiEditViewController.h" 4 | #import "IRPeripheralNameEditViewController.h" 5 | #import "IRGuideWifiViewController.h" 6 | #import "IRSearcher.h" 7 | 8 | // pre definition for delegate 9 | @protocol IRNewPeripheralViewControllerDelegate; 10 | 11 | @interface IRNewPeripheralViewController : UIViewController< 12 | IRGuidePowerViewControllerDelegate, 13 | IRWifiEditViewControllerDelegate, 14 | IRGuideWifiViewControllerDelegate, 15 | IRPeripheralNameEditViewControllerDelegate, 16 | IRSearcherDelegate 17 | > 18 | 19 | @property (nonatomic, weak) id delegate; 20 | @property (nonatomic) UINavigationController *navController; 21 | 22 | @end 23 | 24 | @protocol IRNewPeripheralViewControllerDelegate 25 | 26 | @required 27 | 28 | // Your implementation of this method should dismiss view controller. 29 | - (void)newPeripheralViewController:(IRNewPeripheralViewController *)viewController didFinishWithPeripheral:(IRPeripheral *)peripheral; 30 | 31 | @end 32 | -------------------------------------------------------------------------------- /IRKit/IRKit/IRGuideWifiViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // IRWifiAdhocViewController.h 3 | // IRKit 4 | // 5 | // Created by Masakazu Ohtsuka on 2014/01/05. 6 | // 7 | // 8 | 9 | #import 10 | #import "IRKeys.h" 11 | #import "IRFAQViewController.h" 12 | 13 | @protocol IRGuideWifiViewControllerDelegate; 14 | 15 | @interface IRGuideWifiViewController : UIViewController 16 | 17 | @property (nonatomic, weak) id delegate; 18 | @property (nonatomic) IRKeys *keys; // passed from IRNewPerpheralViewController 19 | @property (nonatomic) IBOutlet UIView *progressView; 20 | @property (nonatomic) IBOutlet UIActivityIndicatorView *progressActivityIndicatorView; 21 | @property (nonatomic) IBOutlet UIView *progressViewCenterBackgroundView; 22 | @property (nonatomic) IBOutlet UIView *progressCheckmarkView; 23 | 24 | @end 25 | 26 | @protocol IRGuideWifiViewControllerDelegate 27 | @required 28 | 29 | // Your implementation of this method should dismiss view controller. 30 | - (void)guideWifiViewController:(IRGuideWifiViewController *)viewController didFinishWithInfo:(NSDictionary *)info; 31 | 32 | @end 33 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2013- 4 | Masakazu Ohtsuka http://maaash.jp/ 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /Minimal/Minimal/MMSignalsDataSource.m: -------------------------------------------------------------------------------- 1 | #import "MMSignalsDataSource.h" 2 | 3 | @interface MMSignalsDataSource () 4 | 5 | @property (nonatomic) IRSignals *signals; 6 | 7 | @end 8 | 9 | @implementation MMSignalsDataSource 10 | 11 | - (instancetype) init { 12 | self = [super init]; 13 | if (! self) { return nil; } 14 | 15 | _signals = [[IRSignals alloc] init]; 16 | 17 | return self; 18 | } 19 | 20 | #pragma mark - IRSignals delegate 21 | 22 | - (void)addSignalsObject: (IRSignal*) signal { 23 | [_signals addSignalsObject:signal]; 24 | } 25 | 26 | - (IRSignal*)objectAtIndex: (NSUInteger) index { 27 | return [_signals objectAtIndex:index]; 28 | } 29 | 30 | #pragma mark - UITableViewDataSource 31 | 32 | - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { 33 | return [_signals countOfSignals]; 34 | } 35 | 36 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 37 | UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"MMSignalCell"]; 38 | IRSignal *signal = [_signals objectAtIndex:indexPath.row]; 39 | cell.textLabel.text = signal.name; 40 | return cell; 41 | } 42 | 43 | @end 44 | -------------------------------------------------------------------------------- /IRKit/IRKit/IRHTTPClient+UIKit.m: -------------------------------------------------------------------------------- 1 | // 2 | // IRHTTPClient+UIKit.m 3 | // IRKit 4 | // 5 | // Created by Masakazu Ohtsuka on 2014/04/02. 6 | // 7 | // 8 | 9 | #import "IRHTTPClient+UIKit.h" 10 | #import "Log.h" 11 | 12 | @implementation IRHTTPClient (UIKit) 13 | 14 | + (void) loadImage:(NSString *)url 15 | completionHandler:(void (^)(NSHTTPURLResponse *response, UIImage *image, NSError *error))handler { 16 | LOG_CURRENT_METHOD; 17 | 18 | NSURLRequest *request = [NSURLRequest requestWithURL: [NSURL URLWithString: url] 19 | cachePolicy: NSURLRequestUseProtocolCachePolicy timeoutInterval: 60.]; 20 | [NSURLConnection sendAsynchronousRequest: request 21 | queue: [[NSOperationQueue alloc] init] 22 | completionHandler:^(NSURLResponse *res, NSData *data, NSError *error) { 23 | UIImage *ret; 24 | if (!error) { 25 | ret = [UIImage imageWithData: data]; 26 | } 27 | if (!handler) { 28 | return; 29 | } 30 | dispatch_async(dispatch_get_main_queue(), ^{ 31 | handler((NSHTTPURLResponse *)res, ret, error); 32 | }); 33 | }]; 34 | } 35 | 36 | @end 37 | -------------------------------------------------------------------------------- /IRKit/IRKitTests/XCTestCase+Async.m: -------------------------------------------------------------------------------- 1 | // thanks to https://github.com/ishkawa/ISHTTPOperation 2 | 3 | #import "XCTestCase+Async.h" 4 | #import 5 | 6 | static char XCTestCaseWaitingKey; 7 | 8 | @implementation XCTestCase (Async) 9 | 10 | - (BOOL)isWaiting { 11 | return [objc_getAssociatedObject(self, &XCTestCaseWaitingKey) boolValue]; 12 | } 13 | 14 | - (void)setWaiting:(BOOL)waiting { 15 | objc_setAssociatedObject(self, &XCTestCaseWaitingKey, @(waiting), OBJC_ASSOCIATION_RETAIN_NONATOMIC); 16 | } 17 | 18 | - (void)startWaiting { 19 | self.waiting = YES; 20 | 21 | do { 22 | [[NSRunLoop currentRunLoop] runUntilDate: [NSDate dateWithTimeIntervalSinceNow: 0.1]]; 23 | } while (self.isWaiting); 24 | } 25 | 26 | - (void)startWaitingForInterval:(NSTimeInterval)interval { 27 | self.waiting = YES; 28 | NSDate *startedDate = [NSDate date]; 29 | 30 | do { 31 | [[NSRunLoop currentRunLoop] runUntilDate: [NSDate dateWithTimeIntervalSinceNow: 0.1]]; 32 | } while (self.isWaiting && ([[NSDate date] timeIntervalSinceDate: startedDate] < interval)); 33 | 34 | if (self.isWaiting) { 35 | XCTFail(@"timed out"); 36 | } 37 | } 38 | 39 | - (void)stopWaiting { 40 | self.waiting = NO; 41 | } 42 | 43 | @end 44 | -------------------------------------------------------------------------------- /spec/diagrams/one-create-icon.msc: -------------------------------------------------------------------------------- 1 | msc { 2 | # entities 3 | user, iphoneapp, safari, icon, server, peripheral; 4 | 5 | # space 6 | |||; 7 | 8 | user -> iphoneapp [label = "Taps\n\"CREATE ICON\"\nbutton"]; 9 | 10 | iphoneapp -> server [label = "POST /apps/one/icons/\nmultipart/form-data\n* icon\n* query"]; 11 | 12 | server note server [label = "Stores:\n{ Icon.Id =>\n{ icon, query } }"]; 13 | 14 | iphoneapp << server [label = "{\"Icon\":{\"Id\":\"icon.id\",\"Url\":\"http://...\"}}"]; 15 | 16 | iphoneapp -> safari [label = "[[UIApplication sharedApplication] openURL: json.Icon.Url]"]; 17 | safari -> server [label = "GET /apps/one/icons/{icon.id}"]; 18 | safari << server [label = "302 to \"data:text/html;...\""]; 19 | safari note safari [label = "Show HTML with:\n* Icon\n* Guide to \"Bookmark This Page!\""]; 20 | 21 | user -> safari [label = "Taps \"Bookmark\""]; 22 | safari note icon [label = "Create icon"]; 23 | 24 | user -> icon [label = "Taps new icon"]; 25 | safari <- icon [label = "Open data:text/html;..."]; 26 | iphoneapp <- safari [label = "Open irkit-one://send?irsignals={query}"]; 27 | iphoneapp -> peripheral [label = "IR signal"]; 28 | peripheral note peripheral [label = "Send IR signal"]; 29 | } 30 | -------------------------------------------------------------------------------- /IRKit/IRKit/IRPeripheral.h: -------------------------------------------------------------------------------- 1 | // IRPeripheral is a IRKit device representation 2 | #import 3 | 4 | @interface IRPeripheral : NSObject 5 | 6 | @property (nonatomic, copy) NSString *hostname; 7 | @property (nonatomic, copy) NSString *customizedName; 8 | @property (nonatomic, copy) NSDate *foundDate; 9 | @property (nonatomic, copy) NSString *deviceid; 10 | 11 | @property (nonatomic, copy) NSString *modelName; 12 | @property (nonatomic, copy) NSString *version; 13 | @property (nonatomic, copy) NSString *regdomain; // for debug purpose only 14 | 15 | - (instancetype)initWithDictionary:(NSDictionary *)dictionary; 16 | - (BOOL)hasDeviceID; 17 | - (void)setHostname:(NSString *)hostname; 18 | - (NSString *)local_hostname; 19 | 20 | // this takes time on 1st call, so you might want to prefetch on viewDidLoad or something 21 | - (BOOL)isReachableViaWifi; 22 | 23 | - (void)getKeyWithCompletion:(void (^) ())successfulCompletion; 24 | - (void)getModelNameAndVersionWithCompletion:(void (^) ())successfulCompletion; 25 | - (NSComparisonResult)compareByFirstFoundDate:(IRPeripheral *)otherPeripheral; 26 | 27 | - (NSString *)iconURL; 28 | - (NSString *)modelNameAndRevision; 29 | 30 | - (NSDictionary *)asDictionary; 31 | - (void)inflateFromDictionary:(NSDictionary *)dictionary; 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /IRKit/IRKit/IRUserDefaultsStore.m: -------------------------------------------------------------------------------- 1 | #import "Log.h" 2 | #import "IRUserDefaultsStore.h" 3 | 4 | #define IR_NSUSERDEFAULTS_PREFIX @"ir" 5 | 6 | @implementation IRUserDefaultsStore 7 | 8 | - (void)storeObject:(id)object forKey:(NSString *)key { 9 | LOG_CURRENT_METHOD; 10 | 11 | NSUserDefaults *d = [NSUserDefaults standardUserDefaults]; 12 | [d setObject: object 13 | forKey: [NSString stringWithFormat: @"%@:%@", 14 | IR_NSUSERDEFAULTS_PREFIX, key]]; 15 | } 16 | 17 | - (void)storePeripherals:(NSDictionary*)object { 18 | LOG_CURRENT_METHOD; 19 | 20 | NSData *data = [NSKeyedArchiver archivedDataWithRootObject: object]; 21 | [self storeObject: data forKey: @"peripherals"]; 22 | } 23 | 24 | - (id)objectForKey:(NSString *)key { 25 | LOG_CURRENT_METHOD; 26 | 27 | NSUserDefaults *d = [NSUserDefaults standardUserDefaults]; 28 | return [d objectForKey: [NSString stringWithFormat: @"%@:%@", 29 | IR_NSUSERDEFAULTS_PREFIX, key]]; 30 | } 31 | 32 | - (NSDictionary*)loadPeripherals { 33 | NSData *data = [self objectForKey: @"peripherals"]; 34 | return data ? [NSKeyedUnarchiver unarchiveObjectWithData: data] 35 | : nil; 36 | } 37 | 38 | - (void)synchronize { 39 | LOG_CURRENT_METHOD; 40 | [[NSUserDefaults standardUserDefaults] synchronize]; 41 | } 42 | 43 | @end 44 | -------------------------------------------------------------------------------- /IRKit/IRKitResources/IRFAQViewController.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /IRKit/IRKitViewSamples/IRKitViewSamples-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleDisplayName 8 | ${PRODUCT_NAME} 9 | CFBundleExecutable 10 | ${EXECUTABLE_NAME} 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | ${PRODUCT_NAME} 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1.0 25 | LSRequiresIPhoneOS 26 | 27 | UIMainStoryboardFile 28 | MainStoryboard 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /spec/diagrams/send-ir-signal.msc: -------------------------------------------------------------------------------- 1 | msc { 2 | # entities 3 | user, peripheral, central, irreceiver; 4 | 5 | # space 6 | |||; 7 | 8 | user note central [label = "Successfully authenticated"]; 9 | 10 | |||; 11 | 12 | peripheral note central [label = "Always connected when app is active in foreground.\nSending can occur when app is in background."]; 13 | 14 | |||; 15 | 16 | user -> central [label = "Select IR signal to send"]; 17 | 18 | peripheral <- central [label = "Connect if disconnected (in background)"]; 19 | 20 | peripheral <= central [label = "Write \"IR Data\" offset = \"0\" value = \"...\""]; 21 | peripheral >> central [label = "ack"]; 22 | peripheral <= central [label = "Write \"IR Data\" offset = \"...\" value = \"...\""]; 23 | peripheral >> central [label = "ack"]; 24 | peripheral <= central [label = "Write \"IR Data\" offset = \"...\" value = \"...\""]; 25 | peripheral >> central [label = "ack"]; 26 | 27 | peripheral <= central [label = "Write \"IR Control Point\" value = \"0 - Send IR Data\""]; 28 | peripheral >> central [label = "ack"]; 29 | 30 | peripheral -> irreceiver [label = "Send IR signal"]; 31 | 32 | irreceiver note irreceiver [label = "Action"]; 33 | 34 | peripheral note central [label = "Stay connected while app is active"]; 35 | 36 | peripheral <- central [label = "Disconnect when app goes inactive"]; 37 | } 38 | -------------------------------------------------------------------------------- /IRKit/IRKit/IRSignalSendOperation.m: -------------------------------------------------------------------------------- 1 | #import "Log.h" 2 | #import "IRSignalSendOperation.h" 3 | #import "IRConst.h" 4 | #import "IRHelper.h" 5 | 6 | @interface IRSignalSendOperation () 7 | 8 | @property BOOL isExecuting; 9 | @property BOOL isFinished; 10 | 11 | @property (nonatomic) IRPeripheral *peripheral; 12 | @property (nonatomic) NSData *data; 13 | @property (nonatomic, copy) void (^ completion)(NSError *error); 14 | 15 | @end 16 | 17 | @implementation IRSignalSendOperation 18 | 19 | - (id)initWithSignal:(IRSignal *)signal 20 | completion:(void (^)(NSError *error))completion { 21 | LOG_CURRENT_METHOD; 22 | self = [super init]; 23 | if (!self) { 24 | return nil; 25 | } 26 | _signal = signal; 27 | _completion = completion; 28 | return self; 29 | } 30 | 31 | - (void)start { 32 | LOG_CURRENT_METHOD; 33 | 34 | self.isExecuting = YES; 35 | self.isFinished = NO; 36 | 37 | [_signal sendWithCompletion:^(NSError *error) { 38 | _completion(error); 39 | self.isExecuting = NO; 40 | self.isFinished = YES; 41 | }]; 42 | } 43 | 44 | #pragma mark - KVO 45 | 46 | + (BOOL)automaticallyNotifiesObserversForKey:(NSString *)key { 47 | if ([key isEqualToString: @"isExecuting"] || [key isEqualToString: @"isFinished"]) { 48 | return YES; 49 | } 50 | return [super automaticallyNotifiesObserversForKey: key]; 51 | } 52 | 53 | - (BOOL)isConcurrent { 54 | return NO; 55 | } 56 | 57 | @end 58 | -------------------------------------------------------------------------------- /IRKit/IRKit/IRPeripherals+UIKit.m: -------------------------------------------------------------------------------- 1 | // 2 | // IRPeripherals+UIKit.m 3 | // IRKit 4 | // 5 | // Created by Masakazu Ohtsuka on 2014/04/01. 6 | // 7 | // 8 | 9 | #import "IRPeripherals+UIKit.h" 10 | #import "Log.h" 11 | #import "IRPeripheralCell.h" 12 | #import "IRConst.h" 13 | #import "IRHelper.h" 14 | 15 | @implementation IRPeripherals (UITableView) 16 | 17 | #pragma mark - UITableViewDataSource 18 | 19 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 20 | LOG(@"indexPath.row: %ld", (long)indexPath.row); 21 | 22 | IRPeripheralCell *cell = (IRPeripheralCell *)[tableView dequeueReusableCellWithIdentifier: IRKitCellIdentifierPeripheral]; 23 | if (cell == nil) { 24 | [tableView registerNib: [UINib nibWithNibName: @"IRPeripheralCell" bundle: [IRHelper resources]] 25 | forCellReuseIdentifier: IRKitCellIdentifierPeripheral]; 26 | 27 | cell = [tableView dequeueReusableCellWithIdentifier: IRKitCellIdentifierPeripheral]; 28 | } 29 | cell.peripheral = [self objectAtIndex: indexPath.row]; 30 | return cell; 31 | } 32 | 33 | - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { 34 | LOG_CURRENT_METHOD; 35 | return self.countOfReadyPeripherals; 36 | } 37 | 38 | #pragma mark - UITableViewDelegate 39 | 40 | - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { 41 | LOG_CURRENT_METHOD; 42 | return [IRPeripheralCell height]; 43 | } 44 | 45 | @end 46 | -------------------------------------------------------------------------------- /Minimal/Minimal/Minimal-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleDisplayName 8 | ${PRODUCT_NAME} 9 | CFBundleExecutable 10 | ${EXECUTABLE_NAME} 11 | CFBundleIdentifier 12 | jp.maaash.irkit.${PRODUCT_NAME:rfc1034identifier} 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | ${PRODUCT_NAME} 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1.0 25 | LSRequiresIPhoneOS 26 | 27 | NSAppTransportSecurity 28 | 29 | NSAllowsArbitraryLoads 30 | 31 | 32 | UIMainStoryboardFile 33 | MainStoryboard 34 | UIRequiredDeviceCapabilities 35 | 36 | armv7 37 | 38 | UISupportedInterfaceOrientations 39 | 40 | UIInterfaceOrientationPortrait 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /IRKit/IRKitResources/IRKitResources-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIconFile 10 | 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | ${PRODUCT_NAME} 17 | CFBundlePackageType 18 | BNDL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1 25 | CFPlugInDynamicRegisterFunction 26 | 27 | CFPlugInDynamicRegistration 28 | NO 29 | CFPlugInFactories 30 | 31 | 00000000-0000-0000-0000-000000000000 32 | MyFactoryFunction 33 | 34 | CFPlugInTypes 35 | 36 | 00000000-0000-0000-0000-000000000000 37 | 38 | 00000000-0000-0000-0000-000000000000 39 | 40 | 41 | CFPlugInUnloadFunction 42 | 43 | NSHumanReadableCopyright 44 | Copyright © 2013年 mash (Masakazu Ohtsuka). All rights reserved. 45 | 46 | 47 | -------------------------------------------------------------------------------- /IRKit/IRKit/IRConst.h: -------------------------------------------------------------------------------- 1 | #ifndef IRKit_IRConst_h 2 | #define IRKit_IRConst_h 3 | 4 | #pragma mark - UITableViewCell identifiers 5 | 6 | #define IRKitCellIdentifierSignal @"IRSignalCell" 7 | #define IRKitCellIdentifierPeripheral @"IRPeripheralCell" 8 | #define IRKitCellIdentifierEdit @"IREditCell" 9 | 10 | #pragma mark - IR*ViewControllerDelegate 11 | 12 | #define IRViewControllerResultType @"result" 13 | #define IRViewControllerResultTypeCancelled @"cancelled" 14 | #define IRViewControllerResultTypeDone @"done" 15 | #define IRViewControllerResultPeripheral @"peripheral" 16 | #define IRViewControllerResultSignal @"signal" 17 | #define IRViewControllerResultText @"text" 18 | #define IRViewControllerResultKeys @"keys" 19 | 20 | #pragma mark - Errors 21 | 22 | #define IRKitErrorDomain @"irkit" 23 | #define IRKitErrorDomainHTTP @"irkit.http" 24 | 25 | #define IRKitHTTPStatusCodeUnknown 999 26 | 27 | #pragma mark - URLs 28 | 29 | #define STATICENDPOINT_BASE @"http://getirkit.com" 30 | #define APIENDPOINT_BASE @"https://api.getirkit.com" 31 | #define APIENDPOINT_APPS @"http://api.getirkit.com/1/apps/recommended" 32 | 33 | #pragma mark - Notifications 34 | 35 | extern NSString *const IRClientDidRegisterNotification; 36 | 37 | #endif // ifndef IRKit_IRConst_h 38 | -------------------------------------------------------------------------------- /spec/diagrams/connect.msc: -------------------------------------------------------------------------------- 1 | msc { 2 | # entities 3 | user, peripheral, central; 4 | 5 | user -> peripheral [label = "Power ON"]; 6 | peripheral note peripheral [label = "Starts advertising"]; 7 | peripheral -> central [label = "Advertise"]; 8 | 9 | user -> central [label = "Launch App"]; 10 | 11 | peripheral <= central [label = "Connect, fetch services, characteristics"]; 12 | peripheral >> central [label = "..."]; 13 | 14 | peripheral <= central [label = "Read 'Authentication Status' c12c"]; 15 | peripheral >> central [label = "0 - Unauthenticated"]; 16 | 17 | central note central [label = "Show guide to move central close to peripheral"]; 18 | 19 | central note central [label = "Periodically read 'Authentication Status' c12c"]; 20 | 21 | peripheral <= central [label = "Read 'Authentication Status' c12c"]; 22 | peripheral note peripheral [label = "RSSI is low"]; 23 | peripheral >> central [label = "0 - Unauthenticated"]; 24 | 25 | peripheral <= central [label = "Read 'Authentication Status' c12c"]; 26 | peripheral note peripheral [label = "RSSI is low"]; 27 | peripheral >> central [label = "0 - Unauthenticated"]; 28 | 29 | user note central [label = "User moves central towards peripheral"]; 30 | 31 | peripheral <= central [label = "Read 'Authentication Status' c12c"]; 32 | peripheral note peripheral [label = "RSSI is high"]; 33 | peripheral >> central [label = "1 - Authenticated"]; 34 | 35 | user note central [label = "Successfully authenticated"]; 36 | 37 | peripheral note central [label = "Stay connected while app is active"]; 38 | 39 | peripheral <- central [label = "Disconnect when app goes inactive"]; 40 | } 41 | -------------------------------------------------------------------------------- /IRKit/IRKit/IRHTTPClient.h: -------------------------------------------------------------------------------- 1 | // 2 | // IRHTTPClient.h 3 | // IRKit 4 | // 5 | // Created by Masakazu Ohtsuka on 2013/11/21. 6 | // 7 | // 8 | 9 | #import 10 | #import "IRSignal.h" 11 | 12 | @interface IRHTTPClient : NSObject 13 | 14 | - (void)cancel; 15 | + (NSURL *)base; 16 | + (void)fetchHostInfoOf:(NSString *)hostname withCompletion:(void (^) (NSHTTPURLResponse * res, NSDictionary * info, NSError * error))completion; 17 | + (NSDictionary *)hostInfoFromResponse:(NSHTTPURLResponse *)res; 18 | + (void)checkIfAdhocWithCompletion:(void (^) (NSHTTPURLResponse * res, BOOL isAdhoc, NSError * error))completion; 19 | + (void)postWifiKeys:(NSString *)keys withCompletion:(void (^) (NSHTTPURLResponse * res, id body, NSError * error))completion; 20 | + (void)postSignal:(IRSignal *)signal withCompletion:(void (^) (NSError * error))completion; 21 | + (void)postSignal:(IRSignal *)signal toPeripheral:(IRPeripheral*)peripheral withCompletion:(void (^)(NSError *error))completion; 22 | + (void)getDeviceIDFromHost:(NSString *)hostname withCompletion:(void (^) (NSHTTPURLResponse * res_local, NSHTTPURLResponse * res_internet, NSString * deviceid, NSError * error))completion; 23 | + (void)ensureRegisteredAndCall:(void (^) (NSError * error))next; 24 | + (void)registerDeviceWithCompletion:(void (^) (NSHTTPURLResponse * res, NSDictionary * keys, NSError * error))completion; 25 | + (IRHTTPClient *)waitForSignalWithCompletion:(void (^) (NSHTTPURLResponse * res, IRSignal * signal, NSError * error))completion; 26 | + (IRHTTPClient *)waitForDoorWithDeviceID:(NSString *)deviceid completion:(void (^) (NSHTTPURLResponse * res, id object, NSError * error))completion; 27 | + (void)showAlertOfError:(NSError *)error; 28 | + (void)cancelLocalRequests; 29 | 30 | @end 31 | -------------------------------------------------------------------------------- /IRKit/IRKit/IRSignalSendOperationQueue.m: -------------------------------------------------------------------------------- 1 | #import "Log.h" 2 | #import "IRSignalSendOperationQueue.h" 3 | 4 | @interface IRSignalSendOperationQueue () 5 | 6 | @property (nonatomic) BOOL didRemoveObserver; 7 | 8 | @end 9 | 10 | @implementation IRSignalSendOperationQueue 11 | 12 | - (id)init { 13 | LOG_CURRENT_METHOD; 14 | self = [super init]; 15 | if (!self) { 16 | return nil; 17 | } 18 | 19 | [self setSuspended: NO]; 20 | [self setMaxConcurrentOperationCount: 1]; 21 | 22 | [self addObserver: self 23 | forKeyPath: @"operationCount" 24 | options: NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld 25 | context: nil]; 26 | 27 | return self; 28 | } 29 | 30 | - (void)dealloc { 31 | LOG_CURRENT_METHOD; 32 | if (!_didRemoveObserver) { 33 | [self removeObserver: self 34 | forKeyPath: @"operationCount"]; 35 | } 36 | } 37 | 38 | #pragma mark - KVO 39 | 40 | - (void)observeValueForKeyPath:(NSString *)keyPath 41 | ofObject:(id)object 42 | change:(NSDictionary *)change 43 | context:(void *)context { 44 | LOG(@"keyPath: %@", keyPath); 45 | 46 | if ([keyPath isEqualToString: @"operationCount"]) { 47 | NSObject *newValue = [change objectForKey: NSKeyValueChangeNewKey]; 48 | if (newValue && ([(NSNumber *)newValue unsignedIntegerValue] == 0)) { 49 | _didRemoveObserver = YES; 50 | [self removeObserver: self 51 | forKeyPath: @"operationCount"]; 52 | dispatch_async(dispatch_get_main_queue(), ^{ 53 | _completion(_error); 54 | }); 55 | } 56 | } 57 | } 58 | 59 | @end 60 | -------------------------------------------------------------------------------- /IRKit/IRKit/IRFAQViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // IRFAQViewController.m 3 | // IRKit 4 | // 5 | // Created by Masakazu Ohtsuka on 2014/04/10. 6 | // 7 | // 8 | 9 | #import "IRFAQViewController.h" 10 | #import "Log.h" 11 | #import "IRConst.h" 12 | #import "IRHelper.h" 13 | #import "IRViewCustomizer.h" 14 | 15 | @interface IRFAQViewController () 16 | 17 | @end 18 | 19 | @implementation IRFAQViewController 20 | 21 | - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { 22 | self = [super initWithNibName: nibNameOrNil bundle: nibBundleOrNil]; 23 | if (self) { 24 | // Custom initialization 25 | } 26 | return self; 27 | } 28 | 29 | - (void)viewDidLoad { 30 | [super viewDidLoad]; 31 | 32 | self.navigationItem.title = IRLocalizedString(@"FAQ", @"title of IRFAQViewController"); 33 | self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem: UIBarButtonSystemItemCancel 34 | target: self 35 | action: @selector(cancelButtonPressed:)]; 36 | 37 | [IRViewCustomizer sharedInstance].viewDidLoad(self); 38 | 39 | UIWebView *webView = (UIWebView*)self.view; 40 | NSURL *url = [NSURL URLWithString: @"/faq" relativeToURL: [NSURL URLWithString: STATICENDPOINT_BASE]]; 41 | [webView loadRequest: [NSURLRequest requestWithURL: url]]; 42 | } 43 | 44 | - (void)cancelButtonPressed:(id)sender { 45 | [self.delegate faqViewControllerDidFinish: self]; 46 | } 47 | 48 | - (void)didReceiveMemoryWarning { 49 | [super didReceiveMemoryWarning]; 50 | // Dispose of any resources that can be recreated. 51 | } 52 | 53 | @end 54 | -------------------------------------------------------------------------------- /IRKit/IRKit/IRViewHelper.m: -------------------------------------------------------------------------------- 1 | // 2 | // IRViewHelper.m 3 | // IRKit 4 | // 5 | // Created by Masakazu Ohtsuka on 2014/04/01. 6 | // 7 | // 8 | 9 | #import "IRViewHelper.h" 10 | #import "IRHelper.h" 11 | 12 | @implementation IRViewHelper 13 | 14 | + (void)enumerateSubviewsOfRootView:(UIView *)view usingBlock:(void (^)(id obj, NSUInteger idx, BOOL *stop))block { 15 | block(view, 0, 0); 16 | for (UIView *subview in view.subviews) { 17 | [self enumerateSubviewsOfRootView: subview usingBlock: block]; 18 | } 19 | } 20 | 21 | + (UIFont *)fontWithSize:(CGFloat)size { 22 | NSString *lang = [[NSLocale preferredLanguages] objectAtIndex: 0]; 23 | 24 | if ([lang isEqualToString: @"ja"]) { 25 | return [UIFont fontWithName: @"HiraKakuProN-W3" size: size]; 26 | } 27 | else { 28 | return [UIFont fontWithName: @"HelveticaNeue-Light" size: size]; 29 | } 30 | } 31 | 32 | + (UIImage *)imageWithColor:(UIColor *)color { 33 | CGRect rect = CGRectMake(0.0f, 0.0f, 1.0f, 1.0f); 34 | 35 | UIGraphicsBeginImageContext(rect.size); 36 | CGContextRef context = UIGraphicsGetCurrentContext(); 37 | 38 | CGContextSetFillColorWithColor(context, [color CGColor]); 39 | CGContextFillRect(context, rect); 40 | 41 | UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); 42 | UIGraphicsEndImageContext(); 43 | 44 | return image; 45 | } 46 | 47 | + (UIImage *)imageInResourceNamed:(NSString *)name { 48 | NSBundle *bundle = [IRHelper resources]; 49 | NSString *path2x = [bundle pathForResource: [NSString stringWithFormat: @"%@@2x", name] 50 | ofType: @"png"]; 51 | UIImage *ret = [UIImage imageWithContentsOfFile: path2x]; 52 | 53 | if (!ret) { 54 | ret = [UIImage imageWithContentsOfFile: [bundle pathForResource: name 55 | ofType: @"png"]]; 56 | } 57 | return ret; 58 | } 59 | 60 | @end 61 | -------------------------------------------------------------------------------- /IRKit/IRKitTests/IRReachabilityTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // IRReachabilityTests.m 3 | // IRKit 4 | // 5 | // Created by Masakazu Ohtsuka on 2014/03/17. 6 | // 7 | // 8 | 9 | #import 10 | #import "IRPeripherals.h" 11 | #import "IRPeripheral.h" 12 | #import "Log.h" 13 | #import "IRReachability.h" 14 | #import "XCTestCase+Async.h" 15 | 16 | @interface IRReachabilityTests : XCTestCase 17 | 18 | @end 19 | 20 | @implementation IRReachabilityTests 21 | 22 | - (void)setUp { 23 | [super setUp]; 24 | // Put setup code here. This method is called before the invocation of each test method in the class. 25 | } 26 | 27 | - (void)tearDown { 28 | // Put teardown code here. This method is called after the invocation of each test method in the class. 29 | [super tearDown]; 30 | } 31 | 32 | - (void)testReachable { 33 | NSDate *before = [NSDate date]; 34 | 35 | IRReachability *r = [IRReachability reachabilityWithHostname: @"google.com"]; 36 | // IRReachability *r = [IRReachability reachabilityWithHostname: @"irkitd2b4.local"]; 37 | BOOL wifi = [r isReachableViaWiFi]; 38 | BOOL direct = [r isReachableViaWiFiAndDirect]; 39 | 40 | NSDate *after = [NSDate date]; 41 | NSTimeInterval interval = [after timeIntervalSinceDate: before]; 42 | LOG( @"reachability took %.1f seconds", interval ); 43 | 44 | XCTAssertEqual(wifi, 0, @"is initially not reachable (wifi)"); 45 | XCTAssertEqual(direct, 0, @"is initially not reachable (direct)"); 46 | XCTAssertEqual(interval < 0.1, true ); 47 | 48 | dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ 49 | BOOL wifi = [r isReachableViaWiFi]; 50 | BOOL direct = [r isReachableViaWiFiAndDirect]; 51 | XCTAssertEqual(wifi, 1, @"is reachable via wifi after a while"); 52 | XCTAssertEqual(direct, 0, @"google is not reachable directly"); 53 | [self stopWaiting]; 54 | }); 55 | [self startWaiting]; 56 | } 57 | 58 | @end 59 | -------------------------------------------------------------------------------- /Minimal/Minimal/MMAppDelegate.m: -------------------------------------------------------------------------------- 1 | #import "MMAppDelegate.h" 2 | #import 3 | 4 | @implementation MMAppDelegate 5 | 6 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 7 | [IRKit startWithAPIKey: @"4C68F181CA1D4D858E6E51F4A4D77FA4"]; 8 | return YES; 9 | } 10 | 11 | - (void)applicationWillResignActive:(UIApplication *)application { 12 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 13 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 14 | } 15 | 16 | - (void)applicationDidEnterBackground:(UIApplication *)application { 17 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 18 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 19 | } 20 | 21 | - (void)applicationWillEnterForeground:(UIApplication *)application { 22 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 23 | } 24 | 25 | - (void)applicationDidBecomeActive:(UIApplication *)application { 26 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 27 | } 28 | 29 | - (void)applicationWillTerminate:(UIApplication *)application { 30 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 31 | } 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /IRKit/IRKitViewSamples/IRAppDelegate.m: -------------------------------------------------------------------------------- 1 | #import "IRAppDelegate.h" 2 | 3 | @implementation IRAppDelegate 4 | 5 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 6 | { 7 | // Override point for customization after application launch. 8 | return YES; 9 | } 10 | 11 | - (void)applicationWillResignActive:(UIApplication *)application 12 | { 13 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 14 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 15 | } 16 | 17 | - (void)applicationDidEnterBackground:(UIApplication *)application 18 | { 19 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 20 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 21 | } 22 | 23 | - (void)applicationWillEnterForeground:(UIApplication *)application 24 | { 25 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 26 | } 27 | 28 | - (void)applicationDidBecomeActive:(UIApplication *)application 29 | { 30 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 31 | } 32 | 33 | - (void)applicationWillTerminate:(UIApplication *)application 34 | { 35 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 36 | } 37 | 38 | @end 39 | -------------------------------------------------------------------------------- /IRKit/IRKit/IRSignal.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import "IRPeripheral.h" 3 | 4 | @protocol IRSendable 5 | 6 | @required 7 | /// Send this! 8 | /// You need to set `peripheral` or `hostname` readwrite property, 9 | /// to specify from which IRKit device to send this. 10 | - (void)sendWithCompletion:(void (^) (NSError * error))block; 11 | 12 | - (instancetype)initWithDictionary:(NSDictionary *)dictionary; 13 | 14 | /// Public, safe to share information about IR signal. 15 | /// You can transfer this dictionary to other end users and `initWithDictionary:` 16 | /// to instantiate a copy. 17 | /// Set `peripheral` or `hostname` readwrite property, 18 | /// to specify from which IRKit device to send this. 19 | - (NSDictionary *)asPublicDictionary; 20 | 21 | /// Includes enough information to send this signal from one IRKit. 22 | /// Does include IRKit device's hostname but not it's deviceid (valid only when used with it's paired clientid). 23 | /// Use this to share signal information within multiple clients used against single IRKit device. 24 | /// ex: OK to Share between multiple client apps on single iPhone/Mac 25 | - (NSDictionary *)asSendableDictionary; 26 | 27 | /// Includes information about end user's IRKit device's hostname and so on, 28 | /// so use `asPublicDictionary` when you want to share signal information over to other end users. 29 | /// Use this to backup signals information inside single app. 30 | - (NSDictionary *)asDictionary; 31 | 32 | @end 33 | 34 | @interface IRSignal : NSObject 35 | 36 | #pragma mark - included in asPublicDictionary 37 | 38 | @property (nonatomic) NSArray *data; 39 | 40 | /// "raw" only for now 41 | @property (nonatomic, copy) NSString *format; 42 | 43 | /// kHz 44 | @property (nonatomic) NSNumber *frequency; 45 | 46 | #pragma mark - also included in asDictionary 47 | 48 | @property (nonatomic) IRPeripheral *peripheral; 49 | @property (nonatomic, copy) NSString *hostname; 50 | 51 | @property (nonatomic, copy) NSString *name; 52 | @property (nonatomic) NSDictionary *custom; 53 | 54 | @end 55 | -------------------------------------------------------------------------------- /IRKit.podspec: -------------------------------------------------------------------------------- 1 | osx_source_files = %w{Log IRKit IRKit+Internal IRPersistentStore IRHelper IRHTTPJSONOperation IRHTTPOperationQueue IRHTTPClient IRReachability IRPeripheral IRPeripherals IRSignal IRSignals IRSignalSequence IRSignalSendOperationQueue IRSignalSendOperation IRSearcher IRUserDefaultsStore IRConst} 2 | 3 | Pod::Spec.new do |s| 4 | s.name = "IRKit" 5 | s.version = "3.0.2" 6 | s.summary = "Send/Receive Infrared signals via IRKit device." 7 | s.description = <<-DESC 8 | IRKit device and SDK(this library) lets you control your home electronics from your iOS devices. 9 | IRKit device has a Infrared LED and receiver, and a WiFi module inside. 10 | WiFi enabled devices (such as your iOS device) can connect with IRKit devices, and make it send IR signals for you. 11 | This library does: 12 | * provide UIViewController subclasses that wraps complex procedures to connect and receive IR signals(to learn before sending) from IRKit devices 13 | * provide a simple interface to send IR signals 14 | DESC 15 | s.homepage = "http://github.com/irkit/ios-sdk" 16 | s.license = 'MIT' 17 | s.author = { "Masakazu OHTSUKA" => "o.masakazu@gmail.com" } 18 | s.source = { :git => "https://github.com/irkit/ios-sdk.git", :tag => "3.0.2" } 19 | s.ios.deployment_target = '6.0' 20 | # s.osx.deployment_target = '10.9' 21 | s.ios.source_files = 'IRKit/IRKit/*.{h,m,c}' 22 | # s.osx.source_files = osx_source_files.map { |file| "IRKit/IRKit/#{file}.{h,m,c}" } 23 | s.public_header_files = 'IRKit/IRKit/' 24 | 25 | s.ios.resource_bundle = { 26 | 'IRKit' => 'IRKit/IRKitResources/**/*.{png,xib,plist,strings}' 27 | } 28 | s.ios.frameworks = 'Foundation', 'QuartzCore', 'CoreGraphics', 'CoreTelephony', 'UIKit', 'MediaPlayer', 'SystemConfiguration', 'AudioToolbox', 'AVFoundation' 29 | # s.osx.frameworks = 'Foundation', 'QuartzCore', 'CoreGraphics', 'SystemConfiguration' 30 | s.library = 'c++' 31 | s.requires_arc = true 32 | s.dependency 'ISHTTPOperation' 33 | end 34 | -------------------------------------------------------------------------------- /IRKit/IRKitTests/IRSignalsTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // IRSignalsTests.m 3 | // IRKit 4 | // 5 | // Created by Masakazu Ohtsuka on 2014/02/18. 6 | // 7 | // 8 | 9 | #import 10 | #import 11 | #import "IRKit.h" 12 | #import "Log.h" 13 | #import "XCTestCase+Async.h" 14 | #import "IRKitTests.h" 15 | 16 | @interface IRSignalsTests : XCTestCase 17 | 18 | @end 19 | 20 | @implementation IRSignalsTests 21 | 22 | - (void)setUp { 23 | [super setUp]; 24 | 25 | [OHHTTPStubs stubRequestsPassingTest:^BOOL (NSURLRequest *request) { 26 | return YES; 27 | } withStubResponse:^OHHTTPStubsResponse *(NSURLRequest *request) { 28 | return [OHHTTPStubsResponse responseWithData: nil 29 | statusCode: 200 30 | headers: nil]; 31 | }]; 32 | } 33 | 34 | - (void)tearDown { 35 | [OHHTTPStubs removeAllStubs]; 36 | [super tearDown]; 37 | } 38 | 39 | - (void)testSaveAndRestore { 40 | IRSignals *signals = [[IRSignals alloc] init]; 41 | IRSignal *signal = [IRKitTests makeTestSignal]; 42 | signal.peripheral = [IRKitTests makeTestPeripheral]; 43 | [signals addSignalsObject: signal]; 44 | 45 | NSData *data = signals.data; 46 | XCTAssertNotNil(data); 47 | 48 | IRSignals *signals2 = [[IRSignals alloc] init]; 49 | [signals2 loadFromData: data]; 50 | XCTAssertEqual(signals2.countOfSignals, (NSUInteger)1); 51 | } 52 | 53 | - (void)testSaveAndRestoreSequences { 54 | IRSignals *signals = [[IRSignals alloc] init]; 55 | IRSignal *signal = [IRKitTests makeTestSignal]; 56 | signal.peripheral = [IRKitTests makeTestPeripheral]; 57 | IRSignalSequence *sequence = [[IRSignalSequence alloc] initWithSignals: @[ signal ] andIntervals: @[]]; 58 | 59 | [signals addSignalsObject: signal]; 60 | [signals addSignalsObject: sequence]; 61 | 62 | NSData *data = signals.data; 63 | XCTAssertNotNil(data); 64 | 65 | IRSignals *signals2 = [[IRSignals alloc] init]; 66 | [signals2 loadFromData: data]; 67 | XCTAssertEqual(signals2.countOfSignals, (NSUInteger)2); 68 | } 69 | 70 | @end 71 | -------------------------------------------------------------------------------- /IRKit/IRKit/IRPeripheralCell.m: -------------------------------------------------------------------------------- 1 | #import "Log.h" 2 | #import "IRPeripheralCell.h" 3 | #import "IRHTTPClient.h" 4 | #import "IRHTTPClient+UIKit.h" 5 | #import 6 | 7 | @interface IRPeripheralCell () 8 | 9 | @end 10 | 11 | @implementation IRPeripheralCell 12 | 13 | - (void)awakeFromNib { 14 | LOG_CURRENT_METHOD; 15 | [super awakeFromNib]; 16 | 17 | self.iconView.layer.cornerRadius = 6.; 18 | self.iconView.layer.masksToBounds = YES; 19 | } 20 | 21 | - (void)dealloc { 22 | LOG_CURRENT_METHOD; 23 | [_peripheral removeObserver: self 24 | forKeyPath: @"peripheral"]; 25 | } 26 | 27 | - (void)setPeripheral:(IRPeripheral *)peripheral { 28 | LOG(@"peripheral: %@", peripheral); 29 | 30 | if (_peripheral) { 31 | // don't double addObserver, nor removeObserver before addObserver 32 | [_peripheral removeObserver: self 33 | forKeyPath: @"peripheral"]; 34 | } 35 | _peripheral = peripheral; 36 | 37 | self.nameLabel.text = peripheral.customizedName; 38 | self.detailLabel.text = self.detailLabelText; 39 | 40 | // load image from internet 41 | NSString *url = _peripheral.iconURL; 42 | [IRHTTPClient loadImage: url 43 | completionHandler:^(NSHTTPURLResponse *response, UIImage *image, NSError *error) { 44 | if (error || (response.statusCode != 200) || !image) { 45 | return; 46 | } 47 | self.iconView.image = image; 48 | }]; 49 | 50 | [_peripheral addObserver: self 51 | forKeyPath: @"peripheral" 52 | options: NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld 53 | context: NULL]; 54 | } 55 | 56 | - (NSString *)detailLabelText { 57 | return [NSString stringWithFormat: @"%@ %@", _peripheral.hostname, _peripheral.modelNameAndRevision]; 58 | } 59 | 60 | + (CGFloat)height { 61 | return 58; 62 | } 63 | 64 | #pragma mark - KVO 65 | 66 | - (void)observeValueForKeyPath:(NSString *)keyPath 67 | ofObject:(id)object 68 | change:(NSDictionary *)change 69 | context:(void *)context { 70 | LOG(@"keyPath: %@", keyPath); 71 | 72 | dispatch_async(dispatch_get_main_queue(), ^{ 73 | self.nameLabel.text = _peripheral.customizedName; 74 | self.detailLabel.text = self.detailLabelText; 75 | [self setNeedsDisplay]; 76 | }); 77 | } 78 | 79 | @end 80 | -------------------------------------------------------------------------------- /IRKit/IRKit/IRSignals.m: -------------------------------------------------------------------------------- 1 | #import "Log.h" 2 | #import "IRSignals.h" 3 | 4 | @interface IRSignals () 5 | 6 | @property (nonatomic) NSMutableArray *signals; 7 | 8 | @end 9 | 10 | @implementation IRSignals 11 | 12 | - (id)init { 13 | self = [super init]; 14 | if (!self) { 15 | return nil; 16 | } 17 | _signals = [NSMutableArray arrayWithCapacity: 0]; 18 | 19 | return self; 20 | } 21 | 22 | - (NSData *)data { 23 | return [NSKeyedArchiver archivedDataWithRootObject: _signals]; 24 | } 25 | 26 | - (void)loadFromData:(NSData *)data { 27 | NSMutableArray *array = data ? ((NSArray *)[NSKeyedUnarchiver unarchiveObjectWithData: data]).mutableCopy 28 | : nil; 29 | 30 | if (array) { 31 | _signals = array; 32 | } 33 | else { 34 | _signals = [[NSMutableArray alloc] init]; 35 | } 36 | LOG(@"loaded signals: %@", _signals); 37 | } 38 | 39 | - (void)loadFromStandardUserDefaultsKey:(NSString *)key { 40 | LOG(@"key: %@", key); 41 | NSUserDefaults *d = [NSUserDefaults standardUserDefaults]; 42 | NSData *data = [d objectForKey: key]; 43 | [self loadFromData: data]; 44 | } 45 | 46 | - (void)saveToStandardUserDefaultsWithKey:(NSString *)key { 47 | [self saveToUserDefaults: [NSUserDefaults standardUserDefaults] 48 | withKey: key]; 49 | } 50 | 51 | - (void)saveToUserDefaults:(NSUserDefaults*) defaults withKey:(NSString *)key { 52 | LOG(@"key: %@", key); 53 | [defaults setObject: self.data 54 | forKey: key]; 55 | [defaults synchronize]; 56 | } 57 | 58 | - (id)objectAtIndex:(NSUInteger)index { 59 | LOG(@"index: %lu", (unsigned long)index); 60 | return _signals[ index ]; 61 | } 62 | 63 | - (NSUInteger)indexOfSignal:(id)signal { 64 | LOG_CURRENT_METHOD; 65 | 66 | return [_signals indexOfObject: signal]; 67 | } 68 | 69 | #pragma mark - Key Value Coding - Mutable Indexed Accessors 70 | 71 | - (NSArray *)signals { 72 | return _signals; 73 | } 74 | 75 | - (NSUInteger)countOfSignals { 76 | return [_signals count]; 77 | } 78 | 79 | - (id)objectInSignalsAtIndex:(NSUInteger)index { 80 | return _signals[ index ]; 81 | } 82 | 83 | - (void)addSignalsObject:(id)object { 84 | [_signals addObject: object]; 85 | } 86 | 87 | - (void)insertObject:(id)object inSignalsAtIndex:(NSUInteger)index { 88 | [_signals insertObject: object atIndex: index]; 89 | } 90 | 91 | - (void)removeObjectFromSignalsAtIndex:(NSUInteger)index { 92 | [_signals removeObjectAtIndex: index]; 93 | } 94 | 95 | @end 96 | -------------------------------------------------------------------------------- /IRKit/IRKitResources/IRWifiSecuritySelectViewController.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /IRKit/IRKit/IRNewSignalViewController.m: -------------------------------------------------------------------------------- 1 | #import "Log.h" 2 | #import "IRNewSignalViewController.h" 3 | #import "IRSignal.h" 4 | #import "IRConst.h" 5 | #import "IRViewCustomizer.h" 6 | #import "IRHelper.h" 7 | 8 | @interface IRNewSignalViewController () 9 | 10 | @end 11 | 12 | @implementation IRNewSignalViewController 13 | 14 | - (void)loadView { 15 | LOG_CURRENT_METHOD; 16 | 17 | CGRect bounds = [[UIScreen mainScreen] bounds]; 18 | UIView *view = [[UIView alloc] initWithFrame: bounds]; 19 | 20 | IRNewSignalScene1ViewController *first = [[IRNewSignalScene1ViewController alloc] initWithNibName: @"IRNewSignalScene1ViewController" 21 | bundle: [IRHelper resources]]; 22 | first.delegate = self; 23 | 24 | _navController = [[UINavigationController alloc] initWithRootViewController: first]; 25 | [view addSubview: _navController.view]; 26 | 27 | self.view = view; 28 | } 29 | 30 | - (void)viewDidLoad { 31 | LOG_CURRENT_METHOD; 32 | [super viewDidLoad]; 33 | 34 | [IRViewCustomizer sharedInstance].viewDidLoad(self); 35 | } 36 | 37 | - (void)viewWillAppear:(BOOL)animated { 38 | LOG_CURRENT_METHOD; 39 | [super viewWillAppear: animated]; 40 | } 41 | 42 | - (void)viewWillDisappear:(BOOL)animated { 43 | LOG_CURRENT_METHOD; 44 | [super viewWillDisappear: animated]; 45 | } 46 | 47 | #pragma mark - UI events 48 | 49 | - (void)didReceiveMemoryWarning { 50 | LOG_CURRENT_METHOD; 51 | [super didReceiveMemoryWarning]; 52 | // Dispose of any resources that can be recreated. 53 | } 54 | 55 | #pragma mark - IRNewSignalScene1ViewControllerDelegate 56 | 57 | - (void)scene1ViewController:(IRNewSignalScene1ViewController *)viewController 58 | didFinishWithInfo:(NSDictionary *)info { 59 | LOG_CURRENT_METHOD; 60 | 61 | if ([info[IRViewControllerResultType] isEqualToString: IRViewControllerResultTypeCancelled]) { 62 | [self.delegate newSignalViewController: self 63 | didFinishWithSignal: nil]; 64 | } 65 | ASSERT(1, @"non cancelled results should be handled elsewhere"); 66 | } 67 | 68 | #pragma mark - IRSignalNameEditViewControllerDelegate 69 | 70 | - (void)signalNameEditViewController:(IRSignalNameEditViewController *)viewController 71 | didFinishWithInfo:(NSDictionary *)info { 72 | LOG_CURRENT_METHOD; 73 | 74 | if ([info[IRViewControllerResultType] isEqualToString: IRViewControllerResultTypeDone]) { 75 | IRSignal *signal = info[IRViewControllerResultSignal]; 76 | 77 | [self.delegate newSignalViewController: self 78 | didFinishWithSignal: signal]; 79 | } 80 | else if ([info[IRViewControllerResultType] isEqualToString: IRViewControllerResultTypeCancelled]) { 81 | [self.delegate newSignalViewController: self 82 | didFinishWithSignal: nil]; 83 | } 84 | } 85 | 86 | @end 87 | -------------------------------------------------------------------------------- /IRKit/IRKitTests/IRSignalSequenceTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // IRSignalSequenceTests.m 3 | // IRKit 4 | // 5 | // Created by Masakazu Ohtsuka on 2014/02/20. 6 | // 7 | // 8 | 9 | #import 10 | #import 11 | #import "IRKit.h" 12 | #import "XCTestCase+Async.h" 13 | #import "IRKitTests.h" 14 | 15 | @interface IRSignalSequenceTests : XCTestCase 16 | 17 | @end 18 | 19 | @implementation IRSignalSequenceTests 20 | 21 | - (void)setUp { 22 | [super setUp]; 23 | 24 | [OHHTTPStubs stubRequestsPassingTest:^BOOL (NSURLRequest *request) { 25 | return YES; 26 | } withStubResponse:^OHHTTPStubsResponse *(NSURLRequest *request) { 27 | return [OHHTTPStubsResponse responseWithData: nil 28 | statusCode: 200 29 | headers: nil]; 30 | }]; 31 | } 32 | 33 | - (void)tearDown { 34 | [OHHTTPStubs removeAllStubs]; 35 | [super tearDown]; 36 | } 37 | 38 | 39 | - (void)testRound { 40 | NSDictionary *signalInfo = @{ 41 | @"data": @[ @100,@100,@100,@100,@100,@100,@100,@100,@100,@100 ], 42 | @"format": @"raw", 43 | @"freq": @38, 44 | @"type": @"single", 45 | }; 46 | IRSignal *signal = [[IRSignal alloc] initWithDictionary: signalInfo]; 47 | IRSignalSequence *sequence = [[IRSignalSequence alloc] initWithSignals: @[ signal ] andIntervals: @[]]; 48 | XCTAssertNotNil(sequence); 49 | 50 | NSDictionary *signalInfo2 = sequence.asPublicDictionary; 51 | NSDictionary *expected = @{ 52 | @"type": @"sequence", 53 | @"signals": @[ signalInfo ], 54 | @"intervals": @[], 55 | }; 56 | XCTAssertEqualObjects(signalInfo2, expected); 57 | } 58 | 59 | - (void)testInitThrows { 60 | IRSignal *signal = [IRKitTests makeTestSignal]; 61 | signal.peripheral = [IRKitTests makeTestPeripheral]; 62 | IRSignal *signal2 = [IRKitTests makeTestSignal]; 63 | signal2.peripheral = [IRKitTests makeTestPeripheral]; 64 | NSArray *signals = @[ signal, signal2 ]; 65 | 66 | XCTAssertThrows( [[IRSignalSequence alloc] initWithSignals: signals andIntervals: @[] ] ); 67 | } 68 | 69 | - (void)testInitAndSend1 { 70 | IRSignal *signal = [IRKitTests makeTestSignal]; 71 | signal.peripheral = [IRKitTests makeTestPeripheral]; 72 | IRSignalSequence *sequence = [[IRSignalSequence alloc] initWithSignals: @[ signal ] andIntervals: @[]]; 73 | XCTAssert(sequence); 74 | 75 | [sequence sendWithCompletion:^(NSError *error) { 76 | XCTAssertNil(error); 77 | [self stopWaiting]; 78 | }]; 79 | [self startWaiting]; 80 | } 81 | 82 | - (void)testInitAndSend2 { 83 | IRSignal *signal = [IRKitTests makeTestSignal]; 84 | signal.peripheral = [IRKitTests makeTestPeripheral]; 85 | IRSignalSequence *sequence = [[IRSignalSequence alloc] initWithSignals: @[ signal, signal ] andIntervals: @[ @0 ]]; 86 | XCTAssert(sequence); 87 | 88 | [sequence sendWithCompletion:^(NSError *error) { 89 | XCTAssertNil(error); 90 | [self stopWaiting]; 91 | }]; 92 | [self startWaiting]; 93 | } 94 | 95 | @end 96 | -------------------------------------------------------------------------------- /IRKit/IRKit/IRHelper.m: -------------------------------------------------------------------------------- 1 | // our SDK does not pollute global namespace or objects 2 | // only classes prefixed with IR* 3 | 4 | #define LOG_DISABLED 1 5 | #import "Log.h" 6 | #import "IRHelper.h" 7 | #include 8 | #include 9 | #import 10 | 11 | NSString * IRLocalizedString(NSString *key, NSString *comment) { 12 | return [[IRHelper resources] localizedStringForKey: key value: key table: nil]; 13 | } 14 | 15 | @implementation IRHelper 16 | 17 | + (NSArray *)mapObjects:(NSArray *)array usingBlock:(id (^)(id obj, NSUInteger idx))block { 18 | NSMutableArray *result = [NSMutableArray arrayWithCapacity: [array count]]; 19 | 20 | [array enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { 21 | [result addObject: block(obj, idx)]; 22 | }]; 23 | return result; 24 | } 25 | 26 | // if we're running Minimal.app, we have IRKit.bundle in the app bundle 27 | // if we're running other app that uses cocoapods to link IRKit.framework, we use IRKit.bundle inside IRKit.framework 28 | + (NSBundle *)resources { 29 | NSBundle *framework = [NSBundle bundleForClass:self]; 30 | NSBundle *resources = [NSBundle bundleWithPath: [framework pathForResource: @"IRKit" 31 | ofType: @"bundle"]]; 32 | return resources; 33 | } 34 | 35 | #pragma mark - Network related 36 | 37 | // thanks to http://stackoverflow.com/questions/6807788/how-to-get-ip-address-of-iphone-programatically 38 | + (NSString *)localIPAddress { 39 | NSString *address = nil; 40 | struct ifaddrs *interfaces = NULL; 41 | struct ifaddrs *temp_addr = NULL; 42 | int success = 0; 43 | // retrieve the current interfaces - returns 0 on success 44 | success = getifaddrs(&interfaces); 45 | if (success == 0) { 46 | // Loop through linked list of interfaces 47 | temp_addr = interfaces; 48 | while(temp_addr != NULL) { 49 | if(temp_addr->ifa_addr->sa_family == AF_INET) { 50 | // Check if interface is en0 which is the wifi connection on the iPhone 51 | if([[NSString stringWithUTF8String: temp_addr->ifa_name] isEqualToString: @"en0"]) { 52 | // Get NSString from C String 53 | address = [NSString stringWithUTF8String: inet_ntoa(((struct sockaddr_in *)temp_addr->ifa_addr)->sin_addr)]; 54 | } 55 | } 56 | temp_addr = temp_addr->ifa_next; 57 | } 58 | } 59 | // Free memory 60 | freeifaddrs(interfaces); 61 | return address; 62 | } 63 | 64 | #if TARGET_OS_IPHONE 65 | // thanks to http://stackoverflow.com/a/15236634/105194 66 | + (NSString *)currentWifiSSID { 67 | // Does not work on the simulator. 68 | NSString *ssid = nil; 69 | NSArray *ifs = (__bridge_transfer id)CNCopySupportedInterfaces(); 70 | for (NSString *ifnam in ifs) { 71 | NSDictionary *info = (__bridge_transfer id)CNCopyCurrentNetworkInfo((__bridge CFStringRef)ifnam); 72 | LOG( @"info: %@", info ); 73 | if (info[@"SSID"]) { 74 | ssid = info[@"SSID"]; 75 | } 76 | } 77 | return ssid; 78 | } 79 | #endif // TARGET_OS_IPHONE 80 | 81 | @end 82 | -------------------------------------------------------------------------------- /IRKit/IRKit/IRNewSignalScene1ViewController.m: -------------------------------------------------------------------------------- 1 | #import "Log.h" 2 | #import "IRNewSignalScene1ViewController.h" 3 | #import "IRSignal.h" 4 | #import "IRConst.h" 5 | #import "IRViewCustomizer.h" 6 | #import "IRSignalNameEditViewController.h" 7 | #import "IRHTTPClient.h" 8 | #import "IRKit.h" 9 | #import "IRHelper.h" 10 | 11 | @interface IRNewSignalScene1ViewController () 12 | 13 | @property (nonatomic) IRHTTPClient *waiter; 14 | 15 | @end 16 | 17 | @implementation IRNewSignalScene1ViewController 18 | 19 | - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { 20 | LOG_CURRENT_METHOD; 21 | self = [super initWithNibName: nibNameOrNil bundle: nibBundleOrNil]; 22 | if (self) { 23 | // Custom initialization 24 | } 25 | return self; 26 | } 27 | 28 | - (void)dealloc { 29 | LOG_CURRENT_METHOD; 30 | } 31 | 32 | - (void)viewDidLoad { 33 | LOG_CURRENT_METHOD; 34 | [super viewDidLoad]; 35 | 36 | self.title = IRLocalizedString(@"Waiting for Signal ...", @"title of IRNewSignalScene1"); 37 | self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] 38 | initWithBarButtonSystemItem: UIBarButtonSystemItemCancel 39 | target: self 40 | action: @selector(cancelButtonPressed:)]; 41 | 42 | [IRViewCustomizer sharedInstance].viewDidLoad(self); 43 | } 44 | 45 | - (void)viewWillAppear:(BOOL)animated { 46 | LOG_CURRENT_METHOD; 47 | [super viewWillAppear: animated]; 48 | } 49 | 50 | - (void)viewDidAppear:(BOOL)animated { 51 | LOG_CURRENT_METHOD; 52 | [super viewDidAppear: animated]; 53 | 54 | __weak IRNewSignalScene1ViewController *_self = self; 55 | _waiter = [IRHTTPClient waitForSignalWithCompletion:^(NSHTTPURLResponse *res, IRSignal *signal, NSError *error) { 56 | if (signal) { 57 | [_self didReceiveSignal: signal]; 58 | } 59 | else { 60 | [_self cancelButtonPressed: nil]; 61 | } 62 | }]; 63 | } 64 | 65 | - (void)viewWillDisappear:(BOOL)animated { 66 | LOG_CURRENT_METHOD; 67 | [super viewWillDisappear: animated]; 68 | 69 | [_waiter cancel]; 70 | _waiter = nil; 71 | } 72 | 73 | - (void)didReceiveSignal:(IRSignal *)signal { 74 | LOG_CURRENT_METHOD; 75 | 76 | IRSignalNameEditViewController *c = [[IRSignalNameEditViewController alloc] initWithNibName: @"IRSignalNameEditViewController" 77 | bundle: [IRHelper resources]]; 78 | c.delegate = (id)self.delegate; 79 | c.signal = signal; 80 | [self.navigationController pushViewController: c 81 | animated: YES]; 82 | } 83 | 84 | #pragma mark - UI events 85 | 86 | - (void)didReceiveMemoryWarning { 87 | LOG_CURRENT_METHOD; 88 | [super didReceiveMemoryWarning]; 89 | // Dispose of any resources that can be recreated. 90 | } 91 | 92 | - (void)cancelButtonPressed:(id)sender { 93 | LOG_CURRENT_METHOD; 94 | 95 | [self.delegate scene1ViewController: self 96 | didFinishWithInfo: @{ 97 | IRViewControllerResultType: IRViewControllerResultTypeCancelled 98 | }]; 99 | } 100 | 101 | @end 102 | -------------------------------------------------------------------------------- /IRKit/IRKit/IRSignalNameEditViewController.m: -------------------------------------------------------------------------------- 1 | #import "Log.h" 2 | #import "IRSignalNameEditViewController.h" 3 | #import "IRConst.h" 4 | #import "IRViewCustomizer.h" 5 | #import "IRHelper.h" 6 | 7 | @interface IRSignalNameEditViewController () 8 | 9 | @end 10 | 11 | @implementation IRSignalNameEditViewController 12 | 13 | - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { 14 | LOG_CURRENT_METHOD; 15 | self = [super initWithNibName: nibNameOrNil bundle: nibBundleOrNil]; 16 | if (self) { 17 | // Custom initialization 18 | } 19 | return self; 20 | } 21 | 22 | - (void)viewDidLoad { 23 | LOG_CURRENT_METHOD; 24 | [super viewDidLoad]; 25 | 26 | self.title = IRLocalizedString(@"Give a name", @"title of IRSignalNameEdit"); 27 | self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem: UIBarButtonSystemItemDone 28 | target: self 29 | action: @selector(doneButtonPressed:)]; 30 | 31 | [IRViewCustomizer sharedInstance].viewDidLoad(self); 32 | } 33 | 34 | - (void)viewWillAppear:(BOOL)animated { 35 | LOG_CURRENT_METHOD; 36 | [super viewWillAppear: animated]; 37 | 38 | // set .signal before viewWillAppear 39 | _textField.text = _signal.name; 40 | 41 | [self editingChanged: nil]; 42 | } 43 | 44 | - (void)viewWillDisappear:(BOOL)animated { 45 | LOG_CURRENT_METHOD; 46 | [super viewWillDisappear: animated]; 47 | } 48 | 49 | - (void)processTextField:(id)sender { 50 | LOG(@"text: %@", _textField.text); 51 | 52 | if (![self isTextValid]) { 53 | return; 54 | } 55 | 56 | _signal.name = _textField.text; 57 | 58 | [self.delegate signalNameEditViewController: self 59 | didFinishWithInfo: @{ 60 | IRViewControllerResultType: IRViewControllerResultTypeDone, 61 | IRViewControllerResultText: _textField.text, 62 | IRViewControllerResultSignal: _signal, 63 | }]; 64 | } 65 | 66 | - (BOOL)isTextValid { 67 | if (!_textField.text) { 68 | return NO; 69 | } 70 | 71 | NSRegularExpression *regex = [NSRegularExpression 72 | regularExpressionWithPattern: @"^\\s*$" 73 | options: 0 74 | error: nil]; 75 | NSUInteger matches = [regex numberOfMatchesInString: _textField.text 76 | options: 0 77 | range: NSMakeRange(0, _textField.text.length)]; 78 | 79 | if (matches > 0) { 80 | // empty or whitespace only 81 | return NO; 82 | } 83 | return YES; 84 | } 85 | 86 | #pragma mark - UI events 87 | 88 | - (void)didReceiveMemoryWarning { 89 | LOG_CURRENT_METHOD; 90 | [super didReceiveMemoryWarning]; 91 | // Dispose of any resources that can be recreated. 92 | } 93 | 94 | - (void)doneButtonPressed:(id)selector { 95 | LOG(@"text: %@", self.textField.text); 96 | [self processTextField: nil]; 97 | } 98 | 99 | - (IBAction)editingChanged:(id)sender { 100 | BOOL valid = [self isTextValid]; 101 | 102 | self.navigationItem.rightBarButtonItem.enabled = valid; 103 | self.textField.textColor = valid ? [IRViewCustomizer textColor] : [IRViewCustomizer inactiveFontColor]; 104 | } 105 | 106 | #pragma mark - UITextFieldDelegate 107 | 108 | - (BOOL)textFieldShouldReturn:(UITextField *)textField { 109 | [self processTextField: nil]; 110 | return NO; 111 | } 112 | 113 | @end 114 | -------------------------------------------------------------------------------- /IRKit/IRKit/IRGuidePowerViewController.m: -------------------------------------------------------------------------------- 1 | #import "Log.h" 2 | #import "IRGuidePowerViewController.h" 3 | #import "IRConst.h" 4 | #import "IRViewCustomizer.h" 5 | #import "IRKit.h" 6 | #import "IRWifiEditViewController.h" 7 | #import "IRHelper.h" 8 | 9 | @interface IRGuidePowerViewController () 10 | 11 | @end 12 | 13 | @implementation IRGuidePowerViewController 14 | 15 | - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { 16 | LOG_CURRENT_METHOD; 17 | self = [super initWithNibName: nibNameOrNil bundle: nibBundleOrNil]; 18 | if (self) { 19 | // Custom initialization 20 | } 21 | return self; 22 | } 23 | 24 | - (void)viewDidLoad { 25 | LOG_CURRENT_METHOD; 26 | [super viewDidLoad]; 27 | 28 | self.title = IRLocalizedString(@"Setup IRKit", @"title of IRGuidePowerViewController"); 29 | self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem: UIBarButtonSystemItemCancel 30 | target: self 31 | action: @selector(cancelButtonPressed:)]; 32 | self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle: IRLocalizedString(@"Next", @"button title of IRGuidePowerViewController") 33 | style: UIBarButtonItemStyleDone 34 | target: self 35 | action: @selector(doneButtonPressed:)]; 36 | [IRViewCustomizer sharedInstance].viewDidLoad(self); 37 | 38 | Class UIApplicationClass = NSClassFromString(@"UIApplication"); 39 | if(UIApplicationClass && [UIApplicationClass respondsToSelector:@selector(sharedApplication)]) { 40 | UIApplication *application = [UIApplication performSelector:@selector(sharedApplication)]; 41 | [application setStatusBarStyle: UIStatusBarStyleLightContent animated: YES]; 42 | } 43 | } 44 | 45 | - (void)viewWillAppear:(BOOL)animated { 46 | LOG_CURRENT_METHOD; 47 | [super viewWillAppear: animated]; 48 | } 49 | 50 | - (void)viewDidAppear:(BOOL)animated { 51 | LOG_CURRENT_METHOD; 52 | [super viewDidAppear: animated]; 53 | } 54 | 55 | - (void)viewWillDisappear:(BOOL)animated { 56 | LOG_CURRENT_METHOD; 57 | [super viewWillDisappear: animated]; 58 | } 59 | 60 | - (void)didReceiveMemoryWarning { 61 | LOG_CURRENT_METHOD; 62 | [super didReceiveMemoryWarning]; 63 | // Dispose of any resources that can be recreated. 64 | } 65 | 66 | #pragma mark - UI events 67 | 68 | - (void)cancelButtonPressed:(id)sender { 69 | LOG_CURRENT_METHOD; 70 | [self.delegate scene1ViewController: self 71 | didFinishWithInfo: @{ 72 | IRViewControllerResultType: IRViewControllerResultTypeCancelled 73 | }]; 74 | } 75 | 76 | - (void)doneButtonPressed:(id)sender { 77 | LOG_CURRENT_METHOD; 78 | [self.delegate scene1ViewController: self 79 | didFinishWithInfo: @{ 80 | IRViewControllerResultType: IRViewControllerResultTypeDone 81 | }]; 82 | } 83 | 84 | - (IBAction)buyButtonPressed:(id)sender { 85 | LOG_CURRENT_METHOD; 86 | 87 | NSString *url = [NSString stringWithFormat: @"%@/store", APIENDPOINT_BASE]; 88 | Class UIApplicationClass = NSClassFromString(@"UIApplication"); 89 | if(UIApplicationClass && [UIApplicationClass respondsToSelector:@selector(sharedApplication)]) { 90 | UIApplication *application = [UIApplication performSelector:@selector(sharedApplication)]; 91 | [application performSelector:@selector(openURL:) withObject: [NSURL URLWithString: url]]; 92 | } 93 | } 94 | 95 | @end 96 | -------------------------------------------------------------------------------- /Minimal/Minimal/MMViewController.m: -------------------------------------------------------------------------------- 1 | #import "Log.h" 2 | #import "MMViewController.h" 3 | #import "MMSignalsDataSource.h" 4 | 5 | @interface MMViewController () 6 | 7 | @property (nonatomic) MMSignalsDataSource *datasource; 8 | 9 | @end 10 | 11 | @implementation MMViewController 12 | 13 | - (void)viewDidLoad 14 | { 15 | [super viewDidLoad]; 16 | 17 | _datasource = [[MMSignalsDataSource alloc] init]; 18 | 19 | self.tableView.delegate = self; 20 | self.tableView.dataSource = _datasource; 21 | } 22 | 23 | - (void)didReceiveMemoryWarning 24 | { 25 | [super didReceiveMemoryWarning]; 26 | // Dispose of any resources that can be recreated. 27 | } 28 | 29 | #pragma mark - UI 30 | 31 | - (void)viewDidAppear:(BOOL)animated { 32 | LOG_CURRENT_METHOD; 33 | static bool did_show = false; 34 | if ( ([IRKit sharedInstance].countOfReadyPeripherals == 0) && ! did_show) { 35 | IRNewPeripheralViewController *vc = [[IRNewPeripheralViewController alloc] init]; 36 | vc.delegate = self; 37 | [self presentViewController:vc 38 | animated:YES 39 | completion:^{ 40 | LOG(@"presented"); 41 | }]; 42 | did_show = true; 43 | } 44 | } 45 | 46 | - (IBAction)addButtonTouched:(id)sender { 47 | if ( [IRKit sharedInstance].countOfReadyPeripherals == 0 ) { 48 | IRNewPeripheralViewController *vc = [[IRNewPeripheralViewController alloc] init]; 49 | vc.delegate = self; 50 | [self presentViewController:vc 51 | animated:YES 52 | completion:^{ 53 | LOG(@"presented"); 54 | }]; 55 | } 56 | else { 57 | IRNewSignalViewController *vc = [[IRNewSignalViewController alloc] init]; 58 | vc.delegate = self; 59 | [self presentViewController:vc 60 | animated:YES 61 | completion:^{ 62 | LOG(@"presented"); 63 | }]; 64 | } 65 | } 66 | 67 | #pragma mark - IRNewPeripheralViewControllerDelegate 68 | 69 | - (void)newPeripheralViewController:(IRNewPeripheralViewController *)viewController 70 | didFinishWithPeripheral:(IRPeripheral *)peripheral { 71 | LOG( @"peripheral: %@", peripheral ); 72 | 73 | [self dismissViewControllerAnimated:YES 74 | completion:^{ 75 | LOG(@"dismissed"); 76 | }]; 77 | } 78 | 79 | #pragma mark - IRNewSignalViewControllerDelegate 80 | 81 | - (void)newSignalViewController:(IRNewSignalViewController *)viewController 82 | didFinishWithSignal:(IRSignal *)signal { 83 | LOG( @"signal: %@", signal ); 84 | 85 | if (signal) { 86 | [_datasource addSignalsObject:signal]; 87 | [self.tableView reloadData]; 88 | } 89 | [self dismissViewControllerAnimated:YES 90 | completion:^{ 91 | LOG(@"dismissed"); 92 | }]; 93 | } 94 | 95 | #pragma mark - UITableViewDelegate 96 | 97 | - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { 98 | return 44; 99 | } 100 | 101 | - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { 102 | LOG(@"indexPath: %@", indexPath); 103 | [tableView deselectRowAtIndexPath:indexPath 104 | animated:YES]; 105 | 106 | IRSignal *signal = [_datasource objectAtIndex:indexPath.row]; 107 | [signal sendWithCompletion:^(NSError *error) { 108 | LOG(@"sent error: %@", error); 109 | }]; 110 | } 111 | 112 | @end 113 | -------------------------------------------------------------------------------- /IRKit/IRKit/IRPeripheralNameEditViewController.m: -------------------------------------------------------------------------------- 1 | #import "Log.h" 2 | #import "IRPeripheralNameEditViewController.h" 3 | #import "IRConst.h" 4 | #import "IRViewCustomizer.h" 5 | #import "IRKit.h" 6 | #import "IRHelper.h" 7 | 8 | @interface IRPeripheralNameEditViewController () 9 | 10 | @end 11 | 12 | @implementation IRPeripheralNameEditViewController 13 | 14 | - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { 15 | LOG_CURRENT_METHOD; 16 | self = [super initWithNibName: nibNameOrNil bundle: nibBundleOrNil]; 17 | if (self) { 18 | // Custom initialization 19 | } 20 | return self; 21 | } 22 | 23 | - (void)viewDidLoad { 24 | LOG_CURRENT_METHOD; 25 | [super viewDidLoad]; 26 | 27 | self.title = IRLocalizedString(@"Give a name", @"title of IRPeripheralNameEdit"); 28 | self.navigationItem.hidesBackButton = YES; 29 | self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem: UIBarButtonSystemItemDone 30 | target: self 31 | action: @selector(doneButtonPressed:)]; 32 | 33 | [IRViewCustomizer sharedInstance].viewDidLoad(self); 34 | } 35 | 36 | - (void)viewWillAppear:(BOOL)animated { 37 | LOG_CURRENT_METHOD; 38 | [super viewWillAppear: animated]; 39 | 40 | // set .peripheral before viewWillAppear 41 | _textField.text = _peripheral.customizedName; 42 | 43 | [self editingChanged: nil]; 44 | } 45 | 46 | - (void)viewWillDisappear:(BOOL)animated { 47 | LOG_CURRENT_METHOD; 48 | [super viewWillDisappear: animated]; 49 | } 50 | 51 | - (IBAction)processTextField:(id)sender { 52 | LOG(@"text: %@", _textField.text); 53 | 54 | if (![self isTextValid]) { 55 | return; 56 | } 57 | 58 | _peripheral.customizedName = _textField.text; 59 | [[IRKit sharedInstance] save]; 60 | 61 | [self.delegate nameEditViewController: self 62 | didFinishWithInfo: @{ 63 | IRViewControllerResultType: IRViewControllerResultTypeDone, 64 | IRViewControllerResultPeripheral: _peripheral, 65 | IRViewControllerResultText: _textField.text, 66 | }]; 67 | } 68 | 69 | - (BOOL)isTextValid { 70 | if (!_textField.text) { 71 | return NO; 72 | } 73 | 74 | NSRegularExpression *regex = [NSRegularExpression 75 | regularExpressionWithPattern: @"^\\s*$" 76 | options: 0 77 | error: nil]; 78 | NSUInteger matches = [regex numberOfMatchesInString: _textField.text 79 | options: 0 80 | range: NSMakeRange(0, _textField.text.length)]; 81 | 82 | if (matches > 0) { 83 | // empty or whitespace only 84 | return NO; 85 | } 86 | return YES; 87 | } 88 | 89 | #pragma mark - UI events 90 | 91 | - (void)didReceiveMemoryWarning { 92 | LOG_CURRENT_METHOD; 93 | [super didReceiveMemoryWarning]; 94 | // Dispose of any resources that can be recreated. 95 | } 96 | 97 | - (void)doneButtonPressed:(id)selector { 98 | LOG(@"text: %@", self.textField.text); 99 | [self processTextField: nil]; 100 | } 101 | 102 | - (IBAction)editingChanged:(id)sender { 103 | BOOL valid = [self isTextValid]; 104 | 105 | self.navigationItem.rightBarButtonItem.enabled = valid; 106 | self.textField.textColor = valid ? [IRViewCustomizer textColor] : [IRViewCustomizer inactiveFontColor]; 107 | } 108 | 109 | #pragma mark - UITextFieldDelegate 110 | 111 | - (BOOL)textFieldShouldReturn:(UITextField *)textField { 112 | [self processTextField: nil]; 113 | return NO; 114 | } 115 | 116 | @end 117 | -------------------------------------------------------------------------------- /IRKit/IRKitResources/IREditCell.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /IRKit/IRKit/IRWifiSecuritySelectViewController.m: -------------------------------------------------------------------------------- 1 | #import "Log.h" 2 | #import "IRWifiSecuritySelectViewController.h" 3 | #import "IRConst.h" 4 | #import "IRViewCustomizer.h" 5 | #import "IRKit.h" 6 | #import "IREditCell.h" 7 | 8 | @interface IRWifiSecuritySelectViewController () 9 | 10 | @end 11 | 12 | @implementation IRWifiSecuritySelectViewController 13 | 14 | - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { 15 | LOG_CURRENT_METHOD; 16 | self = [super initWithNibName: nibNameOrNil bundle: nibBundleOrNil]; 17 | if (self) { 18 | // Custom initialization 19 | } 20 | return self; 21 | } 22 | 23 | - (void)viewDidLoad { 24 | LOG_CURRENT_METHOD; 25 | [super viewDidLoad]; 26 | 27 | self.title = @"Security"; 28 | self.navigationItem.rightBarButtonItem = nil; 29 | 30 | [IRViewCustomizer sharedInstance].viewDidLoad(self); 31 | } 32 | 33 | - (IRSecurityType)securityTypeForRow:(NSUInteger)row { 34 | IRSecurityType ret; 35 | 36 | switch (row) { 37 | case 0: 38 | ret = IRSecurityTypeNone; 39 | break; 40 | case 1: 41 | ret = IRSecurityTypeWEP; 42 | break; 43 | case 2: 44 | default: 45 | ret = IRSecurityTypeWPA2; 46 | break; 47 | } 48 | return ret; 49 | } 50 | 51 | - (NSUInteger)rowForSecurityType:(IRSecurityType)type { 52 | NSUInteger ret; 53 | 54 | switch (type) { 55 | case IRSecurityTypeNone: 56 | ret = 0; 57 | break; 58 | case IRSecurityTypeWEP: 59 | ret = 1; 60 | break; 61 | case IRSecurityTypeWPA2: 62 | ret = 2; 63 | break; 64 | } 65 | return ret; 66 | } 67 | 68 | - (void)viewWillAppear:(BOOL)animated { 69 | LOG_CURRENT_METHOD; 70 | [super viewWillAppear: animated]; 71 | } 72 | 73 | - (void)viewWillDisappear:(BOOL)animated { 74 | LOG_CURRENT_METHOD; 75 | [super viewWillDisappear: animated]; 76 | 77 | [_delegate securitySelectviewController: self 78 | didFinishWithSecurityType: _selectedSecurityType]; 79 | } 80 | 81 | #pragma mark - UI events 82 | 83 | - (void)didReceiveMemoryWarning { 84 | LOG_CURRENT_METHOD; 85 | [super didReceiveMemoryWarning]; 86 | // Dispose of any resources that can be recreated. 87 | } 88 | 89 | #pragma mark - UITableViewDataSource 90 | 91 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 92 | LOG_CURRENT_METHOD; 93 | 94 | UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier: @"IRWifiSecuritySelectCell"]; 95 | if (!cell) { 96 | cell = [[UITableViewCell alloc] initWithStyle: UITableViewCellStyleDefault 97 | reuseIdentifier: @"IRWifiSecuritySelectCell"]; 98 | } 99 | 100 | IRSecurityType security = [self securityTypeForRow: indexPath.row]; 101 | cell.textLabel.text = [IRKeys securityTypeStringOf: security]; 102 | 103 | if ([self securityTypeForRow: indexPath.row] == _selectedSecurityType) { 104 | cell.accessoryType = UITableViewCellAccessoryCheckmark; 105 | } 106 | else { 107 | cell.accessoryType = UITableViewCellAccessoryNone; 108 | } 109 | return cell; 110 | } 111 | 112 | - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { 113 | return 1; 114 | } 115 | 116 | - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { 117 | return 3; 118 | } 119 | 120 | #pragma mark - UITableViewDelegate 121 | 122 | - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { 123 | LOG_CURRENT_METHOD; 124 | [tableView deselectRowAtIndexPath: indexPath animated: YES]; 125 | 126 | NSUInteger row = [self rowForSecurityType: _selectedSecurityType]; 127 | 128 | _selectedSecurityType = [self securityTypeForRow: indexPath.row]; 129 | 130 | if (indexPath.row != row) { 131 | NSArray *indexPaths = @[[NSIndexPath indexPathForRow: row inSection: 0], indexPath]; 132 | [tableView beginUpdates]; 133 | [tableView reloadRowsAtIndexPaths: indexPaths withRowAnimation: UITableViewRowAnimationNone]; 134 | [tableView endUpdates]; 135 | } 136 | } 137 | 138 | @end 139 | -------------------------------------------------------------------------------- /IRKit/IRKit/IRProgressView.m: -------------------------------------------------------------------------------- 1 | // 2 | // IRProgressView.m 3 | // IRKit 4 | // 5 | // Created by Masakazu Ohtsuka on 2014/03/16. 6 | // 7 | // pretty much copied from MBProgressHUD.m 8 | // 9 | // MBProgressHUD.m 10 | // Version 0.8 11 | // Created by Matej Bukovinski on 2.4.09. 12 | // MIT License 13 | // 14 | 15 | 16 | #import "IRProgressView.h" 17 | #import "IRHelper.h" 18 | 19 | @interface IRProgressView () 20 | 21 | @property (nonatomic) BOOL removeFromSuperViewOnHide; 22 | @property (nonatomic) CGAffineTransform rotationTransform; 23 | @property (nonatomic) NSDate *showStarted; 24 | @property (nonatomic) BOOL isFinished; 25 | 26 | @end 27 | 28 | @implementation IRProgressView 29 | 30 | - (void)awakeFromNib { 31 | [super awakeFromNib]; 32 | 33 | _rotationTransform = CGAffineTransformIdentity; 34 | _indicatorView.hidden = NO; 35 | [_indicatorView startAnimating]; 36 | _checkmarkImageView.hidden = YES; 37 | 38 | self.alpha = 0.; 39 | } 40 | 41 | + (instancetype)showHUDAddedTo:(UIView *)parent { 42 | NSArray* nibViews = [[IRHelper resources] loadNibNamed: @"IRProgressView" 43 | owner: self 44 | options: nil]; 45 | IRProgressView *hud; 46 | for (id object in nibViews) { 47 | if ([object isKindOfClass: [IRProgressView class]]) { 48 | hud = (IRProgressView *)object; 49 | } 50 | } 51 | 52 | hud.frame = parent.bounds; 53 | [parent addSubview: hud]; 54 | [hud setNeedsDisplay]; 55 | [hud showUsingAnimation]; 56 | return hud; 57 | } 58 | 59 | + (BOOL)hideHUDForView:(UIView *)view afterDelay:(NSTimeInterval)delay { 60 | IRProgressView *hud = [self HUDForView: view]; 61 | if (hud != nil) { 62 | hud.removeFromSuperViewOnHide = YES; 63 | 64 | // switch to checkmark, and hide after delay 65 | [hud.indicatorView stopAnimating]; 66 | hud.indicatorView.hidden = YES; 67 | hud.checkmarkImageView.hidden = NO; 68 | 69 | [hud hideUsingAnimationAfterDelay: delay]; 70 | return YES; 71 | } 72 | return NO; 73 | } 74 | 75 | + (instancetype)HUDForView:(UIView *)view { 76 | NSEnumerator *subviewsEnum = [view.subviews reverseObjectEnumerator]; 77 | for (UIView *subview in subviewsEnum) { 78 | if ([subview isKindOfClass: self]) { 79 | return (IRProgressView *)subview; 80 | } 81 | } 82 | return nil; 83 | } 84 | 85 | - (void)showUsingAnimation { 86 | self.transform = CGAffineTransformConcat(_rotationTransform, CGAffineTransformMakeScale(0.5f, 0.5f)); 87 | self.showStarted = [NSDate date]; 88 | 89 | // Fade in 90 | [UIView beginAnimations: nil context: NULL]; 91 | [UIView setAnimationDuration: 0.30]; 92 | self.alpha = 1.0f; 93 | self.transform = _rotationTransform; 94 | [UIView commitAnimations]; 95 | } 96 | 97 | - (void)hideUsingAnimationAfterDelay:(NSTimeInterval)delay { 98 | // Fade out 99 | if (_showStarted) { 100 | [UIView beginAnimations: nil context: NULL]; 101 | [UIView setAnimationDelay: delay]; 102 | [UIView setAnimationDuration: 0.30]; 103 | [UIView setAnimationDelegate: self]; 104 | [UIView setAnimationDidStopSelector: @selector(animationFinished:finished:context:)]; 105 | // 0.02 prevents the hud from passing through touches during the animation the hud will get completely hidden 106 | // in the done method 107 | self.transform = CGAffineTransformConcat(_rotationTransform, CGAffineTransformMakeScale(1.5f, 1.5f)); 108 | 109 | self.alpha = 0.02f; 110 | [UIView commitAnimations]; 111 | } 112 | else { 113 | self.alpha = 0.0f; 114 | [self done]; 115 | } 116 | self.showStarted = nil; 117 | } 118 | 119 | - (void)animationFinished:(NSString *)animationID finished:(BOOL)finished context:(void*)context { 120 | [self done]; 121 | } 122 | 123 | - (void)done { 124 | [NSObject cancelPreviousPerformRequestsWithTarget: self]; 125 | _isFinished = YES; 126 | self.alpha = 0.0f; 127 | if (_removeFromSuperViewOnHide) { 128 | [self removeFromSuperview]; 129 | } 130 | } 131 | 132 | @end 133 | -------------------------------------------------------------------------------- /IRKit/IRKit/IRKit.m: -------------------------------------------------------------------------------- 1 | #import "Log.h" 2 | #import "IRKit.h" 3 | #import "IRKit+Internal.h" 4 | #import "IRHTTPClient.h" 5 | #import "IRUserDefaultsStore.h" 6 | 7 | // a place to save id before [IRKit sharedInstance] is called 8 | static id store; 9 | 10 | NSString *const IRClientDidRegisterNotification = @"IRClientDidRegisterNotification"; 11 | 12 | @interface IRKit () 13 | 14 | @property (nonatomic) id terminateObserver; 15 | @property (nonatomic) id becomeActiveObserver; 16 | @property (nonatomic) id enterBackgroundObserver; 17 | @property (nonatomic, copy) NSString *apikey; 18 | @property (nonatomic) id store; 19 | 20 | @end 21 | 22 | @implementation IRKit 23 | 24 | + (instancetype)sharedInstance { 25 | static IRKit *instance; 26 | static dispatch_once_t pred; 27 | 28 | dispatch_once(&pred, ^{ 29 | instance = [[IRKit alloc] init]; 30 | }); 31 | return instance; 32 | } 33 | 34 | + (void)setPersistentStore:(id)store_ { 35 | store = store_; 36 | } 37 | 38 | - (instancetype)init { 39 | self = [super init]; 40 | if (!self) { 41 | return nil; 42 | } 43 | 44 | if (store) { 45 | self.store = store; 46 | store = nil; 47 | } 48 | else { 49 | // defaults to NSUserDefaults, but you can set store using class method 50 | self.store = [[IRUserDefaultsStore alloc] init]; 51 | } 52 | 53 | _peripherals = [[IRPeripherals alloc] initWithPersistentStore: self.store]; 54 | 55 | #if TARGET_OS_IPHONE 56 | __weak IRKit *_self = self; 57 | _terminateObserver = [[NSNotificationCenter defaultCenter] addObserverForName: UIApplicationWillTerminateNotification 58 | object: nil 59 | queue: [NSOperationQueue mainQueue] 60 | usingBlock:^(NSNotification *note) { 61 | LOG(@"terminating"); 62 | [_self save]; 63 | }]; 64 | static bool first = YES; 65 | _becomeActiveObserver = [[NSNotificationCenter defaultCenter] addObserverForName: UIApplicationDidBecomeActiveNotification 66 | object: nil 67 | queue: [NSOperationQueue mainQueue] 68 | usingBlock:^(NSNotification *note) { 69 | LOG(@"became active"); 70 | if (first) { 71 | // ensureRegistered.. should be called first time in startWithAPIKey: 72 | first = NO; 73 | } 74 | else { 75 | [IRHTTPClient ensureRegisteredAndCall:^(NSError *error) { 76 | LOG(@"error: %@", error); 77 | }]; 78 | } 79 | }]; 80 | [IRViewCustomizer sharedInstance]; // init 81 | #endif 82 | 83 | return self; 84 | } 85 | 86 | - (void)dealloc { 87 | LOG_CURRENT_METHOD; 88 | [[NSNotificationCenter defaultCenter] removeObserver: _terminateObserver]; 89 | [[NSNotificationCenter defaultCenter] removeObserver: _becomeActiveObserver]; 90 | [[NSNotificationCenter defaultCenter] removeObserver: _enterBackgroundObserver]; 91 | } 92 | 93 | + (void)startWithAPIKey:(NSString *)apikey { 94 | LOG_CURRENT_METHOD; 95 | [IRKit sharedInstance].apikey = apikey; 96 | 97 | [IRHTTPClient ensureRegisteredAndCall:^(NSError *error) { 98 | LOG(@"error: %@", error); 99 | if (!error) { 100 | IRKitLog(@"successfully registered!"); 101 | } 102 | }]; 103 | } 104 | 105 | - (void)save { 106 | LOG_CURRENT_METHOD; 107 | [_peripherals save]; 108 | } 109 | 110 | - (NSUInteger)countOfReadyPeripherals { 111 | LOG_CURRENT_METHOD; 112 | return _peripherals.countOfReadyPeripherals; 113 | } 114 | 115 | #pragma mark - Private 116 | 117 | - (NSString*) clientkey { 118 | return [self.store objectForKey: @"clientkey"]; 119 | } 120 | 121 | - (void) setClientkey:(NSString *)clientkey { 122 | [self.store storeObject: clientkey forKey: @"clientkey"]; 123 | [self.store synchronize]; 124 | } 125 | 126 | @end 127 | -------------------------------------------------------------------------------- /Minimal/Minimal/Base.lproj/MainStoryboard.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | -------------------------------------------------------------------------------- /Minimal/Minimal/ja.lproj/MainStoryboard.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | -------------------------------------------------------------------------------- /IRKit/IRKitResources/IRProgressView.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /IRKit/IRKit/IRSignal.m: -------------------------------------------------------------------------------- 1 | #import "Log.h" 2 | #import "IRSignal.h" 3 | #import "IRHelper.h" 4 | #import "IRKit.h" 5 | #import "IRHTTPClient.h" 6 | 7 | @interface IRSignal () 8 | 9 | @end 10 | 11 | @implementation IRSignal 12 | 13 | - (instancetype)init { 14 | self = [super init]; 15 | if (!self) { 16 | return nil; 17 | } 18 | _frequency = @38; // default 19 | return self; 20 | } 21 | 22 | - (instancetype)initWithDictionary:(NSDictionary *)dictionary { 23 | LOG_CURRENT_METHOD; 24 | self = [self init]; 25 | if (!self) { 26 | return nil; 27 | } 28 | 29 | [self inflateFromDictionary: dictionary]; 30 | 31 | return self; 32 | } 33 | 34 | - (NSDictionary *)asDictionary { 35 | LOG_CURRENT_METHOD; 36 | NSMutableDictionary *ret = [self asPublicDictionary].mutableCopy; 37 | [ret addEntriesFromDictionary: @{ 38 | @"name": _name ? _name : [NSNull null], 39 | @"hostname": _hostname ? _hostname : [NSNull null], 40 | @"deviceid": self.peripheral.deviceid ? self.peripheral.deviceid : [NSNull null], 41 | @"custom": _custom ? _custom : [NSNull null], 42 | }]; 43 | return ret; 44 | } 45 | 46 | - (NSDictionary *)asSendableDictionary { 47 | LOG_CURRENT_METHOD; 48 | NSMutableDictionary *ret = [self asPublicDictionary].mutableCopy; 49 | [ret addEntriesFromDictionary: @{ 50 | @"name": _name ? _name : [NSNull null], 51 | @"hostname": _hostname ? _hostname : [NSNull null], 52 | }]; 53 | return ret; 54 | } 55 | 56 | - (NSDictionary *)asPublicDictionary { 57 | LOG_CURRENT_METHOD; 58 | return @{ 59 | @"data": _data ? _data : [NSNull null], 60 | @"format": _format ? _format : [NSNull null], 61 | @"freq": _frequency ? _frequency : [NSNull null], 62 | @"type": @"single" 63 | }; 64 | } 65 | 66 | #pragma mark - IRSendable protocol 67 | 68 | - (void)sendWithCompletion:(void (^)(NSError *error))completion { 69 | LOG_CURRENT_METHOD; 70 | 71 | [IRHTTPClient postSignal: self 72 | withCompletion: completion]; 73 | } 74 | 75 | #pragma mark - Accessors 76 | 77 | - (IRPeripheral *)peripheral { 78 | LOG_CURRENT_METHOD; 79 | if (_peripheral) { 80 | return _peripheral; 81 | } 82 | if (_hostname) { 83 | // we can't use [IRKit sharedInstance] inside our initWithCoder (circular call) 84 | // so we temporary save peripheral.name in _hostname 85 | // and recover IRPeripheral afterwards (here) 86 | _peripheral = [[IRKit sharedInstance].peripherals peripheralWithName: _hostname]; 87 | return _peripheral; 88 | } 89 | return nil; 90 | } 91 | 92 | #pragma mark - Private methods 93 | 94 | - (void)inflateFromDictionary:(NSDictionary *)dictionary { 95 | if (dictionary[ @"message" ]) { 96 | [self inflateFromDictionary: dictionary[@"message"]]; 97 | } 98 | 99 | if (dictionary[@"name"]) { 100 | _name = dictionary[@"name"]; 101 | } 102 | if (dictionary[@"data"]) { 103 | _data = dictionary[@"data"]; 104 | } 105 | if (dictionary[@"format"]) { 106 | _format = dictionary[@"format"]; 107 | } 108 | 109 | // either name is fine 110 | if (dictionary[@"freq"]) { 111 | _frequency = dictionary[@"freq"]; 112 | } 113 | if (dictionary[@"frequency"]) { 114 | _frequency = dictionary[@"frequency"]; 115 | } 116 | 117 | if (dictionary[@"hostname"]) { 118 | _hostname = dictionary[@"hostname"]; 119 | } 120 | if (dictionary[@"custom"]) { 121 | _custom = dictionary[@"custom"]; 122 | } 123 | } 124 | 125 | #pragma mark - NSCoding 126 | 127 | - (void)encodeWithCoder:(NSCoder *)coder { 128 | [coder encodeObject: _name forKey: @"n"]; 129 | [coder encodeObject: _data forKey: @"d"]; 130 | [coder encodeObject: _format forKey: @"fo"]; 131 | [coder encodeObject: _frequency forKey: @"f"]; 132 | [coder encodeObject: _custom forKey: @"c"]; 133 | [coder encodeObject: _hostname forKey: @"h"]; 134 | } 135 | 136 | - (instancetype)initWithCoder:(NSCoder *)coder { 137 | self = [super init]; 138 | if (self) { 139 | _name = [coder decodeObjectForKey: @"n"]; 140 | _data = [coder decodeObjectForKey: @"d"]; 141 | _format = [coder decodeObjectForKey: @"fo"]; 142 | _frequency = [coder decodeObjectForKey: @"f"]; 143 | _custom = [coder decodeObjectForKey: @"c"]; 144 | _hostname = [coder decodeObjectForKey: @"h"]; 145 | } 146 | return self; 147 | } 148 | 149 | @end 150 | -------------------------------------------------------------------------------- /IRKit/IRKit/IRPeripherals.m: -------------------------------------------------------------------------------- 1 | #import "Log.h" 2 | #import "IRPeripherals.h" 3 | #import "IRHelper.h" 4 | #import "IRConst.h" 5 | #import "IRHTTPClient.h" 6 | 7 | @interface IRPeripherals () 8 | 9 | // NSNetService.hostName => IRPeripheral 10 | @property (nonatomic) NSMutableDictionary *irperipheralForName; 11 | @property (nonatomic) id store; 12 | 13 | @end 14 | 15 | @implementation IRPeripherals 16 | 17 | - (instancetype)initWithPersistentStore:(id)store { 18 | self = [super init]; 19 | if (!self) { 20 | return nil; 21 | } 22 | self.store = store; 23 | [self load]; 24 | return self; 25 | } 26 | 27 | - (id)objectAtIndex:(NSUInteger)index { 28 | LOG(@"index: %lu", (unsigned long)index); 29 | 30 | NSArray *keys = [_irperipheralForName keysSortedByValueUsingSelector: @selector(compareByFirstFoundDate:)]; 31 | NSString *key = [keys objectAtIndex: index]; 32 | return _irperipheralForName[key]; 33 | } 34 | 35 | - (NSUInteger)indexOfObject:(id)object { 36 | return [self.peripherals indexOfObject: object]; 37 | } 38 | 39 | - (IRPeripheral *)peripheralWithName:(NSString *)name { 40 | LOG_CURRENT_METHOD; 41 | if (!name) { 42 | return nil; 43 | } 44 | return _irperipheralForName[name.lowercaseString]; 45 | } 46 | 47 | - (void)save { 48 | LOG_CURRENT_METHOD; 49 | 50 | [self saveToStore:_store]; 51 | } 52 | 53 | - (void)saveToStore:(id)store { 54 | LOG_CURRENT_METHOD; 55 | 56 | [store storePeripherals: _irperipheralForName]; 57 | [store synchronize]; 58 | } 59 | 60 | - (NSUInteger)countOfReadyPeripherals { 61 | LOG_CURRENT_METHOD; 62 | return [[[_irperipheralForName allValues] filteredArrayUsingPredicate: [NSPredicate predicateWithBlock:^BOOL (id evaluatedObject, NSDictionary *bindings) { 63 | return [(IRPeripheral *)evaluatedObject hasDeviceID]; 64 | }] 65 | ] count]; 66 | } 67 | 68 | - (BOOL)isKnownName:(NSString *)hostname { 69 | LOG(@"hostname: %@", hostname); 70 | return _irperipheralForName[ hostname.lowercaseString ] ? YES : NO; 71 | } 72 | 73 | - (IRPeripheral *)registerPeripheralWithName:(NSString *)hostname { 74 | LOG(@"hostname: %@", hostname); 75 | IRPeripheral *peripheral = [[IRPeripheral alloc] init]; 76 | peripheral.hostname = hostname; 77 | peripheral.customizedName = hostname; 78 | [self addPeripheralsObject: peripheral]; 79 | return peripheral; 80 | } 81 | 82 | - (IRPeripheral *)savePeripheralWithName:(NSString *)hostname deviceid:(NSString *)deviceid { 83 | LOG(@"hostname: %@ deviceid: %@", hostname, deviceid); 84 | 85 | IRPeripheral *p = [self peripheralWithName: hostname]; 86 | if (!p) { 87 | p = [self registerPeripheralWithName: hostname]; 88 | } 89 | p.deviceid = deviceid; 90 | [self save]; 91 | [p getModelNameAndVersionWithCompletion:^{ 92 | [self save]; 93 | }]; 94 | return p; 95 | } 96 | 97 | - (void)clearPeripherals { 98 | LOG_CURRENT_METHOD; 99 | _irperipheralForName = @{}.mutableCopy; 100 | } 101 | 102 | #pragma mark - Private methods 103 | 104 | - (void)load { 105 | LOG_CURRENT_METHOD; 106 | 107 | _irperipheralForName = [[_store loadPeripherals] mutableCopy]; 108 | if (!_irperipheralForName) { 109 | _irperipheralForName = @{}.mutableCopy; 110 | } 111 | 112 | LOG(@"_irperipheralForName: %@", _irperipheralForName); 113 | } 114 | 115 | #pragma mark - Key Value Coding - Mutable Unordered Accessors 116 | 117 | - (NSArray *)peripherals { 118 | LOG_CURRENT_METHOD; 119 | 120 | return [_irperipheralForName.allValues sortedArrayUsingSelector: @selector(compareByFirstFoundDate:)]; 121 | } 122 | 123 | - (NSUInteger)countOfPeripherals { 124 | LOG_CURRENT_METHOD; 125 | 126 | return _irperipheralForName.count; 127 | } 128 | 129 | - (NSEnumerator *)enumeratorOfPeripherals { 130 | LOG_CURRENT_METHOD; 131 | 132 | return self.peripherals.objectEnumerator; 133 | } 134 | 135 | - (IRPeripheral *)memberOfPeripherals:(IRPeripheral *)object { 136 | NSString *lowercased = object.hostname.lowercaseString; 137 | 138 | for (IRPeripheral *p in self.peripherals) { 139 | if ([p.hostname.lowercaseString isEqualToString: lowercased]) { 140 | return p; 141 | } 142 | } 143 | return nil; 144 | } 145 | 146 | // -addObject: 147 | - (void)addPeripheralsObject:(IRPeripheral *)peripheral { 148 | LOG(@"peripheral: %@", peripheral); 149 | 150 | if (!peripheral.hostname) { 151 | // can't add a peripheral without a name 152 | return; 153 | } 154 | 155 | _irperipheralForName[peripheral.hostname.lowercaseString] = peripheral; 156 | } 157 | 158 | - (void)removePeripheralsObject:(IRPeripheral *)peripheral { 159 | LOG(@"peripheral: %@", peripheral); 160 | 161 | [_irperipheralForName removeObjectForKey: peripheral.hostname.lowercaseString]; 162 | } 163 | 164 | @end 165 | -------------------------------------------------------------------------------- /IRKit/IRKit/IRReachability.m: -------------------------------------------------------------------------------- 1 | // 2 | // IRReachability.m 3 | // IRKit 4 | // 5 | // Created by Masakazu Ohtsuka on 2014/03/17. 6 | // 7 | // 8 | 9 | #import "IRReachability.h" 10 | #import "Log.h" 11 | #import 12 | 13 | @interface IRReachability () 14 | 15 | @property (nonatomic) SCNetworkReachabilityRef reachability; 16 | @property (nonatomic) dispatch_queue_t reachabilityQueue; 17 | @property (nonatomic) SCNetworkReachabilityFlags flags; 18 | @property (nonatomic, copy) NSString *hostname; 19 | 20 | @end 21 | 22 | @implementation IRReachability 23 | 24 | static void NetworkReachabilityCallback(SCNetworkReachabilityRef __unused target, SCNetworkReachabilityFlags flags, void *info){ 25 | IRReachability *_self = (__bridge IRReachability *)info; 26 | _self.flags = flags; 27 | 28 | LOG( @"reachability for host:%@ %@", _self.hostname, NSStringFromNetworkReachabilityFlags(flags) ); 29 | } 30 | 31 | #pragma clang diagnostic push 32 | #pragma clang diagnostic ignored "-Wunused-function" 33 | static NSString *NSStringFromNetworkReachabilityFlags(SCNetworkReachabilityFlags flags) { 34 | #pragma clang diagnostic pop 35 | return [NSString stringWithFormat: @"Reachability Flag Status: %c%c %c%c%c%c%c%c%c", 36 | #if TARGET_OS_IPHONE 37 | (flags & kSCNetworkReachabilityFlagsIsWWAN) ? 'W' : '-', 38 | #else 39 | '-', 40 | #endif 41 | (flags & kSCNetworkReachabilityFlagsReachable) ? 'R' : '-', 42 | (flags & kSCNetworkReachabilityFlagsTransientConnection) ? 't' : '-', 43 | (flags & kSCNetworkReachabilityFlagsConnectionRequired) ? 'c' : '-', 44 | (flags & kSCNetworkReachabilityFlagsConnectionOnTraffic) ? 'C' : '-', 45 | (flags & kSCNetworkReachabilityFlagsInterventionRequired) ? 'i' : '-', 46 | (flags & kSCNetworkReachabilityFlagsConnectionOnDemand) ? 'D' : '-', 47 | (flags & kSCNetworkReachabilityFlagsIsLocalAddress) ? 'l' : '-', 48 | (flags & kSCNetworkReachabilityFlagsIsDirect) ? 'd' : '-' 49 | ]; 50 | } 51 | 52 | - (instancetype) initWithReachability: (SCNetworkReachabilityRef)reachability { 53 | self = [super init]; 54 | if (!self) { return nil; } 55 | 56 | self.reachability = reachability; 57 | 58 | return self; 59 | } 60 | 61 | - (void)dealloc { 62 | LOG_CURRENT_METHOD; 63 | 64 | [self stopMonitoring]; 65 | 66 | if (_reachability) { 67 | CFRelease(_reachability); 68 | _reachability = NULL; 69 | } 70 | } 71 | 72 | - (void) startMonitoring { 73 | SCNetworkReachabilityContext context = { 74 | 0, 75 | (__bridge void *)(self), 76 | NULL, 77 | NULL, 78 | NULL 79 | }; 80 | 81 | if (!SCNetworkReachabilitySetCallback(_reachability, NetworkReachabilityCallback, &context)) { 82 | LOG(@"SCNetworkReachabilitySetCallback() failed with error code: %s", SCErrorString(SCError())); 83 | return; 84 | } 85 | 86 | [self createReachabilityQueue]; 87 | } 88 | 89 | - (void)createReachabilityQueue { 90 | _reachabilityQueue = dispatch_queue_create("com.getirkit.reachability.queue", DISPATCH_QUEUE_SERIAL); 91 | 92 | if (!SCNetworkReachabilitySetDispatchQueue(_reachability, _reachabilityQueue)) { 93 | LOG(@"SCNetworkReachabilitySetDispatchQueue() failed with error code: %s", SCErrorString(SCError())); 94 | [self releaseReachabilityQueue]; 95 | } 96 | } 97 | 98 | - (void)releaseReachabilityQueue { 99 | if (_reachability) { 100 | SCNetworkReachabilitySetDispatchQueue(_reachability, NULL); 101 | } 102 | 103 | if (_reachabilityQueue) { 104 | _reachabilityQueue = NULL; 105 | } 106 | } 107 | 108 | - (void) stopMonitoring { 109 | if (_reachability) { 110 | SCNetworkReachabilitySetCallback(_reachability, NULL, NULL); 111 | } 112 | [self releaseReachabilityQueue]; 113 | } 114 | 115 | + (instancetype) reachabilityWithHostname: (NSString*)hostname { 116 | SCNetworkReachabilityRef ref = SCNetworkReachabilityCreateWithName(NULL, [hostname UTF8String]); 117 | 118 | // implicitly monitor reachability, to respond with correct results synchronously 119 | IRReachability *instance = [[IRReachability alloc] initWithReachability: ref]; 120 | instance.hostname = hostname; 121 | [instance startMonitoring]; 122 | return instance; 123 | } 124 | 125 | -(BOOL)isReachableViaWiFi { 126 | // reachable and not on WWAN 127 | return (_flags & kSCNetworkReachabilityFlagsReachable) && 128 | #if TARGET_OS_IPHONE 129 | !(_flags & kSCNetworkReachabilityFlagsIsWWAN); 130 | #else 131 | 1; 132 | #endif 133 | } 134 | 135 | -(BOOL)isReachableViaWiFiAndDirect { 136 | // reachable, direct and not on WWAN 137 | return (_flags & kSCNetworkReachabilityFlagsReachable) && 138 | (_flags & kSCNetworkReachabilityFlagsIsDirect) && 139 | #if TARGET_OS_IPHONE 140 | !(_flags & kSCNetworkReachabilityFlagsIsWWAN); 141 | #else 142 | 1; 143 | #endif 144 | } 145 | 146 | @end 147 | -------------------------------------------------------------------------------- /IRKit/IRKit/IRSignalSequence.m: -------------------------------------------------------------------------------- 1 | // 2 | // IRSignalSequence.m 3 | // IRKit 4 | // 5 | // Created by Masakazu Ohtsuka on 2014/02/20. 6 | // 7 | // 8 | 9 | #import "IRSignalSequence.h" 10 | #import "Log.h" 11 | #import "IRSignalSendOperationQueue.h" 12 | #import "IRSignalSendOperation.h" 13 | #import "IRHelper.h" 14 | 15 | @interface IRSignalSequence () 16 | 17 | @property (nonatomic) NSArray* signals; 18 | @property (nonatomic) NSArray* intervals; 19 | 20 | @end 21 | 22 | @implementation IRSignalSequence 23 | 24 | - (instancetype)initWithSignals:(NSArray*)signals andIntervals:(NSArray*)intervals { 25 | LOG_CURRENT_METHOD; 26 | NSAssert( signals.count == (intervals.count + 1), @"number of intervals should be `countofSignals - 1`" ); 27 | NSAssert( signals && intervals, @"neither signals nor intervals can be null" ); 28 | 29 | self = [self init]; 30 | if (!self) { 31 | return nil; 32 | } 33 | 34 | _signals = signals; 35 | _intervals = intervals; 36 | 37 | return self; 38 | } 39 | 40 | - (instancetype)initWithDictionary:(NSDictionary *)dictionary { 41 | LOG_CURRENT_METHOD; 42 | self = [self init]; 43 | if (!self) { 44 | return nil; 45 | } 46 | NSAssert( [dictionary[@"type"] isEqualToString: @"sequence"], @"dictionary.type must be \"sequence \"" ); 47 | 48 | NSArray* signals = dictionary[ @"signals" ]; 49 | NSArray* intervals = dictionary[ @"intervals" ]; 50 | self = [self initWithSignals: signals andIntervals: intervals]; 51 | 52 | if (dictionary[@"name"]) { 53 | _name = dictionary[@"name"]; 54 | } 55 | else { 56 | _name = @"unknown"; 57 | } 58 | 59 | if (dictionary[@"custom"]) { 60 | _custom = dictionary[@"custom"]; 61 | } 62 | 63 | return self; 64 | } 65 | 66 | #pragma mark - IRSendable protocol 67 | 68 | - (void)sendWithCompletion:(void (^)(NSError *))completion { 69 | LOG_CURRENT_METHOD; 70 | 71 | IRSignalSendOperationQueue *q = [[IRSignalSendOperationQueue alloc] init]; 72 | q.completion = completion; 73 | 74 | for (int i=0; i<_signals.count; i++) { 75 | IRSignal *signal = _signals[ i ]; 76 | __weak IRSignalSendOperationQueue *_q = q; 77 | IRSignalSendOperation *op = [[IRSignalSendOperation alloc] initWithSignal: signal 78 | completion:^(NSError *error) { 79 | LOG(@"error: %@", error); 80 | if (error) { 81 | _q.error = error; 82 | } 83 | }]; 84 | [q addOperation: op]; 85 | 86 | if (i != _signals.count - 1) { 87 | NSTimeInterval interval = ((NSNumber*)_intervals[ i ]).doubleValue; 88 | NSBlockOperation *b = [NSBlockOperation blockOperationWithBlock:^{ 89 | LOG( @"will sleep for: %.1f sec", interval ); 90 | [NSThread sleepForTimeInterval: interval]; 91 | LOG( @"slept for: %.1f sec", interval ); 92 | }]; 93 | [q addOperation: b]; 94 | } 95 | } 96 | } 97 | 98 | - (NSDictionary*)asDictionary { 99 | LOG_CURRENT_METHOD; 100 | 101 | NSArray *signals = [IRHelper mapObjects: _signals usingBlock:^id (id obj, NSUInteger idx) { 102 | return [obj asDictionary]; 103 | }]; 104 | return @{ 105 | @"type": @"sequence", 106 | @"name": _name ? _name : [NSNull null], 107 | @"custom": _custom ? _custom : [NSNull null], 108 | @"signals": signals, 109 | @"intervals": _intervals, 110 | }; 111 | } 112 | 113 | - (NSDictionary *)asSendableDictionary { 114 | LOG_CURRENT_METHOD; 115 | 116 | NSArray *signals = [IRHelper mapObjects: _signals usingBlock:^id (id obj, NSUInteger idx) { 117 | return [obj asSendableDictionary]; 118 | }]; 119 | return @{ 120 | @"type": @"sequence", 121 | @"name": _name ? _name : [NSNull null], 122 | @"signals": signals, 123 | @"intervals": _intervals, 124 | }; 125 | } 126 | 127 | - (NSDictionary *)asPublicDictionary { 128 | LOG_CURRENT_METHOD; 129 | 130 | NSArray *signals = [IRHelper mapObjects: _signals usingBlock:^id (id obj, NSUInteger idx) { 131 | return [obj asPublicDictionary]; 132 | }]; 133 | return @{ 134 | @"type": @"sequence", 135 | @"signals": signals, 136 | @"intervals": _intervals, 137 | }; 138 | } 139 | 140 | #pragma mark - NSCoding 141 | 142 | - (void)encodeWithCoder:(NSCoder *)coder { 143 | [coder encodeObject: _name forKey: @"n"]; 144 | [coder encodeObject: _custom forKey: @"c"]; 145 | [coder encodeObject: _signals forKey: @"s"]; 146 | [coder encodeObject: _intervals forKey: @"i"]; 147 | } 148 | 149 | - (id)initWithCoder:(NSCoder *)coder { 150 | self = [super init]; 151 | if (self) { 152 | _name = [coder decodeObjectForKey: @"n"]; 153 | _custom = [coder decodeObjectForKey: @"c"]; 154 | _signals = [coder decodeObjectForKey: @"s"]; 155 | _intervals = [coder decodeObjectForKey: @"i"]; 156 | } 157 | return self; 158 | } 159 | 160 | @end 161 | -------------------------------------------------------------------------------- /IRKit/IRKitResources/IRPeripheralCell.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 37 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | IRKit iOS SDK 2 | === 3 | 4 | [IRKit device](https://github.com/irkit/device) and SDK(this library) lets you control your home electronics from your iOS devices. 5 | IRKit device has a Infrared LED and receiver, and a WiFi module inside. 6 | Any device with internet or local wifi connection can use IRKit devices to make it send IR signals. 7 | 8 | This library does: 9 | * provide UIViewController subclasses that wraps complex procedures to connect and learn IR signals from IRKit devices 10 | * provide a simple interface to send IR signals 11 | 12 | ## Get IRKit Device 13 | 14 | see [IRKit device](https://github.com/irkit/device) 15 | 16 | ## Installing 17 | 18 | Use [cocoapods](http://cocoapods.org/) 1.0.0 or higher 19 | 20 | ```sh 21 | $ cat Podfile 22 | source 'https://github.com/CocoaPods/Specs.git' 23 | use_frameworks! 24 | 25 | platform :ios, '8.0' 26 | workspace 'MyApp.xcworkspace' 27 | project 'MyApp/MyApp.xcodeproj' 28 | 29 | pod 'IRKit', '~> 3.0' 30 | 31 | target 'MyApp' do 32 | project 'MyApp/MyApp.xcodeproj' 33 | end 34 | 35 | $ pod install 36 | ``` 37 | 38 | ## Usage 39 | 40 | See [Minimal app](https://github.com/irkit/ios-sdk/tree/master/Minimal/Minimal) for a working minimal IR remote controller application. 41 | 42 | ### Include header 43 | 44 | ```objective-c 45 | #import 46 | ``` 47 | 48 | ### Initialize 49 | 50 | ```objective-c 51 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 52 | { 53 | [IRKit startWithAPIKey:@"#{ fill in your apikey }"]; 54 | return YES; 55 | } 56 | ``` 57 | 58 | ### Get API key 59 | 60 | ```sh 61 | % curl -d "email={your email}" "http://api.getirkit.com/1/apps" 62 | {"message":"You will receive an email shortly, please click the URL in it to get an apikey"} 63 | ``` 64 | 65 | and open the URL in the email. 66 | 67 | ### Sending IR signals 68 | 69 | IR signal is represented as a [IRSignal](https://github.com/irkit/ios-sdk/blob/master/IRKit/IRKit/IRSignal.h) instance. 70 | 71 | ```objective-c 72 | [signal sendWithCompletion:^(NSError *error) { 73 | NSLog(@"sent error: %@", error); 74 | }]; 75 | ``` 76 | 77 | ### How to get an IRSignal? 78 | 79 | You get your first `IRSignal` by *learning* it, which means: you point your old infrared remote controller at IRKit device's IR receiver, and press it's button. 80 | IRKit device will send it over to your app(with IRKit iOS SDK). 81 | 82 | But first, you need to *pair* with an IRKit device. 83 | 84 | ```objective-c 85 | // in your main view controller 86 | - (void)viewDidAppear:(BOOL)animated { 87 | [super viewDidAppear:animated]; 88 | 89 | // find IRKit if none is known 90 | if ([IRKit sharedInstance].countOfReadyPeripherals == 0) { 91 | IRNewPeripheralViewController *vc = [[IRNewPeripheralViewController alloc] init]; 92 | vc.delegate = self; 93 | [self presentViewController:vc 94 | animated:YES 95 | completion:^{ 96 | NSLog(@"presented"); 97 | }]; 98 | } 99 | } 100 | 101 | #pragma mark - IRNewPeripheralViewControllerDelegate 102 | 103 | - (void)newPeripheralViewController:(IRNewPeripheralViewController *)viewController 104 | didFinishWithPeripheral:(IRPeripheral *)peripheral { 105 | NSLog( @"peripheral: %@", peripheral ); 106 | 107 | [self dismissViewControllerAnimated:YES 108 | completion:^{ 109 | NSLog(@"dismissed"); 110 | }]; 111 | } 112 | ``` 113 | 114 | When pairing is done, you're ready to learn an IRSignal from it. 115 | 116 | ```objective-c 117 | IRNewSignalViewController *vc = [[IRNewSignalViewController alloc] init]; 118 | vc.delegate = self; 119 | [self presentViewController:vc 120 | animated:YES 121 | completion:^{ 122 | NSLog(@"presented"); 123 | }]; 124 | 125 | #pragma mark - IRNewSignalViewControllerDelegate 126 | 127 | - (void)newSignalViewController:(IRNewSignalViewController *)viewController 128 | didFinishWithSignal:(IRSignal *)signal { 129 | NSLog( @"signal: %@", signal ); 130 | 131 | if (signal) { 132 | // successfully learned! 133 | _signal = signal; 134 | } 135 | [self dismissViewControllerAnimated:YES 136 | completion:^{ 137 | LOG(@"dismissed"); 138 | }]; 139 | } 140 | 141 | ``` 142 | 143 | ### Collection of multiple IRSignals 144 | 145 | Most remote controllers have more than 1 button, so you'll want to manage a collection of IRSignals. 146 | `IRSignals` (with a `s` postfix) is it. 147 | 148 | ```objective-c 149 | _signals = [[IRSignals alloc] init]; 150 | 151 | // and add a signal to the collection 152 | [_signals addSignalsObject:_signal]; 153 | 154 | // send multiple IRSignal-s sequentially 155 | [_signals sendSequentiallyWithCompletion:^(NSError *error) { 156 | NSLog( @"sent with error: %@", error ); 157 | }]; 158 | 159 | // and save it in NSUserDefaults 160 | [_signals saveToStandardUserDefaultsWithKey:@"irkit.signals"]; 161 | 162 | // or load it from NSUserDefaults 163 | [_signals loadFromStandardUserDefaultsKey:@"irkit.signals"]; 164 | 165 | // or send it elsewhere 166 | NSData *data = [_signals data]; 167 | 168 | // or as JSON 169 | NSString *json = [_signals JSONRepresentation]; 170 | ``` 171 | 172 | ### App Transport Security 173 | 174 | IRKit's Device HTTP API doesn't support HTTPS. 175 | Add following lines in your `Info.plist`. 176 | 177 | ```xml 178 | NSAppTransportSecurity 179 | 180 | NSAllowsArbitraryLoads 181 | 182 | 183 | ``` 184 | 185 | ## [Contributing](Contributing.md) 186 | 187 | --------------------------------------------------------------------------------