netguru / blueswift Goto Github PK
View Code? Open in Web Editor NEWSwift framework for easy connection with Bluetooth peripherals.
License: MIT License
Swift framework for easy connection with Bluetooth peripherals.
License: MIT License
I get the following error,
/Users/rlotech/Documents/BlueSwift-master/Framework/Source Files/Command/Command.swift:30:5: 'internal' modifier is redundant for instance method declared in an internal extension
actually i want to develop bluetooth low energy where central application send data to peripheral and that peripheral app is on ios and android platform so is this possible using your library
Hi!
I installed library using cocoapods. It is not compiled
place internal extension AdvertisementData
method internal var data: Any? {
case .servicesUUIDs(let uuid):
return try? [CBUUID(uuidString: uuid)] -> Maybe [try? CBUUID(uuidString: uuid)]
With best wishes
Now writing is only possible with response. It would be nice to have possibility of choosing type of write requests, as some peripherals might advertise characteristic with only writeWithoutResponse property.
I am attempting to write to a characteristic. The first time I run the code below, it works and my peripheral is written to and I receive a callback handler for "write" function with no error. Then, when I attempt to run the same exact code a second time, the peripheral is written to but I do not receive a callback handler.
Note: I am using the "develop" branch because the changes to read/write validation were necessary to make the write work in the first place... If you can merge this into master I would much appreciate it.
Here is the example code:
let characteristic1 = try! Characteristic(uuid: "EXAMPLE")
let characteristic2 = try! Characteristic(uuid: "EXAMPLE")
let service = try! Service(uuid: uuid, characteristics: [characteristic1, characteristic2])
let configuration = try! Configuration(services: [service], advertisement: uuid)
let peripheral = Peripheral(configuration: configuration)
// connect to the peripheral
connection.connect(peripheral) { [weak self] error in
guard error == nil else {
return
}
let command = Command.int8(1)
// write command to characteristic1
peripheral.write(command: command,
characteristic: characteristic1,
type: .withResponse)
{ (error) in
// on second run, this handler code does not execute
guard error == nil else {
// if error writing, read characteristic2
peripheral.read(errorCharacteristic) { (result, error) in
guard let result = result else {
self?.connection.disconnect(peripheral)
return
}
var resultNumber: UInt8 = 0
result.copyBytes(to:&resultNumber, count: MemoryLayout<UInt8>.size)
print(resultNumber)
self?.connection.disconnect(peripheral)
}
return
}
// always disconnect
self?.connection.disconnect(peripheral)
}
}
hi i want to match advertisement string for example from peripheral side it advertise "gtpV5nm8Znm" and central side it scan for "gtpV5nm8Znm" if both match then central able to write data so how is it possible i put this string with let configuration = try! Configuration(services: [service], advertisement: "1004FD87-820F-438A-B757-7AC2C15C2D56") but it give me error
Reproduction steps:
Bluetooth.xcodeproj
with Xcode 10.1 (10B61)Connection
or Advertisement
buttonCrash log:
'[<UIViewController 0x7fbba8d1ed70> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key notifyLabel.'
*** First throw call stack:
(
0 CoreFoundation 0x000000010d6a71bb __exceptionPreprocess + 331
1 libobjc.A.dylib 0x000000010c100735 objc_exception_throw + 48
2 CoreFoundation 0x000000010d6a6d29 -[NSException raise] + 9
3 Foundation 0x000000010bb2bde4 -[NSObject(NSKeyValueCoding) setValue:forKey:] + 292
4 UIKitCore 0x0000000111a87292 -[UIViewController setValue:forKey:] + 87
5 UIKitCore 0x0000000111d1e573 -[UIRuntimeOutletConnection connect] + 109
6 CoreFoundation 0x000000010d692cfd -[NSArray makeObjectsPerformSelector:] + 317
7 UIKitCore 0x0000000111d1b2b9 -[UINib instantiateWithOwner:options:] + 1814
8 UIKitCore 0x0000000111a8e452 -[UIViewController _loadViewFromNibNamed:bundle:] + 383
9 UIKitCore 0x0000000111a8eddc -[UIViewController loadView] + 177
10 UIKitCore 0x0000000111a8f0ee -[UIViewController loadViewIfRequired] + 175
11 UIKitCore 0x0000000111a8f940 -[UIViewController view] + 27
12 UIKitCore 0x00000001119d9a9b -[UINavigationController _startCustomTransition:] + 931
13 UIKitCore 0x00000001119f03f0 -[UINavigationController _startDeferredTransitionIfNeeded:] + 741
14 UIKitCore 0x00000001119f17e0 -[UINavigationController __viewWillLayoutSubviews] + 150
15 UIKitCore 0x00000001119d1600 -[UILayoutContainerView layoutSubviews] + 217
16 UIKitCore 0x0000000112598795 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1441
17 QuartzCore 0x0000000113b20b19 -[CALayer layoutSublayers] + 175
18 QuartzCore 0x0000000113b259d3 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 395
19 QuartzCore 0x0000000113a9e7ca _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 342
20 QuartzCore 0x0000000113ad597e _ZN2CA11Transaction6commitEv + 576
21 UIKitCore 0x00000001120a8701 _UIApplicationFlushRunLoopCATransactionIfTooLate + 165
22 UIKitCore 0x00000001121a2569 __handleEventQueueInternal + 6874
23 CoreFoundation 0x000000010d60c721 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
24 CoreFoundation 0x000000010d60bf93 __CFRunLoopDoSources0 + 243
25 CoreFoundation 0x000000010d60663f __CFRunLoopRun + 1263
26 CoreFoundation 0x000000010d605e11 CFRunLoopRunSpecific + 625
27 GraphicsServices 0x0000000115cb51dd GSEventRunModal + 62
28 UIKitCore 0x00000001120ae81d UIApplicationMain + 140
29 BlueSwiftSample 0x000000010b7405b7 main + 71
30 libdyld.dylib 0x000000010e089575 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
SPM support would be great for this
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.