public ble_msg_flash_write_data_rsp_t ble_cmd_flash_write_data(long address, byte[] data)
{
log("ble_cmd_flash_write_data_id");
byte[] _data = new byte[SIZE_HEADER + 0 + 4 + 1 + data.Length];
int idx = 0;
// header
_data[idx++] = (byte)ble_dev_types.ble_dev_type_ble|(byte)ble_msg_types.ble_msg_type_cmd|0x0;
_data[idx++] = (byte)(0 + 4 + 1 + data.Length);
_data[idx++] = (byte)ble_classes.ble_cls_flash;
_data[idx++] = (byte)ble_command_ids.ble_cmd_flash_write_data_id;
// data
_data[idx++] = (byte)address;
_data[idx++] = (byte)(address >> 8);
_data[idx++] = (byte)(address >> 16);
_data[idx++] = (byte)(address >> 24);
_data[idx++] = (byte)(data.Length);
for(int i = 0; i < data.Length; i++)
{
_data[idx++] = data[i];
}
// send
BgApiResponse response = Send(new BgApiCommand() { Data = _data }, false);
return (ble_msg_flash_write_data_rsp_t)response;
}