![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
master to control sensor node
Dependencies: mbed
Diff: gateway.cpp
- Revision:
- 5:85fea4ceaa1f
- Parent:
- 4:5518470323de
- Child:
- 6:9daa56b8a027
--- a/gateway.cpp Tue Nov 10 23:44:36 2015 +0000 +++ b/gateway.cpp Wed Nov 11 00:47:05 2015 +0000 @@ -62,19 +62,16 @@ */ void rf_send(packet *data, uint8_t len) { - //We need to prepend the message with a valid ZigBee header - //uint8_t header[8]= {1, 8, 0, 0xA1, 0xB2, 0xC3, 0xD4, 0x00}; - //uint8_t *send_buf = (uint8_t *) malloc( sizeof(uint8_t) * (len) ); - //for(uint8_t i = 0; i < len+8; i++) { + + uint8_t header[8]= {1, 8, 0, 0xA1, 0xB2, 0xC3, 0xD4, 0x00}; + uint8_t *send_buf = (uint8_t *) malloc( sizeof(uint8_t) * (len+8) ); + + for(uint8_t i = 0; i < len+8; i++) { //prepend the 8-byte header - //send_buf[i] = (i<8) ? header[i] : data[i-8]; -// } - //pc.printf("Sent: %s\r\n", send_buf+8); - - //for(unit8_t i = 0; i < len; i++){ - //} + send_buf[i] = (i<8) ? header[i] : ((uint8_t *) data)[i-8]; + } - mrf.Send((uint8_t *) data, (len*4)+4); + mrf.Send((uint8_t *) data, (len*4)+12); //free(send_buf); } @@ -83,9 +80,11 @@ int nodes = 6; // char buffer[128]; - packet buffer(NODE,2,HELLO_TYPE,4.0,5.0); - rf_send(&buffer, 2); - /* while(1) { + + packet buffer(NODE,2,HELLO_TYPE,4.0,5.0); + rf_send(&buffer, 2); + pc.printf("sent\r\n"); + /* while(1) { pc.printf("Select operation: \r\n"); pc.printf("1) get node list\r\n"); pc.printf("2) Update data rates\r\n");