Combine hex for xbee

Is there a way to combine several Serial.write's into one?

For example, in this DH and DL xbee snippet (I've left off the other parts of the frame)

Serial.write((byte)0x00); 
Serial.write((byte)0x13);  
Serial.write((byte)0xA2); 
Serial.write((byte)0x00); 
Serial.write((byte)0x40); 
Serial.write((byte)0xB0);
Serial.write((byte)0x9D);
Serial.write((byte)0x78);
Serial.write(0xFF); 
Serial.write(0xFE); 

// this would be the checksum
long sum =  0x00 + 0x13 + 0xA2 + 0x00 + 0x40 + 0xB0 + 0x9D + 0x78 + 0xFF + 0xFE;

I've tried building the DH and DL part of the frame like this. But this doesn't work. (I'm just showing the DH and DL part of the frame)

Serial.write(0x0013A200);
Serial.write(0x40B09D78);
and then the checksum
long sum = 0x17 + 0x0013A200 + 0x40B09D78 + 0xFF + 0xFE;

My goal is to combine the high and low byte of the destination xbee into one line.

Can someone help

Is there a way to combine several Serial.write's into one?

  1. yes, make an array of it

uint8_t ar = { 0x00 ,0x13 , 0xA2 , 0x00, 0x40, 0xB0, 0x9D , 0x78 , 0xFF, 0xFE};
Serial.print(ar, 10);

  1. it wont be substantial faster as the write functionis faster than the serial Port normally
    still it might reduce the footprint of the code/exe

If I recall correctly the calcultion of the checksum is still per byte, so
long sum = 0x00 + 0x13 + 0xA2 + 0x00 + 0x40 + 0xB0 + 0x9D + 0x78 + 0xFF + 0xFE;
is the right way even is you send the bytes like
Serial.write(0x0013A200);