commit
234582339d
|
@ -49,10 +49,21 @@ class CloudServiceAPI{
|
||||||
Response r = await get(url, headers: headers);
|
Response r = await get(url, headers: headers);
|
||||||
return json.decode(r.body) as Map<String, dynamic>;
|
return json.decode(r.body) as Map<String, dynamic>;
|
||||||
}
|
}
|
||||||
Future<bool> createDevice(
|
Future<bool> createDevice(id, primaryThumbprint, secondaryThumbprint) async{
|
||||||
id,
|
var url = Uri.https(address, '/api/devices');
|
||||||
primaryThumbprint,
|
Response r = await post(
|
||||||
secondaryThumbprint) async{
|
url,
|
||||||
|
headers: headers,
|
||||||
|
body: jsonEncode(<String, String>{
|
||||||
|
'id': id,
|
||||||
|
'primaryThumbprint' : primaryThumbprint,
|
||||||
|
'secondaryThumbprint' : secondaryThumbprint
|
||||||
|
})
|
||||||
|
);
|
||||||
|
if (r.statusCode == 200){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
debugPrint('Error createDevice: ${r.statusCode.toString()}');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -39,6 +39,8 @@ class _CloudService extends State<CloudService>{
|
||||||
debugPrint('Devices: ${respond1[0].toString()}');
|
debugPrint('Devices: ${respond1[0].toString()}');
|
||||||
var respond2 = await cloudServiceAPI.getInformation();
|
var respond2 = await cloudServiceAPI.getInformation();
|
||||||
debugPrint('Information: ${respond2.toString()}');
|
debugPrint('Information: ${respond2.toString()}');
|
||||||
|
var respond3 = await cloudServiceAPI.createDevice('1', 'asdas', 'sdwe1');
|
||||||
|
debugPrint('CreateDevice: ${respond3.toString()}');
|
||||||
}, child: const Text("Example"),
|
}, child: const Text("Example"),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_provisioning_for_iot/bluetooth_test.dart';
|
import 'package:flutter_provisioning_for_iot/bluetooth_test.dart';
|
||||||
|
import 'package:flutter_provisioning_for_iot/cloud_service_ui.dart';
|
||||||
import 'main_page.dart';
|
import 'main_page.dart';
|
||||||
import 'settings.dart';
|
import 'settings.dart';
|
||||||
|
|
||||||
|
@ -34,6 +35,12 @@ class Sidebar extends StatelessWidget {
|
||||||
Navigator.push(context, MaterialPageRoute(builder: (context) => const BluetoothTest()));
|
Navigator.push(context, MaterialPageRoute(builder: (context) => const BluetoothTest()));
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
ListTile(
|
||||||
|
title: const Text("Cloud Service"),
|
||||||
|
onTap: () {
|
||||||
|
Navigator.push(context, MaterialPageRoute(builder: (context) => const CloudService()));
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|
Loading…
Reference in New Issue