当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript BLE.write方法代码示例

本文整理汇总了TypeScript中ionic-native.BLE.write方法的典型用法代码示例。如果您正苦于以下问题:TypeScript BLE.write方法的具体用法?TypeScript BLE.write怎么用?TypeScript BLE.write使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ionic-native.BLE的用法示例。


在下文中一共展示了BLE.write方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: sendDate

    /* Inform the peripheral of the current date */
    sendDate(peripheral) {

	/* Data must be sent through the BLE plugin as an ArrayBuffer */
	let uint8 = new Uint8Array(4);

	/* Grab the current time without milliseconds */
	let time = Math.floor((new Date).getTime() / 1000);

	/* Store the time in 4 byte increments */
	uint8[0] = time & 0xFF;
	uint8[1] = (time & 0xFF00) >>> 8;
	uint8[2] = (time & 0xFF0000) >>> 16;
	uint8[3] = (time & 0xFF000000) >>> 24;

	//console.log("Time sent: " + uint8);
	
	/* Write the data to the peripheral */
	BLE.write(peripheral.id, this.scanInfo.service, this.scanInfo.datecheck, uint8.buffer).then(
	    succ => console.log("Time written successfully"),
	    fail => console.log("Time not written successfully")
	);

    }
开发者ID:mdash-ursi2016,项目名称:ionic_code_typescript,代码行数:24,代码来源:blservice.ts

示例2: Uint8Array

	this.dateCheckSubscription.subscribe(buffer => {
	    let data = new Uint8Array(buffer);
	    
	    let curDate = this.calcDate(data[3],data[2],data[1],data[0]);
	    if (!this.lastDate)
		return;
	    
	    let uint8 = new Uint8Array(4);

	    let caughtUp = 0;
	    if (this.lastDate >= curDate)
		caughtUp = 1;

	    /* Send back an array of the boolean result */
	    for (let i = 0; i < 4; i++) {
		uint8[i] = caughtUp;
	    }

	    BLE.write(peripheral.id, this.scanInfo.service, this.scanInfo.datecheck, uint8.buffer).then(
		succ => {console.log("wrote back: " + uint8);},
		fail => {console.log("did not write back");}
	    );
	});
开发者ID:mdash-ursi2016,项目名称:ionic_code_typescript,代码行数:23,代码来源:blservice.ts


注:本文中的ionic-native.BLE.write方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。