Latest 1.2.3
Homepage https://github.com/loopdinc/iOS-Loopd-SDK
License MIT
Platforms ios 8.0, requires ARC
Authors

iOS-Loopd-SDK

CI Status
Version
License
Platform

Description

The Loopd Beacon SDK provides apis to interact with the Loopd Beacons from Android/iOS devices, and includes ranging, connecting, and writing and reading data between Loopd Beacons.

Requirements

Version Minimum iOS Target
1.x iOS 8

Installation





Drag the ./Pod/LoopdSDK.framework file into your project.

Usage

Clone the repo, and the example project in the Example directory.

LCBadgeManager

LCBadgeManager is a basic manager than helps the developer to control the Loopd Badge.

@interface ViewController () <LCBadgeManagerDelegate>
@property (strong, nonatomic) LCBadgeManager *badgeManager;
@end

- (void)viewDidLoad {
    [super viewDidLoad];

    self.badgeManager = [LCBadgeManager new];
    self.badgeManager.delegate = self;
    [self.badgeManager startScan];
}

You can also give limitations to it.

// config
LCScanningConfig *scanningConfig = [LCScanningConfig new];
scanningConfig.RSSI = -50;
scanningConfig.isAllowDuplicatesKey = YES;

[self.badgeManager startScanWithConfig:scanningConfig];

Try to connect with the badge.
When connected, you can execute commands to the badge.

#pragma mark - Badge Manager Delegate

- (void)badgeManager:(LCBadgeManager *)badgeManager didDiscoverBadge:(LCBadge *)badge {
    [self.badgeManager connectBadge:badge];
}

- (void)badgeManager:(LCBadgeManager *)badgeManager didConnectBadge:(LCBadge *)badge {
    // turn on red LED
    [self.badgeManager executeCommandCode:@"0F"];
}

LCBadgeManagerDelegate

@protocol LCBadgeManagerDelegate <NSObject>
@optional
- (void)badgeManager:(LCBadgeManager *)badgeManager didDiscoverBadge:(LCBadge *)badge;
- (void)badgeManager:(LCBadgeManager *)badgeManager didConnectBadge:(LCBadge *)badge;
- (void)badgeManager:(LCBadgeManager *)badgeManager didFailToConnectBadge:(LCBadge *)badge error:(NSError *)error;
- (void)badgeManager:(LCBadgeManager *)badgeManager didDisconnectBadge:(LCBadge *)badge error:(NSError *)error;
- (void)badgeManager:(LCBadgeManager *)badgeManager didUpdateValueForBadge:(LCBadge *)badge;
@end

LCContactExchangeManager

LCContactExchangeManager is a manager that helps the developer implement contact exchange easily.

@interface ViewController () <LCContactExchangeManagerDelegate>
@property (strong, nonatomic) LCContactExchangeManager *contactExchangeManager;
@end

- (void)viewDidLoad {
    [super viewDidLoad];

    self.contactExchangeManager = [LCContactExchangeManager new];
    self.contactExchangeManager.delegate = self;

    // target badge id
    NSString *badgeId = @"123abc";
    [self.contactExchangeManager startScanningWithBadgeId:badgeId];

    // if you need to scan all the badges, target badge id nil.
    // [self.contactExchangeManager startScanningWithBadgeId:nil];
}

#pragma mark - Contact Exchange Manager Delegate

- (void)contactExchangeManager:(LCContactExchangeManager *)contactExchangeManager
    didUpdateExchangedBadgeIds:(NSArray *)exchangedBadgeIds
                   targetBadge:(LCBadge *)targetBadge {
    // targetBadge is the current badge
    // exchangedBadgeIds is the array of other user's badge id
}

LCContactExchangeManagerDelegate

@protocol LCContactExchangeManagerDelegate <NSObject>
@optional
- (void)contactExchangeManager:(LCContactExchangeManager *)contactExchangeManager
                didDetectBadge:(LCBadge *)badge;

- (void)contactExchangeManager:(LCContactExchangeManager *)contactExchangeManager
    didUpdateExchangedBadgeIds:(NSArray *)exchangedBadgeIds;

- (void)contactExchangeManager:(LCContactExchangeManager *)contactExchangeManager
    didUpdateExchangedBadgeIds:(NSArray *)exchangedBadgeIds
                   targetBadge:(LCBadge *)targetBadge;
@end

Commands

command action
00 Switch off both LEDs
FF Switch on both LEDs
11 Force the device to disconnect
A0xx advertise xx times per second
07 Read contact exchange data
[comment]: # ( 0F Switch on red LED )
[comment]: # ( F0 Switch on yellow LED )
[comment]: # ( 100004 Change transmission power +4dBm )
[comment]: # ( 10FF04 Change transmission power -4dBm )
[comment]: # ( 12 Get the mac address
Write 0x12 to the characteristic to get 12 byte MAC address AA:BB:CC:DD:EE:FF The notification is 0x12AABBCCDDEEFF
)
[comment]: # ( 14 Get the amount of free space left
Write 0x14, and the notification it will return will be 0x144060. This translates to 0x6040 = 24640 bytes of memory is free.
)
[comment]: # ( 20 Set the Local Name of the device
Write 0x20 + 8 bytes (Hex conversion of the ASCII)
)
[comment]: # ( 80 iBeacon mode
0x80+16 bytes of Data + 1byte Major ID + 1 byte Minor ID
)
[comment]: # ( 90 Eddystone mode
0x90+1 byte Frame Type + PDU based on Frame type
)
[comment]: # ( 89 Advertise iBeacon and Eddystone Alternatively )

Example:

- (void)turnOnBothLEDs {
    [self.badgeManager executeCommandCode:@"00"];
}

- (void)advertise4timesPerSecond {
    [self.badgeManager executeCommandCode:@"A004"];
}

- (void)advertise8timesPerSecond {
    [self.badgeManager executeCommandCode:@"A008"];
}

- (void)iBeaconExample {
    // 0x80+16 bytes of Data + 1byte Major ID + 1 byte Minor ID
    [self.badgeManager executeCommandCode:@"80FFEEDDCCBBAA99887766554433221100ABCD"];
}

- (void)eddystoneExample {
    // 0x90+1 byte Frame Type + PDU based on Frame type
    [self.badgeManager executeCommandCode:@"9000CEAAAAAAAAAAAAAAAAAAAABBBBBBBBBBBB"];
}

Author

Derrick Chao, [email protected]

License

Loopd-iOS-SDK is available under the MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "Loopd-iOS-SDK",
    "version": "1.2.3",
    "summary": "A framework easy to use Loopd Badge",
    "description": "A framework to control Loopd Badge.",
    "homepage": "https://github.com/loopdinc/iOS-Loopd-SDK",
    "license": "MIT",
    "authors": {
        "Derrick": "[email protected]"
    },
    "source": {
        "git": "https://github.com/loopdinc/iOS-Loopd-SDK.git",
        "tag": "1.2.3"
    },
    "platforms": {
        "ios": "8.0"
    },
    "requires_arc": true,
    "source_files": "Pod/Classes/**/*"
}

Pin It on Pinterest

Share This