@@ -48,7 +48,7 @@ func NewClient(cred *config.Credentials) (*Client, error) {
48
48
49
49
// DeviceCreate allows to create a new device on Arduino IoT Cloud.
50
50
// It returns the newly created device, and an error.
51
- func (cl * Client ) DeviceCreate (ctx context.Context , fqbn , name , serial , dType string ) (* iotclient.ArduinoDevicev2 , error ) {
51
+ func (cl * Client ) DeviceCreate (ctx context.Context , fqbn , name , serial , dType string , cType * string ) (* iotclient.ArduinoDevicev2 , error ) {
52
52
ctx , err := ctxWithToken (ctx , cl .token )
53
53
if err != nil {
54
54
return nil , err
@@ -60,6 +60,11 @@ func (cl *Client) DeviceCreate(ctx context.Context, fqbn, name, serial, dType st
60
60
Serial : serial ,
61
61
Type : dType ,
62
62
}
63
+
64
+ if cType != nil {
65
+ payload .ConnectionType = * cType
66
+ }
67
+
63
68
dev , _ , err := cl .api .DevicesV2Api .DevicesV2Create (ctx , payload , nil )
64
69
if err != nil {
65
70
err = fmt .Errorf ("creating device, %w" , errorDetail (err ))
@@ -85,7 +90,8 @@ func (cl *Client) DeviceLoraCreate(ctx context.Context, name, serial, devType, e
85
90
Type : devType ,
86
91
UserId : "me" ,
87
92
}
88
- dev , _ , err := cl .api .LoraDevicesV1Api .LoraDevicesV1Create (ctx , payload )
93
+
94
+ dev , _ , err := cl .api .LoraDevicesV1Api .LoraDevicesV1Create (ctx , payload , nil )
89
95
if err != nil {
90
96
err = fmt .Errorf ("creating lora device: %w" , errorDetail (err ))
91
97
return nil , err
0 commit comments