Nod Developer Center

Developer Guide

The OpenSpatial Framework

    • The source for the Nod iOS SDK is contained in the Open Spatial iOS SDK Folder in our iOS GitHub repository.
    • To use the SDK, import the OpenSpatial.framework into your project as an embedded binary.
    • The source contains a class called OpenSpatialBluetooth which handles all of the interfacing with the Nod device.
    • There are 3 aspects to using the OpenSpatialBluetooth object
      • Understanding the Subscription/Event model
      • Using the OpenSpatialBluetooth object
      • Implementing the OpenSpatialBluetoothDelegate
        • The Subscription/Event Model
          • The subscription/event model describes the way the SDK asks for and receives data from Nod.
          • There are 10 types of events (Please refer to your device manual for a description of each)
            • Accelerometer
            • Gyro
            • Compass
            • Euler Angles
            • Translations
            • Analog
            • RelativeXY
            • Gesture Direction
            • Slider Gesture
            • Button
            • These events are subscribed to using the OpenSpatialBluetooth Object and then the Events are fired by calling the corresponding method in the OpenSpatialBluetoothDelegate you implement.
        • The OpenSpatialBluetooth Object
          • The Open Spatial Bluetooth Object is a singleton object that must be instantiated using its static singleton method [OpenSpatialBluetooth sharedBluetoothServ] which will return the singleton object.
          • ex/ your OpenSpatialBluetooth instance = [OpenSpatialBluetooth sharedBluetoothServ]
          • The OpenSpatialBluetooth object allows you to send commands to Nod to ask for the data you need.
          • There are three methods relevant to communicating with Nod
            • (void)scanForPeripherals
              • Call this method to find paired Nods, all devices found will be stored in the connectedPeripherals NSMutableArray property of the OpenSpatialBluetooth object.
            • NOTE: NOD DEVICES MUST BE PAIRED TO THE IOS SYSTEM TO BE FOUND BY THIS METHOD
              • (void)connectToPeripheral:(CBPeripheral *)peripheral connects to the specified peripheral
            • One method to subscribe to events:
            • -(void)subscribeToEvents:(NSString *)peripheralName forEventTypes:(NSArray *)eventTypesToToggle;
      • The OpenSpatialBluetoothDelegate
        • You must create a class which implements the OpenSpatialBluetoothDelegate to receive data from Nod. Subscribing to events calls the event methods of the delegate corresponding to the event type.
        • There are four methods to implement from the OpenSpatialBluetoothDelegate
          • -(void)didConnectToNod:(CBPeripheral *)peripheral;
          • called when a Nod device is connected after calling connectToPeripheral
        • -(void)didDisconnectFromNod:(CBPeripheral *)peripheral;
        • called when a Nod device is disconnects from the device
      • -(void)didFindNewDevice:(NSArray *)peripherals;
        • called when a device is found after calling scanForPeripherals
      • -(void)openSpatialDataFired:(OpenSpatialData *)openSpatialData;

Sample workflow to subscribe to Euler Angle and RelativeXY Data

  • Instantiate:
    • opSpcBluetooth = [OpenSpatialBluetooth sharedBluetoothServ];
  • Set Delegate (after creating the delegate):
    • opSpcBluetooth.delegate = your delegate
  • Scan:
    • [opSpcBluetooth scanForPeripherals];
  • Connect:
    • [opSpcBluetooth connectToPeripheral: peripheral found in scan];
  • Subscribe
    • [opSpcBluetooth subscribeToEvents:name forEventTypes:@[@(OS_RELATIVE_XY_TAG), @(OS_EULER_ANGLES_TAG)]];
  • Now your delegate’s openSpatialDataFired method will be called whenever there is new RelativeXY and Euler Angle data available from the Nod device.

Subscribing to other events follows the same workflow.

Thank You for using Nod!

For any questions regarding this iOS service or Nod in general please email: support@nod-labs.com

More information

If you want to know more, these are some good places to continue exploring:

  • Links to SDKs, developer focussed support, IRC.
  • Engage with the larger Nod development community on a variety of topics