@apocaliss92/nodelink-js 0.4.12 → 0.4.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -30,7 +30,7 @@ import {
30
30
  runAllDiagnosticsConsecutively,
31
31
  runMultifocalDiagnosticsConsecutively,
32
32
  xmlEscape
33
- } from "./chunk-IJG45AOT.js";
33
+ } from "./chunk-2JNXKT3C.js";
34
34
  import {
35
35
  BC_CLASS_FILE_DOWNLOAD,
36
36
  BC_CLASS_LEGACY,
@@ -65,6 +65,7 @@ import {
65
65
  BC_CMD_ID_GET_AUDIO_CFG,
66
66
  BC_CMD_ID_GET_AUDIO_TASK,
67
67
  BC_CMD_ID_GET_AUTO_FOCUS,
68
+ BC_CMD_ID_GET_AUTO_REBOOT,
68
69
  BC_CMD_ID_GET_BATTERY_INFO,
69
70
  BC_CMD_ID_GET_BATTERY_INFO_LIST,
70
71
  BC_CMD_ID_GET_DAY_NIGHT_THRESHOLD,
@@ -72,6 +73,8 @@ import {
72
73
  BC_CMD_ID_GET_DING_DONG_CFG,
73
74
  BC_CMD_ID_GET_DING_DONG_LIST,
74
75
  BC_CMD_ID_GET_DING_DONG_SILENT,
76
+ BC_CMD_ID_GET_DST,
77
+ BC_CMD_ID_GET_EMAIL,
75
78
  BC_CMD_ID_GET_EMAIL_TASK,
76
79
  BC_CMD_ID_GET_ENC,
77
80
  BC_CMD_ID_GET_FTP_TASK,
@@ -79,6 +82,7 @@ import {
79
82
  BC_CMD_ID_GET_KIT_AP_CFG,
80
83
  BC_CMD_ID_GET_LED_STATE,
81
84
  BC_CMD_ID_GET_MOTION_ALARM,
85
+ BC_CMD_ID_GET_NTP,
82
86
  BC_CMD_ID_GET_ONLINE_USER_LIST,
83
87
  BC_CMD_ID_GET_OSD_DATETIME,
84
88
  BC_CMD_ID_GET_PIR_INFO,
@@ -117,15 +121,21 @@ import {
117
121
  BC_CMD_ID_SET_AUDIO_CFG,
118
122
  BC_CMD_ID_SET_AUDIO_TASK,
119
123
  BC_CMD_ID_SET_AUTO_FOCUS,
124
+ BC_CMD_ID_SET_AUTO_REBOOT,
120
125
  BC_CMD_ID_SET_DAY_NIGHT_THRESHOLD,
121
126
  BC_CMD_ID_SET_DING_DONG_CFG,
122
127
  BC_CMD_ID_SET_DING_DONG_SILENT,
128
+ BC_CMD_ID_SET_DST,
129
+ BC_CMD_ID_SET_EMAIL,
130
+ BC_CMD_ID_SET_EMAIL_TASK,
123
131
  BC_CMD_ID_SET_ENC,
124
132
  BC_CMD_ID_SET_LED_STATE,
125
133
  BC_CMD_ID_SET_MOTION_ALARM,
134
+ BC_CMD_ID_SET_NTP,
126
135
  BC_CMD_ID_SET_OSD_DATETIME,
127
136
  BC_CMD_ID_SET_PIR_INFO,
128
137
  BC_CMD_ID_SET_PRIVACY_MASK,
138
+ BC_CMD_ID_SET_SYSTEM_GENERAL,
129
139
  BC_CMD_ID_SET_VIDEO_INPUT,
130
140
  BC_CMD_ID_SET_WHITE_LED_STATE,
131
141
  BC_CMD_ID_SET_WHITE_LED_TASK,
@@ -135,6 +145,7 @@ import {
135
145
  BC_CMD_ID_TALK_ABILITY,
136
146
  BC_CMD_ID_TALK_CONFIG,
137
147
  BC_CMD_ID_TALK_RESET,
148
+ BC_CMD_ID_TEST_EMAIL,
138
149
  BC_CMD_ID_UDP_KEEP_ALIVE,
139
150
  BC_CMD_ID_VIDEO,
140
151
  BC_CMD_ID_VIDEO_STOP,
@@ -165,7 +176,7 @@ import {
165
176
  splitAnnexBToNalPayloads2,
166
177
  talkTraceLog,
167
178
  traceLog
168
- } from "./chunk-W2ANCJVM.js";
179
+ } from "./chunk-C57QV7IL.js";
169
180
 
170
181
  // src/protocol/framing.ts
171
182
  function encodeHeader(h) {
@@ -8334,6 +8345,304 @@ function parseXmlFragmentToJson(xml) {
8334
8345
  return parsed.root;
8335
8346
  }
8336
8347
 
8348
+ // src/reolink/baichuan/utils/email.ts
8349
+ var parseInt01 = (text) => {
8350
+ if (text === void 0) return void 0;
8351
+ return text.trim() === "1" ? 1 : 0;
8352
+ };
8353
+ var parseNumberSafe = (text) => {
8354
+ if (text === void 0) return void 0;
8355
+ const n = Number(text);
8356
+ return Number.isFinite(n) ? n : void 0;
8357
+ };
8358
+ var VALID_ATTACHMENT_TYPES = [
8359
+ "picture",
8360
+ "video",
8361
+ "none"
8362
+ ];
8363
+ var VALID_TEXT_TYPES = ["withText", "noText"];
8364
+ var normalizeAttachmentType = (text) => {
8365
+ const t = (text ?? "").trim();
8366
+ return VALID_ATTACHMENT_TYPES.includes(t) ? t : "picture";
8367
+ };
8368
+ var normalizeTextType = (text) => {
8369
+ const t = (text ?? "").trim();
8370
+ return VALID_TEXT_TYPES.includes(t) ? t : "withText";
8371
+ };
8372
+ function parseEmailConfigFromXml(xml) {
8373
+ const cfg = {
8374
+ smtpServer: getXmlText(xml, "smtpServer") ?? "",
8375
+ userName: getXmlText(xml, "userName") ?? "",
8376
+ password: getXmlText(xml, "password") ?? "",
8377
+ address1: getXmlText(xml, "address1") ?? "",
8378
+ address2: getXmlText(xml, "address2") ?? "",
8379
+ address3: getXmlText(xml, "address3") ?? "",
8380
+ smtpPort: parseNumberSafe(getXmlText(xml, "smtpPort")) ?? 0,
8381
+ sendNickname: getXmlText(xml, "sendNickname") ?? "",
8382
+ attachment: parseInt01(getXmlText(xml, "attachment")) ?? 0,
8383
+ attachmentType: normalizeAttachmentType(getXmlText(xml, "attachmentType")),
8384
+ textType: normalizeTextType(getXmlText(xml, "textType")),
8385
+ ssl: parseInt01(getXmlText(xml, "ssl")) ?? 0,
8386
+ interval: parseNumberSafe(getXmlText(xml, "interval")) ?? 30
8387
+ };
8388
+ const senderMaxLen = parseNumberSafe(getXmlText(xml, "senderMaxLen"));
8389
+ if (senderMaxLen !== void 0) cfg.senderMaxLen = senderMaxLen;
8390
+ const pwdMaxLen = parseNumberSafe(getXmlText(xml, "pwdMaxLen"));
8391
+ if (pwdMaxLen !== void 0) cfg.pwdMaxLen = pwdMaxLen;
8392
+ const ability = parseNumberSafe(getXmlText(xml, "emailAttachAbility"));
8393
+ if (ability !== void 0) cfg.emailAttachAbility = ability;
8394
+ return cfg;
8395
+ }
8396
+ function buildSetEmailXml(current, patch) {
8397
+ const merged = { ...current, ...patch };
8398
+ return ensureXmlHeader(
8399
+ `<body><Email version="1.1"><smtpServer>${xmlEscape(merged.smtpServer)}</smtpServer><userName>${xmlEscape(merged.userName)}</userName><password>${xmlEscape(merged.password)}</password><address1>${xmlEscape(merged.address1)}</address1><address2>${xmlEscape(merged.address2)}</address2><address3>${xmlEscape(merged.address3)}</address3><smtpPort>${merged.smtpPort}</smtpPort><sendNickname>${xmlEscape(merged.sendNickname)}</sendNickname><attachment>${merged.attachment}</attachment><attachmentType>${merged.attachmentType}</attachmentType><textType>${merged.textType}</textType><ssl>${merged.ssl}</ssl><interval>${merged.interval}</interval></Email></body>`
8400
+ );
8401
+ }
8402
+ function parseEmailTaskFromXml(xml) {
8403
+ const channelId = parseNumberSafe(getXmlText(xml, "channelId")) ?? 0;
8404
+ const enable = parseInt01(getXmlText(xml, "enable")) ?? 0;
8405
+ const items = [];
8406
+ const itemRe = /<item>([\s\S]*?)<\/item>/g;
8407
+ let match;
8408
+ while ((match = itemRe.exec(xml)) !== null) {
8409
+ const block = match[1] ?? "";
8410
+ items.push({
8411
+ type: getXmlText(block, "type") ?? "none",
8412
+ valueTable: getXmlText(block, "valueTable") ?? ""
8413
+ });
8414
+ }
8415
+ return { channelId, enable, typeScheduleList: items };
8416
+ }
8417
+ function buildEmailScheduleValueTable(spec) {
8418
+ if (spec.kind === "always") return "1".repeat(168);
8419
+ const grid = new Array(168).fill("0");
8420
+ if (spec.kind === "never") return grid.join("");
8421
+ for (const w of spec.windows) {
8422
+ const startH = Math.max(0, Math.min(24, w.startHour));
8423
+ const endH = Math.max(startH, Math.min(24, w.endHour));
8424
+ for (const d of w.days) {
8425
+ if (d < 0 || d > 6) continue;
8426
+ for (let h = startH; h < endH; h++) {
8427
+ grid[d * 24 + h] = "1";
8428
+ }
8429
+ }
8430
+ }
8431
+ return grid.join("");
8432
+ }
8433
+ function buildSetEmailTaskXml(task) {
8434
+ const items = task.typeScheduleList.map(
8435
+ (item) => `<item><type>${xmlEscape(item.type)}</type><valueTable>${xmlEscape(item.valueTable)}</valueTable></item>`
8436
+ ).join("");
8437
+ return ensureXmlHeader(
8438
+ `<body><EmailTask version="1.1"><channelId>${task.channelId}</channelId><enable>${task.enable}</enable><typeScheduleList>${items}</typeScheduleList></EmailTask></body>`
8439
+ );
8440
+ }
8441
+
8442
+ // src/reolink/baichuan/utils/ntp.ts
8443
+ var parseNumberSafe2 = (text) => {
8444
+ if (text === void 0) return void 0;
8445
+ const n = Number(text);
8446
+ return Number.isFinite(n) ? n : void 0;
8447
+ };
8448
+ var parseInt012 = (text) => {
8449
+ if (text === void 0) return void 0;
8450
+ return text.trim() === "1" ? 1 : 0;
8451
+ };
8452
+ function parseNtpConfigFromXml(xml) {
8453
+ return {
8454
+ enable: parseInt012(getXmlText(xml, "enable")) ?? 0,
8455
+ server: getXmlText(xml, "server") ?? "",
8456
+ synchronizeInterval: parseNumberSafe2(getXmlText(xml, "synchronizeInterval")) ?? 1440,
8457
+ port: parseNumberSafe2(getXmlText(xml, "port")) ?? 123
8458
+ };
8459
+ }
8460
+ function buildSetNtpXml(current, patch) {
8461
+ const merged = { ...current, ...patch };
8462
+ return ensureXmlHeader(
8463
+ `<body><Ntp version="1.1"><enable>${merged.enable}</enable><server>${xmlEscape(merged.server)}</server><synchronizeInterval>${merged.synchronizeInterval}</synchronizeInterval><port>${merged.port}</port></Ntp></body>`
8464
+ );
8465
+ }
8466
+
8467
+ // src/reolink/baichuan/utils/dst.ts
8468
+ var parseNumberSafe3 = (text) => {
8469
+ if (text === void 0) return void 0;
8470
+ const n = Number(text);
8471
+ return Number.isFinite(n) ? n : void 0;
8472
+ };
8473
+ var parseInt013 = (text) => {
8474
+ if (text === void 0) return void 0;
8475
+ return text.trim() === "1" ? 1 : 0;
8476
+ };
8477
+ var VALID_WEEKDAYS = [
8478
+ "Sunday",
8479
+ "Monday",
8480
+ "Tuesday",
8481
+ "Wednesday",
8482
+ "Thursday",
8483
+ "Friday",
8484
+ "Saturday"
8485
+ ];
8486
+ var normalizeWeekday = (text) => {
8487
+ const t = (text ?? "").trim();
8488
+ return VALID_WEEKDAYS.includes(t) ? t : "Sunday";
8489
+ };
8490
+ function parseDstConfigFromXml(xml) {
8491
+ const cfg = {
8492
+ enable: parseInt013(getXmlText(xml, "enable")) ?? 0,
8493
+ offset: parseNumberSafe3(getXmlText(xml, "offset")) ?? 1,
8494
+ startMonth: parseNumberSafe3(getXmlText(xml, "startMonth")) ?? 3,
8495
+ startWeekIndex: parseNumberSafe3(getXmlText(xml, "startWeekIndex")) ?? 5,
8496
+ startWeekday: normalizeWeekday(getXmlText(xml, "startWeekday")),
8497
+ startHour: parseNumberSafe3(getXmlText(xml, "startHour")) ?? 2,
8498
+ startMinute: parseNumberSafe3(getXmlText(xml, "startMinute")) ?? 0,
8499
+ startSecond: parseNumberSafe3(getXmlText(xml, "startSecond")) ?? 0,
8500
+ endMonth: parseNumberSafe3(getXmlText(xml, "endMonth")) ?? 10,
8501
+ endWeekIndex: parseNumberSafe3(getXmlText(xml, "endWeekIndex")) ?? 4,
8502
+ endWeekday: normalizeWeekday(getXmlText(xml, "endWeekday")),
8503
+ endHour: parseNumberSafe3(getXmlText(xml, "endHour")) ?? 3,
8504
+ endMinute: parseNumberSafe3(getXmlText(xml, "endMinute")) ?? 0,
8505
+ endSecond: parseNumberSafe3(getXmlText(xml, "endSecond")) ?? 0
8506
+ };
8507
+ const version = parseNumberSafe3(getXmlText(xml, "version"));
8508
+ if (version !== void 0) cfg.version = version;
8509
+ return cfg;
8510
+ }
8511
+ function buildSetDstXml(current, patch) {
8512
+ const merged = { ...current, ...patch };
8513
+ return ensureXmlHeader(
8514
+ `<body><Dst version="1.1"><enable>${merged.enable}</enable><offset>${merged.offset}</offset><startMonth>${merged.startMonth}</startMonth><startWeekIndex>${merged.startWeekIndex}</startWeekIndex><startWeekday>${xmlEscape(merged.startWeekday)}</startWeekday><startHour>${merged.startHour}</startHour><startMinute>${merged.startMinute}</startMinute><startSecond>${merged.startSecond}</startSecond><endMonth>${merged.endMonth}</endMonth><endWeekIndex>${merged.endWeekIndex}</endWeekIndex><endWeekday>${xmlEscape(merged.endWeekday)}</endWeekday><endHour>${merged.endHour}</endHour><endMinute>${merged.endMinute}</endMinute><endSecond>${merged.endSecond}</endSecond></Dst></body>`
8515
+ );
8516
+ }
8517
+
8518
+ // src/reolink/baichuan/utils/autoReboot.ts
8519
+ var parseNumberSafe4 = (text) => {
8520
+ if (text === void 0) return void 0;
8521
+ const n = Number(text);
8522
+ return Number.isFinite(n) ? n : void 0;
8523
+ };
8524
+ var parseInt014 = (text) => {
8525
+ if (text === void 0) return void 0;
8526
+ return text.trim() === "1" ? 1 : 0;
8527
+ };
8528
+ var VALID_WEEKDAYS2 = [
8529
+ "Sunday",
8530
+ "Monday",
8531
+ "Tuesday",
8532
+ "Wednesday",
8533
+ "Thursday",
8534
+ "Friday",
8535
+ "Saturday",
8536
+ "everyday"
8537
+ ];
8538
+ var normalizeWeekday2 = (text) => {
8539
+ const t = (text ?? "").trim();
8540
+ return VALID_WEEKDAYS2.includes(t) ? t : "Sunday";
8541
+ };
8542
+ function parseAutoRebootFromXml(xml) {
8543
+ return {
8544
+ enable: parseInt014(getXmlText(xml, "enable")) ?? 0,
8545
+ weekDay: normalizeWeekday2(getXmlText(xml, "weekDay")),
8546
+ hour: parseNumberSafe4(getXmlText(xml, "hour")) ?? 0,
8547
+ minute: parseNumberSafe4(getXmlText(xml, "minute")) ?? 0,
8548
+ second: parseNumberSafe4(getXmlText(xml, "second")) ?? 0
8549
+ };
8550
+ }
8551
+ function buildSetAutoRebootXml(current, patch) {
8552
+ const merged = { ...current, ...patch };
8553
+ return ensureXmlHeader(
8554
+ `<body><AutoReboot version="1.1"><enable>${merged.enable}</enable><weekDay>${xmlEscape(merged.weekDay)}</weekDay><hour>${merged.hour}</hour><minute>${merged.minute}</minute><second>${merged.second}</second></AutoReboot></body>`
8555
+ );
8556
+ }
8557
+
8558
+ // src/reolink/baichuan/utils/systemGeneral.ts
8559
+ var parseNumberSafe5 = (text) => {
8560
+ if (text === void 0) return void 0;
8561
+ const n = Number(text);
8562
+ return Number.isFinite(n) ? n : void 0;
8563
+ };
8564
+ var parseInt015 = (text) => {
8565
+ if (text === void 0) return void 0;
8566
+ return text.trim() === "1" ? 1 : 0;
8567
+ };
8568
+ var VALID_OSD_FORMATS = ["DMY", "MDY", "YMD"];
8569
+ var normalizeOsdFormat = (text) => {
8570
+ const t = (text ?? "").trim();
8571
+ return VALID_OSD_FORMATS.includes(t) ? t : "YMD";
8572
+ };
8573
+ function parseSystemGeneralFromXml(xml) {
8574
+ return {
8575
+ timeZone: parseNumberSafe5(getXmlText(xml, "timeZone")) ?? 0,
8576
+ osdFormat: normalizeOsdFormat(getXmlText(xml, "osdFormat")),
8577
+ year: parseNumberSafe5(getXmlText(xml, "year")) ?? 0,
8578
+ month: parseNumberSafe5(getXmlText(xml, "month")) ?? 0,
8579
+ day: parseNumberSafe5(getXmlText(xml, "day")) ?? 0,
8580
+ hour: parseNumberSafe5(getXmlText(xml, "hour")) ?? 0,
8581
+ minute: parseNumberSafe5(getXmlText(xml, "minute")) ?? 0,
8582
+ second: parseNumberSafe5(getXmlText(xml, "second")) ?? 0,
8583
+ deviceId: parseNumberSafe5(getXmlText(xml, "deviceId")) ?? 0,
8584
+ timeFormat: parseInt015(getXmlText(xml, "timeFormat")) ?? 0,
8585
+ language: getXmlText(xml, "language") ?? "English",
8586
+ deviceName: getXmlText(xml, "deviceName") ?? "",
8587
+ loginLock: parseInt015(getXmlText(xml, "loginLock")) ?? 0,
8588
+ lockTime: parseNumberSafe5(getXmlText(xml, "lockTime")) ?? 0,
8589
+ allowedTimes: parseNumberSafe5(getXmlText(xml, "allowedTimes")) ?? 0,
8590
+ isDst: parseInt015(getXmlText(xml, "isDst")) ?? 0
8591
+ };
8592
+ }
8593
+ function buildSetSystemGeneralXml(patch) {
8594
+ const parts = [];
8595
+ const isDeviceNameOnly = patch.deviceName !== void 0 && patch.timeZone === void 0 && patch.osdFormat === void 0 && patch.timeFormat === void 0 && patch.language === void 0 && patch.loginLock === void 0 && patch.lockTime === void 0 && patch.allowedTimes === void 0 && patch.manualTime === void 0;
8596
+ if (isDeviceNameOnly) {
8597
+ parts.push("<year>0</year>");
8598
+ parts.push(`<deviceName>${xmlEscape(patch.deviceName)}</deviceName>`);
8599
+ parts.push("<deviceNameOnly>1</deviceNameOnly>");
8600
+ } else if (patch.manualTime !== void 0) {
8601
+ const mt = patch.manualTime;
8602
+ if (patch.timeZone !== void 0)
8603
+ parts.push(`<timeZone>${patch.timeZone}</timeZone>`);
8604
+ if (patch.osdFormat !== void 0)
8605
+ parts.push(`<osdFormat>${patch.osdFormat}</osdFormat>`);
8606
+ parts.push(`<year>${mt.year}</year>`);
8607
+ parts.push(`<month>${mt.month}</month>`);
8608
+ parts.push(`<day>${mt.day}</day>`);
8609
+ parts.push(`<hour>${mt.hour}</hour>`);
8610
+ parts.push(`<minute>${mt.minute}</minute>`);
8611
+ parts.push(`<second>${mt.second}</second>`);
8612
+ if (patch.timeFormat !== void 0)
8613
+ parts.push(`<timeFormat>${patch.timeFormat}</timeFormat>`);
8614
+ if (patch.language !== void 0)
8615
+ parts.push(`<language>${xmlEscape(patch.language)}</language>`);
8616
+ if (patch.deviceName !== void 0)
8617
+ parts.push(`<deviceName>${xmlEscape(patch.deviceName)}</deviceName>`);
8618
+ if (patch.loginLock !== void 0)
8619
+ parts.push(`<loginLock>${patch.loginLock}</loginLock>`);
8620
+ if (patch.lockTime !== void 0)
8621
+ parts.push(`<lockTime>${patch.lockTime}</lockTime>`);
8622
+ if (patch.allowedTimes !== void 0)
8623
+ parts.push(`<allowedTimes>${patch.allowedTimes}</allowedTimes>`);
8624
+ } else {
8625
+ if (patch.timeZone !== void 0)
8626
+ parts.push(`<timeZone>${patch.timeZone}</timeZone>`);
8627
+ if (patch.osdFormat !== void 0)
8628
+ parts.push(`<osdFormat>${patch.osdFormat}</osdFormat>`);
8629
+ if (patch.timeFormat !== void 0)
8630
+ parts.push(`<timeFormat>${patch.timeFormat}</timeFormat>`);
8631
+ if (patch.language !== void 0)
8632
+ parts.push(`<language>${xmlEscape(patch.language)}</language>`);
8633
+ if (patch.loginLock !== void 0)
8634
+ parts.push(`<loginLock>${patch.loginLock}</loginLock>`);
8635
+ if (patch.lockTime !== void 0)
8636
+ parts.push(`<lockTime>${patch.lockTime}</lockTime>`);
8637
+ if (patch.allowedTimes !== void 0)
8638
+ parts.push(`<allowedTimes>${patch.allowedTimes}</allowedTimes>`);
8639
+ parts.push("<year>0</year>");
8640
+ }
8641
+ return ensureXmlHeader(
8642
+ `<body><SystemGeneral version="1.1">${parts.join("")}</SystemGeneral></body>`
8643
+ );
8644
+ }
8645
+
8337
8646
  // src/reolink/baichuan/ReolinkBaichuanApi.ts
8338
8647
  import { Jimp, JimpMime } from "jimp";
8339
8648
 
@@ -12488,7 +12797,7 @@ var ReolinkBaichuanApi = class _ReolinkBaichuanApi {
12488
12797
  return;
12489
12798
  }
12490
12799
  this.objectDetectionStreamStartInFlight = (async () => {
12491
- const { BaichuanVideoStream: BaichuanVideoStream2 } = await import("./BaichuanVideoStream-PHQG4A2L.js");
12800
+ const { BaichuanVideoStream: BaichuanVideoStream2 } = await import("./BaichuanVideoStream-HGPU2MZ3.js");
12492
12801
  const sessionKey = `live:object-detections:ch0:sub`;
12493
12802
  const dedicated = await this.createDedicatedSession(sessionKey);
12494
12803
  const stream = new BaichuanVideoStream2({
@@ -19084,7 +19393,7 @@ ${xml}`
19084
19393
  * @returns Test results for all stream types and profiles
19085
19394
  */
19086
19395
  async testChannelStreams(channel, logger) {
19087
- const { testChannelStreams } = await import("./DiagnosticsTools-HGJGVQXZ.js");
19396
+ const { testChannelStreams } = await import("./DiagnosticsTools-BQOWJ23L.js");
19088
19397
  return await testChannelStreams({
19089
19398
  api: this,
19090
19399
  channel: this.normalizeChannel(channel),
@@ -19100,7 +19409,7 @@ ${xml}`
19100
19409
  * @returns Complete diagnostics for all channels and streams
19101
19410
  */
19102
19411
  async collectMultifocalDiagnostics(logger) {
19103
- const { collectMultifocalDiagnostics } = await import("./DiagnosticsTools-HGJGVQXZ.js");
19412
+ const { collectMultifocalDiagnostics } = await import("./DiagnosticsTools-BQOWJ23L.js");
19104
19413
  return await collectMultifocalDiagnostics({
19105
19414
  api: this,
19106
19415
  logger
@@ -20169,7 +20478,279 @@ ${xml}`
20169
20478
  ...channel != null ? { channel } : {},
20170
20479
  ...options?.timeoutMs != null ? { timeoutMs: options.timeoutMs } : {}
20171
20480
  });
20172
- return parseXmlFragmentToJson(xml);
20481
+ return parseEmailTaskFromXml(xml);
20482
+ }
20483
+ /**
20484
+ * SetEmailTask via Baichuan (cmdId=216). Updates the email alarm schedule
20485
+ * (per-event-type 7×24 valueTable + master enable).
20486
+ *
20487
+ * Reolink expects the FULL `typeScheduleList` — pass the array from a prior
20488
+ * GET and only flip the entries you care about. Slots you don't track must
20489
+ * be sent back unchanged to avoid the camera dropping them.
20490
+ */
20491
+ async setEmailTask(channel, task, options) {
20492
+ const ch = this.normalizeChannel(channel);
20493
+ const payloadXml = buildSetEmailTaskXml({ ...task, channelId: ch });
20494
+ await this.sendXml({
20495
+ cmdId: BC_CMD_ID_SET_EMAIL_TASK,
20496
+ channel: ch,
20497
+ payloadXml,
20498
+ ...options?.timeoutMs != null ? { timeoutMs: options.timeoutMs } : {}
20499
+ });
20500
+ }
20501
+ /**
20502
+ * Convenience wrapper that patches the schedule of one or more trigger
20503
+ * types on the camera's EmailTask without touching the others.
20504
+ *
20505
+ * Pass a high-level schedule spec (`always` / `never` / explicit windows)
20506
+ * and the trigger types it should apply to. The method:
20507
+ *
20508
+ * 1. Reads the current EmailTask via GET (so we keep every existing slot).
20509
+ * 2. Builds the new `valueTable` once from `schedule`.
20510
+ * 3. Replaces the `valueTable` of every matching `type` in the list.
20511
+ * 4. Appends entries for any requested type not already present.
20512
+ * 5. Writes the merged list back via SET.
20513
+ *
20514
+ * Returns the list of types that were actually touched.
20515
+ */
20516
+ async patchEmailSchedule(channel, spec, options) {
20517
+ const current = await this.getEmailTask(channel, options);
20518
+ const newValueTable = buildEmailScheduleValueTable(spec.schedule);
20519
+ const targetSet = new Set(spec.types);
20520
+ const touched = [];
20521
+ const updatedList = current.typeScheduleList.map((item) => {
20522
+ if (targetSet.has(item.type)) {
20523
+ touched.push(item.type);
20524
+ return { ...item, valueTable: newValueTable };
20525
+ }
20526
+ return item;
20527
+ });
20528
+ for (const t of spec.types) {
20529
+ if (!current.typeScheduleList.some((item) => item.type === t)) {
20530
+ updatedList.push({ type: t, valueTable: newValueTable });
20531
+ touched.push(t);
20532
+ }
20533
+ }
20534
+ await this.setEmailTask(
20535
+ channel,
20536
+ {
20537
+ channelId: current.channelId,
20538
+ enable: spec.enable ?? current.enable,
20539
+ typeScheduleList: updatedList
20540
+ },
20541
+ options
20542
+ );
20543
+ return { touchedTypes: touched };
20544
+ }
20545
+ // ====================================================================
20546
+ // Email server (cmdId 42/43/141), NTP (38/39), DST (106/107),
20547
+ // SystemGeneral SET (105), AutoReboot (100/101).
20548
+ // Schemas derived from Reolink Client pcap (2026-05-16).
20549
+ // ====================================================================
20550
+ /**
20551
+ * Read the SMTP email configuration (cmdId=42). Returns the full `<Email>`
20552
+ * block including capability hints (`senderMaxLen`, `pwdMaxLen`,
20553
+ * `emailAttachAbility`).
20554
+ */
20555
+ async getEmail(options) {
20556
+ const xml = await this.sendXml({
20557
+ cmdId: BC_CMD_ID_GET_EMAIL,
20558
+ ...options?.timeoutMs != null ? { timeoutMs: options.timeoutMs } : {}
20559
+ });
20560
+ return parseEmailConfigFromXml(xml);
20561
+ }
20562
+ /**
20563
+ * Patch the SMTP email configuration (cmdId=43). Reads the current config
20564
+ * first then merges the patch — Reolink rejects partial `<Email>` blocks.
20565
+ */
20566
+ async setEmail(patch, options) {
20567
+ const current = await this.getEmail(options);
20568
+ const payloadXml = buildSetEmailXml(current, patch);
20569
+ await this.sendXml({
20570
+ cmdId: BC_CMD_ID_SET_EMAIL,
20571
+ payloadXml,
20572
+ ...options?.timeoutMs != null ? { timeoutMs: options.timeoutMs } : {}
20573
+ });
20574
+ }
20575
+ /**
20576
+ * Send a test email using either the current config or an override patch
20577
+ * (cmdId=141). Returns true when the camera reports 200 (test succeeded),
20578
+ * false when it reports 482 (test failed — server unreachable / bad creds).
20579
+ * Other non-200 codes propagate as exceptions via `sendXml`.
20580
+ */
20581
+ async testEmail(patch, options) {
20582
+ const current = await this.getEmail(options);
20583
+ const payloadXml = buildSetEmailXml(current, patch ?? {});
20584
+ const timeoutMs = options?.timeoutMs ?? 6e4;
20585
+ try {
20586
+ await this.sendXml({
20587
+ cmdId: BC_CMD_ID_TEST_EMAIL,
20588
+ payloadXml,
20589
+ timeoutMs
20590
+ });
20591
+ return true;
20592
+ } catch (err) {
20593
+ const msg = err instanceof Error ? err.message : String(err);
20594
+ if (msg.includes("response_code 482") || msg.includes("response_code=482")) {
20595
+ return false;
20596
+ }
20597
+ throw err;
20598
+ }
20599
+ }
20600
+ /**
20601
+ * Read the NTP server configuration (cmdId=38).
20602
+ */
20603
+ async getNtp(options) {
20604
+ const xml = await this.sendXml({
20605
+ cmdId: BC_CMD_ID_GET_NTP,
20606
+ ...options?.timeoutMs != null ? { timeoutMs: options.timeoutMs } : {}
20607
+ });
20608
+ return parseNtpConfigFromXml(xml);
20609
+ }
20610
+ /**
20611
+ * Patch the NTP server configuration (cmdId=39). Reads the current state
20612
+ * first and merges the patch — Reolink rejects partial `<Ntp>` blocks.
20613
+ */
20614
+ async setNtp(patch, options) {
20615
+ const current = await this.getNtp(options);
20616
+ const payloadXml = buildSetNtpXml(current, patch);
20617
+ await this.sendXml({
20618
+ cmdId: BC_CMD_ID_SET_NTP,
20619
+ payloadXml,
20620
+ ...options?.timeoutMs != null ? { timeoutMs: options.timeoutMs } : {}
20621
+ });
20622
+ }
20623
+ /**
20624
+ * Patch SystemGeneral (cmdId=105). Supports partial payloads: include only
20625
+ * the fields you want to change. By default the builder emits `<year>0</year>`
20626
+ * as the "do not set manual clock" marker; pass `manualTime` to actually
20627
+ * set the date/time. Setting only `deviceName` automatically uses the
20628
+ * Reolink Client's `deviceNameOnly=1` shape.
20629
+ */
20630
+ async setSystemGeneral(patch, options) {
20631
+ const payloadXml = buildSetSystemGeneralXml(patch);
20632
+ await this.sendXml({
20633
+ cmdId: BC_CMD_ID_SET_SYSTEM_GENERAL,
20634
+ payloadXml,
20635
+ ...options?.timeoutMs != null ? { timeoutMs: options.timeoutMs } : {}
20636
+ });
20637
+ }
20638
+ /**
20639
+ * Read the Daylight Saving Time configuration (cmdId=106).
20640
+ */
20641
+ async getDst(options) {
20642
+ const xml = await this.sendXml({
20643
+ cmdId: BC_CMD_ID_GET_DST,
20644
+ ...options?.timeoutMs != null ? { timeoutMs: options.timeoutMs } : {}
20645
+ });
20646
+ return parseDstConfigFromXml(xml);
20647
+ }
20648
+ /**
20649
+ * Patch the DST configuration (cmdId=107). Reads the current state first
20650
+ * and merges the patch.
20651
+ */
20652
+ async setDst(patch, options) {
20653
+ const current = await this.getDst(options);
20654
+ const payloadXml = buildSetDstXml(current, patch);
20655
+ await this.sendXml({
20656
+ cmdId: BC_CMD_ID_SET_DST,
20657
+ payloadXml,
20658
+ ...options?.timeoutMs != null ? { timeoutMs: options.timeoutMs } : {}
20659
+ });
20660
+ }
20661
+ /**
20662
+ * Read the auto-reboot schedule (cmdId=101).
20663
+ */
20664
+ async getAutoReboot(options) {
20665
+ const xml = await this.sendXml({
20666
+ cmdId: BC_CMD_ID_GET_AUTO_REBOOT,
20667
+ ...options?.timeoutMs != null ? { timeoutMs: options.timeoutMs } : {}
20668
+ });
20669
+ return parseAutoRebootFromXml(xml);
20670
+ }
20671
+ /**
20672
+ * Patch the auto-reboot schedule (cmdId=100).
20673
+ */
20674
+ async setAutoReboot(patch, options) {
20675
+ const current = await this.getAutoReboot(options);
20676
+ const payloadXml = buildSetAutoRebootXml(current, patch);
20677
+ await this.sendXml({
20678
+ cmdId: BC_CMD_ID_SET_AUTO_REBOOT,
20679
+ payloadXml,
20680
+ ...options?.timeoutMs != null ? { timeoutMs: options.timeoutMs } : {}
20681
+ });
20682
+ }
20683
+ /**
20684
+ * High-level helper that configures the camera to deliver motion alerts via
20685
+ * SMTP to the local nodelink manager. Orchestrates `setEmail` + `setEmailTask`
20686
+ * in a single call so UI code can offer "auto-configure" without juggling
20687
+ * the underlying commands.
20688
+ *
20689
+ * Pass `runTest: true` to also send a test email (cmdId=141). Returns a
20690
+ * structured result describing each leg of the flow so the caller can show
20691
+ * granular feedback.
20692
+ *
20693
+ * @param params Auto-configuration parameters
20694
+ * @param channel Logical channel (default 0). Used for the EmailTask SET.
20695
+ */
20696
+ async setupEmailPushToManager(params, channel, options) {
20697
+ const port = params.managerPort ?? 2525;
20698
+ const domain = params.domain ?? "nodelink.local";
20699
+ const recipient = `${params.recipientLocalPart}@${domain}`;
20700
+ const triggers = params.triggerTypes ?? ["MD", "people", "vehicle"];
20701
+ const attachmentType = params.attachmentType ?? "picture";
20702
+ const interval = params.interval ?? 30;
20703
+ const emailPatch = {
20704
+ smtpServer: params.managerHost,
20705
+ smtpPort: port,
20706
+ userName: params.authUsername ?? recipient,
20707
+ password: params.authPassword ?? "",
20708
+ address1: recipient,
20709
+ address2: "",
20710
+ address3: "",
20711
+ sendNickname: params.sendNickname ?? params.recipientLocalPart,
20712
+ attachment: attachmentType === "none" ? 0 : 1,
20713
+ attachmentType,
20714
+ textType: "withText",
20715
+ ssl: 0,
20716
+ interval
20717
+ };
20718
+ await this.setEmail(emailPatch, options);
20719
+ const fullWeekOn = "1".repeat(168);
20720
+ const current = await this.getEmailTask(channel, options);
20721
+ const triggerSet = new Set(triggers);
20722
+ const touched = [];
20723
+ const updatedList = current.typeScheduleList.map((item) => {
20724
+ if (triggerSet.has(item.type)) {
20725
+ touched.push(item.type);
20726
+ return { ...item, valueTable: fullWeekOn };
20727
+ }
20728
+ return item;
20729
+ });
20730
+ for (const t of triggers) {
20731
+ if (!current.typeScheduleList.some((item) => item.type === t)) {
20732
+ updatedList.push({ type: t, valueTable: fullWeekOn });
20733
+ touched.push(t);
20734
+ }
20735
+ }
20736
+ await this.setEmailTask(
20737
+ channel,
20738
+ {
20739
+ channelId: current.channelId,
20740
+ enable: 1,
20741
+ typeScheduleList: updatedList
20742
+ },
20743
+ options
20744
+ );
20745
+ const result = {
20746
+ setEmail: { applied: true },
20747
+ setEmailTask: { applied: true, touchedTypes: touched }
20748
+ };
20749
+ if (params.runTest) {
20750
+ const ok = await this.testEmail(emailPatch, options);
20751
+ result.testEmail = { success: ok };
20752
+ }
20753
+ return result;
20173
20754
  }
20174
20755
  /**
20175
20756
  * Get siren-on-motion state via AudioTask (cmdId=232).
@@ -20438,7 +21019,7 @@ ${xml}`
20438
21019
  cmdId: BC_CMD_ID_GET_SYSTEM_GENERAL,
20439
21020
  ...options?.timeoutMs != null ? { timeoutMs: options.timeoutMs } : {}
20440
21021
  });
20441
- return parseXmlFragmentToJson(xml);
21022
+ return parseSystemGeneralFromXml(xml);
20442
21023
  }
20443
21024
  /**
20444
21025
  * Get device support/capability flags.
@@ -23280,4 +23861,4 @@ export {
23280
23861
  isTcpFailureThatShouldFallbackToUdp,
23281
23862
  autoDetectDeviceType
23282
23863
  };
23283
- //# sourceMappingURL=chunk-ND73IJIB.js.map
23864
+ //# sourceMappingURL=chunk-R5AJV73A.js.map