XYOracleNetwork/sdk-xyo-swift

View on GitHub
Sources/sdk-xyo-swift/BleInterface/data/XyoGattNameEncoder.swift

Summary

Maintainability
A
1 hr
Test Coverage
//
//  XyoGattNameEncoder.swift
//  Pods-SampleiOS
//
//  Created by Carter Harrison on 2/22/19.
//

import Foundation
import sdk_core_swift

/// A simple struct to encode major and minor values into a string
struct XyoGattNameEncoder {
    
    /// Encodes the major and minor value into a base64 string.
    /// - Parameter major: The major to encode into the string.
    /// - Parameter minor: The minor to encode into the string.
    /// - Returns: Returns a Base64 string of the major and minor.
    static func encode (major : UInt16, minor: UInt16) -> String {
        let buffer = XyoBuffer()
            .put(bits: major)
            .put(bits: minor)
            .toByteArray()
        
        return Data(buffer).base64EncodedString()
    }
}