commit
234582339d
|
@ -49,10 +49,21 @@ class CloudServiceAPI{
|
|||
Response r = await get(url, headers: headers);
|
||||
return json.decode(r.body) as Map<String, dynamic>;
|
||||
}
|
||||
Future<bool> createDevice(
|
||||
id,
|
||||
primaryThumbprint,
|
||||
secondaryThumbprint) async{
|
||||
Future<bool> createDevice(id, primaryThumbprint, secondaryThumbprint) async{
|
||||
var url = Uri.https(address, '/api/devices');
|
||||
Response r = await post(
|
||||
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;
|
||||
}
|
||||
}
|
|
@ -39,6 +39,8 @@ class _CloudService extends State<CloudService>{
|
|||
debugPrint('Devices: ${respond1[0].toString()}');
|
||||
var respond2 = await cloudServiceAPI.getInformation();
|
||||
debugPrint('Information: ${respond2.toString()}');
|
||||
var respond3 = await cloudServiceAPI.createDevice('1', 'asdas', 'sdwe1');
|
||||
debugPrint('CreateDevice: ${respond3.toString()}');
|
||||
}, child: const Text("Example"),
|
||||
),
|
||||
),
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import 'package:flutter/material.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 'settings.dart';
|
||||
|
||||
|
@ -34,6 +35,12 @@ class Sidebar extends StatelessWidget {
|
|||
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