Latest 1.0.0
Homepage https://github.com/Hiroshi-Sugimura/ELSwift
License MIT
Platforms ios 9.0
Dependencies CocoaAsyncSocket
Authors

Overview

CI Status
Version
License
Platform

̃W[ECHONET LitevgRT|[g܂D
ECHONET LitevgR̓X}[[email protected]̒ʐMvgRłD

This module provides ECHONET Lite protocol.
The ECHONET Lite protocol is a communication protocol for smart home devices.

Installation

ELSwift is available through CocoaPods. To install
it, simply add the following line to your Podfile:

use_frameworks!

target 'simpleel' do  # << your target name
  pod 'ELSwift'
end

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

  • Xcode 8.0
  • iOS 9.3 (?)

Demos(controller)

“`Swift:Demo (ViewController.swift)
import UIKit
import ELSwift

class ViewController: UIViewController {

}


## Data stracture

```Swift:ELSwift
public class ELSwift : NSObject {
    static var isIPv6 = false
    static var inSocket: InSocket!
    static var outSocket: OutSocket!
    public static let MULTI_IP: String = "224.0.23.0"
    public static let PORT: UInt16 = 3360

    // define
    public static let SETI_SNA = 0x50
    public static let SETC_SNA = 0x51
    public static let GET_SNA = 0x52
    public static let INF_SNA = 0x53
    public static let SETGET_SNA = 0x5e
    public static let SETI = 0x60
    public static let SETC = 0x61
    public static let GET = 0x62
    public static let INF_REQ = 0x63
    public static let SETGET = 0x6e
    public static let SET_RES = 0x71
    public static let GET_RES = 0x72
    public static let INF = 0x73
    public static let INFC = 0x74
    public static let INFC_RES = 0x7a
    public static let SETGET_RES = 0x7e
    public static let EL_port = 3610
    public static let EL_Multi = "224.0.23.0"
    public static let EL_Multi6 = "FF02::1"

    static var EL_obj: [String]!
    static var EL_cls: [String]!

    public static var Node_details: Dictionary
    public static var facilities:Dictionary
}

“`Swift:EL_STRUCTURE
public class EL_STRUCTURE : NSObject{
public var EHD : [UInt8]
public var TID : [UInt8]
public var SEOJ : [UInt8]
public var DEOJ : [UInt8]
public var EDATA: [UInt8] // LEDATȀڍ
public var ESV : UInt8
public var OPC : UInt8
public var DETAIL: [UInt8]
public var DETAILs: Dictionary<String, [UInt8]>

override init() {
    EHD = []
    TID = []
    SEOJ = []
    DEOJ = []
    EDATA = []
    ESV = 0x00
    OPC = 0x00
    DETAIL = []
    DETAILs = [String: [UInt8]]()
}

}

ELSwift.initialize( objList: [String], callback: (( rinfo:(address:String, port:UInt16), els: ELSTRUCTURE?, err: Error?) -> Void)?, _ ipVer: UInt8? ) throws -> Void

do {
try ELSwift.initialize( objectList, { rinfo, els, err in
if let error = err {
print (error)
return
}

    // ToDo

}, 4)

}catch let error{
print( error )
}

ELSwift.eldataShow(_ eldata:EL_STRUCTURE ) -> Void

ELSwift.stringShow(_ str: String ) throws -> Void

ELSwift.bytesShow(_ bytes: [UInt8] ) throws -> Void

ELSwift.parseDetail( opc:UInt8, str:String ) throws -> Dictionary<String, [UInt8]>

ELSwift.parseBytes(_ bytes:[UInt8] ) throws -> EL_STRUCTURE

ELSwift.parseString(_ str: String ) throws -> EL_STRUCTURE

ELSwift.getSeparatedStringString( str: String ) -> String

ELSwift.substr( str:String, begginingIndex:UInt, _ count:UInt) -> String

ELSwift.getSeparatedStringELDATA( eldata : EL_STRUCTURE ) -> String

ELSwift.ELDATA2Array(_ eldata: EL_STRUCTURE ) throws -> [UInt8]

ELSwift.toHexString(_ byte:UInt8 ) -> String

ELSwift.toHexArray(_ str: String ) -> [UInt8]

ELSwift.bytesToString(_ bytes: [UInt8] ) throws -> String

ELSwift.sendBase( ip:String, data:Data ) throws -> Void

ELSwift.sendArray( ip:String, array:[UInt8] ) throws -> Void

ELSwift.sendOPC1( ip:String, seoj:[UInt8], deoj:[UInt8], esv: UInt8, epc: UInt8, edt:[UInt8]) throws -> Void


ex.

try ELSwift.sendOPC1( ‘192.168.2.150’, [0x05,0xff,0x01], [0x01,0x35,0x01], 0x61, 0x80, [0x31]);

ELSwift.sendString( ip:String, string:String ) throws -> Void

ELSwift.returner( bytes:[UInt8], rinfo:((address:String, port:UInt16)) ) -> Void

ELSwift.search() -> Void

ELSwift.renewFacilities = function( ip, obj, opc, detail )

ELSwift.renewFacilities( ip:String, els: EL_STRUCTURE ) throws -> Void

ELSwift.getPropertyMaps ( ip:String, eoj:[UInt8] ) throws -> Void

ELSwift.parseMapForm2(_ bitstr:String ) -> [UInt8]

console.dir( EL.facilities );

{ ‘192.168.2.103’:
{ ’05ff01′: { ’80’: ”, d6: ” },
‘0ef001′: { ’80’: ’30’, d6: ‘0100’ } },
‘192.168.2.104’: { ‘0ef001’: { d6: ‘0105ff01′ }, ’05ff01′: { ’80’: ’30’ } },
‘192.168.2.115’: { ‘0ef001′: { ’80’: ’30’, d6: ‘01013501’ } } }

try ELSwift.sendOPC1( "192.168.2.103", [0x05,0xff,0x01], [0x01,0x35,0x01], 0x61, 0x80, [0x30]);

Latest podspec

{
    "name": "ELSwift",
    "version": "1.0.0",
    "summary": "ELSwift carries out the ECHONET Lite protocol.",
    "description": "ELSwift supports the ECHONET Lite protocol.nThe protocol is for connecting and controlling home appliances.nThis library is for iOS.",
    "homepage": "https://github.com/Hiroshi-Sugimura/ELSwift",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Hiroshi-Sugimura": "[email protected]"
    },
    "source": {
        "git": "https://github.com/Hiroshi-Sugimura/ELSwift.git",
        "tag": "1.0.0"
    },
    "platforms": {
        "ios": "9.0"
    },
    "pod_target_xcconfig": {
        "SWIFT_VERSION": "4.0"
    },
    "xcconfig": {
        "SWIFT_VERSION": "4.0"
    },
    "source_files": "ELSwift/Classes/**/*",
    "dependencies": {
        "CocoaAsyncSocket": [
            "~> 7.6.1"
        ]
    },
    "pushed_with_swift_version": "4"
}

Pin It on Pinterest

Share This