Skip to content

service_not_found #261

Description

@erik777

Trying to rewrite the functionality of this cordova plugin example that controls RoboSmart light bulbs in nativescript-vue with this ble plug-in. I'm able to connect to a light. However, there are no services included in the JSON returned by the connect onConnected, though it does connect. There is no perip.services in the object.

I tried moving forward since the cordova code gives me the ID for the service (0xFF10) and the characteristic (0xFF11). At this point, I'm just trying to read the state, which indicates if the light is on or off. When I do, I get back the error service_not_found.

Note that the Cordova app works just fine and can control the bulbs, reading and setting their state, with the code I linked in the first paragraph, on all my phones, Android 11 and 12.

I launched another app, nRF Connect, to diagnose. Unlike when I connected with the ns ble plugin, it is able to get a complete list of services and characteristics. I can expand the 0xFF10 service and see the 0xFF11 characteristic. I can read the state of the light and turn the light on and off by writing a 01 or 00.

The README suggests I should be getting services back via the onConnected. but I am not.

Here you can see part of the screen of nRF where I'm able to interact with the services and characteristics to control the light:

image

Activity

  1. erik777 commented on Dec 22, 2022

    @erik777
    Author

    I was able to get passed it by having it do this on the onConnected

              if (perip.services)
                resolve(perip);
              else {
                this.discoverServices({peripheralUUID: perip.UUID})
                  .then( (result: {services: Service[]}) => {
                    perip.services = result.services;
                    resolve(perip);
                  })
                  .catch(err => reject(err));
              }
    

    And was able to successfully read the on/off state of a light!

  2. farfromrefug commented on Dec 22, 2022

    @farfromrefug
    Member

    @erik777 did you discover services? You can't access services if you didnt

  3. erik777 commented on Dec 22, 2022

    @erik777
    Author

    You might want to update the README because it doesn't mention discoverServices. Are you saying that once you call discoverServices, later, if you call connect again, it provides the services via the cache? I saw a parameter about a cache, so I presume it caches these services after you've called it.

    I have a wrapper around this ble plugin. So, I just put the code in my prior post in my connect, and it behaves the way the README suggests it behaves without needing a pre-flight to discoverServices. One call to the connect, and I get it the services.

    I didn't try discoverCharacteristics or discoverAll, because I was able to read the characteristic value without them, as the characteristicUUID is pre-known in this case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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