fraune
mobile + web dev

BlueSim (iOS)Download BlueSim on the App Store

Updated 2024-12-21

Introduction

BlueSim is an iOS app that turns your phone into a customizable Bluetooth LE (BLE) peripheral! This enables you to test or debug a separate "central" or "host" device with any data you choose. If you've ever used a Bluetooth scanner app, you can think of BlueSim as its logical counterpart.

How it works

When you use BlueSim, you can start by adding any valid BLE service: GATT or custom. For example, you may choose to add service 0x1822 and characteristic 0x2A5E. This specific combination typically corresponds with GATT peripherals that measure a person's blood oxygen concentration as a percentage, for health-evaluative purposes. In this case your phone will be set up to simulate the operation of such a device, and it can even be set to respond with values you would expect a pulse oximeter to send!

Use cases

The intended uses for BlueSim revolve around developing and testing other BLE peripherals and centrals.

  • Integration testing
    • "Isn't there a better way to test my BLE central's interfaces than with unit tests and fake peripherals?"
  • Edge case testing
    • "How does my app respond if a peripheral transmits data outside of the expected range?"
  • Peripheral simulation
    • "I don't want to carry bulky hardware with me, but I need a way to simulate a Bluetooth peripheral's interfaces"
  • BLE investigation
    • "I'd like a hands-on way to learn how a BLE interface transmits data."

JSON Schema Documentation

Verison 4.0.0 introduced the ability to import and export profiles as JSON. You can use the following schema to better understand how to write your own profiles from a text editor.

Root Object

"version": Int
  • Versions the schema for compatibility. The only acceptable version is 1.
"profiles": Array<Profile>
  • An array of Profile objects, such that no two profiles share the same "displayName".

Profile

"displayName": String
  • Represents the name of the profile, which is only displayed in the BlueSim app to help the user distinguish it from other profiles.
"broadcastName": String
  • The value that shall be advertised as the "Local Name", when the profile is broadcasted.
"services": Array<Service>
  • An array of Service objects, such that no two services share the same "cbuuid"

Service

"cbuuid": String
  • The CoreBluetooth UUID of this service, represented as a hexadecimal String. It can be a normal full-length UUID, or a short form 2-byte UUID.
"isPrimary": Bool
  • Represents whether this is a primary service or not.
  • Note: Secondary services are connectable, but not discoverable unless included as part of a primary service. However, BlueSim does not yet provide a way to specify secondary service relationships. Please reach out if you require this feature.
"characteristics": Array<Characteristic>
  • An array of Characteristic objects, such that no two characteristics share the same "cbuuid"

Characteristic

"cbuuid": String
  • The CoreBluetooth UUID of this service, represented as a hexadecimal String. It can be a normal full-length UUID, a short form 2-byte UUID, or a medium form 4-byte UUID.
"properties": Dictionary<Property, Array<String>>
  • A dictionary where the key is a Property, and the value is an array of hexadecimal strings.
  • If the dictionary is missing one or more keys, the app will not broadcast those properties.
  • Use an empty array to specify that a characteristic can communicate with a given property, but has no data to transmit.
  • If the "write" property has an array set, any given values will be ignored by the app, since the app accepts data to be written on that characteristic, i.e. this is not data that can be sent.

Property

There are currently four acceptable properties:

  • "read"
    • Permits reads of the characteristic value.
  • "write"
    • Permits writes of the characteristic value, with the app giving an acknowledgement-type resopnse.
  • "notify"
    • Permits notifications of the characteristic value, without a response.
  • "indicate"
    • Permits indications of the characteristic value.

You can reach out if you would like to request more properties are supported.

Example

Below is a simple demonstration of how you can import two profiles at once.

{
  "profiles": [
    {
      "services": [],
      "displayName": "Empty profile",
      "broadcastName": "Testing"
    },
    {
      "broadcastName": "THERMO 80215",
      "services": [
        {
          "isPrimary": true,
          "characteristics": [
            {
              "properties": {
                "notify": [
                  "ABCD",
                  "1234"
                ],
                "write": []
              },
              "cbuuid": "2A1C"
            }
          ],
          "cbuuid": "1809"
        }
      ],
      "displayName": "Demo Thermometer"
    }
  ],
  "version": 1
}

Version History

  • v4.4.3 - 2024-12-?? (in review)
    • Added: Hint for broadcast name truncation
    • Added: Confirmation prompt for resetting app data
    • Fixed: New users no longer see &quo;Thanks for updating!&quo; on first launch
    • Changed: Minimum supported OS version changed from 16.0 to 16.6
  • v4.4.2 - 2024-12-16
    • Changed: App Store screenshots updated
  • v4.4.1 - 2024-12-12
    • Fixed: Logs were missing in some cases
  • v4.4.0 - 2024-11-27
    • === Logs Tab Makeover ===
    • Added: Ability to filter logs by minimum verbosity
    • Changed: Log items have a more organized layout and include the verbosity level
    • Changed: Moved clear button up to the toolbar for consistency with other pages
    • === Other ===
    • Added: Basic configuration for changing the date format dispalyed
    • Changed: Various wording changes and improvements behind the scenes
  • v4.3.1 - 2024-11-26
    • Fixed: These was a rare issue with focusing the correct field when adding mulitple data values
  • v4.3.0 - 2024-11-14
    • Added: Ability to update data values
    • Changed: Data entry page streamlined into the data list
    • Changed: Overflow options have been expanded into the toolbar on the data list screens
    • Fixed: The badge for the Logs tab could get outdated
  • v4.2.0 - 2024-10-24
    • == Maintenance Release ==
    • Added: App can check for updates, and provide an in-app badge when the version is more than one month outdated
    • Improved: Data consent rules are more strictly applied
    • Other: Minor UI updates, wording changes, and external references
  • v4.1.1 - 2024-10-01
    • Fixed: When deleting a service or characteristic, the app could remove the wrong one
  • v4.1.0 - 2024-09-30
    • Added: ASCII string format is now a supported data type
    • Added: Data input/output type is remembered
    • Added: Multiple data input items can now be duplicated or deleted all at once
    • Added: Provide hints when a property has no data or can't access data
    • Added: The complete changelog history can now be viewed
    • Changed: When switching between data input formats, the data is no longer converted from the previous format
  • v4.0.1 - 2024-09-25
    • Fixed: When the data input method was switched from hexadecimal to binary, the empty form would be submitted... twice!
    • Fixed: If the 'new keyboard' was not enabled, the binary input field did not default to showing the numerical keyboard
    • Fixed: There was a visual bug where the data input sheet did not immediately fully open on presentation
    • Changed: Custom service and characteristic UUID forms now have a clear button, and the standard keyboard now gets dismissed when the done key is tapped
    • Changed: Keyboard presentation happens automatically when switching between hexadecimal and binary input fields
    • Added: A cancel button for the data input form, instead of just relying on swiping the sheet to dismiss
  • v4.0.0 - 2024-09-24
    • Added: Ability to import and export profiles, in JSON format
    • Added: Display descriptive error messages when the app refuses to create a profile, service, or characteristic
    • Changed: Most text fields will automatically gain focus at the right time
    • Changed: Migrated data off of Keychain, improving storage performance and avoiding stale data after uninstall
  • v3.0.0 - 2024-09-10
    • Welcome to version 3.0 of BlueSim! A huge thanks goes out to those who reached out to me with ideas, especially those who joined the TestFlight—your time and patience has been immensely valuable.
    • Added: Characteristic properties support sending/receiving multiple values instead of repeating the same one
    • Fixed: Writes made to characteristics were not properly responded to, causing a 10-second delay in processing the next write
    • Other: Various performance and stability improvements
  • v2.2.1 - 2024-03-05
    • Changed: Web link updates
  • v2.2.0 - 2024-02-22
    • Added: There is a new keyboard specifically for writing hexadecimal/binary. You can toggle its use in the Preferences tab.
    • Improved: Data input fields can now stretch multiple lines
    • Fixed: When editing a filtered text field, the cursor position could get reset to the end of line
    • Fixed: Text could overlap with the clear button on the hexadecimal/binary data input fields
    • Fixed: A data input field could clip text on some devices
    • Other: Accent color tuning
  • v2.1.0 - 2024-02-15
    • Added: A new toggle in the Preferences tab can be used to prevent the app from sleeping
  • v2.0.3 - 2023-12-25
    • Fixed: App would crash when broadcsting a service with a 4-byte UUID
  • v2.0.2 - 2023-12-18
    • Fixed: Some valid custom service and characteristic UUID inputs were not accepted
    • Fixed: Service and characteristic UUID inputs were not properly formatting
    • Changed: Version changelog moved to the about tab
    • Changed: Contact email template now includes the app version
    • Changed: Back-end tweaks to support more reliable instrumentation
  • v2.0.1 - 2023-10-10 - "New Icon"
    • Changed: App icon (art inspired by the shape of antenna spread patterns)
    • Changed: Data sharing preference text refined to be more specific
  • v2.0.0 - 2023-10-04 - "Low-Profile"
    • Changed: UI migrated to a tabbed view to enable new workflows
    • Added: Profiles feature - to enable quickly switching between sets of services/characteristics
    • Added: Open source attributions
    • Changed: Broadcast is now enabled by default on first launch
    • Other: Major app logic has been rewritten: improving reliability, enhancing flexibility, and supporting future work
  • v1.4.1 - 2023-04-11 - "UI Fixes"
    • Changed: Disabled rotation on iPhone since it can break some views
    • Fixed: Home view text could go into overflow mode on iPhone mini
  • v1.4.0 - Superseded - "Contact Me"
    • Added: Contact form to improve communication between developer and user
    • Added: Realtime feedback when user resets all preferences
  • v1.3.1 - 2023-03-09 - "Don't Suggest Dupes"
    • Fixed: App was suggesting GATT services/characteristics that were already added
    • Fixed: Updates view on iPhone was a half-sheet, which could cut off text
  • v1.3.0 - 2023-03-07 - "Optional Diagnostics"
    • Added: An optional diagnostics/crash reporting module, to help with the detection of breaking bugs
    • Changed: App Settings was renamed to Preferences, to avoid confusion with the iOS Settings app
    • Other: The privacy policy has been updated to reflect the optional diagnostics feature
  • v1.2.0 - 2023-02-12 - "Notify and Indicate"
    • Added: Characteristic properties to send data via notify and indicate
    • Fixed: The app was able to advertise even when the setting was switched off
    • Fixed: If characteristic output data was set while in binary-editing mode, changes might not have been saved
  • v1.1.0 - 2023-01-16 - "GATT Numbers"
    • Added: List of predefined GATT services and characteristics
    • Added: Updates screen to display the most recent app changes
    • Fixed: Local name updates not saved when using back button
  • v1.0.0 - 2023-01-15 - "MVP"
    • Customizable local name
    • Custom services and characteristics can be set and advertised
    • Read and Write properties allowed on characteristics
    • Basic logging system helps users keep track of multiple reads/writes
    • Stored preferences helps the app start up with the last configurations used

Support the project

This project is not my day job. If you would like to accelerate development of a particular feature (or treat me to a coffee), you can support my work through PayPal.

Support my work

Copyright

© 2022 Brandon Fraune