Application callback
The application should register a callback handler with the function goal_cclIeFbNew(). This callback will be called by the stack to inform the application about an event. The callback has three parameters:
Table: Application callback handler parameters
Parameter | Description |
---|---|
GOAL_CCLIEFB_HANDLE_T *pCfb | GOAL CCLIEFB handle |
GOAL_CCLIEFB_CB_ID_T cbId | callback ID |
GOAL_CCLIEFB_CB_DATA_T *pCbData | callback data |
The callback ID is used to indicate the event. Depending on the event pCbData must be casted to the appropriate data type. The callback must return a GOAL_STATUS_T value. This return value is used for certain events as a decision indicator. If no callback handler is registered, a default callback handler is used. It accepts all events.
static GOAL_STATUS_T appl_cclfbCb(
GOAL_CCLIEFB_HANDLE_T *pCfb, /**< GOAL CCLIEFB handle */
GOAL_CCLIEFB_CB_ID_T cbId, /**< callback ID */
GOAL_CCLIEFB_CB_DATA_T *pCbData /**< callback data */
)
{
GOAL_STATUS_T res = GOAL_OK; /* result */
UNUSEDARG(pCfb);
switch (cbId) {
/* ... */
}
return res;
GOAL_CCLIEFB_CB_ID_TIMEOUT
The connection to Master Station timed out. This callback is called if to many cyclicData request messages of the master are not received if the communication is running.
callback data type: none
callback data: none
return value: ignored
/* ... */
case GOAL_CCLIEFB_CB_ID_TIMEOUT:
goal_logInfo("connection to Master Station timed out");
appRun = GOAL_FALSE;
break;
/* ... */
GOAL_CCLIEFB_CB_ID_CYC_STOP
Received cyclic stop instruction from Master Station. This callback is called if the master stops the cyclic communication.
callback data type: none
callback data: none
return value: ignored
/* ... */
case GOAL_CCLIEFB_CB_ID_CYC_STOP:
goal_logInfo("cyclic stop instruction from Master Station");
appRun = GOAL_FALSE;
break;
/* ... */
GOAL_CCLIEFB_CB_ID_NEW_MASTER
Found and connected to new master station. This callback if the GOAL CCLIEFB slave is not connected to any master and a new master starts sending cyclic request messages.
callback data type: ID of new master station
callback data: uint32_t *
return value: ignored
GOAL_CCLIEFB_CB_ID_MASTER_STOP_ERR
Master Station application stopped because of error. This callback is called if the master application stops because of an error (master protocol version 2).
callback data type: none
callback data: none
return value: ignored
GOAL_CCLIEFB_CB_ID_MASTER_STOP_USER
Master Station application stopped because of error. This callback is called if the master application stops because of the user (master protocol version 2).
callback data type: none
callback data: none
return value: ignored
GOAL_CCLIEFB_CB_ID_MASTER_STOP_UNKNOWN
Master Station application stopped because of error. This callback is called if the master application stops (master protocol version 1).
callback data type: none
callback data: none
return value: ignored
GOAL_CCLIEFB_CB_ID_MASTER_RUN
Master Station application running. This callback is called if a stopped master application is running again.
callback data type: none
callback data: none
return value: ignored
GOAL_CCLIEFB_CB_ID_CYC_DATA_VALID
The cyclic data from Master Station is valid. Detected that the master changed cyclic transmission state to 1 indicating that cyclic data started to exchange.
callback data type: none
callback data: none
return value: ignored
GOAL_CCLIEFB_CB_ID_CYC_DATA_INVALID
The cyclic data from Master Station is invalid. Detected that the master changed cyclic transmission state to 0 indicating that cyclic data stopped to exchange.
callback data type: none
callback data: none
return value: ignored
GOAL_CCLIEFB_CB_ID_DUPL_MASTER
The station detected master station duplication. Another master tried to connected during a running connection with the current master.
callback data type: none
callback data: none
return value: ignored
GOAL_CCLIEFB_CB_ID_DUPL_SLAVE
The station detected master station duplication. Received a frame with active cyclic connection and same station ID of the device, i.e. the master is exchanging data with another device with the same station ID. Therefore the device knows that its station ID s a duplicate.
callback data type: none
callback data: none
return value: ignored
- 1 GOAL_CCLIEFB_CB_ID_TIMEOUT
- 2 GOAL_CCLIEFB_CB_ID_CYC_STOP
- 3 GOAL_CCLIEFB_CB_ID_NEW_MASTER
- 4 GOAL_CCLIEFB_CB_ID_MASTER_STOP_ERR
- 5 GOAL_CCLIEFB_CB_ID_MASTER_STOP_USER
- 6 GOAL_CCLIEFB_CB_ID_MASTER_STOP_UNKNOWN
- 7 GOAL_CCLIEFB_CB_ID_MASTER_RUN
- 8 GOAL_CCLIEFB_CB_ID_CYC_DATA_VALID
- 9 GOAL_CCLIEFB_CB_ID_CYC_DATA_INVALID
- 10 GOAL_CCLIEFB_CB_ID_DUPL_MASTER
- 11 GOAL_CCLIEFB_CB_ID_DUPL_SLAVE