Skip to content

Commit

Permalink
fix(hci): addressing issue on ubuntu 24 by updating hci layer (#2)
Browse files Browse the repository at this point in the history
* fix(hci): update to node bluetooth hci socket 1.3.0

* chore: cleanup after squash

---------

Co-authored-by: Marek Serafin <[email protected]>
  • Loading branch information
stoprocent and Marek Serafin authored Sep 27, 2024
1 parent 8b3a162 commit 6452ef2
Show file tree
Hide file tree
Showing 9 changed files with 4,949 additions and 3,688 deletions.
5 changes: 3 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
module.exports = {
root: true,
extends: ['eslint:recommended', 'semistandard'],
extends: ['eslint:recommended'],
parserOptions: {
ecmaVersion: 2017
},
env: {
browser: true,
mocha: true,
node: true
node: true,
es6: true
},
globals: {
Promise: true
Expand Down
30 changes: 16 additions & 14 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
name: Build
on:
push:
branches:
- main
- beta
pull_request:
concurrency:
group: build-${{ github.ref }}
cancel-in-progress: false
Expand All @@ -13,7 +11,7 @@ jobs:
matrix:
include:
- name: darwin
os: macos-11
os: macos-12
node: x64
command: prebuildify
args: --arch x64+arm64
Expand All @@ -40,17 +38,19 @@ jobs:
name: Build ${{ matrix.name }}
runs-on: ${{ matrix.os }}
steps:
- if: matrix.os == 'macos-12'
run: sudo -H pip install setuptools
- if: matrix.node
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 18.x
node-version: 20.x
architecture: ${{ matrix.node }}
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- run: npm ci
- run: npm run ${{ matrix.command }} -- ${{ matrix.args }}
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: build-artifacts
name: build-artifacts-${{ matrix.name }}
path: prebuilds/
if-no-files-found: error
- if: failure()
Expand All @@ -60,15 +60,17 @@ jobs:
needs: prebuild
name: Release
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v3
- uses: actions/download-artifact@v3
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: build-artifacts
path: prebuilds
- uses: actions/setup-node@v3
pattern: build-artifacts-*
merge-multiple: true
- uses: actions/setup-node@v4
with:
node-version: 18.x
node-version: 20.x
- run: npm ci
- run: npm run semantic-release
env:
Expand Down
18 changes: 18 additions & 0 deletions .github/workflows/commit-message-validator.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: "Commit message validation on pull request"

on: pull_request

jobs:
commit-message-validation:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Commit message validation
uses: lumapps/commit-message-validator@master
with:
no_jira: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
18 changes: 10 additions & 8 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,31 +9,33 @@ jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 18.x
node-version: 20.x
- run: npm ci
- run: npm run lint
test:
runs-on: ${{ matrix.config.os }}
strategy:
matrix:
node-version: [16.x, 18.x, 20.x]
node-version: [18.x, 20.x]
config:
# arch isn't used and we have no way to use it currently
- { os: macos-latest, arch: x64 }
- { os: macos-12, arch: x64 }
- { os: ubuntu-latest, arch: x64 }
- { os: windows-2019, arch: x64 }
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- if: matrix.config.os == 'macos-12'
run: sudo -H pip install setuptools
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- run: npm ci
- run: npm run rebuild
- run: npm test
- run: npm run coverage
- uses: codecov/codecov-action@v3
- uses: codecov/codecov-action@v4
with:
directory: ./coverage/
42 changes: 21 additions & 21 deletions lib/mac/src/ble_peripheral_manager.mm
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ @implementation BLEPeripheralManager

- (instancetype)init {
if (self = [super init]) {
NSLog(@"-[BLEPeripheralManager init]");
// NSLog(@"-[BLEPeripheralManager init]");

self.queue = dispatch_queue_create("CBqueue", 0);
}
Expand All @@ -36,7 +36,7 @@ - (void)start {
}

- (void)startAdvertising:(nonnull NSString *)name serviceUUIDs:(nonnull NSArray<CBUUID *> *)serviceUUIDs {
NSLog(@"startAdvertising:%@ serviceUUIDs:%@", name, serviceUUIDs);
// NSLog(@"startAdvertising:%@ serviceUUIDs:%@", name, serviceUUIDs);
if (self.peripheralManager.isAdvertising) {
return;
}
Expand All @@ -48,19 +48,19 @@ - (void)startAdvertising:(nonnull NSString *)name serviceUUIDs:(nonnull NSArray<
}

- (void)startAdvertisingIBeacon:(NSData *)data {
NSLog(@"startAdvertisingIBeacon:%@", data);
// NSLog(@"startAdvertisingIBeacon:%@", data);
}

- (void)startAdvertisingWithEIRData:(NSData *)data {
NSLog(@"startAdvertisingWithEIRData:%@", data);
// NSLog(@"startAdvertisingWithEIRData:%@", data);

if (self.peripheralManager.isAdvertising) {
return;
}
}

- (void)stopAdvertising {
NSLog(@"stopAdvertising");
// NSLog(@"stopAdvertising");

[self.peripheralManager stopAdvertising];
}
Expand All @@ -72,13 +72,13 @@ - (void)setServices:(NSArray<CBMutableService *> *)services {
}

- (void)disconnect {
NSLog(@"disconnect");
// NSLog(@"disconnect");

// throw new Error('disconnect is not supported on OS X!');
}

- (void)updateRssi {
NSLog(@"updateRssi");
// NSLog(@"updateRssi");
}

#pragma mark - CBPeripheralManagerDelegate
Expand Down Expand Up @@ -111,36 +111,36 @@ - (void)peripheralManagerDidUpdateState:(CBPeripheralManager *)peripheral {
break;
}

NSLog(@"%@", string);
// NSLog(@"%@", string);

auto state = StringFromCBPeripheralState(peripheral.state);
emit.StateChange(state);
}

- (void)peripheralManager:(CBPeripheralManager *)peripheral willRestoreState:(NSDictionary<NSString *, id> *)dict {
NSLog(@"willRestoreState");
// NSLog(@"willRestoreState");
}

- (void)peripheralManagerDidStartAdvertising:(CBPeripheralManager *)peripheral error:(nullable NSError *)error {
NSLog(@"peripheralManagerDidStartAdvertising: %@", peripheral.description);
// NSLog(@"peripheralManagerDidStartAdvertising: %@", peripheral.description);
if (error) {
NSLog(@"Error advertising: %@", [error localizedDescription]);
// NSLog(@"Error advertising: %@", [error localizedDescription]);
}

emit.AdvertisingStart();
}

- (void)peripheralManager:(CBPeripheralManager *)peripheral didAddService:(CBService *)service error:(nullable NSError *)error {
NSLog(@"peripheralManagerDidAddService: %@ %@", service, error);
// NSLog(@"peripheralManagerDidAddService: %@ %@", service, error);
if (error) {
NSLog(@"Error publishing service: %@", [error localizedDescription]);
// NSLog(@"Error publishing service: %@", [error localizedDescription]);
}

emit.ServicesSet();
}

- (void)peripheralManager:(CBPeripheralManager *)peripheral central:(CBCentral *)central didSubscribeToCharacteristic:(CBMutableCharacteristic *)characteristic {
NSLog(@"didSubscribeToCharacteristic");
// NSLog(@"didSubscribeToCharacteristic");

CBUUID *uuid = characteristic.UUID;

Expand All @@ -164,7 +164,7 @@ - (void)peripheralManager:(CBPeripheralManager *)peripheral central:(CBCentral *
}

- (void)peripheralManager:(CBPeripheralManager *)peripheral central:(CBCentral *)central didUnsubscribeFromCharacteristic:(CBCharacteristic *)characteristic {
NSLog(@"didUnsubscribeFromCharacteristic");
// NSLog(@"didUnsubscribeFromCharacteristic");

CBUUID *uuid = characteristic.UUID;

Expand All @@ -176,7 +176,7 @@ - (void)peripheralManager:(CBPeripheralManager *)peripheral central:(CBCentral *
}

- (void)peripheralManager:(CBPeripheralManager *)peripheral didReceiveReadRequest:(CBATTRequest *)request {
NSLog(@"didReceiveReadRequest: %@ %@", request.central, request.characteristic.UUID);
// NSLog(@"didReceiveReadRequest: %@ %@", request.central, request.characteristic.UUID);

CBCharacteristic *characteristic = request.characteristic;
CBUUID *uuid = characteristic.UUID;
Expand All @@ -197,7 +197,7 @@ - (void)peripheralManager:(CBPeripheralManager *)peripheral didReceiveReadReques

- (void)peripheralManager:(CBPeripheralManager *)peripheral didReceiveWriteRequests:(NSArray<CBATTRequest *> *)requests {
for (CBATTRequest *request in requests) {
NSLog(@"didReceiveWriteRequest: %@ %@", request.central, request.characteristic.UUID);
// NSLog(@"didReceiveWriteRequest: %@ %@", request.central, request.characteristic.UUID);

CBCharacteristic *characteristic = request.characteristic;
CBUUID *uuid = characteristic.UUID;
Expand All @@ -223,19 +223,19 @@ - (void)peripheralManager:(CBPeripheralManager *)peripheral didReceiveWriteReque
}

- (void)peripheralManagerIsReadyToUpdateSubscribers:(CBPeripheralManager *)peripheral {
NSLog(@"peripheralManagerIsReadyToUpdateSubscribers");
// NSLog(@"peripheralManagerIsReadyToUpdateSubscribers");
}

- (void)peripheralManager:(CBPeripheralManager *)peripheral didPublishL2CAPChannel:(CBL2CAPPSM)PSM error:(nullable NSError *)error {
NSLog(@"didPublishL2CAPChannel");
// NSLog(@"didPublishL2CAPChannel");
}

- (void)peripheralManager:(CBPeripheralManager *)peripheral didUnpublishL2CAPChannel:(CBL2CAPPSM)PSM error:(nullable NSError *)error {
NSLog(@"didUnpublishL2CAPChannel");
// NSLog(@"didUnpublishL2CAPChannel");
}

- (void)peripheralManager:(CBPeripheralManager *)peripheral didOpenL2CAPChannel:(nullable CBL2CAPChannel *)channel error:(nullable NSError *)error {
NSLog(@"didOpenL2CAPChannel");
// NSLog(@"didOpenL2CAPChannel");
}

@end
16 changes: 8 additions & 8 deletions lib/mac/src/bleno_mac.mm
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
}

Napi::Value BlenoMac::Init(const Napi::CallbackInfo& info) {
NSLog(@"BlenoMac::Init");
// NSLog(@"BlenoMac::Init");

Napi::Function emit = info.This().As<Napi::Object>().Get("emit").As<Napi::Function>();
peripheralManager = [BLEPeripheralManager new];
Expand All @@ -64,7 +64,7 @@

// startAdvertising(name, undashedServiceUuids)
Napi::Value BlenoMac::StartAdvertising(const Napi::CallbackInfo& info) {
NSLog(@"BlenoMac::StartAdvertising");
// NSLog(@"BlenoMac::StartAdvertising");

CHECK_MANAGER();
ARG2(String, Array);
Expand All @@ -80,28 +80,28 @@

// startAdvertisingIBeacon(iBeaconData)
Napi::Value BlenoMac::StartAdvertisingIBeacon(const Napi::CallbackInfo& info) {
NSLog(@"BlenoMac::StartAdvertisingIBeacon");
// NSLog(@"BlenoMac::StartAdvertisingIBeacon");

return Napi::Value();
}

// startAdvertisingWithEIRData(advertisementData, scanData)
Napi::Value BlenoMac::StartAdvertisingWithEIRData(const Napi::CallbackInfo& info) {
NSLog(@"BlenoMac::StartAdvertisingWithEIRData");
// NSLog(@"BlenoMac::StartAdvertisingWithEIRData");

return Napi::Value();
}

// stopAdvertising()
Napi::Value BlenoMac::StopAdvertising(const Napi::CallbackInfo& info) {
NSLog(@"BlenoMac::StopAdvertising");
// NSLog(@"BlenoMac::StopAdvertising");

return Napi::Value();
}

// setServices(services)
Napi::Value BlenoMac::SetServices(const Napi::CallbackInfo& info) {
NSLog(@"BlenoMac::SetServices");
// NSLog(@"BlenoMac::SetServices");

CHECK_MANAGER();
ARG1(Array);
Expand Down Expand Up @@ -131,14 +131,14 @@

// disconnect()
Napi::Value BlenoMac::Disconnect(const Napi::CallbackInfo& info) {
NSLog(@"BlenoMac::Disconnect");
// NSLog(@"BlenoMac::Disconnect");

return Napi::Value();
}

// updateRssi()
Napi::Value BlenoMac::UpdateRssi(const Napi::CallbackInfo& info) {
NSLog(@"BlenoMac::UpdateRssi");
// NSLog(@"BlenoMac::UpdateRssi");

return Napi::Value();
}
Expand Down
Loading

0 comments on commit 6452ef2

Please sign in to comment.