Skip to content
This repository was archived by the owner on Feb 23, 2023. It is now read-only.

Commit 06736f6

Browse files
authored
Update to v2 (#31)
1 parent f50bf9a commit 06736f6

10 files changed

Lines changed: 457 additions & 237 deletions

File tree

ios/Runner.xcodeproj/project.pbxproj

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@
174174
CreatedOnToolsVersion = 7.3.1;
175175
DevelopmentTeam = 52H6FSSL8K;
176176
LastSwiftMigration = 1100;
177-
ProvisioningStyle = Automatic;
177+
ProvisioningStyle = Manual;
178178
};
179179
};
180180
};
@@ -375,10 +375,10 @@
375375
buildSettings = {
376376
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
377377
CLANG_ENABLE_MODULES = YES;
378-
CODE_SIGN_IDENTITY = "Apple Development";
379-
CODE_SIGN_STYLE = Automatic;
380-
CURRENT_PROJECT_VERSION = 2;
381-
DEVELOPMENT_TEAM = "";
378+
CODE_SIGN_IDENTITY = "iPhone Distribution";
379+
CODE_SIGN_STYLE = Manual;
380+
CURRENT_PROJECT_VERSION = 1;
381+
DEVELOPMENT_TEAM = 52H6FSSL8K;
382382
ENABLE_BITCODE = NO;
383383
FRAMEWORK_SEARCH_PATHS = (
384384
"$(inherited)",
@@ -395,12 +395,14 @@
395395
"$(inherited)",
396396
"$(PROJECT_DIR)/Flutter",
397397
);
398+
MARKETING_VERSION = 1.2.0;
398399
PRODUCT_BUNDLE_IDENTIFIER = dev.plgd;
399400
PRODUCT_NAME = plgd;
400-
PROVISIONING_PROFILE_SPECIFIER = "";
401+
PROVISIONING_PROFILE_SPECIFIER = dev.plgd;
401402
STRIP_BITCODE_FROM_COPIED_FILES = NO;
402403
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
403404
SWIFT_VERSION = 5.0;
405+
VALID_ARCHS = "arm64 arm64e";
404406
VERSIONING_SYSTEM = "apple-generic";
405407
};
406408
name = Profile;
@@ -517,10 +519,10 @@
517519
buildSettings = {
518520
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
519521
CLANG_ENABLE_MODULES = YES;
520-
CODE_SIGN_IDENTITY = "Apple Development";
521-
CODE_SIGN_STYLE = Automatic;
522-
CURRENT_PROJECT_VERSION = 2;
523-
DEVELOPMENT_TEAM = "";
522+
CODE_SIGN_IDENTITY = "iPhone Distribution";
523+
CODE_SIGN_STYLE = Manual;
524+
CURRENT_PROJECT_VERSION = 1;
525+
DEVELOPMENT_TEAM = 52H6FSSL8K;
524526
ENABLE_BITCODE = NO;
525527
FRAMEWORK_SEARCH_PATHS = (
526528
"$(inherited)",
@@ -537,13 +539,15 @@
537539
"$(inherited)",
538540
"$(PROJECT_DIR)/Flutter",
539541
);
542+
MARKETING_VERSION = 1.2.0;
540543
PRODUCT_BUNDLE_IDENTIFIER = dev.plgd;
541544
PRODUCT_NAME = plgd;
542-
PROVISIONING_PROFILE_SPECIFIER = "";
545+
PROVISIONING_PROFILE_SPECIFIER = dev.plgd;
543546
STRIP_BITCODE_FROM_COPIED_FILES = NO;
544547
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
545548
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
546549
SWIFT_VERSION = 5.0;
550+
VALID_ARCHS = "arm64 arm64e";
547551
VERSIONING_SYSTEM = "apple-generic";
548552
};
549553
name = Debug;
@@ -554,10 +558,10 @@
554558
buildSettings = {
555559
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
556560
CLANG_ENABLE_MODULES = YES;
557-
CODE_SIGN_IDENTITY = "Apple Development";
558-
CODE_SIGN_STYLE = Automatic;
559-
CURRENT_PROJECT_VERSION = 2;
560-
DEVELOPMENT_TEAM = "";
561+
CODE_SIGN_IDENTITY = "iPhone Distribution";
562+
CODE_SIGN_STYLE = Manual;
563+
CURRENT_PROJECT_VERSION = 1;
564+
DEVELOPMENT_TEAM = 52H6FSSL8K;
561565
ENABLE_BITCODE = NO;
562566
FRAMEWORK_SEARCH_PATHS = (
563567
"$(inherited)",
@@ -574,12 +578,14 @@
574578
"$(inherited)",
575579
"$(PROJECT_DIR)/Flutter",
576580
);
581+
MARKETING_VERSION = 1.2.0;
577582
PRODUCT_BUNDLE_IDENTIFIER = dev.plgd;
578583
PRODUCT_NAME = plgd;
579-
PROVISIONING_PROFILE_SPECIFIER = "";
584+
PROVISIONING_PROFILE_SPECIFIER = dev.plgd;
580585
STRIP_BITCODE_FROM_COPIED_FILES = NO;
581586
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
582587
SWIFT_VERSION = 5.0;
588+
VALID_ARCHS = "arm64 arm64e";
583589
VERSIONING_SYSTEM = "apple-generic";
584590
};
585591
name = Release;

ios/Runner/AppDelegate.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import UIKit
22
import Flutter
3-
import Ocfclient
3+
import OCFClient
44

55
@UIApplicationMain
66
@objc class AppDelegate: FlutterAppDelegate {

ios/Runner/Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<key>CFBundlePackageType</key>
1616
<string>APPL</string>
1717
<key>CFBundleShortVersionString</key>
18-
<string>$(FLUTTER_BUILD_NAME)</string>
18+
<string>$(MARKETING_VERSION)</string>
1919
<key>CFBundleSignature</key>
2020
<string>????</string>
2121
<key>CFBundleVersion</key>

lib/models/cloudConfiguration.dart

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -25,28 +25,28 @@ class CloudConfiguration {
2525
rawJson = jsonString;
2626
Map<String, dynamic> json = jsonDecode(jsonString);
2727

28-
accessTokenUrl = json['access_token_url'];
29-
authCodeUrl = json['auth_code_url'];
30-
authorizationProvider = json['cloud_authorization_provider'];
31-
certificateAutorities = json['cloud_certificate_authorities'];
32-
cloudID = json['cloud_id'];
33-
cloudUrl = json['cloud_url'];
34-
jwtClaimOwnerId = json['jwt_claim_owner_id'];
35-
signingServerAddress = json['signing_server_address'];
28+
accessTokenUrl = json['accessTokenUrl'];
29+
authCodeUrl = json['authCodeUrl'];
30+
authorizationProvider = json['cloudAuthorizationProvider'];
31+
certificateAutorities = json['cloudCertificateAuthorities'];
32+
cloudID = json['cloudId'];
33+
cloudUrl = json['cloudUrl'];
34+
jwtClaimOwnerId = json['jwtClaimOwnerId'];
35+
signingServerAddress = json['signingServerAddress'];
3636
}
3737

3838
static bool isValid(String jsonString) {
3939
try {
4040
Map<String, dynamic> configuration = jsonDecode(jsonString);
4141
return
42-
configuration.containsKey('access_token_url') && Uri.parse(configuration['access_token_url']).isAbsolute &&
43-
configuration.containsKey('auth_code_url') && Uri.parse(configuration['auth_code_url']).isAbsolute &&
44-
configuration.containsKey('cloud_authorization_provider') &&
45-
configuration.containsKey('cloud_certificate_authorities') &&
46-
configuration.containsKey('cloud_id') &&
47-
configuration.containsKey('cloud_url') &&
48-
configuration.containsKey('jwt_claim_owner_id') &&
49-
configuration.containsKey('signing_server_address');
42+
configuration.containsKey('accessTokenUrl') && Uri.parse(configuration['accessTokenUrl']).isAbsolute &&
43+
configuration.containsKey('authCodeUrl') && Uri.parse(configuration['authCodeUrl']).isAbsolute &&
44+
configuration.containsKey('cloudAuthorizationProvider') &&
45+
configuration.containsKey('cloudCertificateAuthorities') &&
46+
configuration.containsKey('cloudId') &&
47+
configuration.containsKey('cloudUrl') &&
48+
configuration.containsKey('jwtClaimOwnerId') &&
49+
configuration.containsKey('signingServerAddress');
5050
} on Exception catch (_) {
5151
return false;
5252
}

lib/models/device.dart

Lines changed: 9 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ class Device {
1010
String ownershipStatus;
1111
CloudResourceConfiguration cloudConfiguration;
1212
List<Resources> resources;
13-
List<Endpoints> endpoints;
1413

1514
Device(
1615
{this.id,
@@ -23,8 +22,7 @@ class Device {
2322
this.ownership,
2423
this.ownershipStatus,
2524
this.cloudConfiguration,
26-
this.resources,
27-
this.endpoints});
25+
this.resources});
2826

2927
bool isOwnedBy(String ownerId) {
3028
if (!this.isSecured || !this.ownership.owned) {
@@ -38,18 +36,12 @@ class Device {
3836

3937
Device.fromJson(Map<String, dynamic> json) {
4038
id = json['ID'];
41-
if (json['Device'] != null) {
42-
resourceTypes = json['Device']['rt'] != null ? json['Device']['rt'].cast<String>() : '';
43-
interfaces = json['Device']['if'] != null ? json['Device']['if'] .cast<String>() : '';
44-
name = json['Device']['n'];
45-
manufacturerName = json['Device']['dmn'];
46-
modelNumber = json['Device']['dmno'];
47-
} else {
48-
resourceTypes = json['Device']['rt'].cast<String>();
49-
interfaces = json['Device']['if'].cast<String>();
50-
name = json['Device']['n'];
51-
manufacturerName = json['Device']['dmn'];
52-
modelNumber = json['Device']['dmno'];
39+
if (json['Details'] != null) {
40+
resourceTypes = json['Details']['rt'] != null ? json['Details']['rt'].cast<String>() : '';
41+
interfaces = json['Details']['if'] != null ? json['Details']['if'].cast<String>() : '';
42+
name = json['Details']['n'];
43+
manufacturerName = json['Details']['dmn'];
44+
modelNumber = json['Details']['dmno'];
5345
}
5446
isSecured = json['IsSecured'];
5547
ownership = json['Ownership'] != null ? new Ownership.fromJson(json['Ownership']) : null;
@@ -61,12 +53,6 @@ class Device {
6153
resources.add(new Resources.fromJson(v));
6254
});
6355
}
64-
if (json['Endpoints'] != null) {
65-
endpoints = new List<Endpoints>();
66-
json['Endpoints'].forEach((v) {
67-
endpoints.add(new Endpoints.fromJson(v));
68-
});
69-
}
7056
}
7157
}
7258

@@ -130,63 +116,18 @@ class CloudResourceConfiguration {
130116
}
131117

132118
class Resources {
133-
String id;
134119
String href;
135120
List<String> resourceTypes;
136121
List<String> interfaces;
137-
List<Endpoints> endpoints;
138-
String anchor;
139-
String deviceID;
140-
int instanceID;
141-
String title;
142-
String supportedContentTypes;
143122

144123
Resources(
145-
{this.id,
146-
this.href,
124+
{this.href,
147125
this.resourceTypes,
148-
this.interfaces,
149-
this.endpoints,
150-
this.anchor,
151-
this.deviceID,
152-
this.instanceID,
153-
this.title,
154-
this.supportedContentTypes});
126+
this.interfaces});
155127

156128
Resources.fromJson(Map<String, dynamic> json) {
157-
id = json['id'];
158129
href = json['href'];
159130
resourceTypes = json['rt'].cast<String>();
160131
interfaces = json['if'].cast<String>();
161-
if (json['eps'] != null) {
162-
endpoints = new List<Endpoints>();
163-
json['eps'].forEach((v) {
164-
endpoints.add(new Endpoints.fromJson(v));
165-
});
166-
}
167-
anchor = json['anchor'];
168-
deviceID = json['di'];
169-
instanceID = json['ins'];
170-
title = json['title'];
171-
supportedContentTypes = json['type'];
172-
}
173-
}
174-
175-
class Endpoints {
176-
String uRI;
177-
int priority;
178-
179-
Endpoints({this.uRI, this.priority});
180-
181-
Endpoints.fromJson(Map<String, dynamic> json) {
182-
uRI = json['ep'];
183-
priority = json['pri'];
184-
}
185-
186-
Map<String, dynamic> toJson() {
187-
final Map<String, dynamic> data = new Map<String, dynamic>();
188-
data['ep'] = this.uRI;
189-
data['pri'] = this.priority;
190-
return data;
191132
}
192133
}

ocfclient/OCFClient.go

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@ import (
55
"time"
66

77
"github.com/plgd-dev/cloud/grpc-gateway/pb"
8+
grpcCloud "github.com/plgd-dev/cloud/pkg/net/grpc"
89
"github.com/plgd-dev/kit/codec/json"
9-
kitGrpc "github.com/plgd-dev/kit/net/grpc"
1010
"github.com/plgd-dev/kit/security"
11-
"github.com/plgd-dev/kit/strings"
1211
"github.com/plgd-dev/sdk/app"
1312
"github.com/plgd-dev/sdk/local"
1413
"github.com/plgd-dev/sdk/local/core"
1514
"github.com/plgd-dev/sdk/schema"
1615
"github.com/plgd-dev/sdk/schema/acl"
1716
"github.com/plgd-dev/sdk/schema/cloud"
17+
"google.golang.org/protobuf/encoding/protojson"
1818
)
1919

2020
type (
@@ -27,7 +27,7 @@ type (
2727

2828
// Initialize creates and initializes new local client
2929
func (c *Ocfclient) Initialize(accessToken, cloudConfiguration string) error {
30-
err := json.Decode([]byte(cloudConfiguration), &c.cloudConfiguration)
30+
err := protojson.Unmarshal([]byte(cloudConfiguration), &c.cloudConfiguration)
3131
if err != nil {
3232
return err
3333
}
@@ -46,14 +46,15 @@ func (c *Ocfclient) Initialize(accessToken, cloudConfiguration string) error {
4646
SigningServerAddress: c.cloudConfiguration.GetSigningServerAddress(),
4747
JWTClaimOwnerID: c.cloudConfiguration.GetJwtClaimOwnerId(),
4848
},
49-
}, appCallback, func(err error) {})
49+
}, appCallback, nil, func(err error) {})
50+
5051
if err != nil {
5152
return err
5253
}
5354

5455
ctx, cancel := context.WithTimeout(context.Background(), 4*time.Second)
5556
defer cancel()
56-
ctx = kitGrpc.CtxWithToken(ctx, accessToken)
57+
ctx = grpcCloud.CtxWithToken(ctx, accessToken)
5758
err = localClient.Initialization(ctx)
5859
if err != nil {
5960
return err
@@ -89,9 +90,11 @@ func (c *Ocfclient) Discover(timeoutSeconds int) (string, error) {
8990
func getCloudConfiguration(ctx context.Context, device *core.Device, links schema.ResourceLinks) (out interface{}, _ error) {
9091
var link schema.ResourceLink
9192
for _, l := range links {
92-
if strings.SliceContains(l.ResourceTypes, cloud.ConfigurationResourceType) {
93-
link = l
94-
break
93+
for _, rt := range l.ResourceTypes {
94+
if rt == cloud.ConfigurationResourceType {
95+
link = l
96+
break
97+
}
9598
}
9699
}
97100

@@ -107,7 +110,7 @@ func getCloudConfiguration(ctx context.Context, device *core.Device, links schem
107110
func (c *Ocfclient) OwnDevice(deviceID, accessToken string) (string, error) {
108111
ctx, cancel := context.WithTimeout(context.Background(), 20*time.Second)
109112
defer cancel()
110-
ctx = kitGrpc.CtxWithToken(ctx, accessToken)
113+
ctx = grpcCloud.CtxWithToken(ctx, accessToken)
111114
return c.localClient.OwnDevice(ctx, deviceID, local.WithOTM(local.OTMType_JustWorks))
112115
}
113116

ocfclient/build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
gomobile bind --target ios -bundleid dev.plgd -o ../ios/Frameworks/OCFClient.framework
1+
gomobile bind --target ios/arm64 -bundleid dev.plgd -o ../ios/Frameworks/OCFClient.framework

ocfclient/go.mod

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
module github.com/plgd-dev/onboarding/ocfclient
1+
module github.com/plgd-dev/plgd.mobile/ocfclient
22

3-
go 1.14
3+
go 1.16
44

55
require (
6-
github.com/plgd-dev/cloud v1.0.1
7-
github.com/plgd-dev/go-coap/v2 v2.1.2-0.20201106162854-b526118f5e1c // indirect
8-
github.com/plgd-dev/kit v0.0.0-20201012075715-45376a9f2c61
9-
github.com/plgd-dev/sdk v0.0.0-20201028101719-4e0d1c693a90
10-
golang.org/x/mobile v0.0.0-20200801112145-973feb4309de // indirect
6+
github.com/plgd-dev/cloud v1.1.3-0.20210614184948-03b478890cfe
7+
github.com/plgd-dev/kit v0.0.0-20210614190235-99984a49de48
8+
github.com/plgd-dev/sdk v0.0.0-20210629124313-64311af90a6f
9+
golang.org/x/tools v0.1.2 // indirect
10+
google.golang.org/protobuf v1.27.1
1111
)

0 commit comments

Comments
 (0)