Protective Stop
Loading...
Searching...
No Matches
pstop_remote_data.h
1// SPDX-FileCopyrightText: 2026 Polymath Robotics, Inc.
2// SPDX-License-Identifier: Apache-2.0
3
4#ifndef PSTOP_PSTOP_REMOTE_DATA_H
5#define PSTOP_PSTOP_REMOTE_DATA_H
6
7#include <stdint.h>
8#include <stdbool.h>
9
10#include "pstop/device_id.h"
11#include "pstop/constants.h"
12#include "pstop/protocol_data.h"
13
15typedef enum {
16
17 PSTOP_REMOTE_INITING = 0,
18 PSTOP_REMOTE_BONDED = 1,
19 PSTOP_REMOTE_OK = 2,
20 PSTOP_REMOTE_STOPPED = 3,
21 PSTOP_REMOTE_UNKNOWN = 255
22
23} pstop_remote_state_t;
24
26typedef struct {
27
30
33
35 uint8_t last_message;
36
39
42
45
47 pstop_remote_state_t remote_state;
48
50
52typedef struct {
53
56
58 uint16_t max_remotes;
59
61
67void pstop_remote_init(pstop_remote_data_t *remote);
68
74void pstop_remotes_init(pstop_remotes_t *remotes);
75
82uint16_t pstop_remote_num_active(const pstop_remotes_t *remotes);
83
89pstop_remote_data_t *pstop_remote_get_free_remote(pstop_remotes_t *remotes);
90
96void pstop_remote_deactivate(pstop_remote_data_t *remote);
97
104uint16_t pstop_remote_num_stopped(const pstop_remotes_t *remotes);
105
111pstop_remote_data_t *pstop_remote_get(const pstop_remotes_t *remotes, const device_id_t *remote_id);
112
113#endif /* PSTOP_PSTOP_REMOTE_DATA_H */
Identifier of a pstop device.
Definition device_id.h:12
Per-remote protocol state.
Definition protocol_data.h:12
State tracked for one remote.
Definition pstop_remote_data.h:26
uint8_t last_message
Last message type received from the remote.
Definition pstop_remote_data.h:35
bool is_stop_only
True if the remote can stop but not restart the robot.
Definition pstop_remote_data.h:38
pstop_remote_state_t remote_state
Lifecycle state of the remote.
Definition pstop_remote_data.h:47
uint16_t lost_message_counter
Messages lost so far.
Definition pstop_remote_data.h:41
protocol_data_t remote_data
Protocol state for the remote.
Definition pstop_remote_data.h:32
uint32_t local_remote_id
Local identifier of the remote.
Definition pstop_remote_data.h:29
uint16_t missed_heartbeats_counter
Heartbeats missed so far.
Definition pstop_remote_data.h:44
A fixed-capacity collection of remotes.
Definition pstop_remote_data.h:52
pstop_remote_data_t * remotes
Caller-owned array of max_remotes entries.
Definition pstop_remote_data.h:55
uint16_t max_remotes
Capacity of the remotes array.
Definition pstop_remote_data.h:58