123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134 |
- #include <stdint.h>
- #include <stdlib.h>
- #include <stdio.h>
- #include "network_ra.h"
- #include "service_provider.h"
- int ra_network_send_receive(const char *server_url,
- const ra_samp_request_header_t *p_req,
- ra_samp_response_header_t **p_resp)
- {
- int ret = 0;
- ra_samp_response_header_t* p_resp_msg;
- if((NULL == server_url) ||
- (NULL == p_req) ||
- (NULL == p_resp))
- {
- return -1;
- }
- switch(p_req->type)
- {
- case TYPE_RA_MSG0:
- ret = sp_ra_proc_msg0_req((const sample_ra_msg0_t*)((uint8_t*)p_req
- + sizeof(ra_samp_request_header_t)),
- p_req->size);
- if (0 != ret)
- {
- fprintf(stderr, "\nError, call sp_ra_proc_msg1_req fail [%s].",
- __FUNCTION__);
- }
- break;
- case TYPE_RA_MSG1:
- ret = sp_ra_proc_msg1_req((const sample_ra_msg1_t*)((uint8_t*)p_req
- + sizeof(ra_samp_request_header_t)),
- p_req->size,
- &p_resp_msg);
- if(0 != ret)
- {
- fprintf(stderr, "\nError, call sp_ra_proc_msg1_req fail [%s].",
- __FUNCTION__);
- }
- else
- {
- *p_resp = p_resp_msg;
- }
- break;
- case TYPE_RA_MSG3:
- ret =sp_ra_proc_msg3_req((const sample_ra_msg3_t*)((uint8_t*)p_req +
- sizeof(ra_samp_request_header_t)),
- p_req->size,
- &p_resp_msg);
- if(0 != ret)
- {
- fprintf(stderr, "\nError, call sp_ra_proc_msg3_req fail [%s].",
- __FUNCTION__);
- }
- else
- {
- *p_resp = p_resp_msg;
- }
- break;
- default:
- ret = -1;
- fprintf(stderr, "\nError, unknown ra message type. Type = %d [%s].",
- p_req->type, __FUNCTION__);
- break;
- }
- return ret;
- }
- void ra_free_network_response_buffer(ra_samp_response_header_t *resp)
- {
- if(resp!=NULL)
- {
- free(resp);
- }
- }
|