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