Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update old code to see dc27 badges #1

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion Software/modules/ble.c
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ static void ble_evt_handler(ble_evt_t const *p_ble_evt, void *p_context) {

// Parsed OK
// Is this a defcon badge?
if (adv.appearance == badgeYear_25 || adv.appearance == badgeYear_26) {
if (getBadgeYear(adv.appearance)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd recommend checking for not zero rather than treating this as a boolean

// Yes

BADGE_ADV badge;
Expand Down Expand Up @@ -730,6 +730,29 @@ void advertising_setGodCommand(GODMODE_COMMAND command, uint32_t data){

}

/**
* @param year we want info on
* @return string, group name
*/
uint8_t getBadgeYear(BADGE_YEAR year){
switch (year)
{
case badgeYear_25:
return 25;
break;
case badgeYear_26:
return 26;
break;
case badgeYear_27:
return 27;
break;
default: // code to be executed if n doesn't match any cases
return 0;
break;
}
return 0;
}

/**
* @param group we want info on
* @return string, group name
Expand Down
2 changes: 2 additions & 0 deletions Software/modules/ble.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ typedef struct{
typedef enum {
badgeYear_25 = 0x19DC,
badgeYear_26 = 0x26DC,
badgeYear_27 = 0x27DC,
NUM_BADGE_YEARS
} BADGE_YEAR;

Expand Down Expand Up @@ -89,6 +90,7 @@ bool parseAdvertisementData(uint8_t *data, uint8_t len, ADVERTISEMENT *adv);
uint8_t getBadges(BADGE_ADV *badges);
bool getBadge(uint8_t index, BADGE_ADV *badge);
uint8_t getBadgeNum(void);
uint8_t getBadgeYear(BADGE_YEAR year);
char* getBadgeGroupName(BADGE_GROUP group);
char* getBadgeIconFile(BADGE_GROUP group);
char* getBadgeContact(BADGE_GROUP group);
Expand Down
3 changes: 2 additions & 1 deletion Software/nearby.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,11 @@ static void drawItems(BADGE_ADV *badge, uint8_t numItems, uint8_t startRow){
util_gfx_set_font(FONT_VERAMONO_5PT);

// First row
printf("numItems %d", numItems);
snprintf(row, 25, "%d %02X%02X%02X%02X%02X%02X DC%d", i + startRow + 1,
badge[i + startRow].mac[0], badge[i + startRow].mac[1], badge[i + startRow].mac[2],
badge[i + startRow].mac[3], badge[i + startRow].mac[4], badge[i + startRow].mac[5],
badge[i + startRow].year == badgeYear_25 ? 25 : 26);
getBadgeYear(badge[i + startRow].year));
util_gfx_print(row);

// Second row
Expand Down