Changeset 5926:5ce8b7f77388 in roaraudio


Ignore:
Timestamp:
09/11/13 14:16:48 (6 years ago)
Author:
phi
Branch:
default
Message:

added support EVENT type messages

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • include/libroarlight/roardmx.h

    r5924 r5926  
    128128// Not yet supported. 
    129129// * EVENT: 
    130 // Not yet supported. 
     130int roar_roardmx_message_new_event(struct roar_roardmx_message * mes); 
     131int roar_roardmx_message_add_events(struct roar_roardmx_message * mes, const uint8_t * events, size_t len); 
     132#define roar_roardmx_message_add_event(mes,event) roar_roardmx_message_add_events((mes), &(uint8_t){(event)}, 1) 
     133int roar_roardmx_message_get_events(struct roar_roardmx_message * mes, const uint8_t ** events, size_t * len); 
     134 
    131135// * CONTROL: 
    132136// Not yet supported. 
  • libroarlight/roardmx.c

    r5924 r5926  
    231231// * SSET: 
    232232int roar_roardmx_message_new_sset   (struct roar_roardmx_message * mes) { 
     233 BCHK(mes); 
     234 
    233235 if ( roar_roardmx_message_new(mes) == -1 ) 
    234236  return -1; 
     
    239241} 
    240242 
     243// * IPO1: 
     244// Not yet supported. 
     245// * IPO4: 
     246// Not yet supported. 
     247// * INC8S: 
     248// Not yet supported. 
     249// * RANGESET: 
     250// Not yet supported. 
     251// * EVENT: 
     252int roar_roardmx_message_new_event(struct roar_roardmx_message * mes) { 
     253 BCHK(mes); 
     254 
     255 if ( roar_roardmx_message_new(mes) == -1 ) 
     256  return -1; 
     257 
     258 mes->type = ROAR_ROARDMX_TYPE_EVENT; 
     259 
     260 return 0; 
     261} 
     262 
     263int roar_roardmx_message_add_events(struct roar_roardmx_message * mes, const uint8_t * events, size_t len) { 
     264 BCHK(mes); 
     265 
     266 if ( mes->type != ROAR_ROARDMX_TYPE_EVENT ) { 
     267  roar_err_set(ROAR_ERROR_TYPEMM); 
     268  return -1; 
     269 } 
     270 
     271 if ( (mes->length + len) > ROAR_ROARDMX_DATA_LENGTH ) { // message would be to long 
     272  roar_err_set(ROAR_ERROR_NOSPC); 
     273  return -1; 
     274 } 
     275 
     276 memcpy(mes->data + 3 + mes->length, events, len); 
     277 mes->length += len; 
     278 
     279 return 0; 
     280} 
     281 
     282int roar_roardmx_message_get_events(struct roar_roardmx_message * mes, const uint8_t ** events, size_t * len) { 
     283 BCHK(mes); 
     284 
     285 if ( mes->type != ROAR_ROARDMX_TYPE_EVENT ) { 
     286  roar_err_set(ROAR_ERROR_TYPEMM); 
     287  return -1; 
     288 } 
     289 
     290 *events = (const uint8_t *)(mes->data + 3); 
     291 *len    = mes->length; 
     292 
     293 return 0; 
     294} 
     295 
     296// * CONTROL: 
     297// Not yet supported. 
     298 
    241299//ll 
Note: See TracChangeset for help on using the changeset viewer.