From 963f4ffe3c5b03bd87b30e3c307cfb76602f1dfa Mon Sep 17 00:00:00 2001 From: Thuc Tran <thuc.tran@silabs.com> Date: Fri, 11 Sep 2020 12:44:51 -0400 Subject: [PATCH] NOJIRA Fork built-in generation templates --- package.json | 8 +- src-electron/util/args.js | 2 +- test/gen-template/{ => chip}/README.md | 0 test/gen-template/{ => chip}/addon-helper.js | 0 test/gen-template/{ => chip}/cli.json | 0 .../{ => chip}/externalOptions.json | 0 .../{ => chip}/gen-templates.json | 0 test/gen-template/{ => chip}/simple-test.zapt | 0 test/gen-template/{ => chip}/zap-cli.zapt | 0 .../{ => chip}/zap-command-parser.zapt | 0 test/gen-template/{ => chip}/zap-command.zapt | 0 test/gen-template/{ => chip}/zap-config.zapt | 0 test/gen-template/{ => chip}/zap-id.zapt | 0 test/gen-template/{ => chip}/zap-print.zapt | 0 test/gen-template/{ => chip}/zap-type.zapt | 0 test/gen-template/{ => chip}/zcl-test.zapt | 0 test/gen-template/zigbee/README.md | 8 + test/gen-template/zigbee/addon-helper.js | 7 + test/gen-template/zigbee/cli.json | 216 ++++++++++++++++++ test/gen-template/zigbee/externalOptions.json | 11 + test/gen-template/zigbee/gen-templates.json | 63 +++++ test/gen-template/zigbee/simple-test.zapt | 7 + test/gen-template/zigbee/zap-cli.zapt | 5 + .../zigbee/zap-command-parser.zapt | 1 + test/gen-template/zigbee/zap-command.zapt | 1 + test/gen-template/zigbee/zap-config.zapt | 30 +++ test/gen-template/zigbee/zap-id.zapt | 34 +++ test/gen-template/zigbee/zap-print.zapt | 27 +++ test/gen-template/zigbee/zap-type.zapt | 55 +++++ test/gen-template/zigbee/zcl-test.zapt | 26 +++ test/resource/save-file-2.zap | 2 +- test/resource/save-file-test-regen.zap | 2 +- 32 files changed, 498 insertions(+), 7 deletions(-) rename test/gen-template/{ => chip}/README.md (100%) rename test/gen-template/{ => chip}/addon-helper.js (100%) rename test/gen-template/{ => chip}/cli.json (100%) rename test/gen-template/{ => chip}/externalOptions.json (100%) rename test/gen-template/{ => chip}/gen-templates.json (100%) rename test/gen-template/{ => chip}/simple-test.zapt (100%) rename test/gen-template/{ => chip}/zap-cli.zapt (100%) rename test/gen-template/{ => chip}/zap-command-parser.zapt (100%) rename test/gen-template/{ => chip}/zap-command.zapt (100%) rename test/gen-template/{ => chip}/zap-config.zapt (100%) rename test/gen-template/{ => chip}/zap-id.zapt (100%) rename test/gen-template/{ => chip}/zap-print.zapt (100%) rename test/gen-template/{ => chip}/zap-type.zapt (100%) rename test/gen-template/{ => chip}/zcl-test.zapt (100%) create mode 100644 test/gen-template/zigbee/README.md create mode 100644 test/gen-template/zigbee/addon-helper.js create mode 100644 test/gen-template/zigbee/cli.json create mode 100644 test/gen-template/zigbee/externalOptions.json create mode 100644 test/gen-template/zigbee/gen-templates.json create mode 100644 test/gen-template/zigbee/simple-test.zapt create mode 100644 test/gen-template/zigbee/zap-cli.zapt create mode 100644 test/gen-template/zigbee/zap-command-parser.zapt create mode 100644 test/gen-template/zigbee/zap-command.zapt create mode 100644 test/gen-template/zigbee/zap-config.zapt create mode 100644 test/gen-template/zigbee/zap-id.zapt create mode 100644 test/gen-template/zigbee/zap-print.zapt create mode 100644 test/gen-template/zigbee/zap-type.zapt create mode 100644 test/gen-template/zigbee/zcl-test.zapt diff --git a/package.json b/package.json index 098dc2ba..7b470242 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,7 @@ "format-code": "pretty-quick", "pretty-quick": "pretty-quick", "self-check": "electron src-electron/main-process/electron-main.js selfCheck", - "gen": "node src-script/zap-generate.js -z ./zcl-builtin/silabs/zcl-test.properties -g ./test/gen-template/gen-templates.json -i ./test/resource/save-file-test-regen.zap -o ./tmp", + "gen": "node src-script/zap-generate.js -z ./zcl-builtin/silabs/zcl-test.properties -g ./test/gen-template/zigbee/gen-templates.json -i ./test/resource/save-file-test-regen.zap -o ./tmp", "pack": "node src-script/build-spa.js && electron-builder --dir", "dist": "electron-builder", "dist-all": "electron-builder -mwl", @@ -38,9 +38,9 @@ "apack:win": "cp apack.info.dist dist/win-unpacked/apack.info && cd dist/win-unpacked && zip -r ../zap_apack_win * && cd -", "apack:mac": "cp apack.info.dist dist/mac/apack.info && cd dist/mac && zip -r ../zap_apack_mac * && cd -", "apack:linux": "cp apack.info.dist dist/linux-unpacked/apack.info && cd dist/linux-unpacked && zip -r ../zap_apack_linux *", - "linuxpack-ui": "./dist/linux-unpacked/zap --zclProperties zcl-builtin/silabs/zcl-test.properties --genTemplateJson test/gen-template/gen-templates.json", - "linuxpack-check": "./dist/linux-unpacked/zap selfCheck --zclProperties zcl-builtin/silabs/zcl-test.properties --genTemplateJson test/gen-template/gen-templates.json", - "linuxpack-gen": "./dist/linux-unpacked/zap generate --noUi --noServer --zclProperties zcl-builtin/silabs/zcl-test.properties --genTemplateJson test/gen-template/gen-templates.json --output tmp", + "linuxpack-ui": "./dist/linux-unpacked/zap --zclProperties zcl-builtin/silabs/zcl-test.properties --genTemplateJson test/gen-template/zigbee/gen-templates.json", + "linuxpack-check": "./dist/linux-unpacked/zap selfCheck --zclProperties zcl-builtin/silabs/zcl-test.properties --genTemplateJson test/gen-template/zigbee/gen-templates.json", + "linuxpack-gen": "./dist/linux-unpacked/zap generate --noUi --noServer --zclProperties zcl-builtin/silabs/zcl-test.properties --genTemplateJson test/gen-template/zigbee/gen-templates.json --output tmp", "linuxpack-help": "./dist/linux-unpacked/zap -?" }, "dependencies": { diff --git a/src-electron/util/args.js b/src-electron/util/args.js index 285931b3..657c3852 100644 --- a/src-electron/util/args.js +++ b/src-electron/util/args.js @@ -24,7 +24,7 @@ exports.zclPropertiesFile = path.join( __dirname, '../../zcl-builtin/silabs/zcl.json' ) -exports.genTemplateJsonFile = './test/gen-template/gen-templates.json' +exports.genTemplateJsonFile = './test/gen-template/zigbee/gen-templates.json' exports.httpPort = 9070 exports.studioHttpPort = 9000 exports.uiMode = restApi.uiMode.ZIGBEE diff --git a/test/gen-template/README.md b/test/gen-template/chip/README.md similarity index 100% rename from test/gen-template/README.md rename to test/gen-template/chip/README.md diff --git a/test/gen-template/addon-helper.js b/test/gen-template/chip/addon-helper.js similarity index 100% rename from test/gen-template/addon-helper.js rename to test/gen-template/chip/addon-helper.js diff --git a/test/gen-template/cli.json b/test/gen-template/chip/cli.json similarity index 100% rename from test/gen-template/cli.json rename to test/gen-template/chip/cli.json diff --git a/test/gen-template/externalOptions.json b/test/gen-template/chip/externalOptions.json similarity index 100% rename from test/gen-template/externalOptions.json rename to test/gen-template/chip/externalOptions.json diff --git a/test/gen-template/gen-templates.json b/test/gen-template/chip/gen-templates.json similarity index 100% rename from test/gen-template/gen-templates.json rename to test/gen-template/chip/gen-templates.json diff --git a/test/gen-template/simple-test.zapt b/test/gen-template/chip/simple-test.zapt similarity index 100% rename from test/gen-template/simple-test.zapt rename to test/gen-template/chip/simple-test.zapt diff --git a/test/gen-template/zap-cli.zapt b/test/gen-template/chip/zap-cli.zapt similarity index 100% rename from test/gen-template/zap-cli.zapt rename to test/gen-template/chip/zap-cli.zapt diff --git a/test/gen-template/zap-command-parser.zapt b/test/gen-template/chip/zap-command-parser.zapt similarity index 100% rename from test/gen-template/zap-command-parser.zapt rename to test/gen-template/chip/zap-command-parser.zapt diff --git a/test/gen-template/zap-command.zapt b/test/gen-template/chip/zap-command.zapt similarity index 100% rename from test/gen-template/zap-command.zapt rename to test/gen-template/chip/zap-command.zapt diff --git a/test/gen-template/zap-config.zapt b/test/gen-template/chip/zap-config.zapt similarity index 100% rename from test/gen-template/zap-config.zapt rename to test/gen-template/chip/zap-config.zapt diff --git a/test/gen-template/zap-id.zapt b/test/gen-template/chip/zap-id.zapt similarity index 100% rename from test/gen-template/zap-id.zapt rename to test/gen-template/chip/zap-id.zapt diff --git a/test/gen-template/zap-print.zapt b/test/gen-template/chip/zap-print.zapt similarity index 100% rename from test/gen-template/zap-print.zapt rename to test/gen-template/chip/zap-print.zapt diff --git a/test/gen-template/zap-type.zapt b/test/gen-template/chip/zap-type.zapt similarity index 100% rename from test/gen-template/zap-type.zapt rename to test/gen-template/chip/zap-type.zapt diff --git a/test/gen-template/zcl-test.zapt b/test/gen-template/chip/zcl-test.zapt similarity index 100% rename from test/gen-template/zcl-test.zapt rename to test/gen-template/chip/zcl-test.zapt diff --git a/test/gen-template/zigbee/README.md b/test/gen-template/zigbee/README.md new file mode 100644 index 00000000..d2b3ed2f --- /dev/null +++ b/test/gen-template/zigbee/README.md @@ -0,0 +1,8 @@ +# ZAP generation templates + +## What is this repo? + +This repo contains test generation templates for ZAP, ZCL Advanced Platform. + +**IMPORTANT**: these files are NOT the root repository of the template files files. It is ONLY a test snapshot so that the +zap application has ability to run in a standalone mode. Do not worry about maintaining these files up to spec and so on. diff --git a/test/gen-template/zigbee/addon-helper.js b/test/gen-template/zigbee/addon-helper.js new file mode 100644 index 00000000..6aa9943d --- /dev/null +++ b/test/gen-template/zigbee/addon-helper.js @@ -0,0 +1,7 @@ +// This is an example of an addon helper for templates. + +function test_addon_helper() { + return 'This is example of test addon helper.' +} + +exports.test_addon_helper = test_addon_helper diff --git a/test/gen-template/zigbee/cli.json b/test/gen-template/zigbee/cli.json new file mode 100644 index 00000000..62e9819c --- /dev/null +++ b/test/gen-template/zigbee/cli.json @@ -0,0 +1,216 @@ +{ + "SetpointRaiseLower": "zcl tstat set", + "SetWeeklySchedule": "zcl tstat sws", + "GetWeeklySchedule": "zcl tstat gws", + "ClearWeeklySchedule": "zcl tstat cws", + "GetRelayStatusLog": "zcl tstat grs", + "MoveToHue": "zcl color-control movetohue", + "MoveHue": "zcl color-control movehue", + "StepHue": "zcl color-control stephue", + "MoveToSaturation": "zcl color-control movetosat", + "MoveSaturation": "zcl color-control movesat", + "StepSaturation": "zcl color-control stepsat", + "MoveToHueAndSaturation": "zcl color-control movetohueandsat", + "MoveToColor": "zcl color-control movetocolor", + "MoveColor": "zcl color-control movecolor", + "StepColor": "zcl color-control stepcolor", + "MoveToColorTemperature": "zcl color-control movetocolortemp", + "ZoneStatusChangeNotification": "zcl ias-zone sc", + "ZoneEnrollRequest": "zcl ias-zone enroll", + "Arm": "zcl ias-ace a", + "Bypass": "zcl ias-ace b", + "Emergency": "zcl ias-ace e", + "Fire": "zcl ias-ace f", + "Panic": "zcl ias-ace p", + "GetZoneIdMap": "zcl ias-ace getzm", + "GetZoneInformation": "zcl ias-ace getzi", + "LockDoor": "zcl lock lock", + "UnlockDoor": "zcl lock unlock", + "UnlockWithTimeout": "zcl lock unlock-with-timeout", + "GetLogRecord": "zcl lock get-log-record", + "SetPin": "zcl lock set-pin", + "GetPin": "zcl lock get-pin", + "ClearPin": "zcl lock clear-pin", + "SetWeekdaySchedule": "zcl lock set-weekday-schedule", + "GetWeekdaySchedule": "zcl lock get-weekday-schedule", + "ClearWeekdaySchedule": "zcl lock clear-weekday-schedule", + "SetYeardaySchedule": "zcl lock set-yearday-schedule", + "GetYeardaySchedule": "zcl lock get-yearday-schedule", + "ClearYeardaySchedule": "zcl lock clear-yearday-schedule", + "SetHolidaySchedule": "zcl lock set-holiday-schedule", + "GetHolidaySchedule": "zcl lock get-holiday-schedule", + "ClearHolidaySchedule": "zcl lock clear-holiday-schedule", + "SetUserType": "zcl lock set-user-type", + "GetUserType": "zcl lock get-user-type", + "SetRfid": "zcl lock set-rfid", + "GetRfid": "zcl lock get-rfid", + "ClearRfid": "zcl lock clear-rfid", + "ClearAllRfids": "zcl lock clear-all-rfids", + "WindowCoveringUpOpen": "zcl window-covering up", + "WindowCoveringDownClose": "zcl window-covering down", + "WindowCoveringStop": "zcl window-covering stop", + "WindowCoveringGoToLiftValue": "zcl window-covering go-to-lift-value", + "WindowCoveringGoToLiftPercentage": "zcl window-covering go-to-lift-percent", + "WindowCoveringGoToTiltValue": "zcl window-covering go-to-tilt-value", + "WindowCoveringGoToTiltPercentage": "zcl window-covering go-to-tilt-percentage", + "BarrierControlGoToPercent": "zcl barrier-control go-to-percent", + "BarrierControlStop": "zcl barrier-control stop", + "PowerProfileRequest": "zcl power-profile profile", + "PowerProfileStateRequest": "zcl power-profile state", + "EnergyPhasesScheduleNotification": "zcl power-profile energy-phases-schedule", + "PowerProfileScheduleConstraintsRequest": "zcl power-profile schedule-constraints", + "EnergyPhasesScheduleStateRequest": "zcl power-profile energy-phases-schedule-states", + "FastPollStop": "zcl poll-control stop", + "SetLongPollInterval": "zcl poll-control long", + "SetShortPollInterval": "zcl poll-control short", + "MatchProtocolAddress": "zcl tunnel match", + "MatchProtocolAddressResponse": "zcl tunnel response", + "AdvertiseProtocolAddress": "zcl tunnel advertise", + "TransferNpdu": "zcl bacnet transfer-npdu random", + "ResetToFactoryDefaults": "zcl basic rtfd", + "Identify": "zcl identify id", + "IdentifyQuery": "zcl identify query", + "EZModeInvoke": "zcl identify ez-mode", + "AddGroup": "zcl groups add", + "ViewGroup": "zcl groups view", + "GetGroupMembership": "zcl groups get", + "RemoveGroup": "zcl groups remove", + "RemoveAllGroups": "zcl groups rmall", + "AddGroupIfIdentifying": "zcl groups add-if-id", + "AddScene": "zcl scenes add", + "ViewScene": "zcl scenes view", + "RemoveScene": "zcl scenes remove", + "RemoveAllScenes": "zcl scenes rmall", + "StoreScene": "zcl scenes store", + "RecallScene": "zcl scenes recall", + "GetSceneMembership": "zcl scenes get", + "Off": "zcl on-off off", + "On": "zcl on-off on", + "Toggle": "zcl on-off toggle", + "MoveToLevel": "zcl level-control mv-to-level", + "Move": "zcl level-control move", + "Step": "zcl level-control step", + "Stop": "zcl level-control stop", + "MoveToLevelWithOnOff": "zcl level-control o-mv-to-level", + "MoveWithOnOff": "zcl level-control o-move", + "StepWithOnOff": "zcl level-control o-step", + "StopWithOnOff": "zcl level-control o-stop", + "PublishPrice": "zcl price pub-price", + "PublishBlockPeriod": "zcl price pub-block-period", + "PublishConversionFactor": "zcl price pub-x-factor", + "PublishCalorificValue": "zcl price pub-cal-val", + "PublishTariffInformation": "zcl price pub-tariff-info", + "PublishPriceMatrix": "zcl price pub-price-matrix", + "PublishBlockThresholds": "zcl price pub-block-threshold", + "PublishCO2Value": "zcl price pub-co2-val", + "PublishTierLabels": "zcl price pub-tier-labels", + "PublishBillingPeriod": "zcl price pub-billing-period", + "PublishConsolidatedBill": "zcl price pub-consolidated-bill", + "PublishCppEvent": "zcl price pub-cpp-event", + "PublishCreditPayment": "zcl price pub-credit-payment", + "PublishCurrencyConversion": "zcl price pub-currency-conversion", + "CancelTariff": "zcl price cancel-tariff", + "GetCurrentPrice": "zcl price current", + "GetScheduledPrices": "zcl price scheduled", + "PriceAcknowledgement": "zcl price price-ack", + "GetBlockPeriods": "zcl price get-block-periods", + "GetConversionFactor": "zcl price get-conversion-factor", + "GetCalorificValue": "zcl price get-cal-val", + "GetTariffInformation": "zcl price get-tariff-info", + "GetPriceMatrix": "zcl price get-price-matrix", + "GetBlockThresholds": "zcl price get-block-thresholds", + "GetCO2Value": "zcl price get-co2-value", + "GetTierLabels": "zcl price get-tier-labels", + "GetBillingPeriod": "zcl price get-billing-period", + "GetConsolidatedBill": "zcl price get-con-bill", + "CppEventResponse": "zcl price cpp-event-resp", + "GetCreditPayment": "zcl price get-credit-payment", + "GetCurrencyConversionCommand": "zcl price get-cur-conv-cmd", + "GetTariffCancellation": "zcl price get-tariff-cancellation", + "CancelLoadControlEvent": "zcl drlc cl", + "CancelAllLoadControlEvents": "zcl drlc ca", + "GetScheduledEvents": "zcl drlc gse", + "RequestMirror": "zcl metering request-mirror", + "RemoveMirror": "zcl metering remove-mirror", + "ScheduleSnapshotResponse": "zcl metering sch-snapshot-resp", + "TakeSnapshotResponse": "zcl metering take-snapshot-resp", + "PublishSnapshot": "zcl metering pub-ss", + "ConfigureMirror": "zcl metering cfg-mirror", + "ConfigureNotificationScheme": "zcl metering cfg-nft-scheme", + "ConfigureNotificationFlags": "zcl metering cfg-nft-flags", + "GetNotifiedMessage": "zcl metering get-ntfy-msg", + "SupplyStatusResponse": "zcl metering sup-stat-rsp", + "StartSamplingResponse": "zcl metering start-samp-rsp", + "GetProfile": "zcl metering get-profile", + "MirrorRemoved": "zcl metering mirror-removed", + "RequestFastPollMode": "zcl metering req-fast-poll-mode", + "ScheduleSnapshot": "zcl metering sch-snapshot", + "TakeSnapshot": "zcl metering take-snapshot", + "GetSnapshot": "zcl metering get-snapshot", + "StartSampling": "zcl metering start-sampling", + "GetSampledData": "zcl metering get-sampled-data", + "ResetLoadLimitCounter": "zcl metering rst-load-limit-ctr", + "ChangeSupply": "zcl metering chg-supply", + "LocalChangeSupply": "zcl metering local-chg-supply", + "SetSupplyStatus": "zcl metering set-supply-status", + "SetUncontrolledFlowThreshold": "zcl metering set-uncntrl-flow-threshold", + "DisplayMessage": "zcl msg disp", + "CancelMessage": "zcl msg cancel", + "DisplayProtectedMessage": "zcl msg disp-protd", + "CancelAllMessages": "zcl msg x-all", + "GetLastMessage": "zcl msg get", + "MessageConfirmation": "zcl msg confirm", + "GetMessageCancellation": "zcl msg get-msg-x", + "RequestTunnel": "zcl tunneling request", + "CloseTunnel": "zcl tunneling close", + "SelectAvailableEmergencyCredit": "zcl prepayment sel-av-em-cred", + "ChangeDebt": "zcl prepayment chg-debt", + "EmergencyCreditSetup": "zcl prepayment em-cred-setup", + "ConsumerTopUp": "zcl prepayment cons-top-up", + "CreditAdjustment": "zcl prepayment cred-adj", + "ChangePaymentMode": "zcl prepayment chg-pmt-mode", + "GetPrepaySnapshot": "zcl prepayment get-pp-ss", + "GetTopUpLog": "zcl prepayment get-top-up-log", + "SetLowCreditWarningLevel": "zcl prepayment set-low-cred-wng-lvl", + "GetDebtRepaymentLog": "zcl prepayment get-debt-repmt-log", + "SetMaximumCreditLimit": "zcl prepayment set-max-cred-lmt", + "SetOverallDebtCap": "zcl prepayment set-oa-debt-cap", + "PublishPrepaySnapshot": "zcl prepayment pub-prep-ss", + "ChangePaymentModeResponse": "zcl prepayment chg-pmt-mode-resp", + "ConsumerTopUpResponse": "zcl prepayment cons-top-up-resp", + "PublishTopUpLog": "zcl prepayment pub-top-up-log", + "PublishDebtLog": "zcl prepayment pub-debt-log", + "GetCalendar": "zcl calendar get-calendar", + "GetDayProfiles": "zcl calendar get-day-profiles", + "GetWeekProfiles": "zcl calendar get-week-profiles", + "GetSeasons": "zcl calendar get-seasons", + "GetSpecialDays": "zcl calendar get-special-days", + "GetCalendarCancellation": "zcl calendar get-cancellation", + "GetChangeOfTenancy": "zcl dm get-chg-of-tenancy", + "GetChangeOfSupplier": "zcl dm get-chg-of-supplier", + "RequestNewPassword": "zcl dm req-new-pass", + "GetSiteId": "zcl dm get-site-id", + "ReportEventConfiguration": "zcl dm rpt-event-config", + "GetCIN": "zcl dm get-cin", + "PublishChangeOfSupplier": "zcl dm pub-chg-of-supplier", + "RequestNewPasswordResponse": "zcl dm req-new-pass-resp", + "SetEventConfiguration": "zcl dm set-event-config", + "GetEventConfiguration": "zcl dm get-event-config", + "GetEventLog": "zcl events get-event-log", + "ClearEventLogRequest": "zcl events clear-event-log", + "TriggerEffect": "zcl identify trigger", + "EnhancedAddScene": "zcl scenes eadd", + "EnhancedViewScene": "zcl scenes eview", + "CopyScene": "zcl scenes copy", + "OffWithEffect": "zcl on-off offeffect", + "OnWithRecallGlobalScene": "zcl on-off onrecall", + "OnWithTimedOff": "zcl on-off ontimedoff", + "EnhancedMoveToHue": "zcl color-control emovetohue", + "EnhancedMoveHue": "zcl color-control emovehue", + "EnhancedStepHue": "zcl color-control estephue", + "EnhancedMoveToHueAndSaturation": "zcl color-control emovetohueandsat", + "ColorLoopSet": "zcl color-control loop", + "StopMoveStep": "zcl color-control stopmovestep", + "MoveColorTemperature": "zcl color-control movecolortemp", + "StepColorTemperature": "zcl color-control stepcolortemp" +} diff --git a/test/gen-template/zigbee/externalOptions.json b/test/gen-template/zigbee/externalOptions.json new file mode 100644 index 00000000..9d27e4b6 --- /dev/null +++ b/test/gen-template/zigbee/externalOptions.json @@ -0,0 +1,11 @@ +{ + "ext1": "extLabel1", + "ext2": "extLabel2", + "ext3": "extLabel3", + "ext4": "extLabel4", + "ext5": "extLabel5", + "ext6": "extLabel6", + "ext7": "extLabel7", + "ext8": "extLabel8", + "ext9": "extLabel9" +} diff --git a/test/gen-template/zigbee/gen-templates.json b/test/gen-template/zigbee/gen-templates.json new file mode 100644 index 00000000..f28c458d --- /dev/null +++ b/test/gen-template/zigbee/gen-templates.json @@ -0,0 +1,63 @@ +{ + "name": "Test templates", + "version": "test-v1", + "options": { + "testOption": { + "code1": "label1", + "code2": "label2", + "code3": "label3", + "code4": "label4", + "code5": "label5" + }, + "externalOption": "externalOptions.json", + "cli": "cli.json" + }, + "helpers": ["addon-helper.js"], + "templates": [ + { + "path": "simple-test.zapt", + "name": "Test template", + "output": "simple-test.out" + }, + { + "path": "zcl-test.zapt", + "name": "Test ZCL template", + "output": "zcl-test.out" + }, + { + "path": "zap-id.zapt", + "name": "Various ZCL ids", + "output": "zap-id.h" + }, + { + "path": "zap-type.zapt", + "name": "ZCL types", + "output": "zap-type.h" + }, + { + "path": "zap-cli.zapt", + "name": "ZCL command-line contribution", + "output": "zap-cli.h" + }, + { + "path": "zap-command-parser.zapt", + "name": "ZCL command parsers", + "output": "zap-command-parser.h" + }, + { + "path": "zap-command.zapt", + "name": "ZCL command APIs", + "output": "zap-command.h" + }, + { + "path": "zap-config.zapt", + "name": "ZCL endpoint configuration", + "output": "zap-config.h" + }, + { + "path": "zap-print.zapt", + "name": "ZCL human readable strings", + "output": "zap-print.h" + } + ] +} diff --git a/test/gen-template/zigbee/simple-test.zapt b/test/gen-template/zigbee/simple-test.zapt new file mode 100644 index 00000000..5836d3fc --- /dev/null +++ b/test/gen-template/zigbee/simple-test.zapt @@ -0,0 +1,7 @@ +Test template file. + +Header:{{zap_header}} + +SessionId: {{sessionId}} + +Addon: {{test_addon_helper}} \ No newline at end of file diff --git a/test/gen-template/zigbee/zap-cli.zapt b/test/gen-template/zigbee/zap-cli.zapt new file mode 100644 index 00000000..aa3a1611 --- /dev/null +++ b/test/gen-template/zigbee/zap-cli.zapt @@ -0,0 +1,5 @@ +{{zap_header}} + +{{#template_options category="cli"}} +{{optionCode}} => {{optionLabel}} +{{/template_options}} \ No newline at end of file diff --git a/test/gen-template/zigbee/zap-command-parser.zapt b/test/gen-template/zigbee/zap-command-parser.zapt new file mode 100644 index 00000000..71140fca --- /dev/null +++ b/test/gen-template/zigbee/zap-command-parser.zapt @@ -0,0 +1 @@ +{{zap_header}} diff --git a/test/gen-template/zigbee/zap-command.zapt b/test/gen-template/zigbee/zap-command.zapt new file mode 100644 index 00000000..71140fca --- /dev/null +++ b/test/gen-template/zigbee/zap-command.zapt @@ -0,0 +1 @@ +{{zap_header}} diff --git a/test/gen-template/zigbee/zap-config.zapt b/test/gen-template/zigbee/zap-config.zapt new file mode 100644 index 00000000..3679d0e6 --- /dev/null +++ b/test/gen-template/zigbee/zap-config.zapt @@ -0,0 +1,30 @@ +{{zap_header}} + +#define FIXED_ENPOINT_COUNT ({{user_endpoint_type_count}}) + +#define GENERATED_DEFAULTS { +{{#user_all_attributes}} +// {{name}} : {{clusterCode}}/{{attributeCode}} / {{type}} +def: {{asBytes defaultValue type}} +{{/user_all_attributes}} +} + +#define GENERATED_MIN_MAX_DEFAULTS { +{{#user_all_attributes}} +// default: {{clusterCode}} / {{attributeCode}} / {{name}} +{{/user_all_attributes}} +} + +{{#user_endpoint_types}} +// Endpoint: {{endpointTypeId}}, {{name}} / Device Type: {{deviceTypeName}}, {{deviceTypeCode}} + +{{#user_clusters}} +// Cluster: {{code}} / {{name}} ({{side}}) / {{mfgCode}} +{{#user_cluster_attributes}} +// - attribute: {{code}} / {{name}} +{{/user_cluster_attributes}} +{{#user_cluster_commands}} +// - command: {{code}} / {{name}} +{{/user_cluster_commands}} +{{/user_clusters}} +{{/user_endpoint_types}} \ No newline at end of file diff --git a/test/gen-template/zigbee/zap-id.zapt b/test/gen-template/zigbee/zap-id.zapt new file mode 100644 index 00000000..2b8b35d4 --- /dev/null +++ b/test/gen-template/zigbee/zap-id.zapt @@ -0,0 +1,34 @@ +{{zap_header}} + +#ifndef __ZAP_GEN_ID__ +#define __ZAP_GEN_ID__ + +// Global, non-cluster-specific things +{{#zcl_global_commands}} +#define ZCL_{{asDelimitedMacro label}}_COMMAND_ID ({{asHex code}}) +{{/zcl_global_commands}} + +{{#zcl_clusters}} + +// Definitions for cluster: {{label}} +#define ZCL_{{asDelimitedMacro define}}_ID ({{asHex code}}) + +// Client attributes for cluster: {{label}} +{{#zcl_attributes_client}} +#define ZCL_{{asDelimitedMacro define}}_ATTRIBUTE_ID ({{asHex code}}) +{{/zcl_attributes_client}} + +// Server attributes for cluster: {{label}} +{{#zcl_attributes_server}} +#define ZCL_{{asDelimitedMacro define}}_ATTRIBUTE_ID ({{asHex code}}) +{{/zcl_attributes_server}} + +// Commands for cluster: {{label}} +{{#zcl_commands}} +#define ZCL_{{asDelimitedMacro label}}_COMMAND_ID ({{asHex code}}) +{{/zcl_commands}} + +// End of cluster: {{label}} +{{/zcl_clusters}} + +#endif // __ZAP_GEN_ID__ diff --git a/test/gen-template/zigbee/zap-print.zapt b/test/gen-template/zigbee/zap-print.zapt new file mode 100644 index 00000000..562bc0b0 --- /dev/null +++ b/test/gen-template/zigbee/zap-print.zapt @@ -0,0 +1,27 @@ +{{zap_header}} + +// Enclosing macro to prevent multiple inclusion +#ifndef SILABS_PRINT_CLUSTER +#define SILABS_PRINT_CLUSTER + + +// This is the mapping of IDs to cluster names assuming a format according +// to the "EmberAfClusterName" defined in the ZCL header. +// The names of clusters that are not present, are removed. + +{{#zcl_clusters}} +#if defined(ZCL_USING_{{asDelimitedMacro this.define}}_SERVER) || defined(ZCL_USING_{{asDelimitedMacro this.define}}_CLIENT) + #define SILABS_PRINTCLUSTER_{{asDelimitedMacro this.define}} {ZCL_{{asDelimitedMacro this.define}}_ID, {{this.code}}, "{{this.label}}" }, +#else + #define SILABS_PRINTCLUSTER_{{asDelimitedMacro this.define}} +#endif + +{{/zcl_clusters}} + +#define CLUSTER_IDS_TO_NAMES \ +{{#zcl_clusters}} + SILABS_PRINTCLUSTER_{{asDelimitedMacro this.define}} \ +{{/zcl_clusters}} + +#define MAX_CLUSTER_NAME_LENGTH {{zcl_cluster_largest_label_length}} +#endif // SILABS_PRINT_CLUSTER \ No newline at end of file diff --git a/test/gen-template/zigbee/zap-type.zapt b/test/gen-template/zigbee/zap-type.zapt new file mode 100644 index 00000000..91be64e1 --- /dev/null +++ b/test/gen-template/zigbee/zap-type.zapt @@ -0,0 +1,55 @@ +{{zap_header}} + +#ifndef __ZAP_GEN_TYPE__ +#define __ZAP_GEN_TYPE__ + +// ZCL attribute types +enum { +{{#zcl_atomics}} +{{ident}}ZCL_{{asDelimitedMacro name}}_ATTRIBUTE_TYPE = {{asHex atomicId}}, // {{description}} +{{/zcl_atomics}} +}; + +// ZCL attribute sizes +#define ZAP_GENERATED_ATTRIBUTE_SIZES { \ +{{#zcl_atomics}} +{{#if size}} +{{ident}}ZCL_{{asDelimitedMacro name}}_ATTRIBUTE_TYPE, {{size}}, \ +{{/if}} +{{/zcl_atomics}} +} + +// ZCL enums + +{{#zcl_enums}} + +// Enum for {{label}} +typedef enum { +{{#zcl_enum_items}} +{{ident}}EMBER_ZCL_{{asDelimitedMacro parent.label}}_{{asDelimitedMacro label}} = {{value}}, +{{/zcl_enum_items}} +} EmberAf{{asType label}}; +{{/zcl_enums}} + +// ZCL bitmaps + +{{#zcl_bitmaps}} +{{#zcl_bitmap_items}} +#define EMBER_AF_{{asDelimitedMacro parent.label}}_{{asDelimitedMacro label}} ({{mask}}) +#define EMBER_AF_{{asDelimitedMacro parent.label}}_{{asDelimitedMacro label}}_OFFSET ({{asOffset mask}}) +{{/zcl_bitmap_items}} +{{/zcl_bitmaps}} + +// ZCL Structs + +{{#zcl_structs}} + +// Struct for {{label}} +typedef struct _{{asType label}} { +{{#zcl_struct_items}} +{{ident}}{{asUnderlyingType type}} {{asSymbol label}}; +{{/zcl_struct_items}} +} {{asType label}}; +{{/zcl_structs}} + +#endif \ No newline at end of file diff --git a/test/gen-template/zigbee/zcl-test.zapt b/test/gen-template/zigbee/zcl-test.zapt new file mode 100644 index 00000000..0a26576a --- /dev/null +++ b/test/gen-template/zigbee/zcl-test.zapt @@ -0,0 +1,26 @@ +/******************/ +{{#zcl_enums}} +// label=>{{label}} caption=>{{caption}} +{{/zcl_enums}} + +/******************/ +{{#zcl_structs}} +// struct: {{label}} +{{/zcl_structs}} + + +/******************/ +{{#zcl_clusters}} +// cluster: {{code}} {{label}} +// {{description}} +{{/zcl_clusters}} + +/******************/ +{{#zcl_commands}} +// cmd: {{code}} {{label}} +{{/zcl_commands}} + +/******************/ +{{#zcl_attributes}} +// att: {{code}} {{label}} +{{/zcl_attributes}} \ No newline at end of file diff --git a/test/resource/save-file-2.zap b/test/resource/save-file-2.zap index a90c6a71..f6758f0f 100644 --- a/test/resource/save-file-2.zap +++ b/test/resource/save-file-2.zap @@ -14,7 +14,7 @@ "type": "zcl-properties" }, { - "path": "/home/timotej/git/zap/test/gen-template/gen-templates.json", + "path": "/home/timotej/git/zap/test/gen-template/zigbee/gen-templates.json", "version": "test-v1", "type": "gen-templates-json" } diff --git a/test/resource/save-file-test-regen.zap b/test/resource/save-file-test-regen.zap index a90c6a71..f6758f0f 100644 --- a/test/resource/save-file-test-regen.zap +++ b/test/resource/save-file-test-regen.zap @@ -14,7 +14,7 @@ "type": "zcl-properties" }, { - "path": "/home/timotej/git/zap/test/gen-template/gen-templates.json", + "path": "/home/timotej/git/zap/test/gen-template/zigbee/gen-templates.json", "version": "test-v1", "type": "gen-templates-json" } -- GitLab