Upload packaging folder
[platform/upstream/iotjs.git] / tools / docs / api / IoT.js-API-BLE.md
1 ## Module: ble
2
3 ### Platform Support
4
5 The following shows ble module APIs available for each platform.
6
7 |  | Linux<br/>(Ubuntu) | Raspbian<br/>(Raspberry Pi) | Nuttx<br/>(STM32F4-Discovery) |
8 | :---: | :---: | :---: | :---: |
9 | ble.startAdvertising | O | O | X |
10 | ble.stopAdvertising | O | O | X |
11 | ble.setServices | O | O | X |
12
13 ### Events
14
15 #### `'stateChange'`
16 * `callback: Function(state)`
17
18   * `state: String` - "unknown" | "resetting" | "unsupported" | "unauthorized" | "poweredOff" | "poweredOn"
19
20 Emitted when adapter state is changed.
21
22
23 ### Methods
24
25 #### ble.startAdvertising(name, serviceUuids[, callback(error)])
26 * `name: String` - maximum 26 bytes
27 * `serviceUuids: Array`
28   * 1 128-bit service UUID
29   * 1 128-bit service UUID + 2 16-bit service UUIDs
30   * 7 16-bit service UUID
31 * `callback: Function(error)`
32
33 Start advertising.
34
35 ble.state must be poweredOn before advertising is started. 
36 ble.on('stateChange', callback(state)); can be used register for state change events.
37
38
39 #### ble.stopAdvertising(callback)
40 * `callback: Function()`
41
42 Stop advertising.