Latest 0.2.8
Homepage https://github.com/helinyu/YDOpenHardwarePod
License MIT
Platforms ios 7.0, requires ARC
Dependencies Masonry, BabyBluetooth, WebViewJavascriptBridge, SVProgressHUD, NJKWebViewProgress, YYModel, MJRefresh, Reachability
Authors

YDOpenHardwarePod

YDOpenHardware library for hard ware to cache or store datas from bluetooth and so on

用于悦动圈跑步开放平台的简单demo
问题咨询: qq:295235985 邮箱:[email protected]

第三方最终提供给我们一个framework,模拟器和真机通用的
YDOpenHardwarePod

S3.html (this file for interative with oc)

define the mathod to call the oc in html file

1、this module it not be modified

    function setupWebViewJavascriptBridge(callback) {
        if (window.WebViewJavascriptBridge) { return callback(WebViewJavascriptBridge); }
        if (window.WVJBCallbacks) { return window.WVJBCallbacks.push(callback); }
        window.WVJBCallbacks = [callback];
        var WVJBIframe = document.createElement('iframe');
        WVJBIframe.style.display = 'none';
        WVJBIframe.src = 'https://__bridge_loaded__';
        document.documentElement.appendChild(WVJBIframe);
        setTimeout(function() { document.documentElement.removeChild(WVJBIframe) }, 0)
    }

2、 invoke the last method to do business neccesary
like that:

    setupWebViewJavascriptBridge(function(bridge) {
        …………………………
        to do the business necessary
    }

3、sj invoke the oc method

 var callbackButton = document.getElementById('scanBtn')
 callbackButton.innerHTML = 'scanBtn'
 callbackButton.onclick = function(e) {
     e.preventDefault();
     log('JS calling handler "scan peripheral"')
     // window.location.href='./peripheralList.html';
     bridge.callHandler('onScanS3Click', 'S3', function(response) {
        log('JS got response', response)
    });
 };

4、oc invoke the js method , so that we must register the method

 bridge.registerHandler('deliverCharacteristic', function(data, responseCallback) {
    log('data'+data+':'+data.uuid+data.value.value0 +':'+data.value.value1+':'+data.value.value2+':'+data.value.value3+'.');

    var stepLabel = document.getElementById('stepLabel');
    // stepLabel.innerHTML = 
    var calorieLabel = document.getElementById('calorieLabel');
    // calorieLabel.innerHTMLp =
    var distanceLabel = document.getElementById('distanceLabel');
    // distanceLabel.innerHTML = 

    responseCallback(responseData);
});

5、data deliver protocol:
we must deliver the data by the json format , you can deliver json object or data string and so on which can deliver to the oc
so we recomend the format si key:value which is simpler ,it will more eaier to use.
like the data of oc that :

@{
@"uuid":c.UUID.UUIDString,
@"value":@{
         @"value0":value0,
         @"value1":value1,
         @"value2":value2,
         @"value3":value3
         }
};

more detail you can see the S3.html

Latest podspec

{
    "name": "YDOpenHardware",
    "version": "0.2.8",
    "summary": "u84ddu7259u786cu4ef6u5f00u53d1u5e73u53f0uff0cu6570u636eu5b58u50a8",
    "platforms": {
        "ios": "7.0"
    },
    "homepage": "https://github.com/helinyu/YDOpenHardwarePod",
    "license": "MIT",
    "authors": {
        "felix": "[email protected]"
    },
    "source": {
        "git": "https://github.com/helinyu/YDOpenHardwarePod.git",
        "tag": "0.2.8"
    },
    "source_files": [
        "ydOpenHardware/Bluetooth/*.{h,m}",
        "ydOpenHardware/extension/*.{h,m}",
        "ydOpenHardware/MSJsonKit/*.{h,mm}"
    ],
    "requires_arc": true,
    "description": "YDOpenHardware is for easier to use",
    "dependencies": {
        "Masonry": [
            "~> 1.0.2"
        ],
        "BabyBluetooth": [
            "~> 0.7.0"
        ],
        "WebViewJavascriptBridge": [
            "~> 6.0.2"
        ],
        "SVProgressHUD": [
            "~> 2.1.2"
        ],
        "NJKWebViewProgress": [
            "~> 0.2.3"
        ],
        "YYModel": [
            "~> 1.0.4"
        ],
        "MJRefresh": [
            "~> 3.1.12"
        ],
        "Reachability": [
            "~> 3.2"
        ]
    }
}

Pin It on Pinterest

Share This