mirror of
				https://github.com/hackku21/loc-chain-app.git
				synced 2025-06-13 12:54:05 +00:00 
			
		
		
		
	update bluetooth
This commit is contained in:
		
							parent
							
								
									13eeafabaa
								
							
						
					
					
						commit
						7b1810f9da
					
				| @ -60,3 +60,116 @@ class Connect { | |||||||
|     } |     } | ||||||
|   } |   } | ||||||
| } | } | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | //  ElevatedButton( | ||||||
|  | //               child: Text("Send Random Bytes Payload"), | ||||||
|  | //               onPressed: () async { | ||||||
|  | //                 endpointMap.forEach((key, value) { | ||||||
|  | //                   String a = Random().nextInt(100).toString(); | ||||||
|  | 
 | ||||||
|  | //                   showSnackbar("Sending $a to ${value.endpointName}, id: $key"); | ||||||
|  | //                   Nearby() | ||||||
|  | //                       .sendBytesPayload(key, Uint8List.fromList(a.codeUnits)); | ||||||
|  | //                 }); | ||||||
|  | //               }, | ||||||
|  | //             ), | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  |   | ||||||
|  | // void onConnectionInit(String id, ConnectionInfo info) { | ||||||
|  | //     showModalBottomSheet( | ||||||
|  | //       context: context, | ||||||
|  | //       builder: (builder) { | ||||||
|  | //         return Center( | ||||||
|  | //           child: Column( | ||||||
|  | //             children: <Widget>[ | ||||||
|  | //               Text("id: " + id), | ||||||
|  | //               Text("Token: " + info.authenticationToken), | ||||||
|  | //               Text("Name" + info.endpointName), | ||||||
|  | //               Text("Incoming: " + info.isIncomingConnection.toString()), | ||||||
|  | //               ElevatedButton( | ||||||
|  | //                 child: Text("Accept Connection"), | ||||||
|  | //                 onPressed: () { | ||||||
|  | //                   Navigator.pop(context); | ||||||
|  | //                   setState(() { | ||||||
|  | //                     endpointMap[id] = info; | ||||||
|  | //                   }); | ||||||
|  | //                   Nearby().acceptConnection( | ||||||
|  | //                     id, | ||||||
|  | //                     onPayLoadRecieved: (endid, payload) async { | ||||||
|  | //                       if (payload.type == PayloadType.BYTES) { | ||||||
|  | //                         String str = String.fromCharCodes(payload.bytes!); | ||||||
|  | //                         showSnackbar(endid + ": " + str); | ||||||
|  | 
 | ||||||
|  | //                         if (str.contains(':')) { | ||||||
|  | //                           // used for file payload as file payload is mapped as | ||||||
|  | //                           // payloadId:filename | ||||||
|  | //                           int payloadId = int.parse(str.split(':')[0]); | ||||||
|  | //                           String fileName = (str.split(':')[1]); | ||||||
|  | 
 | ||||||
|  | //                           if (map.containsKey(payloadId)) { | ||||||
|  | //                             if (await tempFile!.exists()) { | ||||||
|  | //                               tempFile!.rename( | ||||||
|  | //                                   tempFile!.parent.path + "/" + fileName); | ||||||
|  | //                             } else { | ||||||
|  | //                               showSnackbar("File doesn't exist"); | ||||||
|  | //                             } | ||||||
|  | //                           } else { | ||||||
|  | //                             //add to map if not already | ||||||
|  | //                             map[payloadId] = fileName; | ||||||
|  | //                           } | ||||||
|  | //                         } | ||||||
|  | //                       } else if (payload.type == PayloadType.FILE) { | ||||||
|  | //                         showSnackbar(endid + ": File transfer started"); | ||||||
|  | //                         tempFile = File(payload.filePath!); | ||||||
|  | //                       } | ||||||
|  | //                     }, | ||||||
|  | //                     onPayloadTransferUpdate: (endid, payloadTransferUpdate) { | ||||||
|  | //                       if (payloadTransferUpdate.status == | ||||||
|  | //                           PayloadStatus.IN_PROGRESS) { | ||||||
|  | //                         print(payloadTransferUpdate.bytesTransferred); | ||||||
|  | //                       } else if (payloadTransferUpdate.status == | ||||||
|  | //                           PayloadStatus.FAILURE) { | ||||||
|  | //                         print("failed"); | ||||||
|  | //                         showSnackbar(endid + ": FAILED to transfer file"); | ||||||
|  | //                       } else if (payloadTransferUpdate.status == | ||||||
|  | //                           PayloadStatus.SUCCESS) { | ||||||
|  | //                         showSnackbar( | ||||||
|  | //                             "$endid success, total bytes = ${payloadTransferUpdate.totalBytes}"); | ||||||
|  | 
 | ||||||
|  | //                         if (map.containsKey(payloadTransferUpdate.id)) { | ||||||
|  | //                           //rename the file now | ||||||
|  | //                           String name = map[payloadTransferUpdate.id]!; | ||||||
|  | //                           tempFile!.rename(tempFile!.parent.path + "/" + name); | ||||||
|  | //                         } else { | ||||||
|  | //                           //bytes not received till yet | ||||||
|  | //                           map[payloadTransferUpdate.id] = ""; | ||||||
|  | //                         } | ||||||
|  | //                       } | ||||||
|  | //                     }, | ||||||
|  | //                   ); | ||||||
|  | //                 }, | ||||||
|  | //               ), | ||||||
|  | //               ElevatedButton( | ||||||
|  | //                 child: Text("Reject Connection"), | ||||||
|  | //                 onPressed: () async { | ||||||
|  | //                   Navigator.pop(context); | ||||||
|  | //                   try { | ||||||
|  | //                     await Nearby().rejectConnection(id); | ||||||
|  | //                   } catch (e) { | ||||||
|  | //                     showSnackbar(e); | ||||||
|  | //                   } | ||||||
|  | //                 }, | ||||||
|  | //               ), | ||||||
|  | //             ], | ||||||
|  | //           ), | ||||||
|  | //         ); | ||||||
|  | //       }, | ||||||
|  | //     ); | ||||||
|  | //   } | ||||||
|  | // } | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user