@mobione/thermalib-expo v0.1.8
thermalib-expo
ETI Bluetherm LE Protocol 1.1 integration

This is an integration to the thermalib SDK from the company ETI, to read temperature from their theromoter devices, e.g. Thermapen © Blue Theromoter (pictured).
- thermalib-expo
- Installation in managed Expo projects
- Installation in bare React Native projects
- Usage
- Permissions
- Scanning for devices
- Configure for Android
- Configure for iOS
- Running the Expo module example
- Contributing
Table of contents generated with markdown-toc
Installation in managed Expo projects
Note that you need to install expo-location as well to make BLE work on Android API >= 30.
Make sure to configure your app.json accordingly.
npx expo install @mobione/thermalib-expo expo-locationAdd @mobione/thermalib-expo to your app.jsonto include the module in Expo build:
// ./app.json
{
"expo": {
"name": "ThermalibApp",
"slug": "thermalib",
"version": "1.0.0",
"orientation": "portrait",
"plugins": [
"@mobione/thermalib-expo",
]
}
}Installation in bare React Native projects
For bare React Native projects, you must ensure that you have installed and configured the expo package before continuing.
Usage

Screenshot is from the included example.
Permissions
When you call upon any function like startScanning, it is still imperative that you request bluetooth permissions first. The module includes a standard helper to achieve this.
import { requestBluetoothPermission } from "@mobioone/thermalib-expo";
await requestBluetoothPermission();Scanning for devices
import thermalib, { Device, requestBluetoothPermission } from "@mobioone/thermalib-expo";
export default function App() {
const onChangePayload = useEvent(thermalib, "onChange");
const startScanning = async () => {
await requestBluetoothPermission();
await thermalib?.startScanning();
getDevices();
};
...
}Get available devices
import { thermalib, Device, requestBluetoothPermission } from "@mobioone/thermalib-expo";
export default function App() {
const [devices, setDevices] = useState<Device[]>([]);
const getDevices = async () => {
await requestBluetoothPermission();
const devs = thermalib?.devices();
if (devs) {
setDevices(devs.map((d) => d as Device));
} else {
console.log("No devices");
}
};
...
}Connect to device
import { thermalib, Device, requestBluetoothPermission } from "@mobioone/thermalib-expo";
export default function App() {
const [selectedDev, setSelectedDev] = useState<Device | undefined>(undefined);
const selectDevice = (deviceId: string) => {
console.log("Fetch device", deviceId);
const dev = thermalib.readDevice(deviceId) as { device?: Device };
if (dev?.device?.deviceName) {
setSelectedDev(dev.device);
}
};
...
}Read temperature
import { thermalib, Device, requestBluetoothPermission } from "@mobioone/thermalib-expo";
export default function App() {
const [reading, setReading] = useState<number | undefined>(undefined);
const getTemperature = (deviceId: string) => {
console.log("Scan device", deviceId);
const read = thermalib.readTemperature(deviceId) as {
reading?: number;
};
setReading(read.reading);
};
...
}Configure for Android
This library depends on Bluetooth LE (low energy) and will add the required permissions to your app. For Android, the following permissions are added. Remember to still ask for permissions before calling any BT function.
<uses-permission-sdk-23 android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission-sdk-23 android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.BLUETOOTH"/>
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT"/>
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" tools:targetApi="31"/>
<uses-feature android:name="android.hardware.bluetooth_le" android:required="true"/>Configure for iOS
Run npx pod-install after installing the npm package.
Running the Expo module example
Build the library
npm run build # typescript
# in a separate terminal
npm run prepare
npm run prepub
npm run podsRun the example project
cd example
npm run prebuild
npm run pods
npm run android # or iosFor convenience, we've added a command that runs all the required steps from the root project:
npm run android:build
Publish a new version
- Commit and push your feature.
- Up version in
package.jsonusing the scriptnpm version patch. This will tag and push to your branch. - PR and merge your branch.
- Draft a new Release from that the new tag.
- GitHub Action builds and publishes. The package becomes available in "packages" GitHub page.
Contributing
Contributions are very welcome! Please refer to guidelines described in the contributing guide.