Coder Social home page Coder Social logo

nordicsemiconductor / ios-memfault-library Goto Github PK

View Code? Open in Web Editor NEW
8.0 4.0 0.0 2.88 MB

nRF Memfault Library + Example App

Swift 100.00%
ble bluetooth bluetooth-low-energy ios macos memfault nordic nordic-bluetooth nordic-semiconductor nordicsemi

ios-memfault-library's Introduction

iOS nRF Memfault Library + Example App

A Swift-based library for iOS/iPadOS/macOS can connects to a Bluetooth LE device supporting the Memfault Diagnostic Service, downloads data Chunks and uploads them to the Memfault Console.

The device is expected to support the Memfault Diagnostic Service, as defined here.

Library

Minimum OS Requirements

  • iOS: 15.0
  • macOS: 12.0

In all cases, the Library requires an active Internet connection. If an Error is encountered when uploading a Chunk of Data, the BLE connection to the device will be dropped immediately to ensure the least amount of Chunks of Data are lost.

Basic Usage

let memfaultManager = MemfaultManager()
// Connects to the Device and begins automagically streaming / uploading data.
await memfaultManager.connect(to: device)

// To stop / disconnect.
await memfaultManager.disconnect(from: device)

Memfault's APIs take a BluetoothDevice, which is a very simple protocol requiring only the UUID String of a Device. A CBPeripheral extension is provided as part of the library, so you're free to pass-in your scanned CBPeripheral with no issues.

Advanced Usage

It is possible to listen to all state changes & errors as they occur from the Memfault Library, like so:

let memfaultManager = MemfaultManager()

let connectionStream = await memfaultManager.connect(to: device)
do {
    for try await newEvent in connectionStream {
        switch newEvent.event {
            // Logic for each Event.
        }
    }
} catch {
    // Error handling.
}

// Disconnect when needed.
await memfaultManager.disconnect(from: device)

Furthermore, it's also possible to manually ask the framework to upload a specific Chunk if an error were to happen:

try await memfaultManager.upload(chunk, with: chunkAuth)

This requires passing-in the MemfaultChunkAuth struct, which is received through an autentication event from the connection stream (AsyncSequence).

Example App

The aforementioned Advanced Usage is what enables a UI-based app to inform the user of what the underlying Memfault Library is doing, as well as providing manual control of connection / disconnection and forcing a Memfault Chunk of Data to be uploaded in case an error occurs.

ios-memfault-library's People

Contributors

dinesharjani avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

ios-memfault-library's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.