Skip to content

Commit 7408bfd

Browse files
Add "backpack.list" command
1 parent b3186a6 commit 7408bfd

File tree

3 files changed

+20
-10
lines changed

3 files changed

+20
-10
lines changed

Scout.cpp

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,19 +45,10 @@ void PinoccioScout::setup(bool isForcedLeadScout) {
4545
delay(5);
4646
bp.begin(BACKPACK_BUS);
4747
if (!bp.enumerate()) {
48+
Serial.print("Backpack enumeration failed: ");
4849
bp.printLastError(Serial);
4950
Serial.println();
5051
}
51-
//Serial.println("Backpacks found:");
52-
for (uint8_t i = 0; i < bp.num_slaves; ++i) {
53-
for (uint8_t j = 0; j < UNIQUE_ID_LENGTH; ++j) {
54-
if (bp.slave_ids[i][j] < 0x10) {
55-
Serial.print('0');
56-
}
57-
//Serial.print(bp.slave_ids[i][j]);
58-
}
59-
//Serial.println();
60-
}
6152

6253
handler.setup();
6354
Shell.setup();

Shell.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ void PinoccioShell::setup() {
6868
addBitlashFunction("pin.report", (bitlash_function) pinReport);
6969

7070
addBitlashFunction("backpack.report", (bitlash_function) backpackReport);
71+
addBitlashFunction("backpack.list", (bitlash_function) backpackList);
7172

7273
addBitlashFunction("scout.report", (bitlash_function) scoutReport);
7374
addBitlashFunction("scout.isleadscout", (bitlash_function) isScoutLeadScout);
@@ -525,6 +526,23 @@ static numvar backpackReport(void) {
525526
sp("[{\"name\":\"wifi\",\"version\":\"1.0\"},{\"name\":\"environment\",\"version\":\"2.0\"}]");
526527
}
527528

529+
static numvar backpackList(void) {
530+
if (Scout.bp.num_slaves == 0) {
531+
Serial.println("No backpacks found");
532+
} else {
533+
for (uint8_t i = 0; i < Scout.bp.num_slaves; ++i) {
534+
for (uint8_t j = 0; j < UNIQUE_ID_LENGTH; ++j) {
535+
if (Scout.bp.slave_ids[i][j] < 0x10) {
536+
Serial.print('0');
537+
}
538+
Serial.print(Scout.bp.slave_ids[i][j]);
539+
}
540+
Serial.println();
541+
}
542+
}
543+
return 0;
544+
}
545+
528546
/****************************\
529547
* SCOUT REPORT HANDLERS *
530548
\****************************/

Shell.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ static numvar pinThreshold(void);
9191
static numvar pinReport(void);
9292

9393
static numvar backpackReport(void);
94+
static numvar backpackList(void);
9495

9596
static numvar scoutReport(void);
9697
static numvar isScoutLeadScout(void);

0 commit comments

Comments
 (0)