var dlfcn = require("dlfcna.js");
//console.log(dlfcn)

var funcs = [
    ["get_ble_mac_address", "ss"],
];

//console.log("in factory_bleInfo.js")
function register() {
    //console.log("will register test_ble.so")
    var isSuccess = dlfcn.register("@native.test_ble", "./lib/factory/test_ble.so", funcs);
    if (isSuccess) {
        //console.log("load so successfully")
        var test_ble = require("@native.test_ble");
        return test_ble
    } else {
        //console.log("load so failed")
    }
    return undefined;
}
var test_ble = register();
function read(option) {

    //    option -> "mac" // return "78:22:88:7B:65:3F"
    //    option -> "qos" // return "11"
    //    return test_ble.read(option);
    //console.log("will read ble info")
    var mac = undefined;
    try {
        mac = test_ble.get_ble_mac_address();
    } catch (e) {
        mac = undefined
        //console.log("!!!ERROR:" + e)
    }
    // //console.log("mac: " + mac)
    return mac;

}

module.exports = {
    read: read,
}

