This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
uint8 timerNotify = 0; | |
uint8 bleConnected = 0; | |
uint8 count = 0; | |
CYBLE_CONN_HANDLE_T connectionHandle; | |
static volatile uint32_t millisecondTimerCount = 0u; | |
/************************************************************ | |
* This function is the handler for BLE stack events | |
* | |
* Arguments: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FloatingActionButton( | |
onPressed: () { | |
_ledChar.write([0xff, 0xff, 0xff, 0x10]); | |
}, | |
tooltip: 'Increment', | |
child: Icon(Icons.add), | |
), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
final FlutterBlue flutterBlue = FlutterBlue.instance; | |
BluetoothCharacteristic _ledChar; | |
var _myService = "bb89ad38-c3a8-4e49-8c9f-b15573ee9a70"; | |
var _myChar = "a404a877-90d8-44ae-af73-92a17ede3d11"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bool _getLEDChar(List<BluetoothService> services) { | |
for (BluetoothService s in services) { | |
if (s.uuid.toString() == _myService) { | |
var characteristics = s.characteristics; | |
for (BluetoothCharacteristic c in characteristics) { | |
if (c.uuid.toString() == _myChar) { | |
_ledChar = c; | |
return true; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void _connectDevice(BluetoothDevice device) async { | |
flutterBlue.stopScan(); | |
try { | |
await device.connect(); | |
} catch (e) { | |
if (e.code != 'already_connected') { | |
throw e; | |
} | |
} finally { | |
List<BluetoothService> services = await device.discoverServices(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void _incrementCounter() { | |
flutterBlue.scanResults.listen((List<ScanResult> results) { | |
for (ScanResult result in results) { | |
if (result.device.name == "customGlow") { | |
_connectDevice(result.device); | |
} | |
} | |
}); | |
flutterBlue.startScan(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dependencies: | |
flutter: | |
sdk: flutter | |
cupertino_icons: ^0.1.2 | |
flutter_blue: ^0.7.2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
final String endPoint = 'http://10.0.2.2:8000/analyze'; | |
void _upload(File file) async { | |
String fileName = file.path.split('/').last; | |
print(fileName); | |
FormData data = FormData.fromMap({ | |
"file": await MultipartFile.fromFile( | |
file.path, | |
filename: fileName, | |
), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void _choose() async { | |
File file; | |
file = await ImagePicker.pickImage( | |
source: ImageSource.camera, | |
); | |
if (file != null) { | |
haveImg = true; | |
futureImg = _upload(file); | |
setState(() {}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void _choose() async { | |
} | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
appBar: AppBar( | |
title: Text(widget.title), | |
), | |
body: Center( |
NewerOlder