-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Mikael Kindborg
committed
Jan 29, 2016
1 parent
5758d01
commit 51b4d33
Showing
65 changed files
with
46,656 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,205 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>JSDoc: Source: arduinoble/arduinoble.js</title> | ||
|
||
<script src="scripts/prettify/prettify.js"> </script> | ||
<script src="scripts/prettify/lang-css.js"> </script> | ||
<!--[if lt IE 9]> | ||
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script> | ||
<![endif]--> | ||
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css"> | ||
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css"> | ||
</head> | ||
|
||
<body> | ||
|
||
<div id="main"> | ||
|
||
<h1 class="page-title">Source: arduinoble/arduinoble.js</h1> | ||
|
||
|
||
|
||
|
||
|
||
|
||
<section> | ||
<article> | ||
<pre class="prettyprint source linenums"><code>// File: arduinoble.js | ||
|
||
// Load library EasyBLE. | ||
evothings.loadScript('libs/evothings/easyble/easyble.js'); | ||
|
||
/** | ||
* @namespace | ||
* @author Mikael Kindborg | ||
* @description <p>Functions for communicating with an Arduino BLE shield.</p> | ||
* <p>It is safe practise to call function {@link evothings.scriptsLoaded} | ||
* to ensure dependent libraries are loaded before calling functions | ||
* in this library.</p> | ||
* | ||
* @todo This is a very simple library that has only write capability, | ||
* read and notification functions should be added. | ||
* | ||
* @todo Add function to set the write characteristic UUID to make | ||
* the code more generic. | ||
*/ | ||
evothings.arduinoble = {}; | ||
|
||
;(function() | ||
{ | ||
// Internal functions. | ||
var internal = {}; | ||
|
||
/** | ||
* Stop any ongoing scan and disconnect all devices. | ||
* @public | ||
*/ | ||
evothings.arduinoble.close = function() | ||
{ | ||
evothings.easyble.stopScan(); | ||
evothings.easyble.closeConnectedDevices(); | ||
}; | ||
|
||
/** | ||
* Called when you've connected to an Arduino BLE shield. | ||
* @callback evothings.arduinoble.connectsuccess | ||
* @param {evothings.arduinoble.ArduinoBLEDevice} device - | ||
* The connected BLE shield. | ||
*/ | ||
|
||
/** | ||
* Connect to a BLE-shield. | ||
* @param deviceName BLE name if the shield. | ||
* @param {evothings.arduinoble.connectsuccess} success - | ||
* Success callback: success(device) | ||
* @param {function} fail - Error callback: fail(errorCode) | ||
* @example | ||
* evothings.arduinoble.connect( | ||
* 'arduinoble', // Name of BLE shield. | ||
* function(device) | ||
* { | ||
* console.log('connected!'); | ||
* device.writeDataArray(new Uint8Array([1])); | ||
* evothings.arduinoble.close(); | ||
* }, | ||
* function(errorCode) | ||
* { | ||
* console.log('Error: ' + errorCode); | ||
* }); | ||
* @public | ||
*/ | ||
evothings.arduinoble.connect = function(deviceName, success, fail) | ||
{ | ||
evothings.easyble.startScan( | ||
function(device) | ||
{ | ||
if (device.name == deviceName) | ||
{ | ||
evothings.easyble.stopScan(); | ||
internal.connectToDevice(device, success, fail); | ||
} | ||
}, | ||
function(errorCode) | ||
{ | ||
fail(errorCode); | ||
}); | ||
}; | ||
|
||
/** | ||
* Connect to the BLE shield. | ||
* @private | ||
*/ | ||
internal.connectToDevice = function(device, success, fail) | ||
{ | ||
device.connect( | ||
function(device) | ||
{ | ||
// Get services info. | ||
internal.getServices(device, success, fail); | ||
}, | ||
function(errorCode) | ||
{ | ||
fail(errorCode); | ||
}); | ||
}; | ||
|
||
/** | ||
* Read all services from the device. | ||
* @private | ||
*/ | ||
internal.getServices = function(device, success, fail) | ||
{ | ||
device.readServices( | ||
null, // null means read info for all services | ||
function(device) | ||
{ | ||
internal.addMethodsToDeviceObject(device); | ||
success(device); | ||
}, | ||
function(errorCode) | ||
{ | ||
fail(errorCode); | ||
}); | ||
}; | ||
|
||
/** | ||
* Add instance methods to the device object. | ||
* @private | ||
*/ | ||
internal.addMethodsToDeviceObject = function(device) | ||
{ | ||
/** | ||
* Object that holds info about an Arduino BLE shield. | ||
* @namespace evothings.arduinoble.ArduinoBLEDevice | ||
*/ | ||
|
||
/** | ||
* @function writeDataArray | ||
* @description Write data to an Arduino BLE shield. | ||
* @param {Uint8Array} uint8array - The data to be written. | ||
* @memberof evothings.arduinoble.ArduinoBLEDevice | ||
* @instance | ||
* @public | ||
*/ | ||
device.writeDataArray = function(uint8array) | ||
{ | ||
device.writeCharacteristic( | ||
// TODO: Make this possible to set. | ||
'713d0003-503e-4c75-ba94-3148f18d941e', | ||
uint8array, | ||
function() | ||
{ | ||
console.log('writeCharacteristic success'); | ||
}, | ||
function(errorCode) | ||
{ | ||
console.log('writeCharacteristic error: ' + errorCode); | ||
}); | ||
}; | ||
}; | ||
})(); | ||
</code></pre> | ||
</article> | ||
</section> | ||
|
||
|
||
|
||
|
||
</div> | ||
|
||
<nav> | ||
<h2><a href="index.html">Home</a></h2><h3>Namespaces</h3><ul><li><a href="evothings.html">evothings</a></li><li><a href="evothings.arduinoble.html">arduinoble</a></li><li><a href="evothings.arduinoble.ArduinoBLEDevice.html">ArduinoBLEDevice</a></li><li><a href="evothings.arduinotcp.html">arduinotcp</a></li><li><a href="evothings.easyble.html">easyble</a></li><li><a href="evothings.easyble.EasyBLEDevice.html">EasyBLEDevice</a></li><li><a href="evothings.easyble.error.html">error</a></li><li><a href="evothings.nordicble.html">nordicble</a></li><li><a href="evothings.nordicble.NordicBLEDevice.html">NordicBLEDevice</a></li><li><a href="evothings.nRF51_ble.html">nRF51_ble</a></li><li><a href="evothings.os.html">os</a></li><li><a href="evothings.rfduinoble.html">rfduinoble</a></li><li><a href="evothings.rfduinoble.RFduinoBLEDevice.html">RFduinoBLEDevice</a></li><li><a href="evothings.tisensortag.html">tisensortag</a></li><li><a href="evothings.tisensortag.ble.html">ble</a></li><li><a href="evothings.tisensortag.ble.CC2541.html">CC2541</a></li><li><a href="evothings.tisensortag.ble.CC2650.html">CC2650</a></li><li><a href="evothings.tisensortag.ble.error.html">error</a></li><li><a href="evothings.tisensortag.ble.status.html">status</a></li><li><a href="evothings.tisensortag.SensorTagInstance.html">SensorTagInstance</a></li><li><a href="evothings.tisensortag.SensorTagInstanceBLE.html">SensorTagInstanceBLE</a></li><li><a href="evothings.tisensortag.SensorTagInstanceBLE_CC2541.html">SensorTagInstanceBLE_CC2541</a></li><li><a href="evothings.tisensortag.SensorTagInstanceBLE_CC2650.html">SensorTagInstanceBLE_CC2650</a></li><li><a href="evothings.util.html">util</a></li></ul><h3>Global</h3><ul><li><a href="global.html#HIGH">HIGH</a></li><li><a href="global.html#INPUT">INPUT</a></li><li><a href="global.html#LOW">LOW</a></li><li><a href="global.html#OUTPUT">OUTPUT</a></li></ul> | ||
</nav> | ||
|
||
<br class="clear"> | ||
|
||
<footer> | ||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.3</a> on Tue Oct 27 2015 14:39:06 GMT+0100 (CET) | ||
</footer> | ||
|
||
<script> prettyPrint(); </script> | ||
<script src="scripts/linenumber.js"> </script> | ||
</body> | ||
</html> |
Oops, something went wrong.