StoreIndexedPersistentField

Description:

This method stores the current field value to an inter-frame data array, indexed by the value in the field specified in the parameter. This method is similar to the StorePersistentField method in that the data is saved forever rather than just for the length of the layer or frame. The difference between this method and StorePersistentField is that you can store multiple values to the same inter-frame data name.

Parameters:

[Required]

StaticName

"Inter-frame data name"


[Required]

Field

"Field that contains the index"


Example:

Say you have a central device talking to multiple centrals. The central sends a Read command to Peripheral 1, a Write Configuration command to Peripheral 4, and a Read Configuration command to central 7. The command frames contain both the command and the central the command is directed to. The responses from the centrals, however, don't reference the command, though they do say which central the response is from. You can't correctly decode the responses unless you can match them up to the commands.

You can do this if you save the command value indexed by the central number. The command part of the decoder might look like this:

FIELD central_number (Fixed 1) (Decimal) "Peripheral Number"

FIELD command_code (Fixed 1) RETRIEVE (StoreIndexedPersistentField command central_number) (Hex) "Command"

The response section might look like this:

FIELD central_number (Fixed 1) (Decimal) "Peripheral Number"

FIELD retrieved_command_code (Fixed 0) RETRIEVE (IndexedPersistentField command central_ number) SUPPRESS_DETAIL

BRANCH (FromTable command_code retrieved_command_code)

Using the above example, after the first command frame is decoded, the array holds:

1 Read

After the second and third command frames are decoded, it holds:

1 Read

4 Write Configuration

7 Read Configuration

When a response comes back from Peripheral 7, the response section of the decoder looks up 7 in the array and retrieves the value "Read Configuration". It then branches to the Read Configuration section of the decoder.