2016-06-21 18:46:13 +02:00
# Bluetooth
2016-06-24 18:02:14 +02:00
Support for additional Bluetooth services.
2017-09-07 22:42:08 +02:00
## ~hint
2016-10-19 06:36:42 +02:00
![](/static/bluetooth/Bluetooth_SIG.png)
2016-11-02 01:44:37 +01:00
For another device like a smartphone to use any of the Bluetooth "services" which the @boardname @ has, it must first be [paired with the @boardname@ ](/reference/bluetooth/bluetooth-pairing ). Once paired, the other device may connect to the @boardname @ and exchange data relating to many of the @boardname @'s features.
2016-10-19 06:36:42 +02:00
2017-09-07 22:42:08 +02:00
## ~
2016-10-19 06:36:42 +02:00
2016-06-21 18:46:13 +02:00
```cards
bluetooth.startAccelerometerService();
bluetooth.startButtonService();
bluetooth.startIOPinService();
bluetooth.startLEDService();
bluetooth.startMagnetometerService();
bluetooth.startTemperatureService();
2016-10-19 06:36:42 +02:00
bluetooth.onBluetoothConnected(() => {});
bluetooth.onBluetoothDisconnected(() => {});
2016-12-07 18:05:03 +01:00
bluetooth.setTransmitPower(7);
2016-10-19 06:36:42 +02:00
```
## UART
```cards
bluetooth.startUartService();
bluetooth.uartReadUntil("");
2018-11-26 06:57:18 +01:00
bluetooth.uartWriteLine("");
2016-10-19 06:36:42 +02:00
bluetooth.uartWriteString("");
bluetooth.uartWriteNumber(0);
bluetooth.uartWriteValue("", 0);
2017-04-28 10:05:04 +02:00
bluetooth.onUartDataReceived(",", () => {})
2016-06-21 18:46:13 +02:00
```
2016-11-30 13:06:15 +01:00
## Eddystone
```cards
2016-12-23 17:58:38 +01:00
bluetooth.advertiseUid(42, 1, 7, true);
2017-07-24 22:39:27 +02:00
bluetooth.advertiseUrl("https://makecode.microbit.org/", 7, true);
2016-11-30 13:06:15 +01:00
bluetooth.stopAdvertising();
```
2017-09-07 22:42:08 +02:00
## Advanced
2016-10-19 06:36:42 +02:00
2016-11-02 01:44:37 +01:00
For more advanced information on the @boardname @ Bluetooth UART service including information on using a smartphone, see the [Lancaster University @boardname@ runtime technical documentation ](http://lancaster-university.github.io/microbit-docs/ble/uart-service/ )
2016-10-19 06:36:42 +02:00
2017-09-07 22:42:08 +02:00
## See Also
2016-08-08 22:08:15 +02:00
2016-10-19 06:36:42 +02:00
[startAccelerometerService ](/reference/bluetooth/start-accelerometer-service ), [startButtonService ](/reference/bluetooth/start-button-service ), [startIOPinService ](/reference/bluetooth/start-io-pin-service ), [startLEDService ](/reference/bluetooth/start-led-service ), [startMagnetometerService ](/reference/bluetooth/start-magnetometer-service ), [startTemperatureService ](/reference/bluetooth/start-temperature-service ),
[startUartService ](/reference/bluetooth/start-uart-service ),
[uartReadUntil ](/reference/bluetooth/uart-read-until ),
2018-11-26 06:57:18 +01:00
[uartWriteLine ](/reference/bluetooth/uart-write-line ),
2016-10-19 06:36:42 +02:00
[uartWriteString ](/reference/bluetooth/uart-write-string ),
[uartWriteNumber ](/reference/bluetooth/uart-write-number ),
[uartWriteValue ](/reference/bluetooth/uart-write-value ),
2016-11-30 13:06:15 +01:00
[onBluetoothConnected ](/reference/bluetooth/on-bluetooth-connected ),
[onBluetoothDisconnected ](/reference/bluetooth/on-bluetooth-disconnected ),
[advertiseUrl ](/reference/bluetooth/advertise-url ),
[stopAdvertising ](/reference/bluetooth/stop-advertising )
2017-03-15 23:54:40 +01:00
```package
bluetooth
```