fixed the reservation response
This commit is contained in:
parent
d2bdb38b5d
commit
10fe3435ac
|
|
@ -9,6 +9,8 @@
|
|||
"asn_application.h": "c",
|
||||
"timestamputc.h": "c",
|
||||
"availabilitystatus.h": "c",
|
||||
"chargingspotlabel.h": "c"
|
||||
"chargingspotlabel.h": "c",
|
||||
"reservation-id.h": "c",
|
||||
"stationdetails.h": "c"
|
||||
}
|
||||
}
|
||||
55
src/evm.c
55
src/evm.c
|
|
@ -114,8 +114,8 @@ cleanup:
|
|||
return rv;
|
||||
}
|
||||
|
||||
static int pre_reservation_id = 1;
|
||||
static int reservation_id = 1;
|
||||
static uint64_t pre_reservation_id = 1;
|
||||
static uint64_t reservation_id = 1;
|
||||
|
||||
int evrsrm_recv(EV_RSR_t *evrsr_request) {
|
||||
int rv = 0;
|
||||
|
|
@ -202,7 +202,7 @@ cleanup:
|
|||
return rv;
|
||||
}
|
||||
|
||||
static int evrsrm_reservation_response(EV_RSR_t* evrsrm_request, uint8_t *evrsrm_oer, uint32_t *evrsrm_len) {
|
||||
static int evrsrm_reservation_response(EV_RSR_t *evrsrm_request, uint8_t *evrsrm_oer, uint32_t *evrsrm_len) {
|
||||
int rv = 0;
|
||||
EV_RSR_t *evrsr_response = calloc(1, sizeof(EV_RSR_t));
|
||||
evrsr_response->header.protocolVersion = 1;
|
||||
|
|
@ -215,17 +215,32 @@ static int evrsrm_reservation_response(EV_RSR_t* evrsrm_request, uint8_t *evrsrm
|
|||
ReservationResponseMessage_t *response = &evrsr_response->messageBody.choice.reservationResponseMessage;
|
||||
// Assumes the pre reservation was successful
|
||||
response->reservationResponseCode = ReservationResponseCode_ok;
|
||||
response->reservation_ID = reservation_id;
|
||||
response->reservation_Password->buf = calloc(4, sizeof(uint8_t));
|
||||
response->reservation_Password->size = 4;
|
||||
response->reservation_Password->buf[0] = 'i';
|
||||
response->reservation_Password->buf[1] = 't';
|
||||
response->reservation_Password->buf[2] = '2';
|
||||
response->reservation_Password->buf[3] = 's';
|
||||
response->reservation_ID = calloc(1, sizeof(Reservation_ID_t));
|
||||
response->reservation_ID->buf = calloc(8, sizeof(uint8_t));
|
||||
response->reservation_ID->size = 8;
|
||||
response->reservation_ID->buf[0] = '0' + reservation_id / 10000000;
|
||||
response->reservation_ID->buf[1] = '0' + (reservation_id / 1000000) % 10;
|
||||
response->reservation_ID->buf[2] = '0' + (reservation_id / 100000) % 10;
|
||||
response->reservation_ID->buf[3] = '0' + (reservation_id / 10000) % 10;
|
||||
response->reservation_ID->buf[4] = '0' + (reservation_id / 1000) % 10;
|
||||
response->reservation_ID->buf[5] = '0' + (reservation_id / 100) % 10;
|
||||
response->reservation_ID->buf[6] = '0' + (reservation_id / 10) % 10;
|
||||
response->reservation_ID->buf[7] = '0' + reservation_id % 10;
|
||||
response->reservation_Password = calloc(1, sizeof(Reservation_Password_t));
|
||||
response->reservation_Password->buf = calloc(8, sizeof(uint8_t));
|
||||
response->reservation_Password->size = 8;
|
||||
response->reservation_Password->buf[0] = ' ';
|
||||
response->reservation_Password->buf[1] = ' ';
|
||||
response->reservation_Password->buf[2] = ' ';
|
||||
response->reservation_Password->buf[3] = ' ';
|
||||
response->reservation_Password->buf[4] = 'i';
|
||||
response->reservation_Password->buf[5] = 't';
|
||||
response->reservation_Password->buf[6] = '2';
|
||||
response->reservation_Password->buf[7] = 's';
|
||||
// estimated arrival time + tolerance time
|
||||
response->expirationTime = evrsrm_request->messageBody.choice.reservationRequestMessage.arrivalTime;
|
||||
response->expirationTime += 15 * 60 * 1000; // 15 minutes
|
||||
|
||||
response->expirationTime += 15 * 60 * 1000; // 15 minutes
|
||||
|
||||
asn_enc_rval_t enc = oer_encode_to_buffer(&asn_DEF_EV_RSR, NULL, evrsr_response, evrsrm_oer, 512);
|
||||
if (enc.encoded == -1) {
|
||||
log_error("[ev] failed encoding evrsrm (%s)", enc.failed_type->name);
|
||||
|
|
@ -251,14 +266,14 @@ static int evrsrm_pre_reservation_response(uint8_t *evrsrm_oer, uint32_t *evrsrm
|
|||
PreReservationResponseMessage_t *response = &evrsr_response->messageBody.choice.preReservationResponseMessage;
|
||||
response->preReservation_ID.buf = calloc(8, sizeof(uint8_t));
|
||||
response->preReservation_ID.size = 8;
|
||||
response->preReservation_ID.buf[0] = '0' + (pre_reservation_id >> 56) & 0xff;
|
||||
response->preReservation_ID.buf[1] = '0' + (pre_reservation_id >> 48) & 0xff;
|
||||
response->preReservation_ID.buf[2] = '0' + (pre_reservation_id >> 40) & 0xff;
|
||||
response->preReservation_ID.buf[3] = '0' + (pre_reservation_id >> 32) & 0xff;
|
||||
response->preReservation_ID.buf[4] = '0' + (pre_reservation_id >> 24) & 0xff;
|
||||
response->preReservation_ID.buf[5] = '0' + (pre_reservation_id >> 16) & 0xff;
|
||||
response->preReservation_ID.buf[6] = '0' + (pre_reservation_id >> 8) & 0xff;
|
||||
response->preReservation_ID.buf[7] = '0' + pre_reservation_id & 0xff;
|
||||
response->preReservation_ID.buf[0] = '0' + (pre_reservation_id / 10000000);
|
||||
response->preReservation_ID.buf[1] = '0' + (pre_reservation_id / 1000000) % 10;
|
||||
response->preReservation_ID.buf[2] = '0' + (pre_reservation_id / 100000) % 10;
|
||||
response->preReservation_ID.buf[3] = '0' + (pre_reservation_id / 10000) % 10;
|
||||
response->preReservation_ID.buf[4] = '0' + (pre_reservation_id / 1000) % 10;
|
||||
response->preReservation_ID.buf[5] = '0' + (pre_reservation_id / 100) % 10;
|
||||
response->preReservation_ID.buf[6] = '0' + (pre_reservation_id / 10) % 10;
|
||||
response->preReservation_ID.buf[7] = '0' + pre_reservation_id % 10;
|
||||
|
||||
response->availabilityStatus = 0;
|
||||
|
||||
|
|
|
|||
29
src/evm.h
29
src/evm.h
|
|
@ -1,16 +1,14 @@
|
|||
#ifndef FACILITIES_EVM_H
|
||||
#define FACILITIES_EVM_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <pthread.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <it2s-asn/evcsnm/EvcsnPdu.h>
|
||||
#include <it2s-asn/evrsrm/EV-RSR.h>
|
||||
#include <it2s-asn/itss-transport/BTPPacketIndication.h>
|
||||
|
||||
#include <it2s-tender/epv.h>
|
||||
#include <pthread.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
enum EVM_CHECK_R {
|
||||
EVM_OK,
|
||||
|
|
@ -37,19 +35,18 @@ enum EVM_CHECK_R check_evrsrm(BTPPacketIndication_t *bpi, EV_RSR_t *evrsrm, uint
|
|||
*
|
||||
* @return NULL
|
||||
*/
|
||||
void* evcsn_service();
|
||||
void *evcsn_service();
|
||||
|
||||
/**
|
||||
* @brief Creates a EVCSNM response and sends it
|
||||
* @param evcsnm_request The EVCSNM request
|
||||
*
|
||||
*
|
||||
* @return 0 on success, 1 otherwise
|
||||
*/
|
||||
int evrsrm_recv(EV_RSR_t *evrsr_request);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Creates a pre reservation response.
|
||||
* @brief Creates a pre reservation response.
|
||||
* @param evrsrm_oer The encoded pre reservation response
|
||||
* @param evrsrm_len The length of the encoded pre reservation response
|
||||
*
|
||||
|
|
@ -58,12 +55,22 @@ int evrsrm_recv(EV_RSR_t *evrsr_request);
|
|||
|
||||
static int evrsrm_pre_reservation_response(uint8_t *evrsrm_oer, uint32_t *evrsrm_len);
|
||||
|
||||
/**
|
||||
* @brief Creates a reservation response.
|
||||
* @param evrsrm_oer The encoded reservation response
|
||||
* @param evrsrm_len The length of the encoded reservation response
|
||||
*
|
||||
* @return The reservation response or NULL if the request isn't a Reservation request
|
||||
*/
|
||||
|
||||
static int evrsrm_reservation_response(EV_RSR_t *evrsrm_request, uint8_t *evrsrm_oer, uint32_t *evrsrm_len);
|
||||
|
||||
/**
|
||||
* Analyses a evcsnm
|
||||
* @param evcsnm The evcsnm to be analyzed
|
||||
* @return 0 on success, other value otherwise
|
||||
*/
|
||||
int evcsnm_check(EvcsnPdu_t* evcsnm);
|
||||
int evcsnm_check(EvcsnPdu_t *evcsnm);
|
||||
|
||||
/**
|
||||
* Analyses a evrsrm
|
||||
|
|
|
|||
Loading…
Reference in New Issue