esp32-ble2mqtt icon indicating copy to clipboard operation
esp32-ble2mqtt copied to clipboard

/get and /set issues

Open whatdaybob opened this issue 2 years ago • 4 comments

I have followed all the guides and have successfully set up an esp32 to connect and read characteristics but now am having 2 issues. I get intermittent disconnects on the BLE and I also can do a get or set request. Below is my configuration.

{
  "network": {
    "wifi": {
      "ssid": "SSID_NAME",
      "password": "SSID_PASSWORD"
    }
  },
  "mqtt": {
    "server": {
      "host": "MQTT_IP_ADDRESS",
      "port": 1883,
      "ssl": false,
      "username": "MQTT_USERNAME",
      "password": "MQTT_PASSWORD"
    },
    "publish": {
      "retain": true
    },
    "topics": {
      "prefix": "ESP32-BLE/",
      "get_suffix": "/Get",
      "set_suffix": "/Set"
    }
  },

  "ble": {
    "whitelist": ["10:D0:7A:03:E7:83"],
    "services": {
      "definitions": {
        "F5D0BF71-9670-4B25-97F1-861F5EBF0000": {
          "name": "Features"
        },
        "5842062B-3CF8-4D1B-8DFA-5D5120460000": {
          "name": "Network"
        }
      },
      "blacklist": ["8A6B286F-4198-4765-8BFD-17838F2E0000"]
    },
    "characteristics": {
      "definitions": {
        "F5D0BF71-9670-4B25-97F1-861F5EBF0500": {
          "name": "OP_SWITCH_MOODLIGHT",
          "types": ["utf8s"]
        },
        "F5D0BF71-9670-4B25-97F1-861F5EBF0400": {
          "name": "OP_BRIGHTNESS",
          "types": ["utf8s"]
        },
        "F5D0BF71-9670-4B25-97F1-861F5EBF0300": {
          "name": "OP_PLUGGED_INPUTS",
          "types": ["utf8s"]
        },
        "F5D0BF71-9670-4B25-97F1-861F5EBF0200": {
          "name": "OP_SWITCH_INPUT",
          "types": ["utf8s"]
        },
        "F5D0BF71-9670-4B25-97F1-861F5EBF0100": {
          "name": "OP_SWITCH_MODE",
          "types": ["utf8s"]
        },
        "5842062b-3cf8-4d1b-8dfa-5d5120460030": {
          "name": "WIFI_STATUS",
          "types": ["utf8s"]
        }
      },
      "blacklist": [
        "5842062b-3cf8-4d1b-8dfa-5d5120460020",
        "5842062b-3cf8-4d1b-8dfa-5d5120460010",
        "8a6b286f-4198-4765-8bfd-17838f2e0100",
        "8a6b286f-4198-4765-8bfd-17838f2e0200",
        "8a6b286f-4198-4765-8bfd-17838f2e0300"
      ]
    }
  }
}

I try setting both ESP32-BLE/10:d0:7a:03:e7:83/Features/OP_SWITCH_INPUT and ESP32-BLE/10:d0:7a:03:e7:83/Features/OP_SWITCH_INPUT/Set but neither do anything. I can use GATT on a raspberry pi to change the input but nothing happens when I use the esp2mqtt software.

I am unsure how to do debug logging as well, is this detailed anywhere?

whatdaybob avatar Jan 10 '23 04:01 whatdaybob

Hey,

Do you see messages being published on your MQTT bus at all? Do you see the values read from the BLE device sent on the ESP32-BLE/10:d0:7a:03:e7:83/Features/OP_SWITCH_INPUT topic? Debug logs will be very helpful here, you can enable them by executing idf.py menuconfig and go to "Component config" -> "Log output" and change "Default log verbosity" to "Debug"

shmuelzon avatar Jan 10 '23 07:01 shmuelzon

Yeah, the updates happen pretty regularly once connected, sweeps through and updates them all in order approximately 4 times then disconnects for about 40 seconds. Update notifications also work well and in real-time. I will get the debug logs to you as soon as I can.

Sent from Outlook for iOShttps://aka.ms/o0ukef


From: Assaf Inbal @.> Sent: Tuesday, January 10, 2023 7:18:29 AM To: shmuelzon/esp32-ble2mqtt @.> Cc: Martin Jones @.>; Author @.> Subject: Re: [shmuelzon/esp32-ble2mqtt] /get and /set issues (Issue #171)

Hey,

Do you see messages being published on your MQTT bus at all? Do you see the values read from the BLE device sent on the ESP32-BLE/10:d0:7a:03:e7:83/Features/OP_SWITCH_INPUT topic? Debug logs will be very helpful here, you can enable them by executing idf.py menuconfig and go to "Component config" -> "Log output" and change "Default log verbosity" to "Debug"

— Reply to this email directly, view it on GitHubhttps://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fshmuelzon%2Fesp32-ble2mqtt%2Fissues%2F171%23issuecomment-1376829956&data=05%7C01%7C%7C607e80a6ba164543c6fc08daf2dae10d%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C638089319140191325%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=oE46ftB14%2F3WjrM9Em4OkYjxW2VNalgFyYEBYIgzhDs%3D&reserved=0, or unsubscribehttps://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FABLJ34N7NKTOXXCYWSY5RB3WRUEMLANCNFSM6AAAAAATWGIBSY&data=05%7C01%7C%7C607e80a6ba164543c6fc08daf2dae10d%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C638089319140191325%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=QJ3W6I5g1liV%2FxVmqyOZHeDRByDYSY8vU44o6nn8n9U%3D&reserved=0. You are receiving this because you authored the thread.Message ID: @.***>

whatdaybob avatar Jan 10 '23 08:01 whatdaybob

Log file available here.

Couldn't trim it down as I didn't know what is useful or not.

In short it booted. Sat and did nothing except standard MQTT topic (the one with Uptime).

It then connected and created the read characteristics, then disconnected, it did this a few times. I then added /Set MQTT topics into the mix. Nothing happened.

whatdaybob avatar Jan 10 '23 09:01 whatdaybob

Regarding the disconnections, I see the following messages: I (179034) BLE: Connection closed, reason = 0x13. 0x13 is Connection terminate by peer user. In any case, this project doesn't initiate disconnections (except when upgrading) so it's either really the peripheral or something in the ESP32 BLE implementation.

As for setting values, I don't see any MQTT messages arriving. There should be a log message like MQTT: Received: ESP32-BLE/10:d0:7a:03:e7:83/..... Are you sure you've published that message while the device is still connected?

shmuelzon avatar Jan 10 '23 17:01 shmuelzon