Overview
Welcome to the documentation for OhmKit, a powerful framework for iOS developers
to integrate Ohm devices into their applications. This documentation will guide you
through the installation process, provide an overview of the framework, and offer
detailed explanations of its core features and functionality.
Installation
To begin using OhmKit, you’ll need to install it in your iOS project. Follow the
steps below to get started:
Step 1: Cocoapods Installation
Before integrating OhmKit, ensure that your project has Cocoapods installed.
Open Terminal, navigate to your project directory, and run the following command:
sudo gem install cocoapods
Once Cocoapods is installed, navigate to your project’s root directory and create
a file named Podfile if it doesn’t already exist. Open the Podfile
using a text editor and add the following line:
pod 'OhmKit'
Save the Podfile and run the following command in Terminal:
pod install
Step 2: Import Framework
After installing OhmKit via Cocoapods, open your Xcode project and import the
framework. Add the following import statement at the top of your Swift files
where you’ll be using OhmKit:
import OhmKit
Getting Started
Now that OhmKit is successfully installed in your project, let’s learn how to
use it. Follow the steps below to begin integrating Ohm devices into your iOS app:
Step 1: Set Up the OhmManager
The OhmManager is the heart of OhmKit and manages the discovery and communication
with Ohm devices. In your AppDelegate file, instantiate the OhmManager and set it
as the delegate for OhmKit by implementing the following code:
let ohmManager = OhmManager.shared
// MARK: - Application Delegate
class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Instantiate the OhmManager
let ohmManager = OhmManager.shared
// Set the OhmManager delegate
ohmManager.delegate = self
// Additional app initialization code...
return true
}
}
// MARK: - OhmManagerDelegate
extension AppDelegate: OhmManagerDelegate {
func ohmManagerDidUpdateState(_ state: OhmManager.State) {
// OhmManager state updates handling...
}
func ohmManagerDidDiscoverDevice(_ device: OhmDevice) {
// OhmDevice discovery handling...
}
// Other OhmManager delegate methods...
}
Note: Make sure to replace the comments with appropriate code according to
your application’s needs.
Step 2: Discover Ohm Devices
To discover nearby Ohm devices, call the startDiscovery() method on the
OhmManager instance. This method will initiate the discovery process and notify
the delegate when a device is found. Implement the following code to start discovering:
ohmManager.startDiscovery()
Step 3: Connect to an Ohm Device
Once you’ve discovered Ohm devices, you can connect to a specific device
by calling connect() on the OhmDevice instance. Implement the following
code to connect to a device:
func ohmManagerDidDiscoverDevice(_ device: OhmDevice) {
// Store the discovered device for future use
self.device = device
// Connect to the device
device.connect()
}
Make sure to handle any errors or connection status changes in the appropriate
OhmDevice delegate methods.
Features
1. Ohm Device Communication
OhmKit provides a robust communication interface for interacting with Ohm devices.
This includes sending and receiving messages, reading and writing to device variables,
and subscribing to device events.
2. Real-Time Data Streaming
With OhmKit, you can stream real-time data from Ohm devices to your iOS app.
You’ll be able to continuously monitor sensor values, visualize them on graphs,
and perform any necessary data processing.
3. Device Configuration and Control
OhmKit allows you to configure and control Ohm devices directly from your iOS app.
You can adjust sensor settings, calibrate sensors, update firmware, and more.
4. Error Handling and Logging
OhmKit includes comprehensive error handling and logging mechanisms to help you
troubleshoot and debug your Ohm integration. It provides valuable insights through
log messages and error codes to assist in identifying and resolving issues.
5. Extensive Documentation and Support
In addition to this documentation, OhmKit offers detailed guides, tutorials, and
sample code to help you make the most out of the framework. If you encounter any
issues or need assistance, our support team is always available to help you.
Conclusion
Congratulations! You’re now equipped with the knowledge needed to get started
with OhmKit. Happy integrating Ohm devices into your iOS app!