From 9a665239a1e98b7a2709cae610c76d15ebf22a12 Mon Sep 17 00:00:00 2001 From: Olivier Martin Date: Thu, 27 Jun 2019 14:39:40 +0200 Subject: [PATCH] examples/read_write: Clarify error message --- examples/read_write/read_write.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/examples/read_write/read_write.c b/examples/read_write/read_write.c index 22f8fd5..0a8a0e0 100644 --- a/examples/read_write/read_write.c +++ b/examples/read_write/read_write.c @@ -2,7 +2,7 @@ * * GattLib - GATT Library * - * Copyright (C) 2016-2017 Olivier Martin + * Copyright (C) 2016-2019 Olivier Martin * * * This program is free software; you can redistribute it and/or modify @@ -83,7 +83,12 @@ int main(int argc, char *argv[]) { gattlib_uuid_to_string(&g_uuid, uuid_str, sizeof(uuid_str)); - fprintf(stderr, "Could not find GATT Characteristic with UUID %s (ret:%d)\n", uuid_str, ret); + if (ret == GATTLIB_NOT_FOUND) { + fprintf(stderr, "Could not find GATT Characteristic with UUID %s. " + "You might call the program with '--gatt-discovery'.\n", uuid_str); + } else { + fprintf(stderr, "Error while reading GATT Characteristic with UUID %s (ret:%d)\n", uuid_str, ret); + } goto EXIT; } @@ -101,7 +106,13 @@ int main(int argc, char *argv[]) { gattlib_uuid_to_string(&g_uuid, uuid_str, sizeof(uuid_str)); - fprintf(stderr, "Could not find GATT Characteristic with UUID %s (ret:%d)\n", uuid_str, ret); + if (ret == GATTLIB_NOT_FOUND) { + fprintf(stderr, "Could not find GATT Characteristic with UUID %s. " + "You might call the program with '--gatt-discovery'.\n", uuid_str); + } else { + fprintf(stderr, "Error while writing GATT Characteristic with UUID %s (ret:%d)\n", + uuid_str, ret); + } goto EXIT; } }