Browse Source

add health report, but no filetime

master
qshi 8 years ago
parent
commit
100ea70ea3
  1. 1
      src/runtime.c
  2. 82
      src/wan.c

1
src/runtime.c

@ -381,7 +381,6 @@ void runtime_begin(void )
char lan_local_ip[64] = {0};
char wan_local_ip[64] = {0};
struct wan_config wc;
if ((_G._rc = record_new(_G._rootdir)) == NULL) {
log_printf("can't create audio record \n");
exit(-1);

82
src/wan.c

@ -114,6 +114,38 @@ struct wan_status_type {
uint8_t id5; /* 0x14 */
} __attribute__((packed));
/*
*
* */
struct wan_heath_type {
uint8_t id1; /* 0xAC */
uint8_t id2; /* 0x93 */
uint8_t resv0;
uint8_t resv1;
uint16_t resv2;
uint8_t srcPosId; /* 0xB1 */
uint8_t srcSwId; /* 0xD8 */
uint8_t destLunId;/* 0x0*/
uint8_t destSwId; /* 0x0 */
uint8_t initLunId;/* 0xB1 */
uint8_t lengthl; /* 0x40 */
uint8_t lengthh; /* 0x00 */
uint8_t resv3;
uint64_t fileTime;
uint8_t swId; /*0xD8*/
uint16_t resv4;
uint32_t hwStatus; /*0x00*/
uint8_t resv5[15];
uint8_t swVer[4]; /*eg: v2.03, [0] = 2; [1] = 0; [2] = 3; [3] = 0*/
uint8_t status;/*0x01: health; 0x00: fault*/
uint8_t serv6[5];
uint32_t time;
uint32_t seq;
uint8_t checkNum;
uint8_t id5; /* 0x14 */
} __attribute__((packed));
#define UPLINK_PAKSIZE (64)
#define UPLINK_STREAMS_MAX (2)
#define UPLINK_TICKS (40)
@ -162,6 +194,7 @@ struct wan{
struct wan_udp *alarm;
udp_t *out_audio;
udp_t *stsock;
udp_t *hls;
/* only xx2 use, because 3 start frame + audo frame ... + 3 end frame */
struct uplink_stream streams[UPLINK_STREAMS_MAX];
@ -174,6 +207,9 @@ struct wan{
int no_recv_wan_times; /*10s no recv wan data, need reset reader socket*/
struct wan_config wc;
struct timer *tm;
struct wan_heath_type _hlBuf;
uint32_t _hlSeq;
};
static uint8_t _null_audio[12] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
@ -456,6 +492,25 @@ static void __air_status_timeout(struct timer *tm, void *pdata)
}
}
static void __send_health_packet(wan_t wn)
{
int len = 0;
uint8_t *sbuf;
struct wan_heath_type *wht = &wn->_hlBuf;
udp_t *u = wn->hls;
wht->fileTime =0; //time_get_100ns();
wht->status = 0x01; //health;
wht->time = (unsigned long)time(NULL);
wht->seq = ++wn->_hlSeq;
len = sizeof *wht -2;
sbuf = (uint8_t *)wht;
wht->checkNum = getcs(sbuf, len);
udp_send(u, wht, sizeof *wht);
}
/*interval 5s add a mulit addr */
static void __on_timer(struct timer *tm, void *data)
{
@ -464,6 +519,8 @@ static void __on_timer(struct timer *tm, void *data)
udp_t *in, *msg, *alm;
struct wan_udp *wup;
__send_health_packet(wn);
if (wn->no_recv_wan_times-- <= 0) {
log_printf("wan 10s no recv data, reset wan!!!\n");
wn->no_recv_wan_times = WAN_NO_DATA_TIMES;
@ -541,6 +598,12 @@ wan_t wan_new(struct wan_config *wc)
return NULL;
}
udp_t *hls;
if ((hls = udp_open_mcast_write_only("225.0.0.8", 7011, wc->wan_ip)) == NULL) {
log_printf("'%s[%d]: can't create multicast socket\n", __FILE__, __LINE__);
return NULL;
}
wn = calloc(1, sizeof *wn);
wup = (struct wan_udp *)udp_readable_new(sizeof *wup, msg);
wup->base.is_readable = __mapid_readable;
@ -559,6 +622,7 @@ wan_t wan_new(struct wan_config *wc)
wn->out_audio = out;
wn->stsock = sts;
wn->hls = hls;
for (i = 0; i < UPLINK_STREAMS_MAX; ++i) {
us = &wn->streams[i];
@ -607,6 +671,24 @@ wan_t wan_new(struct wan_config *wc)
timer_set_callback(wn->tm, wn, __on_timer);
timer_active(wn->tm, 1000);
memset(&wn->_hlBuf, 0, sizeof wn->_hlBuf);
wn->_hlBuf.id1 = 0xAC;
wn->_hlBuf.id2 = 0x93;
wn->_hlBuf.srcPosId = 0xB1;
wn->_hlBuf.srcSwId = 0xD8;
wn->_hlBuf.destLunId = 0x00;
wn->_hlBuf.destSwId = 0x00;
wn->_hlBuf.initLunId = 0xB1;
wn->_hlBuf.lengthl = 0x40;
wn->_hlBuf.lengthh = 0x00;
wn->_hlBuf.swId = 0xD8;
wn->_hlBuf.hwStatus = 0x00;
wn->_hlBuf.swVer[0] = 0x02; /*version v2.00*/
wn->_hlBuf.swVer[1] = 0x00;
wn->_hlBuf.swVer[2] = 0x00;
wn->_hlBuf.swVer[3] = 0x00;
wn->_hlBuf.id5 = 0x14;
return wn;
}

Loading…
Cancel
Save