Skip to content

Peer-client mode can't enumerate more than one peer #72

Description

@davidchatting-bot

Where

Two sites in `src/YoYoWiFiManager.cpp`:

`countPeers()`:
```cpp
case YY_MODE_PEER_CLIENT:
//TODO: this should use the list from the gateway and count those elements
if(currentStatus == YY_CONNECTED_PEER_CLIENT) count = 1; //is connected to the server
break;
```

`getPeerN()`:
```cpp
case YY_MODE_PEER_CLIENT:
//TODO: implement
break;
```

Problem

While a device is in `YY_MODE_PEER_CLIENT`, `countPeers()` always reports 0 or 1 (itself connected to the server), regardless of how many other peers are actually on the network - it never asks the gateway for the real peer list the way `getPeersAsJson()`'s `YY_MODE_PEER_CLIENT` branch already does (it `GET`s `/yoyo/peers` from the gateway directly). `getPeerN()`'s `YY_MODE_PEER_CLIENT` case is unimplemented entirely, though as far as I can tell nothing currently calls `getPeerN()` while in that mode, so it may be dead code today rather than an active bug.

Loosely related to #42 (GET /yoyo/peers fails on ESP8266 in peer-client mode) but distinct - that's about the request failing outright on ESP8266, this is about `countPeers()`/`getPeerN()` under-reporting even when the request succeeds.

Ask

Have `countPeers()` (in `YY_MODE_PEER_CLIENT`) fetch and count the gateway's peer list the same way `getPeersAsJson()` already does, rather than hardcoding 0/1. If `getPeerN()`'s `YY_MODE_PEER_CLIENT` case does turn out to be genuinely unreachable, consider removing the TODO/case rather than leaving it as a silent gap.

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