Persistent Store (flash)

Persistent Store commands can be used to manage user data in PS keys in the flash memory of the Bluetooth device. User data stored within the flash memory is persistent across reset and power cycling of the device. The persistent store size is 2048 bytes. As Bluetooth bondings are also stored in this area, the space available for user data additionally depends on the number of bondings the device has at the time. The size of a Bluetooth bonding is around 150 bytes.

The maximum user data size associated to a PS key is 56 bytes.

flash commands

flash_ps_erase

This command can be used to erase a single PS key and its value from the persistent store..

Command

Byte Type Name Description
0 0x20 hilen Message type: Command
1 0x02 lolen Minimum payload length
2 0x0d class Message class:Persistent Store
3 0x04 method Message ID
4-5 uint16 key PS key to erase

Response

Byte Type Name Description
0 0x20 hilen Message type: Response
1 0x02 lolen Minimum payload length
2 0x0d class Message class:Persistent Store
3 0x04 method Message ID
4-5 uint16 result Result code
  • 0: success
  • Non-zero: an error occurred
For other values refer to the Error codes

API

/* Function */
struct gecko_msg_flash_ps_erase_rsp_t *gecko_cmd_flash_ps_erase(uint16 key);

/* Response id */
gecko_rsp_flash_ps_erase_id

/* Response structure */
struct gecko_msg_flash_ps_erase_rsp_t
{
  uint16 result
}

flash_ps_erase_all

This command can be used to erase all PS keys and their corresponding values.

Command

Byte Type Name Description
0 0x20 hilen Message type: Command
1 0x00 lolen Minimum payload length
2 0x0d class Message class:Persistent Store
3 0x01 method Message ID

Response

Byte Type Name Description
0 0x20 hilen Message type: Response
1 0x02 lolen Minimum payload length
2 0x0d class Message class:Persistent Store
3 0x01 method Message ID
4-5 uint16 result Result code
  • 0: success
  • Non-zero: an error occurred
For other values refer to the Error codes

API

/* Function */
struct gecko_msg_flash_ps_erase_all_rsp_t *gecko_cmd_flash_ps_erase_all();

/* Response id */
gecko_rsp_flash_ps_erase_all_id

/* Response structure */
struct gecko_msg_flash_ps_erase_all_rsp_t
{
  uint16 result
}

flash_ps_load

This command can be used for retrieving the value of the specified PS key.

Command

Byte Type Name Description
0 0x20 hilen Message type: Command
1 0x02 lolen Minimum payload length
2 0x0d class Message class:Persistent Store
3 0x03 method Message ID
4-5 uint16 key PS key of the value to be retrieved

Response

Byte Type Name Description
0 0x20 hilen Message type: Response
1 0x03 lolen Minimum payload length
2 0x0d class Message class:Persistent Store
3 0x03 method Message ID
4-5 uint16 result Result code
  • 0: success
  • Non-zero: an error occurred
For other values refer to the Error codes
6 uint8array value The returned value of the specified PS key.

API

/* Function */
struct gecko_msg_flash_ps_load_rsp_t *gecko_cmd_flash_ps_load(uint16 key);

/* Response id */
gecko_rsp_flash_ps_load_id

/* Response structure */
struct gecko_msg_flash_ps_load_rsp_t
{
  uint16 result,
  uint8array value
}

flash_ps_save

This command can be used to store a value into the specified PS key. Allowed PS keys are in range from 0x4000 to 0x407F. At most 56 bytes user data can be stored in one PS key. Error code 0x018a (command_too_long) will be returned if more than 56 bytes data is passed in.

Command

Byte Type Name Description
0 0x20 hilen Message type: Command
1 0x03 lolen Minimum payload length
2 0x0d class Message class:Persistent Store
3 0x02 method Message ID
4-5 uint16 key PS key
6 uint8array value Value to store into the specified PS key.

Response

Byte Type Name Description
0 0x20 hilen Message type: Response
1 0x02 lolen Minimum payload length
2 0x0d class Message class:Persistent Store
3 0x02 method Message ID
4-5 uint16 result Result code
  • 0: success
  • Non-zero: an error occurred
For other values refer to the Error codes

API

/* Function */
struct gecko_msg_flash_ps_save_rsp_t *gecko_cmd_flash_ps_save(uint16 key, uint8 value_len, const uint8 *value_data);

/* Response id */
gecko_rsp_flash_ps_save_id

/* Response structure */
struct gecko_msg_flash_ps_save_rsp_t
{
  uint16 result
}