To try out the nearbyAPI, I decided to build an app that would allow a teacher to track attendance of student in a class. Similar to what Caren Chang is doing.
I hav
That's a great use case, and one we've talked about in the past.
If it's specifically for attendance, then you don't need to form a connection. You can have each device advertise while one device constantly scans. You'll build up a list of devices quickly that way.
If you want to do more than attendance, though, such as pushing an assignment to everyone's device, you'll need to build a mesh. To start with, you'll want to use Strategy.P2P_CLUSTER. We have 3 strategies available inside Nearby Connections (CLUSTER, STAR, POINT_TO_POINT) and cluster is the most general one. With cluster, you can connect to as many devices as you want, and you can receive incoming connections from as many devices as you want. Or, almost... The Bluetooth radio inside phones is weak and can only hold 3~4 connections at a time.
To be able to connect all ~30 devices, I'd recommend forming a 'snake-like' connection. The head and tail of the device will scan and advertise at the same time (and devices that aren't connected to anyone are considered snakes of length 1). The heads and tails will keep connecting to each other (being sure not to connect to itself*), and you'll pretty quickly have a long chain of connections connecting everyone together. From there, you can forward messages down the chain to make sure everyone gets it.