Skip to content

onConnectionStateChanged forwarding object, can't get the services. #1

@ioiofadhil

Description

@ioiofadhil

Hi. I appreciate you creating this package. Helps me a lot.

I noticed that this package, on onConnectionStateChanged manager function, doesn't forward the whole object, instead just the state name and error message if there's any

onConnectionStateChanged(data: {
  state: ConnectionState
  error: BleErrorCode | null
  message: string
  android?: { status: number }
  ios?: { code: number; description: string }
  services?: BleServiceInfo[]
}): void

onConnectionStateChanged(callback: (state: ConnectionState, error: BleError | null) => void): EventSubscription {
  return ReactNativeBleLibraryModule.addListener('onConnectionStateChanged', ({ state, error, message }) => {
    if (error) {
      callback(state, new BleError(error as BleErrorCode, message))
    } else {
      callback(state, null)
    }
  })
}

So I need to do something like this to get the list of services

const subscription = ReactNativeBleLibraryModule.addListener("onConnectionStateChanged", () => {})

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions