Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature mac dev #294

Open
wants to merge 27 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
3073768
update script for arch64
Oct 26, 2023
592cae5
add bin2csv feature
salman2135 Nov 2, 2023
e502902
update connection on sys exit
salman2135 Nov 9, 2023
b47a739
fix flake8 , prune redundant code
salman2135 Nov 9, 2023
7d97d6c
sort imports
salman2135 Nov 9, 2023
17a77f0
update parser file imports
salman2135 Nov 9, 2023
5850273
add pyserial to dependency
salman2135 Nov 10, 2023
ef27778
APIS-864: remove bokeh
salman2135 Nov 17, 2023
be9ae02
Added pyyaml as requirement
SonjaSt Nov 17, 2023
7c57a6c
conditional import of exploresdk
salman2135 Nov 20, 2023
1ea6aa7
add reconnection message
salman2135 Nov 21, 2023
4554d01
remove library copy for mac
salman2135 Nov 21, 2023
001b2ed
remove sdk.py file from src
salman2135 Nov 21, 2023
7bc92f1
update .so file, remove unused variable
salman2135 Nov 22, 2023
ca0ab20
fix isort error
salman2135 Nov 22, 2023
dfcd69e
add exploresdk.py to src folder again
salman2135 Nov 22, 2023
46ae6c0
restore old sdk file
salman2135 Nov 23, 2023
09009a9
update bt_unstable message
salman2135 Nov 30, 2023
c4b36bf
Merge branch 'develop' into feature-mac-dev
salman2135 Dec 13, 2023
0a74c25
update blueutil path
salman2135 Jan 17, 2024
afd52a3
Merge branch 'develop' into feature-mac-dev
salman2135 Jan 17, 2024
7725789
improve connection in iobluetooth
salman2135 Jan 24, 2024
1771a87
copy lib file to src from setup
salman2135 Jan 24, 2024
68e0aa3
Merge branch 'develop' into feature-mac-dev
salman2135 Feb 1, 2024
7a98a12
update sdk.py file
salman2135 Feb 5, 2024
e77342c
Merge branch 'develop' into feature-mac-dev
salman2135 Feb 6, 2024
921c9a6
Merge branch 'develop' into feature-mac-dev
salman2135 Feb 12, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
43 changes: 17 additions & 26 deletions lib/mac/BTSerialPortBinding.mm
Expand Up @@ -56,31 +56,22 @@

int BTSerialPortBinding::Connect()
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSString *addressString = [NSString stringWithCString:address.c_str() encoding:NSASCIIStringEncoding];
BluetoothWorker *worker = [BluetoothWorker getInstance];
// create pipe to communicate with delegate

pipe_t *pipe = pipe_new(sizeof(unsigned char), 0);
int status;
NSString *nsId = [NSString stringWithCString:address.c_str() encoding:NSASCIIStringEncoding];

IOReturn result = [worker connectDevice: addressString onChannel:channelID withPipe:pipe];

if (result == kIOReturnSuccess) {
pipe_consumer_t *c = pipe_consumer_new(pipe);
IOBluetoothDevice *device = nil;
device = [IOBluetoothDevice deviceWithAddressString:nsId];
NSArray *recentDevices = [IOBluetoothDevice recentDevices:0];

// save consumer side of the pipe
data->consumer = c;
status = 0;
} else {
status = 1;
NSArray *byName = [recentDevices filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"name == %@", nsId]];
if (byName.count > 0) {
device = byName.firstObject;
}
if ([device openConnection] != kIOReturnSuccess) {
return -1;
}

pipe_free(pipe);
[pool release];


return status;
return 0;
}

void BTSerialPortBinding::Close()
Expand All @@ -97,22 +88,22 @@
cout << "Socket closed as data consumer is null" << endl;
throw ExploreIOException("BT socket is closed!");
}


if (buffer == nullptr)
return;

size_buffer = -1;

size_buffer = pipe_pop_eager(data->consumer, buffer, *length);

if (size_buffer == 0) {
pipe_consumer_free(data->consumer);
data->consumer = NULL;
cout << "Possible socket closure, raising IO Exception" << endl;
throw ExploreIOException("BT socket is closed!");


}
if(size_buffer < *length){
if(isSocketClosed){
Expand All @@ -126,7 +117,7 @@
}

// when no data is read from rfcomm the connection has been closed.

}

void BTSerialPortBinding::Write(const char *buffer, int length)
Expand Down
Binary file modified lib/mac/_exploresdk.so
Binary file not shown.
9 changes: 9 additions & 0 deletions setup.py
Expand Up @@ -78,6 +78,15 @@ def read(*names, **kwargs):
extra_link_args=["-lbluetooth"],
swig_opts=['-c++']
))
else:
if sys.version_info >= (3, 7):
my_req.append('pyobjc-core>=6')
my_req.append('pyobjc-framework-Cocoa>=6')
else:
my_req.append('pyobjc-core>=3.1,<6')
my_req.append('pyobjc-framework-Cocoa>=3.1,<6')
os.system('cp lib/mac/_exploresdk.so src/explorepy')
os.system('cp lib/mac/exploresdk.py src/explorepy')
setup(
name='explorepy',
version='2.0.0',
Expand Down
2 changes: 1 addition & 1 deletion src/explorepy/__init__.py
Expand Up @@ -23,11 +23,11 @@
__version__ = '2.0.0'

this = sys.modules[__name__]
from . import exploresdk
list_sdk = ['sdk', 'mock', 'pyserial']
if sys.platform == 'darwin':
this._bt_interface = 'pyserial'
else:
from . import exploresdk
this._bt_interface = 'sdk'

if not sys.version_info >= (3, 6):
Expand Down