or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

automation-triggers.mddashboard-management.mddevice-management.mdindex.mdlora-device-management.mdnetwork-credentials.mdproperty-management.mdthing-management.mdtimeseries-analytics.md

network-credentials.mddocs/

0

# Network Credentials

1

2

Network credentials management for device connectivity configuration. Manage Wi-Fi credentials and network connection information for IoT devices.

3

4

## Capabilities

5

6

### Network Credentials Operations

7

8

Retrieve and manage network credentials for device connectivity.

9

10

```javascript { .api }

11

class NetworkCredentialsV1Api {

12

/**

13

* Get network credentials by type

14

* @param type - Network credential type (e.g., 'wifi', 'cellular')

15

* @param opts - Optional parameters including organization ID

16

* @returns Promise<ArduinoCredentialsv1> - Network credentials information

17

*/

18

networkCredentialsV1Show(type: string, opts?: any): Promise<ArduinoCredentialsv1>;

19

20

/**

21

* Get network credentials by device association

22

* @param type - Network credential type

23

* @param opts - Optional parameters including organization ID and device filters

24

* @returns Promise<ArduinoCredentialsv1[]> - Network credentials with device connections

25

*/

26

networkCredentialsV1ShowByDevice(type: string, opts?: any): Promise<ArduinoCredentialsv1[]>;

27

}

28

```

29

30

### Template Management

31

32

Apply templates for creating standardized things and devices configurations.

33

34

```javascript { .api }

35

class TemplatesApi {

36

/**

37

* Apply a template to create things and devices from predefined configurations

38

* @param template - Template configuration with things, devices, and properties

39

* @param opts - Optional parameters including organization ID

40

* @returns Promise<ArduinoTemplate> - Applied template result with created entities

41

*/

42

templatesApply(template: Template, opts?: any): Promise<ArduinoTemplate>;

43

}

44

```

45

46

## Data Models

47

48

```javascript { .api }

49

interface ArduinoCredentialsv1 {

50

connectionType?: string;

51

createdAt?: Date;

52

id?: string;

53

name?: string;

54

organizationId?: string;

55

password?: string;

56

ssid?: string;

57

type?: string;

58

updatedAt?: Date;

59

userId?: string;

60

}

61

62

interface ArduinoTemplate {

63

createdAt?: Date;

64

devices?: ArduinoDevicev2templatedevice[];

65

href?: string;

66

id?: string;

67

name?: string;

68

organizationId?: string;

69

things?: ArduinoThingtemplate[];

70

updatedAt?: Date;

71

userId?: string;

72

}

73

74

interface Template {

75

devices?: ArduinoLinkedDeviceTemplate[];

76

name: string;

77

things?: ArduinoThingtemplate[];

78

}

79

80

interface ArduinoLinkedDeviceTemplate {

81

deviceId?: string;

82

fqbn?: string;

83

name?: string;

84

serial?: string;

85

type?: string;

86

}

87

88

interface ArduinoDevicev2templatedevice {

89

fqbn?: string;

90

name?: string;

91

type?: string;

92

}

93

94

interface ArduinoThingtemplate {

95

name?: string;

96

properties?: ArduinoTemplateproperty[];

97

timezone?: string;

98

webhookUri?: string;

99

}

100

101

interface ArduinoTemplateproperty {

102

maxValue?: number;

103

minValue?: number;

104

name?: string;

105

permission?: PropertyPermission;

106

persist?: boolean;

107

type?: PropertyType;

108

updateParameter?: number;

109

updateStrategy?: PropertyUpdateStrategy;

110

variableName?: string;

111

}

112

```

113

114

**Network Credentials and Template Examples:**

115

116

```javascript

117

import ArduinoIotClient from '@arduino/arduino-iot-client';

118

119

const networkCredentialsApi = new ArduinoIotClient.NetworkCredentialsV1Api();

120

const templatesApi = new ArduinoIotClient.TemplatesApi();

121

122

// Retrieve Wi-Fi credentials

123

async function getWiFiCredentials() {

124

try {

125

const wifiCredentials = await networkCredentialsApi.networkCredentialsV1Show('wifi');

126

127

console.log('Wi-Fi Credentials:');

128

console.log(`- SSID: ${wifiCredentials.ssid}`);

129

console.log(`- Type: ${wifiCredentials.type}`);

130

console.log(`- Connection Type: ${wifiCredentials.connectionType}`);

131

console.log(`- Created: ${wifiCredentials.createdAt}`);

132

133

return wifiCredentials;

134

} catch (error) {

135

console.error('Failed to retrieve Wi-Fi credentials:', error);

136

throw error;

137

}

138

}

139

140

// Get network credentials by device

141

async function getNetworkCredentialsByDevice() {

142

try {

143

const deviceCredentials = await networkCredentialsApi.networkCredentialsV1ShowByDevice('wifi');

144

145

console.log('Network credentials by device:');

146

deviceCredentials.forEach((credential, index) => {

147

console.log(`Device ${index + 1}:`);

148

console.log(` - Name: ${credential.name}`);

149

console.log(` - SSID: ${credential.ssid}`);

150

console.log(` - Type: ${credential.type}`);

151

});

152

153

return deviceCredentials;

154

} catch (error) {

155

console.error('Failed to retrieve network credentials by device:', error);

156

throw error;

157

}

158

}

159

160

// Apply a comprehensive IoT template

161

async function applySensorNetworkTemplate() {

162

try {

163

const template = {

164

name: "Environmental Monitoring Network",

165

things: [

166

{

167

name: "Indoor Climate Monitor",

168

timezone: "America/New_York",

169

properties: [

170

{

171

name: "Temperature",

172

type: "TEMPERATURE",

173

permission: "READ_ONLY",

174

updateStrategy: "ON_CHANGE",

175

variableName: "temperature",

176

persist: true,

177

minValue: -10,

178

maxValue: 50

179

},

180

{

181

name: "Humidity",

182

type: "HUMIDITY",

183

permission: "READ_ONLY",

184

updateStrategy: "TIMED",

185

updateParameter: 60,

186

variableName: "humidity",

187

persist: true,

188

minValue: 0,

189

maxValue: 100

190

},

191

{

192

name: "Air Quality Index",

193

type: "INT",

194

permission: "READ_ONLY",

195

updateStrategy: "TIMED",

196

updateParameter: 300,

197

variableName: "airQuality",

198

persist: true,

199

minValue: 0,

200

maxValue: 500

201

}

202

]

203

},

204

{

205

name: "Outdoor Weather Station",

206

timezone: "America/New_York",

207

properties: [

208

{

209

name: "Temperature",

210

type: "TEMPERATURE",

211

permission: "READ_ONLY",

212

updateStrategy: "ON_CHANGE",

213

variableName: "outdoorTemp",

214

persist: true,

215

minValue: -40,

216

maxValue: 60

217

},

218

{

219

name: "Humidity",

220

type: "HUMIDITY",

221

permission: "READ_ONLY",

222

updateStrategy: "TIMED",

223

updateParameter: 120,

224

variableName: "outdoorHumidity",

225

persist: true,

226

minValue: 0,

227

maxValue: 100

228

},

229

{

230

name: "Pressure",

231

type: "PRESSURE",

232

permission: "READ_ONLY",

233

updateStrategy: "TIMED",

234

updateParameter: 300,

235

variableName: "pressure",

236

persist: true,

237

minValue: 950,

238

maxValue: 1050

239

},

240

{

241

name: "Wind Speed",

242

type: "VELOCITY",

243

permission: "READ_ONLY",

244

updateStrategy: "ON_CHANGE",

245

variableName: "windSpeed",

246

persist: true,

247

minValue: 0,

248

maxValue: 200

249

}

250

]

251

}

252

],

253

devices: [

254

{

255

name: "Indoor Sensor Node",

256

fqbn: "arduino:samd:nano_33_iot",

257

type: "nano_33_iot"

258

},

259

{

260

name: "Outdoor Weather Station",

261

fqbn: "arduino:samd:mkrwifi1010",

262

type: "mkrwifi1010"

263

}

264

]

265

};

266

267

console.log('Applying environmental monitoring template...');

268

const appliedTemplate = await templatesApi.templatesApply(template);

269

270

console.log('Template applied successfully:');

271

console.log(`- Template ID: ${appliedTemplate.id}`);

272

console.log(`- Created Things: ${appliedTemplate.things?.length || 0}`);

273

console.log(`- Created Devices: ${appliedTemplate.devices?.length || 0}`);

274

275

// List created entities

276

if (appliedTemplate.things) {

277

console.log('\nCreated Things:');

278

appliedTemplate.things.forEach((thing, index) => {

279

console.log(`${index + 1}. ${thing.name}`);

280

console.log(` Properties: ${thing.properties?.length || 0}`);

281

console.log(` Timezone: ${thing.timezone}`);

282

});

283

}

284

285

if (appliedTemplate.devices) {

286

console.log('\nCreated Devices:');

287

appliedTemplate.devices.forEach((device, index) => {

288

console.log(`${index + 1}. ${device.name}`);

289

console.log(` FQBN: ${device.fqbn}`);

290

console.log(` Type: ${device.type}`);

291

});

292

}

293

294

return appliedTemplate;

295

296

} catch (error) {

297

console.error('Failed to apply template:', error);

298

throw error;

299

}

300

}

301

302

// Create a reusable sensor template

303

async function createStandardSensorTemplate() {

304

try {

305

const standardSensorTemplate = {

306

name: "Standard Sensor Template",

307

things: [

308

{

309

name: "Generic Sensor Thing",

310

timezone: "UTC",

311

properties: [

312

{

313

name: "Value",

314

type: "FLOAT",

315

permission: "READ_ONLY",

316

updateStrategy: "ON_CHANGE",

317

variableName: "sensorValue",

318

persist: true

319

},

320

{

321

name: "Battery Level",

322

type: "PERCENT",

323

permission: "READ_ONLY",

324

updateStrategy: "TIMED",

325

updateParameter: 3600, // Every hour

326

variableName: "batteryLevel",

327

persist: true,

328

minValue: 0,

329

maxValue: 100

330

},

331

{

332

name: "Status",

333

type: "STRING",

334

permission: "READ_ONLY",

335

updateStrategy: "ON_CHANGE",

336

variableName: "status",

337

persist: false

338

}

339

]

340

}

341

],

342

devices: [

343

{

344

name: "Generic Sensor Device",

345

fqbn: "arduino:samd:nano_33_iot",

346

type: "nano_33_iot"

347

}

348

]

349

};

350

351

const template = await templatesApi.templatesApply(standardSensorTemplate);

352

console.log(`Created standard sensor template: ${template.id}`);

353

354

return template;

355

356

} catch (error) {

357

console.error('Failed to create standard sensor template:', error);

358

throw error;

359

}

360

}

361

362

// Network setup workflow

363

async function setupNetworkAndTemplate() {

364

try {

365

console.log('Setting up network credentials and template workflow...');

366

367

// 1. Check network credentials

368

console.log('\n=== Network Credentials ===');

369

await getWiFiCredentials();

370

await getNetworkCredentialsByDevice();

371

372

// 2. Apply comprehensive template

373

console.log('\n=== Template Application ===');

374

const envTemplate = await applySensorNetworkTemplate();

375

376

// 3. Create reusable standard template

377

console.log('\n=== Standard Template Creation ===');

378

await createStandardSensorTemplate();

379

380

console.log('\nNetwork and template setup completed successfully');

381

return envTemplate;

382

383

} catch (error) {

384

if (error.status === 400) {

385

console.error('Bad request - check template configuration');

386

} else if (error.status === 404) {

387

console.error('Network credentials not found');

388

} else {

389

console.error('Network setup error:', error.detail || error.message);

390

}

391

}

392

}

393

```