} /* */ /* */ public static sbyte[] reqDfuStart(int dfuCrc, int dfuSize) /* */ { /* 364 */ bleCmdType = SppCmdType.cmd_req_dfu_start; /* 365 */ sbyte[] CMD_REQ_DFU_START = new sbyte[] { -86, 67, 8 }; /* */ /* */ /* */ /* */ /* */ /* 371 */ sbyte[] data = new sbyte[CMD_REQ_DFU_START.Length + 8]; /* */ /* 373 */ sbyte[] dataDfuCrc = BinaryHelper.Int2ByteArray(dfuCrc); /* 374 */ sbyte[] dataDfuCrc2 = new sbyte[4]; /* 375 */ dataDfuCrc2[0] = dataDfuCrc[2]; /* 376 */ dataDfuCrc2[1] = dataDfuCrc[3]; /* 377 */ dataDfuCrc2[2] = dataDfuCrc[0]; /* 378 */ dataDfuCrc2[3] = dataDfuCrc[1]; /* 379 */ dataDfuCrc = dataDfuCrc2; /* */ /* 381 */ sbyte[] dataDfuSize = BinaryHelper.Int2ByteArray(dfuSize); /* */ /* 383 */ for (int i = 0; i < data.Length; i++) /* */ { /* 385 */ if (i < CMD_REQ_DFU_START.Length) /* */ { /* 387 */ data[i] = CMD_REQ_DFU_START[i]; /* */ } /* 389 */ else if ((i >= CMD_REQ_DFU_START.Length) && (i < CMD_REQ_DFU_START.Length + 4)) /* */ { /* 391 */ data[i] = dataDfuCrc[(i - CMD_REQ_DFU_START.Length)]; /* */ } /* */ else /* */ { /* 395 */ data[i] = dataDfuSize[(i - CMD_REQ_DFU_START.Length - 4)]; /* */ } /* */ } /* */ /* 399 */ string cmd = HexHelper.encodeHexStr(data); /* 400 */ sendCmd(data); /* 401 */ return(data); /* */ } /* */
} /* */ /* */ public static sbyte[] notifySecStart(int dfuCrc, UpgradeSectionId dfuSecIdx, int dfuSize) /* */ { /* 512 */ int dfuSecIdx2 = dfuSecIdx == UpgradeSectionId.MCU ? 0 : 1; /* 513 */ bleCmdType = SppCmdType.cmd_req_dfu_start_with_sec_id; /* 514 */ sbyte[] CMD_REQ_DFU_START = new sbyte[] { -86, 70, 8 }; /* */ /* */ /* */ /* */ /* */ /* 520 */ sbyte[] data = new sbyte[CMD_REQ_DFU_START.Length + 8]; /* */ /* 522 */ sbyte[] dataDfuCrc = BinaryHelper.Int2ByteArray(dfuCrc); /* 523 */ sbyte[] dataDfuCrc2 = new sbyte[4]; /* 524 */ dataDfuCrc2[0] = dataDfuCrc[2]; /* 525 */ dataDfuCrc2[1] = dataDfuCrc[3]; /* 526 */ dataDfuCrc2[2] = dataDfuCrc[0]; /* 527 */ dataDfuCrc2[3] = dataDfuCrc[1]; /* 528 */ dataDfuCrc = dataDfuCrc2; /* */ /* */ /* 531 */ sbyte[] dataDfuSize = BinaryHelper.Int2ByteArray(dfuSize); /* */ /* 533 */ data[0] = CMD_REQ_DFU_START[0]; /* 534 */ data[1] = CMD_REQ_DFU_START[1]; /* 535 */ data[2] = CMD_REQ_DFU_START[2]; /* */ /* 537 */ data[3] = dataDfuCrc[0]; /* 538 */ data[4] = dataDfuCrc[1]; /* 539 */ data[5] = dataDfuCrc[2]; /* 540 */ data[6] = dataDfuCrc[3]; /* */ /* 542 */ data[7] = ((sbyte)dfuSecIdx2); /* */ /* 544 */ data[8] = dataDfuSize[1]; /* 545 */ data[9] = dataDfuSize[2]; /* 546 */ data[10] = dataDfuSize[3]; /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* 566 */ string cmd = HexHelper.encodeHexStr(data); /* 567 */ sendCmd(data); /* 568 */ return(data); /* */ } /* */
/* */ /* */ public static sbyte[] getDeviceCmd(string deviceName, int devIndex) { /* 67 */ if (deviceName.Length > 16) /* */ { /* 69 */ deviceName = deviceName.Substring(0, 16); /* */ } /* */ /* 72 */ string hexDeviceName = HexHelper.encodeHexStr(deviceName.GetBytes()); /* 73 */ sbyte[] data = HexHelper.decodeHex(hexDeviceName.ToCharArray()); /* */ /* 75 */ sbyte deviceNameLen = (sbyte)data.Length; /* 76 */ sbyte payloadLen = (sbyte)(deviceNameLen + 3); /* 77 */ sbyte[] cmd_set_device_name = new sbyte[] { -86, 21, payloadLen, (sbyte)devIndex, -63, deviceNameLen }; /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* 87 */ List <sbyte?> cmd = new List <sbyte?>(); /* */ /* 89 */ for (int i = 0; i < cmd_set_device_name.Length; i++) /* */ { /* 91 */ cmd.Add(Convert.ToSByte(cmd_set_device_name[i])); /* */ } /* */ /* 94 */ for (int i = 0; i < data.Length; i++) /* */ { /* 96 */ cmd.Add(Convert.ToSByte(data[i])); /* */ } /* */ /* 99 */ sbyte[] cmdFull = new sbyte[cmd.Count]; /* 100 */ for (int i = 0; i < cmd.Count; i++) /* */ { /* 102 */ cmdFull[i] = ((sbyte?)cmd[i]).Value; /* */ } /* */ /* 105 */ return(cmdFull); /* */ } /* */
} /* */ /* */ /* */ public static sbyte[] reqDfuStart(int dfuCrc, UpgradeSectionId dfuSecIdx, int dfuSize, int dfuCrc2, UpgradeSectionId dfuSecIdx2, int dfuSize2) /* */ { /* 407 */ if ((dfuSecIdx == UpgradeSectionId.TRADITIONAL) || (dfuSecIdx2 == UpgradeSectionId.TRADITIONAL)) { return(null); } /* 408 */ if (dfuSecIdx == UpgradeSectionId.None) { return(null); /* */ } /* 410 */ int payloadLen = dfuSecIdx2 == UpgradeSectionId.None ? 8 : 16; /* */ /* 412 */ bleCmdType = SppCmdType.cmd_req_dfu_start_with_sec_id; /* 413 */ sbyte[] CMD_REQ_DFU_START = new sbyte[] { -86, 67, (sbyte)payloadLen }; /* */ /* */ /* */ /* */ /* */ /* 419 */ sbyte[] data = new sbyte[CMD_REQ_DFU_START.Length + payloadLen]; /* */ /* 421 */ int tmp_dfuSecIdx = -1; /* 422 */ if (dfuSecIdx == UpgradeSectionId.MCU) /* */ { /* 424 */ tmp_dfuSecIdx = 0; /* */ } /* 426 */ else if (dfuSecIdx == UpgradeSectionId.BT) /* */ { /* 428 */ tmp_dfuSecIdx = 1; /* */ } /* */ /* 431 */ sbyte[] dataDfuCrc = BinaryHelper.Int2ByteArray(dfuCrc); /* 432 */ sbyte[] tmp_dataDfuCrc = new sbyte[4]; /* 433 */ tmp_dataDfuCrc[0] = dataDfuCrc[2]; /* 434 */ tmp_dataDfuCrc[1] = dataDfuCrc[3]; /* 435 */ tmp_dataDfuCrc[2] = dataDfuCrc[0]; /* 436 */ tmp_dataDfuCrc[3] = dataDfuCrc[1]; /* 437 */ dataDfuCrc = tmp_dataDfuCrc; /* */ /* */ /* 440 */ sbyte[] dataDfuSize = BinaryHelper.Int2ByteArray(dfuSize); /* */ /* 442 */ data[0] = CMD_REQ_DFU_START[0]; /* 443 */ data[1] = CMD_REQ_DFU_START[1]; /* 444 */ data[2] = CMD_REQ_DFU_START[2]; /* */ /* 446 */ data[3] = dataDfuCrc[0]; /* 447 */ data[4] = dataDfuCrc[1]; /* 448 */ data[5] = dataDfuCrc[2]; /* 449 */ data[6] = dataDfuCrc[3]; /* */ /* 451 */ data[7] = ((sbyte)tmp_dfuSecIdx); /* */ /* 453 */ data[8] = dataDfuSize[1]; /* 454 */ data[9] = dataDfuSize[2]; /* 455 */ data[10] = dataDfuSize[3]; /* */ /* 457 */ if (payloadLen == 16) /* */ { /* 459 */ int tmp_dfuSecIdx2 = -1; /* 460 */ if (dfuSecIdx2 == UpgradeSectionId.MCU) /* */ { /* 462 */ tmp_dfuSecIdx2 = 0; /* */ } /* 464 */ else if (dfuSecIdx2 == UpgradeSectionId.BT) /* */ { /* 466 */ tmp_dfuSecIdx2 = 1; /* */ } /* */ /* 469 */ sbyte[] dataDfuCrc2 = BinaryHelper.Int2ByteArray(dfuCrc2); /* 470 */ sbyte[] tmp_dataDfuCrc2 = new sbyte[4]; /* 471 */ tmp_dataDfuCrc2[0] = dataDfuCrc[2]; /* 472 */ tmp_dataDfuCrc2[1] = dataDfuCrc[3]; /* 473 */ tmp_dataDfuCrc2[2] = dataDfuCrc[0]; /* 474 */ tmp_dataDfuCrc2[3] = dataDfuCrc[1]; /* 475 */ dataDfuCrc2 = tmp_dataDfuCrc2; /* */ /* */ /* 478 */ sbyte[] dataDfuSize2 = BinaryHelper.Int2ByteArray(dfuSize2); /* */ /* 480 */ data[11] = dataDfuCrc2[0]; /* 481 */ data[12] = dataDfuCrc2[1]; /* 482 */ data[13] = dataDfuCrc2[2]; /* 483 */ data[14] = dataDfuCrc2[3]; /* */ /* 485 */ data[15] = ((sbyte)tmp_dfuSecIdx2); /* */ /* 487 */ data[16] = dataDfuSize2[1]; /* 488 */ data[17] = dataDfuSize2[2]; /* 489 */ data[18] = dataDfuSize2[3]; /* */ } /* */ /* */ /* 493 */ string cmd = HexHelper.encodeHexStr(data); /* 494 */ sendCmd(data); /* 495 */ return(data); /* */ } /* */