From e0158cb53c43d1842848045a04ae0de58157d343 Mon Sep 17 00:00:00 2001 From: Rauhul Varma Date: Thu, 12 Dec 2024 10:26:18 -0800 Subject: [PATCH] wip --- .../walkthrough-example-led-blink-01.swift | 2 +- .../walkthrough-example-led-blink-02.swift | 2 +- .../walkthrough-example-led-blink-03.swift | 2 +- .../walkthrough-example-led-blink-04.swift | 2 +- .../walkthrough-example-led-blink-05.swift | 2 +- .../walkthrough-example-smart-light-01.swift | 2 +- .../walkthrough-example-smart-light-02.swift | 2 +- .../walkthrough-example-smart-light-03.swift | 2 +- .../walkthrough-example-smart-light-04-a.swift | 2 +- .../walkthrough-example-smart-light-04-b.swift | 2 +- .../walkthrough-example-smart-light-04-c.swift | 2 +- .../walkthrough-example-smart-light-04.swift | 2 +- .../walkthrough-example-smart-light-05.swift | 2 +- .../walkthrough-example-smart-light-06.swift | 2 +- .../Tutorials/Run-Example-LED-Blink.tutorial | 6 ++---- empty-template/main/Main.swift | 2 +- led-blink/main/Main.swift | 2 +- smart-light/Matter/Clusters.swift | 10 ---------- smart-light/Matter/Node.swift | 8 ++++---- smart-light/main/Main.swift | 2 +- 20 files changed, 23 insertions(+), 35 deletions(-) diff --git a/Sources/SwiftMatterExamples/Documentation.docc/Resources/run-example-led-blink/walkthrough-example-led-blink-01.swift b/Sources/SwiftMatterExamples/Documentation.docc/Resources/run-example-led-blink/walkthrough-example-led-blink-01.swift index 23f11f9..649dd82 100644 --- a/Sources/SwiftMatterExamples/Documentation.docc/Resources/run-example-led-blink/walkthrough-example-led-blink-01.swift +++ b/Sources/SwiftMatterExamples/Documentation.docc/Resources/run-example-led-blink/walkthrough-example-led-blink-01.swift @@ -9,6 +9,6 @@ // //===----------------------------------------------------------------------===// -func app_main() { +func main() { print("🏎️ Hello, Embedded Swift! (LED Blink)") } diff --git a/Sources/SwiftMatterExamples/Documentation.docc/Resources/run-example-led-blink/walkthrough-example-led-blink-02.swift b/Sources/SwiftMatterExamples/Documentation.docc/Resources/run-example-led-blink/walkthrough-example-led-blink-02.swift index 5567d02..68e7450 100644 --- a/Sources/SwiftMatterExamples/Documentation.docc/Resources/run-example-led-blink/walkthrough-example-led-blink-02.swift +++ b/Sources/SwiftMatterExamples/Documentation.docc/Resources/run-example-led-blink/walkthrough-example-led-blink-02.swift @@ -10,6 +10,6 @@ //===----------------------------------------------------------------------===// @_cdecl("app_main") -func app_main() { +func main() { print("🏎️ Hello, Embedded Swift! (LED Blink)") } diff --git a/Sources/SwiftMatterExamples/Documentation.docc/Resources/run-example-led-blink/walkthrough-example-led-blink-03.swift b/Sources/SwiftMatterExamples/Documentation.docc/Resources/run-example-led-blink/walkthrough-example-led-blink-03.swift index c0b88f6..b6a0280 100644 --- a/Sources/SwiftMatterExamples/Documentation.docc/Resources/run-example-led-blink/walkthrough-example-led-blink-03.swift +++ b/Sources/SwiftMatterExamples/Documentation.docc/Resources/run-example-led-blink/walkthrough-example-led-blink-03.swift @@ -10,7 +10,7 @@ //===----------------------------------------------------------------------===// @_cdecl("app_main") -func app_main() { +func main() { print("🏎️ Hello, Embedded Swift! (LED Blink)") let led = LED() diff --git a/Sources/SwiftMatterExamples/Documentation.docc/Resources/run-example-led-blink/walkthrough-example-led-blink-04.swift b/Sources/SwiftMatterExamples/Documentation.docc/Resources/run-example-led-blink/walkthrough-example-led-blink-04.swift index 1e33194..f9f0626 100644 --- a/Sources/SwiftMatterExamples/Documentation.docc/Resources/run-example-led-blink/walkthrough-example-led-blink-04.swift +++ b/Sources/SwiftMatterExamples/Documentation.docc/Resources/run-example-led-blink/walkthrough-example-led-blink-04.swift @@ -10,7 +10,7 @@ //===----------------------------------------------------------------------===// @_cdecl("app_main") -func app_main() { +func main() { print("🏎️ Hello, Embedded Swift! (LED Blink)") let led = LED() diff --git a/Sources/SwiftMatterExamples/Documentation.docc/Resources/run-example-led-blink/walkthrough-example-led-blink-05.swift b/Sources/SwiftMatterExamples/Documentation.docc/Resources/run-example-led-blink/walkthrough-example-led-blink-05.swift index 51e6184..4e52b94 100644 --- a/Sources/SwiftMatterExamples/Documentation.docc/Resources/run-example-led-blink/walkthrough-example-led-blink-05.swift +++ b/Sources/SwiftMatterExamples/Documentation.docc/Resources/run-example-led-blink/walkthrough-example-led-blink-05.swift @@ -10,7 +10,7 @@ //===----------------------------------------------------------------------===// @_cdecl("app_main") -func app_main() { +func main() { print("🏎️ Hello, Embedded Swift! (LED Blink)") let led = LED() diff --git a/Sources/SwiftMatterExamples/Documentation.docc/Resources/run-example-smart-light/walkthrough-example-smart-light-01.swift b/Sources/SwiftMatterExamples/Documentation.docc/Resources/run-example-smart-light/walkthrough-example-smart-light-01.swift index 6d60304..9bff489 100644 --- a/Sources/SwiftMatterExamples/Documentation.docc/Resources/run-example-smart-light/walkthrough-example-smart-light-01.swift +++ b/Sources/SwiftMatterExamples/Documentation.docc/Resources/run-example-smart-light/walkthrough-example-smart-light-01.swift @@ -10,6 +10,6 @@ //===----------------------------------------------------------------------===// @_cdecl("app_main") -func app_main() { +func main() { print("🏎️ Hello, Embedded Swift! (Smart Light)") } diff --git a/Sources/SwiftMatterExamples/Documentation.docc/Resources/run-example-smart-light/walkthrough-example-smart-light-02.swift b/Sources/SwiftMatterExamples/Documentation.docc/Resources/run-example-smart-light/walkthrough-example-smart-light-02.swift index 966c706..223d51d 100644 --- a/Sources/SwiftMatterExamples/Documentation.docc/Resources/run-example-smart-light/walkthrough-example-smart-light-02.swift +++ b/Sources/SwiftMatterExamples/Documentation.docc/Resources/run-example-smart-light/walkthrough-example-smart-light-02.swift @@ -10,7 +10,7 @@ //===----------------------------------------------------------------------===// @_cdecl("app_main") -func app_main() { +func main() { print("🏎️ Hello, Embedded Swift! (Smart Light)") let led = LED() diff --git a/Sources/SwiftMatterExamples/Documentation.docc/Resources/run-example-smart-light/walkthrough-example-smart-light-03.swift b/Sources/SwiftMatterExamples/Documentation.docc/Resources/run-example-smart-light/walkthrough-example-smart-light-03.swift index 56e58e2..5e7d064 100644 --- a/Sources/SwiftMatterExamples/Documentation.docc/Resources/run-example-smart-light/walkthrough-example-smart-light-03.swift +++ b/Sources/SwiftMatterExamples/Documentation.docc/Resources/run-example-smart-light/walkthrough-example-smart-light-03.swift @@ -10,7 +10,7 @@ //===----------------------------------------------------------------------===// @_cdecl("app_main") -func app_main() { +func main() { print("🏎️ Hello, Embedded Swift! (Smart Light)") let led = LED() diff --git a/Sources/SwiftMatterExamples/Documentation.docc/Resources/run-example-smart-light/walkthrough-example-smart-light-04-a.swift b/Sources/SwiftMatterExamples/Documentation.docc/Resources/run-example-smart-light/walkthrough-example-smart-light-04-a.swift index b7a6376..daac065 100644 --- a/Sources/SwiftMatterExamples/Documentation.docc/Resources/run-example-smart-light/walkthrough-example-smart-light-04-a.swift +++ b/Sources/SwiftMatterExamples/Documentation.docc/Resources/run-example-smart-light/walkthrough-example-smart-light-04-a.swift @@ -10,7 +10,7 @@ //===----------------------------------------------------------------------===// @_cdecl("app_main") -func app_main() { +func main() { print("🏎️ Hello, Embedded Swift! (Smart Light)") let led = LED() diff --git a/Sources/SwiftMatterExamples/Documentation.docc/Resources/run-example-smart-light/walkthrough-example-smart-light-04-b.swift b/Sources/SwiftMatterExamples/Documentation.docc/Resources/run-example-smart-light/walkthrough-example-smart-light-04-b.swift index aa514fb..2d251c0 100644 --- a/Sources/SwiftMatterExamples/Documentation.docc/Resources/run-example-smart-light/walkthrough-example-smart-light-04-b.swift +++ b/Sources/SwiftMatterExamples/Documentation.docc/Resources/run-example-smart-light/walkthrough-example-smart-light-04-b.swift @@ -10,7 +10,7 @@ //===----------------------------------------------------------------------===// @_cdecl("app_main") -func app_main() { +func main() { print("🏎️ Hello, Embedded Swift! (Smart Light)") let led = LED() diff --git a/Sources/SwiftMatterExamples/Documentation.docc/Resources/run-example-smart-light/walkthrough-example-smart-light-04-c.swift b/Sources/SwiftMatterExamples/Documentation.docc/Resources/run-example-smart-light/walkthrough-example-smart-light-04-c.swift index 7540167..17e904d 100644 --- a/Sources/SwiftMatterExamples/Documentation.docc/Resources/run-example-smart-light/walkthrough-example-smart-light-04-c.swift +++ b/Sources/SwiftMatterExamples/Documentation.docc/Resources/run-example-smart-light/walkthrough-example-smart-light-04-c.swift @@ -10,7 +10,7 @@ //===----------------------------------------------------------------------===// @_cdecl("app_main") -func app_main() { +func main() { print("🏎️ Hello, Embedded Swift! (Smart Light)") let led = LED() diff --git a/Sources/SwiftMatterExamples/Documentation.docc/Resources/run-example-smart-light/walkthrough-example-smart-light-04.swift b/Sources/SwiftMatterExamples/Documentation.docc/Resources/run-example-smart-light/walkthrough-example-smart-light-04.swift index 7a9046e..ecf1472 100644 --- a/Sources/SwiftMatterExamples/Documentation.docc/Resources/run-example-smart-light/walkthrough-example-smart-light-04.swift +++ b/Sources/SwiftMatterExamples/Documentation.docc/Resources/run-example-smart-light/walkthrough-example-smart-light-04.swift @@ -10,7 +10,7 @@ //===----------------------------------------------------------------------===// @_cdecl("app_main") -func app_main() { +func main() { print("🏎️ Hello, Embedded Swift! (Smart Light)") let led = LED() diff --git a/Sources/SwiftMatterExamples/Documentation.docc/Resources/run-example-smart-light/walkthrough-example-smart-light-05.swift b/Sources/SwiftMatterExamples/Documentation.docc/Resources/run-example-smart-light/walkthrough-example-smart-light-05.swift index 06adacc..740cacb 100644 --- a/Sources/SwiftMatterExamples/Documentation.docc/Resources/run-example-smart-light/walkthrough-example-smart-light-05.swift +++ b/Sources/SwiftMatterExamples/Documentation.docc/Resources/run-example-smart-light/walkthrough-example-smart-light-05.swift @@ -10,7 +10,7 @@ //===----------------------------------------------------------------------===// @_cdecl("app_main") -func app_main() { +func main() { print("🏎️ Hello, Embedded Swift! (Smart Light)") let led = LED() diff --git a/Sources/SwiftMatterExamples/Documentation.docc/Resources/run-example-smart-light/walkthrough-example-smart-light-06.swift b/Sources/SwiftMatterExamples/Documentation.docc/Resources/run-example-smart-light/walkthrough-example-smart-light-06.swift index 94ac726..7c7ca9a 100644 --- a/Sources/SwiftMatterExamples/Documentation.docc/Resources/run-example-smart-light/walkthrough-example-smart-light-06.swift +++ b/Sources/SwiftMatterExamples/Documentation.docc/Resources/run-example-smart-light/walkthrough-example-smart-light-06.swift @@ -10,7 +10,7 @@ //===----------------------------------------------------------------------===// @_cdecl("app_main") -func app_main() { +func main() { print("🏎️ Hello, Embedded Swift! (Smart Light)") let led = LED() diff --git a/Sources/SwiftMatterExamples/Documentation.docc/Tutorials/Run-Example-LED-Blink.tutorial b/Sources/SwiftMatterExamples/Documentation.docc/Tutorials/Run-Example-LED-Blink.tutorial index f9d5622..c3c2f40 100644 --- a/Sources/SwiftMatterExamples/Documentation.docc/Tutorials/Run-Example-LED-Blink.tutorial +++ b/Sources/SwiftMatterExamples/Documentation.docc/Tutorials/Run-Example-LED-Blink.tutorial @@ -64,16 +64,14 @@ @Steps { @Step { - We start the application by declaring an **`app_main`** function with a print statement to show the application has started. - - `app_main` serves the same purpose as a `main` function in a traditional user-land application and acts as the primary entry point for our firmware application. + We start the application by declaring an **`main`** function with a print statement to show the application has started. @Code(name: "Main.swift", file: "walkthrough-example-led-blink-01.swift", previousFile: "walkthrough-example-led-blink-00.swift") } @Step { We use the **`@_cdecl("app_main")`** attribute to generate a wrapper C symbol which is expected by ESP IDF. - + > Important: Underscored attributes, like `@_cdecl`, are unstable features of the Swift compiler and may change behavior or break between compiler versions. @Code(name: "Main.swift", file: "walkthrough-example-led-blink-02.swift", previousFile: "walkthrough-example-led-blink-01.swift") diff --git a/empty-template/main/Main.swift b/empty-template/main/Main.swift index 3975cdb..294525e 100644 --- a/empty-template/main/Main.swift +++ b/empty-template/main/Main.swift @@ -10,6 +10,6 @@ //===----------------------------------------------------------------------===// @_cdecl("app_main") -func app_main() { +func main() { print("🏎️ Hello, Embedded Swift!") } diff --git a/led-blink/main/Main.swift b/led-blink/main/Main.swift index 51e6184..4e52b94 100644 --- a/led-blink/main/Main.swift +++ b/led-blink/main/Main.swift @@ -10,7 +10,7 @@ //===----------------------------------------------------------------------===// @_cdecl("app_main") -func app_main() { +func main() { print("🏎️ Hello, Embedded Swift! (LED Blink)") let led = LED() diff --git a/smart-light/Matter/Clusters.swift b/smart-light/Matter/Clusters.swift index 540c9ab..970c19c 100644 --- a/smart-light/Matter/Clusters.swift +++ b/smart-light/Matter/Clusters.swift @@ -32,8 +32,6 @@ protocol MatterConcreteCluster: MatterCluster { struct ClusterID: RawRepresentable { var rawValue: UInt32 - init(rawValue: UInt32) { self.rawValue = rawValue } - static var identify: ClusterID { .init(rawValue: 0x0000_0003) } static var onOff: ClusterID { .init(rawValue: 0x0000_0006) } static var levelControl: ClusterID { @@ -65,8 +63,6 @@ struct Identify: MatterConcreteCluster { static var clusterTypeId: ClusterID { .identify } struct AttributeID: MatterAttributeID { var rawValue: UInt32 - - init(rawValue: UInt32) { self.rawValue = rawValue } } var cluster: UnsafeMutablePointer @@ -87,8 +83,6 @@ struct OnOff: MatterConcreteCluster { struct AttributeID: MatterAttributeID { var rawValue: UInt32 - init(rawValue: UInt32) { self.rawValue = rawValue } - static var state: AttributeID { .init(rawValue: 0x0000_0000) } } @@ -112,8 +106,6 @@ struct LevelControl: MatterConcreteCluster { struct AttributeID: MatterAttributeID { var rawValue: UInt32 - init(rawValue: UInt32) { self.rawValue = rawValue } - static var currentLevel: AttributeID { .init(rawValue: 0x0000_0000) } @@ -139,8 +131,6 @@ struct ColorControl: MatterConcreteCluster { struct AttributeID: MatterAttributeID { var rawValue: UInt32 - init(rawValue: UInt32) { self.rawValue = rawValue } - static var currentHue: AttributeID { .init(rawValue: 0x0000_0000) } diff --git a/smart-light/Matter/Node.swift b/smart-light/Matter/Node.swift index 3093310..62e4f7d 100644 --- a/smart-light/Matter/Node.swift +++ b/smart-light/Matter/Node.swift @@ -36,17 +36,17 @@ struct RootNode: MatterNode { MatterAttributeEvent, Endpoint, Cluster, UInt32, UnsafeMutablePointer? ) -> Void - typealias identifyCallback = ( + typealias IdentifyCallback = ( esp_matter.identification.callback_type_t, UInt16, UInt8, UInt8 ) -> Void final class Context { var attribute: AttributeCallback - var identify: identifyCallback + var identify: IdentifyCallback init( attribute: @escaping AttributeCallback, - identify: @escaping identifyCallback + identify: @escaping IdentifyCallback ) { self.attribute = attribute self.identify = identify @@ -57,7 +57,7 @@ struct RootNode: MatterNode { let context: Context init?( - attribute: @escaping AttributeCallback, identify: @escaping identifyCallback + attribute: @escaping AttributeCallback, identify: @escaping IdentifyCallback ) { var nodeConfig = esp_matter.node.config_t() esp_matter.attribute.set_callback_shim { diff --git a/smart-light/main/Main.swift b/smart-light/main/Main.swift index 7842108..042e64f 100644 --- a/smart-light/main/Main.swift +++ b/smart-light/main/Main.swift @@ -10,7 +10,7 @@ //===----------------------------------------------------------------------===// @_cdecl("app_main") -func app_main() { +func main() { print("🏎️ Hello, Embedded Swift! (Smart Light)") let led = LED()