Thread (17 messages) 17 messages, 2 authors, 2012-09-20

Re: [PATCH v3 06/10] battery: Get Battery ID

flat view

From: Chen Ganir <hidden>
Date: 2012-09-20 11:03:14

Anderson,

On 09/20/2012 01:46 PM, Anderson Lizardo wrote:
Hi Chen,

On Thu, Sep 20, 2012 at 4:27 AM,  [off-list ref] wrote:
quoted
@@ -150,31 +200,35 @@ static void configure_battery_cb(GSList *characteristics, guint8 status,

         for (l = characteristics; l; l = l->next) {
                 struct gatt_char *c = l->data;
-               struct characteristic *ch;
-               uint16_t start, end;
-
-               ch = g_new0(struct characteristic, 1);
-               ch->attr.handle = c->handle;
-               ch->attr.properties = c->properties;
-               ch->attr.value_handle = c->value_handle;
-               memcpy(ch->attr.uuid, c->uuid, MAX_LEN_UUID_STR + 1);
-               ch->batt = batt;

-               batt->chars = g_slist_append(batt->chars, ch);
-
-               start = c->value_handle + 1;
-
-               if (l->next != NULL) {
-                       struct gatt_char *c = l->next->data;
-                       if (start == c->handle)
+               if (g_strcmp0(c->uuid, BATTERY_LEVEL_UUID) == 0) {
Minor comment, but looks like it would be cleaner if you used:

if (g_strcmp0(c->uuid, BATTERY_LEVEL_UUID) != 0)
     continue;

and avoided all this shifting and one more level of indentation.
I'll change that. It does make more sense.

quoted
+                       struct characteristic *ch;
+                       uint16_t start, end;
+
+                       ch = g_new0(struct characteristic, 1);
+                       ch->attr.handle = c->handle;
+                       ch->attr.properties = c->properties;
+                       ch->attr.value_handle = c->value_handle;
+                       memcpy(ch->attr.uuid, c->uuid, MAX_LEN_UUID_STR + 1);
+                       ch->batt = batt;
+
+                       batt->chars = g_slist_append(batt->chars, ch);
+
+                       start = c->value_handle + 1;
+
+                       if (l->next != NULL) {
+                               struct gatt_char *c = l->next->data;
+                               if (start == c->handle)
+                                       continue;
+                               end = c->handle - 1;
+                       } else if (c->value_handle != batt->svc_range->end)
+                               end = batt->svc_range->end;
+                       else
                                 continue;
-                       end = c->handle - 1;
-               } else if (c->value_handle != batt->svc_range->end)
-                       end = batt->svc_range->end;
-               else
-                       continue;

-               gatt_find_info(batt->attrib, start, end, discover_desc_cb, ch);
+                       gatt_find_info(batt->attrib, start, end,
+                                                       discover_desc_cb, ch);
+               }
         }
  }
Regards,
Thanks,

-- 
BR,
Chen Ganir
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help