Skip to content
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
59 changes: 30 additions & 29 deletions apps/AntiTheft/Nodes/antitheft.h
Original file line number Diff line number Diff line change
@@ -1,47 +1,48 @@
// $Id: antitheft.h,v 1.3 2007-04-04 22:06:22 idgay Exp $
/*
* Copyright (c) 2007 Intel Corporation
* All rights reserved.
*
* This file is distributed under the terms in the attached INTEL-LICENSE
* file. If you do not find these files, copies can be found by writing to
* Intel Research Berkeley, 2150 Shattuck Avenue, Suite 1300, Berkeley, CA,
* 94704. Attention: Intel License Inquiry.
*/
/**
*
* @author David Gay
*/
#ifndef ANTITHEFT_H
#define ANTITHEFT_H

enum {
ALERT_LEDS = 1,
ALERT_SOUND = 2,
ALERT_RADIO = 4,
ALERT_ROOT = 8,
ALERT_LEDS = 1 << 0, // Use bit shift for clarity
ALERT_SOUND = 1 << 1,
ALERT_RADIO = 1 << 2,
ALERT_ROOT = 1 << 3,

DETECT_DARK = 1,
DETECT_ACCEL = 2,

AM_SETTINGS = 54,
AM_THEFT = 99,
AM_ALERT = 22,
DIS_SETTINGS = 42,
COL_ALERTS = 11,
DETECT_DARK = 1 << 0, // Use bit shift for clarity
DETECT_ACCEL = 1 << 1,

DEFAULT_ALERT = ALERT_LEDS,
DEFAULT_DETECT = DETECT_DARK,
DEFAULT_CHECK_INTERVAL = 1000
};

// Use enum for message types to avoid magic numbers
typedef enum {
AM_SETTINGS = 54,
AM_THEFT = 99,
AM_ALERT = 22,
DIS_SETTINGS = 42,
COL_ALERTS = 11
} message_types_t;

// Struct to hold anti-theft system settings
typedef nx_struct settings {
nx_uint8_t alert, detect;
nx_uint16_t checkInterval;
nx_uint8_t alert; // Bitmask for alert types (e.g., ALERT_LEDS | ALERT_SOUND)
nx_uint8_t detect; // Bitmask for detection types (e.g., DETECT_DARK | DETECT_ACCEL)
nx_uint16_t checkInterval; // Time interval for checking
} settings_t;

// Struct for alert messages
typedef nx_struct alert {
nx_uint16_t stolenId;
nx_uint16_t stolenId; // ID of the stolen item
} alert_t;

// Utility macros for setting and checking bitmask flags
#define SET_ALERT_TYPE(settings, type) ((settings).alert |= (type))
#define CLEAR_ALERT_TYPE(settings, type) ((settings).alert &= ~(type))
#define IS_ALERT_TYPE_SET(settings, type) ((settings).alert & (type))

#define SET_DETECT_TYPE(settings, type) ((settings).detect |= (type))
#define CLEAR_DETECT_TYPE(settings, type) ((settings).detect &= ~(type))
#define IS_DETECT_TYPE_SET(settings, type) ((settings).detect & (type))

#endif
Loading