Overview
The Ravas RedBox has a parameter system that can be read. The parameters are divided into different parameter pages.
A parameter is addressed by two numbers: the page_id (PageID) and the parameter_id within that page. Both are listed on the pages below.
Overview
The Basic Ravas RedBox has the following configured parameter-pages:
Info
Not all pageID's are available in every Ravas RedBox. For example, the WiFi/BLE page is only accessible if the system is equipped with a WiFi/BLE module.
| PageID | Value | Description |
|---|---|---|
SYSTEM |
1 | Information about the Ravas RedBox |
WIFI |
2 | WiFi connection parameter settings |
BLE |
3 | BLE parameter settings |
SCALE_1 … SCALE_8 |
10–17 | Scale x settings |
LOCAL_REDBOX |
18 | Local Ravas RedBox settings |
EXTERNAL_REDBOX_1 … _7 |
19–25 | Connected RedBoxes, same layout as the local one |
LOADCELL_1 … LOADCELL_32 |
26–57 | Loadcell X information/settings |
Info
The pages with an 'X' in the name have multiple pages available with the same setup. For example, 'LOADCELL_1' has the same setup as 'LOADCELL_2' but only if the system consists of multiple loadcells.
Each page has a ..._PARAMETER_COUNT parameter at id 0. Read it to verify that you received every parameter of that page.
Getting parameters
The following code example can be used to request parameter information.
Example
bool protocol_send_param_request(PageID p_id, uint32_t parameter_id)
{
Request request = {};
request.type = Request_Type_GET_PARAMETER;
request.which_payload = Request_get_parameter_tag;
request.payload.get_parameter.page_id = p_id;
request.payload.get_parameter.parameter_id = parameter_id;
return send_request(&request);
}
The RedBox answers with a ParameterDescription: the name, the flags and the value. To follow a value instead of polling it, subscribe to it.
Setting parameters
A write is refused with PARAMETER_CHANGE_NOT_ALLOWED_READ_ONLY when the parameter is read-only, with USER_LEVEL_TOO_LOW when your access level is not high enough, and with PARAMETER_CHANGE_NOT_ALLOWED_IN_LEGAL_FOR_TRADE_MODE when the parameter is legally relevant and the system is sealed. The flags in the parameter description tell you all three in advance.
Set boolean parameter
Example
bool protocol_send_set_param_bool(PageID p_id, uint32_t parameter_id, bool val)
{
Request request = {};
request.type = Request_Type_SET_PARAMETER;
request.which_payload = Request_set_parameter_tag;
request.payload.set_parameter.page_id = p_id;
request.payload.set_parameter.parameter_id = parameter_id;
request.payload.set_parameter.has_new_value = true;
request.payload.set_parameter.new_value.which_value = ParameterValue_Bool_tag;
request.payload.set_parameter.new_value.value.Bool = val;
return send_request(&request);
}
Set uint32 parameter
Example
bool protocol_send_set_param_uint32(PageID p_id, uint32_t parameter_id, uint32_t val)
{
Request request = {};
request.type = Request_Type_SET_PARAMETER;
request.which_payload = Request_set_parameter_tag;
request.payload.set_parameter.page_id = p_id;
request.payload.set_parameter.parameter_id = parameter_id;
request.payload.set_parameter.has_new_value = true;
request.payload.set_parameter.new_value.which_value = ParameterValue_Uint32_tag;
request.payload.set_parameter.new_value.value.Uint32 = val;
return send_request(&request);
}
Set float32 parameter
Example
bool protocol_send_set_param_float(PageID p_id, uint32_t parameter_id, float val)
{
Request request = {};
request.type = Request_Type_SET_PARAMETER;
request.which_payload = Request_set_parameter_tag;
request.payload.set_parameter.page_id = p_id;
request.payload.set_parameter.parameter_id = parameter_id;
request.payload.set_parameter.has_new_value = true;
request.payload.set_parameter.new_value.which_value = ParameterValue_Float32_tag;
request.payload.set_parameter.new_value.value.Float32 = val;
return send_request(&request);
}
Note
SetParameter takes the page id as a plain uint32, not as a PageID enum value — the numbers are the same, listed in the table above.