JetBrains/kotlin-wrappers#1949
My BLE Scanner & Debugger is now live on the Google Play Store.
This app uses a pre-populated Room database that includes BLE Services, Characteristics, and Descriptors from Nordic's Bluetooth Numbers Database.
Nordic's database might be updated from time to time, and I wanted a way to update my SQLite data without having
to manually recreate my database every time. To accomplish this, I created a Kotlin/JS/React/Ktor Multiplatform app
that does the following when you click Start Sync
:
- From the frontend, it calls a Ktor API path to
/descriptors
, using Ktor Http Client for JS. - From the API, it goes out to GitHub and reads the Raw JSON, using Ktor Http Client CIO. Here's an
example of
descriptor_uuids.json
with added rows: descriptor_uuids.json - Next, the API converts the Raw JSON to an object.
- Using Exposed, the API then reads the existing data from the SQLite database, and creates a list of all new Descriptors.
- If there are new records, the API inserts new Descriptors into the SQLite table.
- Finally, the API returns the response to the React frontend.
In the screenshot below, a new Characteristic was added to the Numbers database after I created my pre-populated room database. You can see the addition here: Nordic's git commit. My app found the new record, and inserted it into my local SQLite database: