#ifndef FACILITIES_CAM_H #define FACILITIES_CAM_H #include #include #include #include #include #include #include #define POS_HISTORY_MAX_LEN 24 #define PATH_HISTORY_MAX_LEN POS_HISTORY_MAX_LEN-1 typedef enum CID_CAM { CID_PROTECTED_ZONES, CID_PUBLIC_TRANSPORT, CID_SPECIAL_TRANSPORT, CID_DANGEROUS_GOODS, CID_ROADWORK, CID_RESCUE, CID_EMERGENCY, CID_SAFETY_CAR, CID_CLOSED_LANES, CID_REQUEST_FOR_RIGHT_OF_WAY, CID_REQUEST_FOR_FREE_CROSSING_AT_A_TRAFFIC_LIGHT, CID_NO_PASSING, CID_NO_PASSING_FOR_TRUCKS, CID_SPEED_LIMIT, CID_RESERVED0, CID_RESERVED1, } CID_CAM_e; typedef struct cid_ssp_bm { const char* container; const uint32_t bitmap_val; } cid_ssp_bm_t; enum CAM_CHECK_R { CAM_OK, CAM_INVALID, CAM_BAD_PERMISSIONS }; typedef struct pos_point { uint64_t ts; uint16_t heading; int32_t lon; int32_t lat; int32_t alt; uint16_t speed; } pos_point_t; typedef struct lightship { bool active; pthread_mutex_t lock; uint8_t type; pos_point_t last_pos; uint64_t t_last_cam; uint64_t next_cam_max; uint64_t next_cam_min; uint64_t t_last_cam_lfc; pos_point_t concise_points[3]; uint8_t concise_points_len; bool concise_keep_start; pos_point_t* path_history[PATH_HISTORY_MAX_LEN]; uint16_t path_history_len; bool is_vehicle_near; uint64_t t_last_vehicle; uint32_t vehicle_gen_min; uint32_t vehicle_gen_max; uint32_t rsu_gen_min; uint32_t rsu_vehicle_permanence; bool use_obd; struct { ProtectedCommunicationZone_t ** pz; uint16_t pz_len; } protected_zones; } lightship_t; /* * @brief Initializes the main CA struct (lightship) * * @return Always zero */ int lightship_init(); /* * @brief Checks if a CAM must be sent * * @return True if CAM must be sent, false otherwise */ int lightship_check(); /* * @brief Resets the CAM sending timer * * @return Nothing */ void lightship_reset_timer(); /* * @brief Analyzes a received CAM * * @return A CAM check code */ enum CAM_CHECK_R check_cam(BTPPacketIndication_t* bpi, CAM_t* cam,uint8_t* ssp, uint32_t ssp_len); /* * @brief Main CA service * * @return NULL */ void* ca_service(); #endif