BSB Developer Docs
Loading...
Searching...
No Matches
device_name.h File Reference

Device Name service API. More...

#include <core/string.h>
#include <core/state.h>
#include "device_name_common.h"

Go to the source code of this file.

Data Structures

struct  DeviceNameInfo
 DeviceName information structure. More...
 

Macros

#define RECORD_DEVICE_NAME   "device_name"
 The string key for DeviceName instance access.
 

Typedefs

typedef struct DeviceName DeviceName
 Opaque data type for the Device Name service instance.
 

Enumerations

enum  DeviceNameError {
  DeviceNameErrorNone , DeviceNameErrorEmpty , DeviceNameErrorTooLong , DeviceNameErrorIllegalChar ,
  DeviceNameErrorOnlySpaces , DeviceNameErrorSaveFailed , DeviceNameErrorMax
}
 Validation status returned by device_name_set(). More...
 

Functions

void device_name_get (DeviceName *instance, FuriString *name)
 Get current device name.
 
DeviceNameError device_name_set (DeviceName *instance, const char *name)
 Set new device name.
 
FuriState * device_name_get_state (const DeviceName *instance)
 Get the DeviceName state object.
 

Detailed Description

Device Name service API.

The Device Name service is responsible for storing and managing the device name. It provides API for getting and setting the name, and publishes rename events via FuriPubSub. If device is linked to account, device name service will send name through MQTT each time the name was updated.

The device name is persisted using SettingsProvider.

Typedef Documentation

◆ DeviceName

typedef struct DeviceName DeviceName

Opaque data type for the Device Name service instance.

Get the instance pointer by calling furi_record_open(RECORD_DEVICE_NAME);

Enumeration Type Documentation

◆ DeviceNameError

Validation status returned by device_name_set().

Enumerator
DeviceNameErrorNone 

Name is valid and was applied successfully.

DeviceNameErrorEmpty 

Name is empty.

DeviceNameErrorTooLong 

Name exceeds the maximum allowed length.

DeviceNameErrorIllegalChar 

Name contains illegal characters.

DeviceNameErrorOnlySpaces 

Name consists only of spaces.

DeviceNameErrorSaveFailed 

Failed to save new name.

DeviceNameErrorMax 

Special value, internal use.

Function Documentation

◆ device_name_get()

void device_name_get ( DeviceName * instance,
FuriString * name )

Get current device name.

Parameters
[in]instanceDevice name service instance
[out]nameDevice name returned by function. Default name will be returned if no name has been set.

◆ device_name_get_state()

FuriState * device_name_get_state ( const DeviceName * instance)

Get the DeviceName state object.

The return value will be of DeviceNameInfo underlying type.

Parameters
[in]instanceDevice name service instance
Returns
pointer to the state object

◆ device_name_set()

DeviceNameError device_name_set ( DeviceName * instance,
const char * name )

Set new device name.

Validates the provided name and, if valid, persists it and publishes it.

Parameters
[in]instanceDevice name service instance
[in]nameNew device name to set
Returns
DeviceNameErrorNone on success, error otherwise