├── firmware └── nRF51 │ ├── tag-ipv6 │ ├── .gitignore │ ├── lib │ │ ├── .gitignore │ │ └── softdevice.s │ ├── inc │ │ └── config.h │ ├── Makefile │ └── src │ │ └── main.c │ ├── tag-proximity │ ├── inc │ │ ├── .gitignore │ │ ├── flash.h │ │ ├── rng.h │ │ ├── radio.h │ │ ├── adc.h │ │ ├── main.h │ │ ├── timer.h │ │ ├── aes.h │ │ ├── acc.h │ │ ├── config.h │ │ └── openbeacon-proto.h │ ├── Makefile │ └── src │ │ ├── timer.c │ │ ├── adc.c │ │ ├── main.c │ │ └── rng.c │ ├── .gitignore │ ├── core │ ├── linker │ │ ├── nrf51822.ld │ │ └── nrf5.ld │ ├── nrf │ │ ├── inc │ │ │ ├── nrf.h │ │ │ ├── system_nrf51.h │ │ │ └── nrf_temp.h │ │ └── src │ │ │ └── system_nrf5.c │ ├── openbeacon │ │ ├── inc │ │ │ ├── crc8.h │ │ │ ├── crc32.h │ │ │ ├── helper.h │ │ │ ├── crc16.h │ │ │ ├── uart.h │ │ │ ├── debug_printf.h │ │ │ ├── xxtea.h │ │ │ └── openbeacon.h │ │ └── src │ │ │ ├── helper.c │ │ │ ├── crc16.c │ │ │ ├── debug_printf.c │ │ │ ├── xxtea.c │ │ │ └── crc8.c │ └── startup │ │ └── inc │ │ └── nrf5.h │ ├── reader-ble │ ├── Makefile │ ├── inc │ │ ├── main.h │ │ ├── timer.h │ │ ├── radio.h │ │ └── config.h │ └── src │ │ └── timer.c │ ├── reader-prox │ ├── Makefile │ ├── inc │ │ ├── main.h │ │ ├── timer.h │ │ ├── radio.h │ │ └── config.h │ └── src │ │ ├── timer.c │ │ └── main.c │ ├── tag-ble-beacon │ ├── Makefile │ ├── inc │ │ ├── radio.h │ │ ├── flash.h │ │ ├── adc.h │ │ ├── main.h │ │ ├── timer.h │ │ ├── acc.h │ │ └── config.h │ └── src │ │ ├── timer.c │ │ ├── adc.c │ │ └── main.c │ ├── tag-physical-web │ ├── Makefile │ ├── entry.c │ ├── lib │ │ ├── inc │ │ │ ├── flash.h │ │ │ ├── adc.h │ │ │ ├── main.h │ │ │ ├── radio.h │ │ │ ├── timer.h │ │ │ ├── lib.h │ │ │ ├── acc.h │ │ │ └── config.h │ │ └── src │ │ │ ├── timer.c │ │ │ ├── main.c │ │ │ └── adc.c │ └── README.md │ ├── tag-mischief │ ├── Makefile │ ├── db-update.php │ ├── inc │ │ ├── flash.h │ │ ├── radio.h │ │ ├── adc.h │ │ ├── main.h │ │ ├── name.h │ │ ├── timer.h │ │ ├── acc.h │ │ └── config.h │ └── src │ │ ├── timer.c │ │ ├── adc.c │ │ └── main.c │ └── tag-power │ ├── inc │ ├── flash.h │ ├── rng.h │ ├── radio.h │ ├── adc.h │ ├── main.h │ ├── timer.h │ ├── aes.h │ ├── acc.h │ ├── config.h │ └── openbeacon-proto.h │ ├── Makefile │ └── src │ ├── timer.c │ ├── adc.c │ ├── main.c │ └── rng.c ├── host ├── openbeacon-cape │ ├── .gitignore │ ├── Makefile │ ├── crc32.h │ ├── helper.h │ ├── crc16.h │ ├── openbeacon.h │ ├── crc16.c │ └── helper.c ├── openbeacon-power │ ├── .gitignore │ ├── Makefile │ └── src │ │ ├── crypto.h │ │ └── bmMapHandleToItem.h └── openbeacon-rx │ ├── .gitignore │ ├── src │ ├── crypto.h │ └── bmMapHandleToItem.h │ └── Makefile └── hardware ├── Hardware-License.pdf ├── tag-proximity ├── design │ ├── OpenBeacon.PcbDoc │ └── OpenBeacon.SchDoc ├── documentation │ ├── OpenBeacon-Proximity-Tag-BL_PCB.PDF │ └── OpenBeacon-Proximity-Tag-BL_SCH.PDF └── production │ └── OpenBeacon-Proximity-Tag-BL_GERBER.zip └── readme.md /firmware/nRF51/tag-ipv6/.gitignore: -------------------------------------------------------------------------------- 1 | *.zip 2 | -------------------------------------------------------------------------------- /firmware/nRF51/tag-ipv6/lib/.gitignore: -------------------------------------------------------------------------------- 1 | /Nordic 2 | *.bin -------------------------------------------------------------------------------- /host/openbeacon-cape/.gitignore: -------------------------------------------------------------------------------- 1 | *.o 2 | openbeacon_forwarder -------------------------------------------------------------------------------- /firmware/nRF51/tag-proximity/inc/.gitignore: -------------------------------------------------------------------------------- 1 | custom-encryption-key.h 2 | -------------------------------------------------------------------------------- /firmware/nRF51/.gitignore: -------------------------------------------------------------------------------- 1 | *.o 2 | *.bin 3 | *.map 4 | *.elf 5 | *.asm 6 | *.log -------------------------------------------------------------------------------- /hardware/Hardware-License.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/henryk/openbeacon-ng/HEAD/hardware/Hardware-License.pdf -------------------------------------------------------------------------------- /host/openbeacon-power/.gitignore: -------------------------------------------------------------------------------- 1 | .depend 2 | .cproject 3 | .project 4 | .settings 5 | openbeacon-power 6 | callgrind.out.* 7 | *.o 8 | *~ 9 | -------------------------------------------------------------------------------- /hardware/tag-proximity/design/OpenBeacon.PcbDoc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/henryk/openbeacon-ng/HEAD/hardware/tag-proximity/design/OpenBeacon.PcbDoc -------------------------------------------------------------------------------- /hardware/tag-proximity/design/OpenBeacon.SchDoc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/henryk/openbeacon-ng/HEAD/hardware/tag-proximity/design/OpenBeacon.SchDoc -------------------------------------------------------------------------------- /firmware/nRF51/core/linker/nrf51822.ld: -------------------------------------------------------------------------------- 1 | MEMORY 2 | { 3 | flash : ORIGIN = 0x00000000, LENGTH = 128K 4 | ram : ORIGIN = 0x20000000, LENGTH = 16K 5 | } 6 | 7 | INCLUDE "../core/linker/nrf5.ld" -------------------------------------------------------------------------------- /hardware/tag-proximity/documentation/OpenBeacon-Proximity-Tag-BL_PCB.PDF: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/henryk/openbeacon-ng/HEAD/hardware/tag-proximity/documentation/OpenBeacon-Proximity-Tag-BL_PCB.PDF -------------------------------------------------------------------------------- /hardware/tag-proximity/documentation/OpenBeacon-Proximity-Tag-BL_SCH.PDF: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/henryk/openbeacon-ng/HEAD/hardware/tag-proximity/documentation/OpenBeacon-Proximity-Tag-BL_SCH.PDF -------------------------------------------------------------------------------- /hardware/tag-proximity/production/OpenBeacon-Proximity-Tag-BL_GERBER.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/henryk/openbeacon-ng/HEAD/hardware/tag-proximity/production/OpenBeacon-Proximity-Tag-BL_GERBER.zip -------------------------------------------------------------------------------- /host/openbeacon-rx/.gitignore: -------------------------------------------------------------------------------- 1 | .depend 2 | .cproject 3 | .project 4 | .settings 5 | openbeacon-rx 6 | filter-singularsighting 7 | src/custom-encryption-keys.h 8 | callgrind.out.* 9 | *.o 10 | *~ 11 | -------------------------------------------------------------------------------- /firmware/nRF51/tag-ipv6/lib/softdevice.s: -------------------------------------------------------------------------------- 1 | .section .softdevice.text, "x" 2 | __softdevice_text_start: 3 | .incbin "lib/softdevice.bin" 4 | .align 12 5 | __softdevice_text_end: 6 | 7 | .section .softdevice.bss,"awM",@nobits 8 | __softdevice_bss_start: 9 | .space 0x2000 10 | __softdevice_bss_end: 11 | -------------------------------------------------------------------------------- /host/openbeacon-cape/Makefile: -------------------------------------------------------------------------------- 1 | CC := g++ 2 | CPPFLAGS := -D_THREAD_SAFE -D_REENTRANT 3 | CFLAGS := -O3 -W -Wall -Werror -I. 4 | LDLIBS := 5 | 6 | TARGET := openbeacon_forwarder 7 | SOURCES := $(TARGET).c helper.c crc32.c crc16.c 8 | OBJECTS := $(patsubst %.c,%.o,$(SOURCES)) 9 | 10 | all: $(TARGET) 11 | 12 | $(TARGET): $(OBJECTS) 13 | $(CC) $(CFLAGS) $(CPPFLAGS) $^ -o $@ 14 | 15 | clean: 16 | rm -f $(TARGET) $(OBJECTS) *.core *~ 17 | -------------------------------------------------------------------------------- /firmware/nRF51/reader-ble/Makefile: -------------------------------------------------------------------------------- 1 | TARGET=reader-ble 2 | ARCH=nrf5 3 | CPU=$(ARCH)1822 4 | DEBUG=-g 5 | OPTIM=-Os -mword-relocations 6 | 7 | APP_CFLAGS=-Iinc -std=gnu99 -fgnu89-inline -D__USE_CMSIS 8 | APP_LDFLAGS=-lm 9 | 10 | APP_SRC= \ 11 | src/radio.c \ 12 | src/timer.c \ 13 | src/main.c 14 | 15 | APP_SRC+=$(IMAGES_C) 16 | 17 | all: $(TARGET).bin 18 | 19 | publish: clean $(TARGET).bin 20 | scp $(TARGET).bin openbeacon.org:/home/wwwrun/open.bitmanufaktur.com/web/www/people/milosch/nrf5/ 21 | 22 | app_clean: 23 | find src -name '*.o' -exec rm \{\} \; 24 | 25 | clean_all: clean 26 | rm -f README $(CUSTOM_KEY) 27 | 28 | include ../core/Makefile.rules 29 | -------------------------------------------------------------------------------- /firmware/nRF51/reader-prox/Makefile: -------------------------------------------------------------------------------- 1 | TARGET=reader-prox 2 | ARCH=nrf5 3 | CPU=$(ARCH)1822 4 | DEBUG=-g 5 | OPTIM=-Os -mword-relocations 6 | 7 | APP_CFLAGS=-Iinc -std=gnu99 -fgnu89-inline -D__USE_CMSIS 8 | APP_LDFLAGS=-lm 9 | 10 | APP_SRC= \ 11 | src/radio.c \ 12 | src/timer.c \ 13 | src/main.c 14 | 15 | APP_SRC+=$(IMAGES_C) 16 | 17 | all: $(TARGET).bin 18 | 19 | publish: clean $(TARGET).bin 20 | scp $(TARGET).bin openbeacon.org:/home/wwwrun/open.bitmanufaktur.com/web/www/people/milosch/nrf5/ 21 | 22 | app_clean: 23 | find src -name '*.o' -exec rm \{\} \; 24 | 25 | clean_all: clean 26 | rm -f README $(CUSTOM_KEY) 27 | 28 | include ../core/Makefile.rules 29 | -------------------------------------------------------------------------------- /firmware/nRF51/tag-ble-beacon/Makefile: -------------------------------------------------------------------------------- 1 | TARGET=tag-ble-beacon 2 | ARCH=nrf5 3 | CPU=$(ARCH)1822 4 | DEBUG=-g 5 | OPTIM=-Os -mword-relocations 6 | 7 | APP_CFLAGS=-Iinc -std=gnu99 -fgnu89-inline -D__USE_CMSIS 8 | APP_LDFLAGS=-lm 9 | 10 | APP_SRC= \ 11 | src/acc.c \ 12 | src/adc.c \ 13 | src/flash.c \ 14 | src/radio.c \ 15 | src/timer.c \ 16 | src/main.c 17 | 18 | APP_SRC+=$(IMAGES_C) 19 | 20 | all: $(TARGET).bin 21 | 22 | publish: clean $(TARGET).bin 23 | scp $(TARGET).bin openbeacon.org:/home/wwwrun/open.bitmanufaktur.com/web/www/people/milosch/nrf5/ 24 | 25 | app_clean: 26 | find src -name '*.o' -exec rm \{\} \; 27 | 28 | clean_all: clean 29 | rm -f README $(CUSTOM_KEY) 30 | 31 | include ../core/Makefile.rules 32 | -------------------------------------------------------------------------------- /firmware/nRF51/tag-physical-web/Makefile: -------------------------------------------------------------------------------- 1 | TARGET=tag-physical-web 2 | ARCH=nrf5 3 | CPU=$(ARCH)1822 4 | DEBUG=-g 5 | OPTIM=-Os -mword-relocations 6 | 7 | APP_CFLAGS=-Ilib/inc -std=gnu99 -fgnu89-inline -D__USE_CMSIS 8 | APP_LDFLAGS=-lm 9 | 10 | APP_SRC=entry.c 11 | 12 | LIB_SRC= \ 13 | lib/src/acc.c \ 14 | lib/src/adc.c \ 15 | lib/src/flash.c \ 16 | lib/src/radio.c \ 17 | lib/src/timer.c \ 18 | lib/src/main.c 19 | 20 | APP_SRC+=$(LIB_SRC) $(IMAGES_C) 21 | 22 | all: $(TARGET).bin 23 | 24 | publish: clean $(TARGET).bin 25 | scp $(TARGET).bin openbeacon.org:/home/wwwrun/open.bitmanufaktur.com/web/www/people/milosch/nrf5/ 26 | 27 | app_clean: 28 | find . -name '*.o' -exec rm \{\} \; 29 | 30 | clean_all: clean 31 | rm -f README $(CUSTOM_KEY) 32 | 33 | include ../core/Makefile.rules 34 | -------------------------------------------------------------------------------- /firmware/nRF51/tag-physical-web/entry.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | /* physical web beacon packet */ 4 | static const uint8_t g_beacon_pkt[] = { 5 | /* 0x03: Service List */ 6 | 3,0x03, 0xD8, 0xFE, 7 | /* 0x16: Service Data - 'http://get.OpenBeacon.org' */ 8 | 21,0x16, 0xD8, 0xFE, 0x00, 0x20, 9 | PROTO_HTTP,'g','e','t','.','O','p','e','n','B','e','a','c','o','n',DOT_ORG 10 | }; 11 | 12 | void entry(void) 13 | { 14 | /* set advertisment packet */ 15 | radio_advertise(&g_beacon_pkt, sizeof(g_beacon_pkt)); 16 | /* run advertisement in background every 995ms */ 17 | radio_interval_ms(995); 18 | 19 | /* infinite foreground loop */ 20 | while(TRUE) 21 | { 22 | /* blink once every five seconds */ 23 | timer_wait_ms(5000); 24 | pin_set(CONFIG_LED_PIN); 25 | timer_wait_ms(1); 26 | pin_clear(CONFIG_LED_PIN); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /firmware/nRF51/tag-mischief/Makefile: -------------------------------------------------------------------------------- 1 | TARGET=tag-mischief 2 | ARCH=nrf5 3 | CPU=$(ARCH)1822 4 | DEBUG=-g 5 | OPTIM=-Os -mword-relocations 6 | 7 | APP_CFLAGS=-Iinc -std=gnu99 -fgnu89-inline -D__USE_CMSIS 8 | APP_LDFLAGS=-lm 9 | 10 | APP_SRC= \ 11 | src/acc.c \ 12 | src/adc.c \ 13 | src/flash.c \ 14 | src/radio.c \ 15 | src/timer.c \ 16 | src/name.c \ 17 | src/main.c 18 | 19 | APP_SRC+=$(IMAGES_C) 20 | DB_FILE=inc/db.h 21 | all: $(TARGET).bin 22 | 23 | publish: clean $(TARGET).bin 24 | scp -P30303 $(TARGET).bin openbeacon.org:/home/wwwrun/open.bitmanufaktur.com/web/www/people/milosch/nrf5/ 25 | 26 | app_clean: 27 | find src -name '*.o' -exec rm \{\} \; 28 | 29 | $(DB_FILE): /usr/share/dict/words 30 | ./db-update.php $^ > $@ 31 | 32 | clean_all: clean 33 | rm -f README $(CUSTOM_KEY) $(DB_FILE) 34 | 35 | include ../core/Makefile.rules 36 | -------------------------------------------------------------------------------- /firmware/nRF51/core/nrf/inc/nrf.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2009 Nordic Semiconductor. All Rights Reserved. 2 | * 3 | * The information contained herein is property of Nordic Semiconductor ASA. 4 | * Terms and conditions of usage are described in detail in NORDIC 5 | * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. 6 | * 7 | * Licensees are granted free, non-transferable use of the information. NO 8 | * WARRANTY of ANY KIND is provided. This heading must NOT be removed from 9 | * the file. 10 | * 11 | */ 12 | 13 | 14 | #ifndef NRF_H 15 | #define NRF_H 16 | 17 | #ifndef _WIN32 18 | 19 | /* Family selection for main includes. NRF51 must be selected. */ 20 | #ifdef __nrf5__ 21 | #include "nrf51.h" 22 | #include "nrf51_bitfields.h" 23 | #include "nrf51_deprecated.h" 24 | #include "nrf_gpio.h" 25 | #include "nrf_gpiote.h" 26 | #include "nrf_temp.h" 27 | #else 28 | #error "Device family must be defined. See nrf.h." 29 | #endif /* __nrf5__ */ 30 | 31 | #endif /* _WIN32 */ 32 | 33 | #endif /* NRF_H */ 34 | 35 | -------------------------------------------------------------------------------- /hardware/readme.md: -------------------------------------------------------------------------------- 1 | ### Hardware Design ### 2 | 3 | In this folder you can find our hardware design for the [nRF51822 based OpenBeacon tag](http://get.openbeacon.org). It contains all necessary information for building tags. If you wish, you are free to manufacture the tags yourself. 4 | 5 | Alternatively you can choose our services for bulk orders or for custom hardware development based on this and other designs we created in the past. Any kind of support for our project is highly appreciated and allows us to continue working on this great project. 6 | 7 | 8 | ### License Information ### 9 | 10 | Our hardware designs are licensed under the [Creative Commons Attribution-ShareAlike 4.0 International License](http://creativecommons.org/licenses/by-sa/4.0/) which specifically allows commercial usage - as long as you mention the origin of our original design openly. 11 | 12 | Please [contact us](mailto:license@bitmanufactory.com) for [obtaining an alternative **closed source license**](mailto:license@bitmanufactory.com?subject=Alternative%20License). 13 | -------------------------------------------------------------------------------- /firmware/nRF51/core/openbeacon/inc/crc8.h: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * 3 | * OpenBeacon.org - CRC8 routine 4 | * 5 | * Copyright 2011 Milosch Meriac 6 | * 7 | *************************************************************** 8 | 9 | This program is free software; you can redistribute it and/or modify 10 | it under the terms of the GNU General Public License as published by 11 | the Free Software Foundation; version 2. 12 | 13 | This program is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | GNU General Public License for more details. 17 | 18 | You should have received a copy of the GNU General Public License along 19 | with this program; if not, write to the Free Software Foundation, Inc., 20 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 21 | 22 | */ 23 | 24 | #ifndef __CRC8_H__ 25 | #define __CRC8_H__ 26 | 27 | extern uint8_t crc8 (const uint8_t * buffer, uint32_t size); 28 | 29 | #endif/*__CRC8_H__*/ 30 | -------------------------------------------------------------------------------- /host/openbeacon-cape/crc32.h: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * 3 | * OpenBeacon.org - CRC32 4 | * 5 | * Copyright 2014 Milosch Meriac 6 | * 7 | *************************************************************** 8 | 9 | This file is part of the OpenBeacon.org active RFID firmware 10 | 11 | OpenBeacon is free software: you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | OpenBeacon is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with Foobar. If not, see . 23 | 24 | */ 25 | 26 | #ifndef __CRC32_H__ 27 | #define __CRC32_H__ 28 | 29 | extern uint32_t crc32(const void *buf, uint32_t size); 30 | 31 | #endif/*__CRC32_H__*/ 32 | -------------------------------------------------------------------------------- /firmware/nRF51/tag-ble-beacon/inc/radio.h: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * 3 | * OpenBeacon.org - nRF51 2.4GHz Radio Routines 4 | * 5 | * Copyright 2013 Milosch Meriac 6 | * 7 | *************************************************************** 8 | 9 | This file is part of the OpenBeacon.org active RFID firmware 10 | 11 | OpenBeacon is free software: you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | OpenBeacon is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with Foobar. If not, see . 23 | 24 | */ 25 | #ifndef __RADIO_H__ 26 | #define __RADIO_H__ 27 | 28 | extern void radio_init(uint32_t uid); 29 | 30 | #endif/*__RADIO_H__*/ 31 | -------------------------------------------------------------------------------- /firmware/nRF51/tag-mischief/db-update.php: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env php 2 | =2) ? $argv[1] : '/usr/share/dict/words'; 5 | 6 | if(!($db = @file($word_db))) 7 | exit("Unable to open '$word_db'\n"); 8 | 9 | function filter_words($filter, $maxlen = 10) 10 | { 11 | global $db; 12 | 13 | $regex = '/^([a-z]*)'.$filter.'$/i'; 14 | 15 | $line = sprintf("\nconst char g_prefix_%s[] = \"", $filter); 16 | 17 | foreach($db as $word) 18 | if(preg_match($regex, $word, $res)) 19 | { 20 | $s = '\0'.ucfirst($res[1]); 21 | if(strlen($s)>$maxlen) 22 | continue; 23 | 24 | if(strlen($line.$s)>75) 25 | { 26 | echo "$line\"\n"; 27 | $line = "\t\""; 28 | } 29 | 30 | $line .= $s; 31 | } 32 | echo "$line\";\n"; 33 | } 34 | 35 | echo "#ifndef __DB_H__\n"; 36 | echo "#define __DB_H__\n"; 37 | 38 | filter_words('cal'); 39 | filter_words('matic'); 40 | filter_words('meter'); 41 | filter_words('ferous'); 42 | filter_words('metric'); 43 | filter_words('nated'); 44 | filter_words('stic'); 45 | filter_words('opic'); 46 | filter_words('ected'); 47 | 48 | filter_words('graph'); 49 | filter_words('scope'); 50 | 51 | echo "\n#endif/*__DB_H__*/\n"; 52 | -------------------------------------------------------------------------------- /firmware/nRF51/core/openbeacon/inc/crc32.h: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * 3 | * OpenBeacon.org - CRC32 4 | * 5 | * Copyright 2014 Milosch Meriac 6 | * 7 | *************************************************************** 8 | 9 | This file is part of the OpenBeacon.org active RFID firmware 10 | 11 | OpenBeacon is free software: you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | OpenBeacon is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with Foobar. If not, see . 23 | 24 | */ 25 | 26 | #ifndef __CRC32_H__ 27 | #define __CRC32_H__ 28 | 29 | extern uint32_t crc32(const void *buf, uint32_t size); 30 | 31 | #endif/*__CRC32_H__*/ 32 | -------------------------------------------------------------------------------- /firmware/nRF51/core/openbeacon/inc/helper.h: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * 3 | * OpenBeacon.org - nRF51 Misc Helper Routines 4 | * 5 | * Copyright 2013 Milosch Meriac 6 | * 7 | *************************************************************** 8 | 9 | This file is part of the OpenBeacon.org active RFID firmware 10 | 11 | OpenBeacon is free software: you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | OpenBeacon is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with Foobar. If not, see . 23 | 24 | */ 25 | 26 | #ifndef __HELPER_H__ 27 | #define __HELPER_H__ 28 | 29 | extern uint32_t sqrt32(uint32_t val); 30 | 31 | #endif/*__HELPER_H__*/ 32 | -------------------------------------------------------------------------------- /host/openbeacon-cape/helper.h: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * 3 | * OpenBeacon.org - helper functions 4 | * 5 | * Copyright 2015 Milosch Meriac 6 | * 7 | *************************************************************** 8 | 9 | This file is part of the OpenBeacon.org active RFID firmware 10 | 11 | OpenBeacon is free software: you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | OpenBeacon is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with Foobar. If not, see . 23 | 24 | */ 25 | #ifndef __HELPER_H__ 26 | #define __HELPER_H__ 27 | 28 | extern void hex_dump (const unsigned char *buf, unsigned int len); 29 | 30 | #endif/*__HELPER_H__*/ 31 | -------------------------------------------------------------------------------- /firmware/nRF51/tag-mischief/inc/flash.h: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * 3 | * OpenBeacon.org - nRF51 Flash Routines 4 | * 5 | * Copyright 2013 Milosch Meriac 6 | * 7 | *************************************************************** 8 | 9 | This file is part of the OpenBeacon.org active RFID firmware 10 | 11 | OpenBeacon is free software: you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | OpenBeacon is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with Foobar. If not, see . 23 | 24 | */ 25 | #ifndef __FLASH_H__ 26 | #define __FLASH_H__ 27 | 28 | extern uint8_t flash_init(void); 29 | extern uint32_t flash_size(void); 30 | 31 | #endif/*__FLASH_H__*/ 32 | -------------------------------------------------------------------------------- /firmware/nRF51/tag-power/inc/flash.h: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * 3 | * OpenBeacon.org - nRF51 Flash Routines 4 | * 5 | * Copyright 2013 Milosch Meriac 6 | * 7 | *************************************************************** 8 | 9 | This file is part of the OpenBeacon.org active RFID firmware 10 | 11 | OpenBeacon is free software: you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | OpenBeacon is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with Foobar. If not, see . 23 | 24 | */ 25 | #ifndef __FLASH_H__ 26 | #define __FLASH_H__ 27 | 28 | extern uint8_t flash_init(void); 29 | extern uint32_t flash_size(void); 30 | 31 | #endif/*__FLASH_H__*/ 32 | -------------------------------------------------------------------------------- /firmware/nRF51/tag-power/inc/rng.h: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * 3 | * OpenBeacon.org - nRF51 Random Number Generation 4 | * 5 | * Copyright 2014 Milosch Meriac 6 | * 7 | *************************************************************** 8 | 9 | This file is part of the OpenBeacon.org active RFID firmware 10 | 11 | OpenBeacon is free software: you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | OpenBeacon is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with Foobar. If not, see . 23 | 24 | */ 25 | 26 | #ifndef __RNG_H__ 27 | #define __RNG_H__ 28 | 29 | extern void rng_init(void); 30 | extern uint32_t rng(uint8_t bits); 31 | 32 | #endif/*__RNG_H__*/ 33 | -------------------------------------------------------------------------------- /firmware/nRF51/tag-proximity/inc/flash.h: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * 3 | * OpenBeacon.org - nRF51 Flash Routines 4 | * 5 | * Copyright 2013 Milosch Meriac 6 | * 7 | *************************************************************** 8 | 9 | This file is part of the OpenBeacon.org active RFID firmware 10 | 11 | OpenBeacon is free software: you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | OpenBeacon is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with Foobar. If not, see . 23 | 24 | */ 25 | #ifndef __FLASH_H__ 26 | #define __FLASH_H__ 27 | 28 | extern uint8_t flash_init(void); 29 | extern uint32_t flash_size(void); 30 | 31 | #endif/*__FLASH_H__*/ 32 | -------------------------------------------------------------------------------- /firmware/nRF51/tag-ble-beacon/inc/flash.h: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * 3 | * OpenBeacon.org - nRF51 Flash Routines 4 | * 5 | * Copyright 2013 Milosch Meriac 6 | * 7 | *************************************************************** 8 | 9 | This file is part of the OpenBeacon.org active RFID firmware 10 | 11 | OpenBeacon is free software: you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | OpenBeacon is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with Foobar. If not, see . 23 | 24 | */ 25 | #ifndef __FLASH_H__ 26 | #define __FLASH_H__ 27 | 28 | extern uint8_t flash_init(void); 29 | extern uint32_t flash_size(void); 30 | 31 | #endif/*__FLASH_H__*/ 32 | -------------------------------------------------------------------------------- /firmware/nRF51/tag-proximity/inc/rng.h: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * 3 | * OpenBeacon.org - nRF51 Random Number Generation 4 | * 5 | * Copyright 2014 Milosch Meriac 6 | * 7 | *************************************************************** 8 | 9 | This file is part of the OpenBeacon.org active RFID firmware 10 | 11 | OpenBeacon is free software: you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | OpenBeacon is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with Foobar. If not, see . 23 | 24 | */ 25 | 26 | #ifndef __RNG_H__ 27 | #define __RNG_H__ 28 | 29 | extern void rng_init(void); 30 | extern uint32_t rng(uint8_t bits); 31 | 32 | #endif/*__RNG_H__*/ 33 | -------------------------------------------------------------------------------- /firmware/nRF51/tag-physical-web/lib/inc/flash.h: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * 3 | * OpenBeacon.org - nRF51 Flash Routines 4 | * 5 | * Copyright 2013 Milosch Meriac 6 | * 7 | *************************************************************** 8 | 9 | This file is part of the OpenBeacon.org active RFID firmware 10 | 11 | OpenBeacon is free software: you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | OpenBeacon is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with Foobar. If not, see . 23 | 24 | */ 25 | #ifndef __FLASH_H__ 26 | #define __FLASH_H__ 27 | 28 | extern uint8_t flash_init(void); 29 | extern uint32_t flash_size(void); 30 | 31 | #endif/*__FLASH_H__*/ 32 | -------------------------------------------------------------------------------- /firmware/nRF51/tag-power/inc/radio.h: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * 3 | * OpenBeacon.org - nRF51 2.4GHz Radio Routines 4 | * 5 | * Copyright 2013 Milosch Meriac 6 | * 7 | *************************************************************** 8 | 9 | This file is part of the OpenBeacon.org active RFID firmware 10 | 11 | OpenBeacon is free software: you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | OpenBeacon is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with Foobar. If not, see . 23 | 24 | */ 25 | #ifndef __RADIO_H__ 26 | #define __RADIO_H__ 27 | 28 | #include 29 | 30 | extern void radio_init(uint32_t uid); 31 | 32 | #endif/*__RADIO_H__*/ 33 | -------------------------------------------------------------------------------- /firmware/nRF51/tag-mischief/inc/radio.h: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * 3 | * OpenBeacon.org - nRF51 2.4GHz Radio Routines 4 | * 5 | * Copyright 2013 Milosch Meriac 6 | * 7 | *************************************************************** 8 | 9 | This file is part of the OpenBeacon.org active RFID firmware 10 | 11 | OpenBeacon is free software: you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | OpenBeacon is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with Foobar. If not, see . 23 | 24 | */ 25 | #ifndef __RADIO_H__ 26 | #define __RADIO_H__ 27 | 28 | extern void radio_init(uint32_t uid); 29 | extern volatile uint32_t g_counter; 30 | 31 | #endif/*__RADIO_H__*/ 32 | -------------------------------------------------------------------------------- /firmware/nRF51/tag-proximity/inc/radio.h: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * 3 | * OpenBeacon.org - nRF51 2.4GHz Radio Routines 4 | * 5 | * Copyright 2013 Milosch Meriac 6 | * 7 | *************************************************************** 8 | 9 | This file is part of the OpenBeacon.org active RFID firmware 10 | 11 | OpenBeacon is free software: you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | OpenBeacon is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with Foobar. If not, see . 23 | 24 | */ 25 | #ifndef __RADIO_H__ 26 | #define __RADIO_H__ 27 | 28 | #include 29 | 30 | extern void radio_init(uint32_t uid); 31 | 32 | #endif/*__RADIO_H__*/ 33 | -------------------------------------------------------------------------------- /firmware/nRF51/tag-power/inc/adc.h: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * 3 | * OpenBeacon.org - nRF51 ADC Support Routines 4 | * 5 | * Copyright 2014 Milosch Meriac 6 | * 7 | *************************************************************** 8 | 9 | This file is part of the OpenBeacon.org active RFID firmware 10 | 11 | OpenBeacon is free software: you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | OpenBeacon is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with Foobar. If not, see . 23 | 24 | */ 25 | #ifndef __ADC_H__ 26 | #define __ADC_H__ 27 | 28 | extern void adc_init(void); 29 | extern void adc_start(void); 30 | extern uint8_t adc_bat(void); 31 | 32 | #endif/*__ADC_H__*/ 33 | -------------------------------------------------------------------------------- /firmware/nRF51/reader-ble/inc/main.h: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * 3 | * OpenBeacon.org - nRF51 Main Entry 4 | * 5 | * Copyright 2013 Milosch Meriac 6 | * 7 | *************************************************************** 8 | 9 | This file is part of the OpenBeacon.org active RFID firmware 10 | 11 | OpenBeacon is free software: you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | OpenBeacon is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with Foobar. If not, see . 23 | 24 | */ 25 | #ifndef __MAIN_H__ 26 | #define __MAIN_H__ 27 | 28 | extern void blink(uint8_t times); 29 | extern void halt(uint8_t times); 30 | extern int8_t tag_angle(void); 31 | 32 | #endif/*__MAIN_H__*/ 33 | -------------------------------------------------------------------------------- /firmware/nRF51/tag-ble-beacon/inc/adc.h: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * 3 | * OpenBeacon.org - nRF51 ADC Support Routines 4 | * 5 | * Copyright 2014 Milosch Meriac 6 | * 7 | *************************************************************** 8 | 9 | This file is part of the OpenBeacon.org active RFID firmware 10 | 11 | OpenBeacon is free software: you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | OpenBeacon is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with Foobar. If not, see . 23 | 24 | */ 25 | #ifndef __ADC_H__ 26 | #define __ADC_H__ 27 | 28 | extern void adc_init(void); 29 | extern void adc_start(void); 30 | extern uint8_t adc_bat(void); 31 | 32 | #endif/*__ADC_H__*/ 33 | -------------------------------------------------------------------------------- /firmware/nRF51/tag-mischief/inc/adc.h: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * 3 | * OpenBeacon.org - nRF51 ADC Support Routines 4 | * 5 | * Copyright 2014 Milosch Meriac 6 | * 7 | *************************************************************** 8 | 9 | This file is part of the OpenBeacon.org active RFID firmware 10 | 11 | OpenBeacon is free software: you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | OpenBeacon is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with Foobar. If not, see . 23 | 24 | */ 25 | #ifndef __ADC_H__ 26 | #define __ADC_H__ 27 | 28 | extern void adc_init(void); 29 | extern void adc_start(void); 30 | extern uint8_t adc_bat(void); 31 | 32 | #endif/*__ADC_H__*/ 33 | -------------------------------------------------------------------------------- /firmware/nRF51/tag-power/inc/main.h: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * 3 | * OpenBeacon.org - nRF51 Main Entry 4 | * 5 | * Copyright 2013 Milosch Meriac 6 | * 7 | *************************************************************** 8 | 9 | This file is part of the OpenBeacon.org active RFID firmware 10 | 11 | OpenBeacon is free software: you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | OpenBeacon is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with Foobar. If not, see . 23 | 24 | */ 25 | #ifndef __MAIN_H__ 26 | #define __MAIN_H__ 27 | 28 | extern void blink(uint8_t times); 29 | extern void halt(uint8_t times); 30 | extern int8_t tag_angle(void); 31 | 32 | #endif/*__MAIN_H__*/ 33 | -------------------------------------------------------------------------------- /firmware/nRF51/tag-proximity/inc/adc.h: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * 3 | * OpenBeacon.org - nRF51 ADC Support Routines 4 | * 5 | * Copyright 2014 Milosch Meriac 6 | * 7 | *************************************************************** 8 | 9 | This file is part of the OpenBeacon.org active RFID firmware 10 | 11 | OpenBeacon is free software: you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | OpenBeacon is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with Foobar. If not, see . 23 | 24 | */ 25 | #ifndef __ADC_H__ 26 | #define __ADC_H__ 27 | 28 | extern void adc_init(void); 29 | extern void adc_start(void); 30 | extern uint8_t adc_bat(void); 31 | 32 | #endif/*__ADC_H__*/ 33 | -------------------------------------------------------------------------------- /firmware/nRF51/tag-ble-beacon/inc/main.h: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * 3 | * OpenBeacon.org - nRF51 Main Entry 4 | * 5 | * Copyright 2013 Milosch Meriac 6 | * 7 | *************************************************************** 8 | 9 | This file is part of the OpenBeacon.org active RFID firmware 10 | 11 | OpenBeacon is free software: you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | OpenBeacon is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with Foobar. If not, see . 23 | 24 | */ 25 | #ifndef __MAIN_H__ 26 | #define __MAIN_H__ 27 | 28 | extern void blink(uint8_t times); 29 | extern void halt(uint8_t times); 30 | extern int8_t tag_angle(void); 31 | 32 | #endif/*__MAIN_H__*/ 33 | -------------------------------------------------------------------------------- /firmware/nRF51/tag-mischief/inc/main.h: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * 3 | * OpenBeacon.org - nRF51 Main Entry 4 | * 5 | * Copyright 2013 Milosch Meriac 6 | * 7 | *************************************************************** 8 | 9 | This file is part of the OpenBeacon.org active RFID firmware 10 | 11 | OpenBeacon is free software: you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | OpenBeacon is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with Foobar. If not, see . 23 | 24 | */ 25 | #ifndef __MAIN_H__ 26 | #define __MAIN_H__ 27 | 28 | extern void blink(uint8_t times); 29 | extern void halt(uint8_t times); 30 | extern int8_t tag_angle(void); 31 | 32 | #endif/*__MAIN_H__*/ 33 | -------------------------------------------------------------------------------- /firmware/nRF51/tag-physical-web/lib/inc/adc.h: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * 3 | * OpenBeacon.org - nRF51 ADC Support Routines 4 | * 5 | * Copyright 2014 Milosch Meriac 6 | * 7 | *************************************************************** 8 | 9 | This file is part of the OpenBeacon.org active RFID firmware 10 | 11 | OpenBeacon is free software: you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | OpenBeacon is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with Foobar. If not, see . 23 | 24 | */ 25 | #ifndef __ADC_H__ 26 | #define __ADC_H__ 27 | 28 | extern void adc_init(void); 29 | extern void adc_start(void); 30 | extern uint8_t adc_bat(void); 31 | 32 | #endif/*__ADC_H__*/ 33 | -------------------------------------------------------------------------------- /firmware/nRF51/tag-proximity/inc/main.h: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * 3 | * OpenBeacon.org - nRF51 Main Entry 4 | * 5 | * Copyright 2013 Milosch Meriac 6 | * 7 | *************************************************************** 8 | 9 | This file is part of the OpenBeacon.org active RFID firmware 10 | 11 | OpenBeacon is free software: you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | OpenBeacon is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with Foobar. If not, see . 23 | 24 | */ 25 | #ifndef __MAIN_H__ 26 | #define __MAIN_H__ 27 | 28 | extern void blink(uint8_t times); 29 | extern void halt(uint8_t times); 30 | extern int8_t tag_angle(void); 31 | 32 | #endif/*__MAIN_H__*/ 33 | -------------------------------------------------------------------------------- /firmware/nRF51/reader-prox/inc/main.h: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * 3 | * OpenBeacon.org - nRF51 Main Entry 4 | * 5 | * Copyright 2013-2015 Milosch Meriac 6 | * 7 | *************************************************************** 8 | 9 | This file is part of the OpenBeacon.org active RFID firmware 10 | 11 | OpenBeacon is free software: you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | OpenBeacon is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with Foobar. If not, see . 23 | 24 | */ 25 | #ifndef __MAIN_H__ 26 | #define __MAIN_H__ 27 | 28 | extern void blink(uint8_t times); 29 | extern void halt(uint8_t times); 30 | extern int8_t tag_angle(void); 31 | 32 | #endif/*__MAIN_H__*/ 33 | -------------------------------------------------------------------------------- /firmware/nRF51/tag-physical-web/lib/inc/main.h: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * 3 | * OpenBeacon.org - nRF51 Main Entry 4 | * 5 | * Copyright 2013 Milosch Meriac 6 | * 7 | *************************************************************** 8 | 9 | This file is part of the OpenBeacon.org active RFID firmware 10 | 11 | OpenBeacon is free software: you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | OpenBeacon is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with Foobar. If not, see . 23 | 24 | */ 25 | #ifndef __MAIN_H__ 26 | #define __MAIN_H__ 27 | 28 | extern void blink(uint8_t times); 29 | extern void halt(uint8_t times); 30 | extern int8_t tag_angle(void); 31 | 32 | #endif/*__MAIN_H__*/ 33 | -------------------------------------------------------------------------------- /host/openbeacon-cape/crc16.h: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * 3 | * OpenBeacon.org - CRC16 routine 4 | * 5 | * Copyright 2007 Milosch Meriac 6 | * 7 | *************************************************************** 8 | 9 | This program is free software; you can redistribute it and/or modify 10 | it under the terms of the GNU General Public License as published by 11 | the Free Software Foundation; version 2. 12 | 13 | This program is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | GNU General Public License for more details. 17 | 18 | You should have received a copy of the GNU General Public License along 19 | with this program; if not, write to the Free Software Foundation, Inc., 20 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 21 | 22 | */ 23 | 24 | #ifndef __CRC16_H__ 25 | #define __CRC16_H__ 26 | 27 | extern uint16_t crc16_continue (uint16_t crc, const uint8_t * buffer, uint32_t size); 28 | extern uint16_t crc16 (const uint8_t * buffer, uint32_t size); 29 | extern uint16_t icrc16 (const uint8_t * buffer, uint32_t size); 30 | 31 | #endif/*__CRC16_H__*/ 32 | -------------------------------------------------------------------------------- /firmware/nRF51/tag-mischief/inc/name.h: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * 3 | * OpenBeacon.org - nRF51 Name Routine 4 | * 5 | * Copyright 2013 Milosch Meriac 6 | * 7 | *************************************************************** 8 | 9 | This file is part of the OpenBeacon.org active RFID firmware 10 | 11 | OpenBeacon is free software: you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | OpenBeacon is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with Foobar. If not, see . 23 | 24 | */ 25 | #ifndef __NAME_H__ 26 | #define __NAME_H__ 27 | 28 | extern int name(int len, char* res, uint32_t seed); 29 | extern int name_prefix(int pos, int len, char* res, uint32_t seed); 30 | extern int name_postfix(int pos, int len, char* res, uint32_t seed); 31 | 32 | #endif/*__NAME_H__*/ 33 | -------------------------------------------------------------------------------- /firmware/nRF51/tag-proximity/Makefile: -------------------------------------------------------------------------------- 1 | TARGET=tag-proximity 2 | ARCH=nrf5 3 | CPU=$(ARCH)1822 4 | DEBUG=-g 5 | OPTIM=-Os -mword-relocations 6 | CUSTOM_KEY=inc/custom-encryption-key.h 7 | 8 | # determine if we have custom encryption keys 9 | ifeq ("$(wildcard $(CUSTOM_KEY))","") 10 | ENCRYPTION_KEY:= 11 | else 12 | ENCRYPTION_KEY:=-DCUSTOM_ENCRYPTION_KEY 13 | endif 14 | 15 | APP_CFLAGS=-Iinc -std=gnu99 -fgnu89-inline -D__USE_CMSIS $(ENCRYPTION_KEY) 16 | APP_LDFLAGS=-lm 17 | 18 | APP_SRC= \ 19 | src/rng.c \ 20 | src/acc.c \ 21 | src/adc.c \ 22 | src/aes.c \ 23 | src/flash.c \ 24 | src/radio.c \ 25 | src/timer.c \ 26 | src/main.c 27 | 28 | APP_SRC+=$(IMAGES_C) 29 | 30 | all: $(TARGET).bin 31 | 32 | publish: clean $(TARGET).bin 33 | scp $(TARGET).bin openbeacon.org:/home/wwwrun/open.bitmanufaktur.com/web/www/people/milosch/nrf5/ 34 | 35 | app_clean: 36 | find src -name '*.o' -exec rm \{\} \; 37 | 38 | key: 39 | printf "static const TAES g_default_key = {\n\t`od -v -t x1 -N 16 /dev/urandom | grep 0000000 | sed 's/^[0 ]* /0x/g' | sed 's/ */, 0x/g'`\n};\n" > $(CUSTOM_KEY) 40 | 41 | clean_all: clean 42 | rm -f README $(CUSTOM_KEY) 43 | 44 | indent: 45 | find src inc -iname '*.[ch]' -exec indent -c81 -i4 -cli4 -bli0 -ts 4 \{\} \; 46 | rm -f src/*.[ch]~ inc/*.[ch]~ 47 | 48 | include ../core/Makefile.rules 49 | -------------------------------------------------------------------------------- /firmware/nRF51/core/openbeacon/inc/crc16.h: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * 3 | * OpenBeacon.org - CRC16 routine 4 | * 5 | * Copyright 2007 Milosch Meriac 6 | * 7 | *************************************************************** 8 | 9 | This program is free software; you can redistribute it and/or modify 10 | it under the terms of the GNU General Public License as published by 11 | the Free Software Foundation; version 2. 12 | 13 | This program is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | GNU General Public License for more details. 17 | 18 | You should have received a copy of the GNU General Public License along 19 | with this program; if not, write to the Free Software Foundation, Inc., 20 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 21 | 22 | */ 23 | 24 | #ifndef __CRC16_H__ 25 | #define __CRC16_H__ 26 | 27 | extern uint16_t crc16_continue (uint16_t crc, const uint8_t * buffer, uint32_t size); 28 | extern uint16_t crc16 (const uint8_t * buffer, uint32_t size); 29 | extern uint16_t icrc16 (const uint8_t * buffer, uint32_t size); 30 | 31 | #endif/*__CRC16_H__*/ 32 | -------------------------------------------------------------------------------- /firmware/nRF51/tag-power/Makefile: -------------------------------------------------------------------------------- 1 | TARGET=tag-power 2 | ARCH=nrf5 3 | CPU=$(ARCH)1822 4 | DEBUG=-g 5 | OPTIM=-Os -mword-relocations 6 | CUSTOM_KEY=inc/custom-encryption-key.h 7 | 8 | # determine if we have custom encryption keys 9 | ifeq ("$(wildcard $(CUSTOM_KEY))","") 10 | ENCRYPTION_KEY:= 11 | else 12 | ENCRYPTION_KEY:=-DCUSTOM_ENCRYPTION_KEY 13 | endif 14 | 15 | APP_CFLAGS=-Iinc -std=gnu99 -fgnu89-inline -D__USE_CMSIS $(ENCRYPTION_KEY) 16 | APP_LDFLAGS=-lm 17 | 18 | APP_SRC= \ 19 | src/rng.c \ 20 | src/acc.c \ 21 | src/adc.c \ 22 | src/aes.c \ 23 | src/flash.c \ 24 | src/radio.c \ 25 | src/timer.c \ 26 | src/main.c 27 | 28 | APP_SRC+=$(IMAGES_C) 29 | 30 | all: $(TARGET).bin 31 | 32 | publish: clean $(TARGET).bin 33 | scp $(TARGET).bin openbeacon.org:/home/wwwrun/open.bitmanufaktur.com/web/www/people/milosch/nrf5/ 34 | 35 | app_clean: 36 | find src -name '*.o' -exec rm \{\} \; 37 | 38 | custom_key: 39 | echo -e "static const uint32_t xxtea_key[XXTEA_BLOCK_COUNT] = {\n\t`od -v -t x4 -N 16 /dev/urandom | grep 0000000 | sed 's/^0\+ /0x/g' | sed 's/ /, 0x/g'`\n};\n" > $(CUSTOM_KEY) 40 | 41 | clean_all: clean 42 | rm -f README $(CUSTOM_KEY) 43 | 44 | indent: 45 | find src inc -iname '*.[ch]' -exec indent -c81 -i4 -cli4 -bli0 -ts 4 \{\} \; 46 | rm -f src/*.[ch]~ inc/*.[ch]~ 47 | 48 | include ../core/Makefile.rules 49 | -------------------------------------------------------------------------------- /firmware/nRF51/reader-ble/inc/timer.h: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * 3 | * OpenBeacon.org - nRF51 Timer Routines 4 | * 5 | * Copyright 2013 Milosch Meriac 6 | * 7 | *************************************************************** 8 | 9 | This file is part of the OpenBeacon.org active RFID firmware 10 | 11 | OpenBeacon is free software: you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | OpenBeacon is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with Foobar. If not, see . 23 | 24 | */ 25 | #ifndef __TIMER_H__ 26 | #define __TIMER_H__ 27 | 28 | #define LF_FREQUENCY 32768UL 29 | 30 | #define SECONDS(x) ((uint32_t)((LF_FREQUENCY*x)+0.5)) 31 | #define MILLISECONDS(x) ((uint32_t)(((LF_FREQUENCY*x)/1000.0)+0.5)) 32 | 33 | extern void timer_init(void); 34 | extern void timer_wait(uint32_t ticks); 35 | 36 | #endif/*__TIMER_H__*/ 37 | -------------------------------------------------------------------------------- /firmware/nRF51/tag-mischief/inc/timer.h: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * 3 | * OpenBeacon.org - nRF51 Timer Routines 4 | * 5 | * Copyright 2013 Milosch Meriac 6 | * 7 | *************************************************************** 8 | 9 | This file is part of the OpenBeacon.org active RFID firmware 10 | 11 | OpenBeacon is free software: you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | OpenBeacon is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with Foobar. If not, see . 23 | 24 | */ 25 | #ifndef __TIMER_H__ 26 | #define __TIMER_H__ 27 | 28 | #define LF_FREQUENCY 32768UL 29 | 30 | #define SECONDS(x) ((uint32_t)((LF_FREQUENCY*x)+0.5)) 31 | #define MILLISECONDS(x) ((uint32_t)(((LF_FREQUENCY*x)/1000.0)+0.5)) 32 | 33 | extern void timer_init(void); 34 | extern void timer_wait(uint32_t ticks); 35 | 36 | #endif/*__TIMER_H__*/ 37 | -------------------------------------------------------------------------------- /firmware/nRF51/tag-power/inc/timer.h: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * 3 | * OpenBeacon.org - nRF51 Timer Routines 4 | * 5 | * Copyright 2013 Milosch Meriac 6 | * 7 | *************************************************************** 8 | 9 | This file is part of the OpenBeacon.org active RFID firmware 10 | 11 | OpenBeacon is free software: you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | OpenBeacon is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with Foobar. If not, see . 23 | 24 | */ 25 | #ifndef __TIMER_H__ 26 | #define __TIMER_H__ 27 | 28 | #define LF_FREQUENCY 32768UL 29 | 30 | #define SECONDS(x) ((uint32_t)((LF_FREQUENCY*x)+0.5)) 31 | #define MILLISECONDS(x) ((uint32_t)(((LF_FREQUENCY*x)/1000.0)+0.5)) 32 | 33 | extern void timer_init(void); 34 | extern void timer_wait(uint32_t ticks); 35 | 36 | #endif/*__TIMER_H__*/ 37 | -------------------------------------------------------------------------------- /firmware/nRF51/reader-prox/inc/timer.h: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * 3 | * OpenBeacon.org - nRF51 Timer Routines 4 | * 5 | * Copyright 2013-2015 Milosch Meriac 6 | * 7 | *************************************************************** 8 | 9 | This file is part of the OpenBeacon.org active RFID firmware 10 | 11 | OpenBeacon is free software: you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | OpenBeacon is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with Foobar. If not, see . 23 | 24 | */ 25 | #ifndef __TIMER_H__ 26 | #define __TIMER_H__ 27 | 28 | #define LF_FREQUENCY 32768UL 29 | 30 | #define SECONDS(x) ((uint32_t)((LF_FREQUENCY*x)+0.5)) 31 | #define MILLISECONDS(x) ((uint32_t)(((LF_FREQUENCY*x)/1000.0)+0.5)) 32 | 33 | extern void timer_init(void); 34 | extern void timer_wait(uint32_t ticks); 35 | 36 | #endif/*__TIMER_H__*/ 37 | -------------------------------------------------------------------------------- /firmware/nRF51/tag-ble-beacon/inc/timer.h: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * 3 | * OpenBeacon.org - nRF51 Timer Routines 4 | * 5 | * Copyright 2013 Milosch Meriac 6 | * 7 | *************************************************************** 8 | 9 | This file is part of the OpenBeacon.org active RFID firmware 10 | 11 | OpenBeacon is free software: you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | OpenBeacon is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with Foobar. If not, see . 23 | 24 | */ 25 | #ifndef __TIMER_H__ 26 | #define __TIMER_H__ 27 | 28 | #define LF_FREQUENCY 32768UL 29 | 30 | #define SECONDS(x) ((uint32_t)((LF_FREQUENCY*x)+0.5)) 31 | #define MILLISECONDS(x) ((uint32_t)(((LF_FREQUENCY*x)/1000.0)+0.5)) 32 | 33 | extern void timer_init(void); 34 | extern void timer_wait(uint32_t ticks); 35 | 36 | #endif/*__TIMER_H__*/ 37 | -------------------------------------------------------------------------------- /firmware/nRF51/tag-proximity/inc/timer.h: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * 3 | * OpenBeacon.org - nRF51 Timer Routines 4 | * 5 | * Copyright 2013 Milosch Meriac 6 | * 7 | *************************************************************** 8 | 9 | This file is part of the OpenBeacon.org active RFID firmware 10 | 11 | OpenBeacon is free software: you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | OpenBeacon is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with Foobar. If not, see . 23 | 24 | */ 25 | #ifndef __TIMER_H__ 26 | #define __TIMER_H__ 27 | 28 | #define LF_FREQUENCY 32768UL 29 | 30 | #define SECONDS(x) ((uint32_t)((LF_FREQUENCY*x)+0.5)) 31 | #define MILLISECONDS(x) ((uint32_t)(((LF_FREQUENCY*x)/1000.0)+0.5)) 32 | 33 | extern void timer_init(void); 34 | extern void timer_wait(uint32_t ticks); 35 | 36 | #endif/*__TIMER_H__*/ 37 | -------------------------------------------------------------------------------- /firmware/nRF51/core/nrf/inc/system_nrf51.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2009 Nordic Semiconductor. All Rights Reserved. 2 | * 3 | * The information contained herein is property of Nordic Semiconductor ASA. 4 | * Terms and conditions of usage are described in detail in NORDIC 5 | * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. 6 | * 7 | * Licensees are granted free, non-transferable use of the information. NO 8 | * WARRANTY of ANY KIND is provided. This heading must NOT be removed from 9 | * the file. 10 | * 11 | */ 12 | 13 | 14 | #ifndef SYSTEM_NRF51_H 15 | #define SYSTEM_NRF51_H 16 | 17 | #ifdef __cplusplus 18 | extern "C" { 19 | #endif 20 | 21 | #include 22 | 23 | 24 | extern uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Clock) */ 25 | 26 | /** 27 | * Initialize the system 28 | * 29 | * @param none 30 | * @return none 31 | * 32 | * @brief Setup the microcontroller system. 33 | * Initialize the System and update the SystemCoreClock variable. 34 | */ 35 | extern void SystemInit (void); 36 | 37 | /** 38 | * Update SystemCoreClock variable 39 | * 40 | * @param none 41 | * @return none 42 | * 43 | * @brief Updates the SystemCoreClock with current core Clock 44 | * retrieved from cpu registers. 45 | */ 46 | extern void SystemCoreClockUpdate (void); 47 | 48 | #ifdef __cplusplus 49 | } 50 | #endif 51 | 52 | #endif /* SYSTEM_NRF51_H */ 53 | -------------------------------------------------------------------------------- /firmware/nRF51/core/openbeacon/inc/uart.h: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * 3 | * OpenBeacon.org - nRF51 USART Serial Handler 4 | * 5 | * Copyright 2013 Milosch Meriac 6 | * 7 | *************************************************************** 8 | 9 | This file is part of the OpenBeacon.org active RFID firmware 10 | 11 | OpenBeacon is free software: you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | OpenBeacon is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with Foobar. If not, see . 23 | 24 | */ 25 | #ifndef __UART_H__ 26 | #define __UART_H__ 27 | 28 | #ifndef CONFIG_UART_BUFFER 29 | #define CONFIG_UART_BUFFER 128 30 | #endif/*CONFIG_UART_BUFFER*/ 31 | 32 | #ifdef CONFIG_UART_BAUDRATE 33 | extern void uart_init(void); 34 | extern BOOL uart_tx(uint8_t data); 35 | extern int uart_rx(void); 36 | #endif/*CONFIG_UART_BAUDRATE*/ 37 | 38 | #endif/*__UART_H__*/ 39 | -------------------------------------------------------------------------------- /firmware/nRF51/tag-physical-web/lib/inc/radio.h: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * 3 | * OpenBeacon.org - nRF51 2.4GHz Radio Routines 4 | * 5 | * Copyright 2013 Milosch Meriac 6 | * 7 | *************************************************************** 8 | 9 | This file is part of the OpenBeacon.org active RFID firmware 10 | 11 | OpenBeacon is free software: you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | OpenBeacon is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with Foobar. If not, see . 23 | 24 | */ 25 | #ifndef __RADIO_H__ 26 | #define __RADIO_H__ 27 | 28 | extern void radio_init(uint32_t uid); 29 | extern void radio_enable(BOOL enable); 30 | extern int radio_advertise(const void* packet, uint32_t len); 31 | extern void radio_interval(uint32_t ticks); 32 | 33 | #define radio_interval_ms(x) radio_interval(MILLISECONDS(x)) 34 | 35 | #endif/*__RADIO_H__*/ 36 | -------------------------------------------------------------------------------- /firmware/nRF51/tag-ipv6/inc/config.h: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * 3 | * OpenBeacon.org - nRF51 board config files 4 | * 5 | * Copyright 2013 Milosch Meriac 6 | * 7 | *************************************************************** 8 | 9 | This file is part of the OpenBeacon.org active RFID firmware 10 | 11 | OpenBeacon is free software: you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | OpenBeacon is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with Foobar. If not, see . 23 | 24 | */ 25 | #ifndef __CONFIG_H__ 26 | #define __CONFIG_H__ 27 | 28 | #define CONFIG_UART_BAUDRATE UART_BAUDRATE_BAUDRATE_Baud38400 29 | #define CONFIG_UART_TXD_PIN 9 30 | #ifdef CONFIG_UART_RX 31 | #define CONFIG_UART_RXD_PIN 8 32 | #else 33 | #define CONFIG_GPIO3_PIN 8 34 | #endif/*CONFIG_UART_RX*/ 35 | 36 | #define CONFIG_LED_PIN 17 37 | #define CONFIG_SWITCH_PIN 29 38 | 39 | #endif/*__CONFIG_H__*/ 40 | -------------------------------------------------------------------------------- /firmware/nRF51/tag-physical-web/lib/inc/timer.h: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * 3 | * OpenBeacon.org - nRF51 Timer Routines 4 | * 5 | * Copyright 2013 Milosch Meriac 6 | * 7 | *************************************************************** 8 | 9 | This file is part of the OpenBeacon.org active RFID firmware 10 | 11 | OpenBeacon is free software: you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | OpenBeacon is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with Foobar. If not, see . 23 | 24 | */ 25 | #ifndef __TIMER_H__ 26 | #define __TIMER_H__ 27 | 28 | #define LF_FREQUENCY 32768UL 29 | 30 | #define SECONDS(x) ((uint32_t)((LF_FREQUENCY*x)+0.5)) 31 | #define MILLISECONDS(x) ((uint32_t)(((LF_FREQUENCY*x)/1000.0)+0.5)) 32 | #define timer_wait_ms(x) timer_wait(MILLISECONDS(x)) 33 | 34 | extern void timer_init(void); 35 | extern void timer_wait(uint32_t ticks); 36 | 37 | #endif/*__TIMER_H__*/ 38 | -------------------------------------------------------------------------------- /firmware/nRF51/core/openbeacon/src/helper.c: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * 3 | * OpenBeacon.org - nRF51 Misc Helper Routines 4 | * 5 | * Copyright 2013 Milosch Meriac 6 | * 7 | *************************************************************** 8 | 9 | This file is part of the OpenBeacon.org active RFID firmware 10 | 11 | OpenBeacon is free software: you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | OpenBeacon is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with Foobar. If not, see . 23 | 24 | */ 25 | #include 26 | #include 27 | 28 | uint32_t sqrt32(uint32_t val) 29 | { 30 | uint32_t res, bit, t; 31 | 32 | bit = 1<<30; 33 | while(bit>val) 34 | bit >>= 2; 35 | 36 | res = 0; 37 | while(bit) 38 | { 39 | t = res+bit; 40 | if(val>=t) 41 | { 42 | val -= t; 43 | res = (res>>1) + bit; 44 | } 45 | else 46 | res >>= 1; 47 | bit>>= 2; 48 | } 49 | return res; 50 | } 51 | -------------------------------------------------------------------------------- /firmware/nRF51/core/openbeacon/inc/debug_printf.h: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * 3 | * OpenBeacon.org - debug_printf wrapper for ts_printf 4 | * 5 | * Copyright 2010-2013 Milosch Meriac 6 | * 7 | *************************************************************** 8 | 9 | This program is free software; you can redistribute it and/or modify 10 | it under the terms of the GNU General Public License as published by 11 | the Free Software Foundation; version 2. 12 | 13 | This program is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | GNU General Public License for more details. 17 | 18 | You should have received a copy of the GNU General Public License along 19 | with this program; if not, write to the Free Software Foundation, Inc., 20 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 21 | 22 | */ 23 | 24 | #ifndef __DEBUG_PRINTF_H__ 25 | #define __DEBUG_PRINTF_H__ 26 | 27 | #if defined UART_DISABLE && !defined ENABLE_USB_FULLFEATURED 28 | #define debug_printf(...) 29 | #else /*UART_DISABLE */ 30 | extern void debug_printf (const char *fmt, ...); 31 | extern char hex_char (unsigned char hex); 32 | extern void hex_dump (const unsigned char *buf, unsigned int addr, 33 | unsigned int len); 34 | #endif /*UART_DISABLE */ 35 | 36 | #endif/*__DEBUG_PRINTF_H__*/ 37 | -------------------------------------------------------------------------------- /firmware/nRF51/tag-ipv6/Makefile: -------------------------------------------------------------------------------- 1 | TARGET=tag-ipv6 2 | ARCH=nrf5 3 | CPU=$(ARCH)1822 4 | DEBUG=-g 5 | OPTIM=-Os -mword-relocations 6 | 7 | # 8 | # import IoT SDK - get from "Downloads Tab" at 9 | # https://www.nordicsemi.com/eng/Products/Bluetooth-Smart-Bluetooth-low-energy/nRF51822 10 | # 11 | # see: "nRF51-IoT-SDK-zip" link 12 | # 13 | nRF51_SDK=nrf51_iot_sdk_0.7.0.zip 14 | nRF51_SDK_URL=http://www.nordicsemi.com/eng/nordic/download_resource/41601/6/71011617 15 | SOFTDEVICE=Nordic/nrf51/components/softdevice/s1xx_iot/s1xx-iot-prototype2_softdevice.hex 16 | 17 | COMP=lib/Nordic/nrf51/components 18 | INCLUDES= \ 19 | -I$(COMP)/softdevice/s1xx_iot/headers \ 20 | -I$(COMP)/ble/ble_6lowpan \ 21 | -I$(COMP)/iot/include 22 | 23 | APP_CFLAGS=$(INCLUDES) -Iinc -std=gnu99 -fgnu89-inline -D__USE_CMSIS -Wno-unused-function -Wno-unused-parameter 24 | APP_LDFLAGS=-lm $(COMP)/ble/ble_6lowpan/lib/ble_6lowpan.a 25 | 26 | APP_SRC= \ 27 | lib/softdevice.s \ 28 | src/main.c 29 | 30 | APP_SRC+=$(IMAGES_C) 31 | 32 | all: $(TARGET).bin 33 | 34 | $(nRF51_SDK): 35 | curl -o $@ $(nRF51_SDK_URL) 36 | 37 | lib/softdevice.bin: $(nRF51_SDK) 38 | rm -rf lib/Nordic 39 | unzip -d lib $< 40 | find lib/Nordic -iname *.[ch] -exec dos2unix \{\} \; 41 | $(OBJCOPY) -Iihex -Obinary lib/$(SOFTDEVICE) $@ 42 | 43 | lib/softdevice.o : lib/softdevice.s lib/softdevice.bin 44 | 45 | app_clean: 46 | find src lib -name '*.o' -exec rm \{\} \; 47 | 48 | clean_all: clean 49 | rm -rf lib/Nordic lib/*.bin 50 | 51 | include ../core/Makefile.rules 52 | -------------------------------------------------------------------------------- /firmware/nRF51/reader-ble/inc/radio.h: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * 3 | * OpenBeacon.org - nRF51 2.4GHz Radio Routines 4 | * 5 | * Copyright 2013-2014 Milosch Meriac 6 | * 7 | *************************************************************** 8 | 9 | This file is part of the OpenBeacon.org active RFID firmware 10 | 11 | OpenBeacon is free software: you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | OpenBeacon is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with Foobar. If not, see . 23 | 24 | */ 25 | #ifndef __RADIO_H__ 26 | #define __RADIO_H__ 27 | 28 | #ifndef RADIO_MAX_PKT_BUFFERS 29 | #define RADIO_MAX_PKT_BUFFERS 32 30 | #endif/*RADIO_MAX_PKT_BUFFERS*/ 31 | 32 | #define RADIO_MAX_PACKET_SIZE 64 33 | 34 | typedef struct 35 | { 36 | int8_t rssi; 37 | uint8_t channel; 38 | uint8_t buf[RADIO_MAX_PACKET_SIZE]; 39 | } TBeaconBuffer; 40 | 41 | extern void radio_init(void); 42 | extern int radio_packet_count(void); 43 | extern BOOL radio_rx(TBeaconBuffer *buf); 44 | 45 | 46 | #endif/*__RADIO_H__*/ 47 | -------------------------------------------------------------------------------- /firmware/nRF51/core/linker/nrf5.ld: -------------------------------------------------------------------------------- 1 | ENTRY(Reset_Handler) 2 | 3 | SECTIONS 4 | { 5 | . = 0; 6 | startup : { *(.startup)} >flash 7 | 8 | prog : 9 | { 10 | KEEP(*(.softdevice.text)) 11 | KEEP(*(.isr_vector)) 12 | *(.text) 13 | *(.text.*) 14 | *(.rodata) 15 | *(.rodata*) 16 | *(.glue_7) 17 | *(.glue_7t) 18 | } >flash 19 | 20 | __end_of_text__ = .; 21 | 22 | .persistent (NOLOAD): 23 | { 24 | KEEP(*(.softdevice.bss)) 25 | __persistent_beg__ = .; 26 | *(.persistent) 27 | *(.persistent.*) 28 | __persistent_end__ = .; 29 | *(.persistent_manage) 30 | *(.persistent_manage.*) 31 | } >ram 32 | 33 | .data : 34 | { 35 | __data_beg__ = .; 36 | __data_beg_src__ = __end_of_text__; 37 | *(.data) 38 | *(.data.*) 39 | *(.fastrun) 40 | *(.ramfunc) 41 | __data_end__ = .; 42 | } >ram AT>flash 43 | /* .ARM.exidx is sorted, so has to go in its own output section. */ 44 | __exidx_start = .; 45 | .ARM.exidx : 46 | { 47 | *(.ARM.exidx* .gnu.linkonce.armexidx.*) 48 | } >ram AT>flash 49 | __exidx_end = .; 50 | 51 | .bss (NOLOAD): 52 | { 53 | __bss_beg__ = .; 54 | *(.bss) 55 | *(.bss.*) 56 | __bss_end__ = .; 57 | } >ram 58 | 59 | /* Align here to ensure that the .bss section occupies space up to 60 | _end. Align after .bss to ensure correct alignment even if the 61 | .bss section disappears because there are no input sections. */ 62 | . = ALIGN(32 / 8); 63 | _end = .; 64 | _bss_end__ = . ; __bss_end__ = . ; __end__ = . ; 65 | PROVIDE (end = .); 66 | PROVIDE (__stack_end__ = ORIGIN(ram) + LENGTH(ram)); 67 | } 68 | . = ALIGN(32 / 8); 69 | -------------------------------------------------------------------------------- /host/openbeacon-cape/openbeacon.h: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * 3 | * OpenBeacon.org - log format specification 4 | * 5 | * Copyright 2014 Milosch Meriac 6 | * 7 | *************************************************************** 8 | 9 | This file is part of the OpenBeacon.org active RFID firmware 10 | 11 | OpenBeacon is free software: you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | OpenBeacon is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with Foobar. If not, see . 23 | 24 | */ 25 | #ifndef __OPENBEACON_H__ 26 | #define __OPENBEACON_H__ 27 | 28 | #define OPENBEACON_SIZE 32 29 | 30 | #define BEACONLOG_SIGHTING 0x01 31 | #define PACKED __attribute__((__packed__)) 32 | 33 | typedef struct 34 | { 35 | uint16_t icrc16; 36 | uint8_t protocol; 37 | uint8_t interface; 38 | uint16_t reader_id; 39 | uint16_t size; 40 | } PACKED TBeaconNetworkHdr; 41 | 42 | /* BEACONLOG_SIGHTING */ 43 | typedef struct 44 | { 45 | TBeaconNetworkHdr hdr; 46 | uint32_t sequence; 47 | uint32_t timestamp; 48 | uint8_t log[OPENBEACON_SIZE]; 49 | } PACKED TBeaconLogSighting; 50 | 51 | #endif/*__OPENBEACON_H__*/ 52 | -------------------------------------------------------------------------------- /firmware/nRF51/core/openbeacon/inc/xxtea.h: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * 3 | * OpenBeacon.org - XXTEA based block encryption 4 | * 5 | * based on "correction to XTEA" by David J. Wheeler and 6 | * Roger M. Needham. 7 | * Computer Laboratory - Cambridge University in 1998 8 | * 9 | * Copyright 2006 Milosch Meriac 10 | * 11 | * ripped into pieces - optimized for the special case 12 | * where 16 bytes are regarded for encryption and decryption 13 | * to increase speed and to decrease memory consumption 14 | * 15 | *************************************************************** 16 | 17 | This program is free software; you can redistribute it and/or modify 18 | it under the terms of the GNU General Public License as published by 19 | the Free Software Foundation; version 2. 20 | 21 | This program is distributed in the hope that it will be useful, 22 | but WITHOUT ANY WARRANTY; without even the implied warranty of 23 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 24 | GNU General Public License for more details. 25 | 26 | You should have received a copy of the GNU General Public License along 27 | with this program; if not, write to the Free Software Foundation, Inc., 28 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 29 | */ 30 | 31 | #ifndef __XXTEA_H__ 32 | #define __XXTEA_H__ 33 | 34 | extern void xxtea_decode (uint32_t * v, uint32_t length, 35 | const uint32_t * tea_key); 36 | extern void xxtea_encode (uint32_t * v, uint32_t length, 37 | const uint32_t * tea_key); 38 | 39 | #endif/*__XXTEA_H__*/ 40 | -------------------------------------------------------------------------------- /host/openbeacon-cape/crc16.c: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * 3 | * OpenBeacon.org - CRC16 routine 4 | * 5 | * Copyright 2007 Milosch Meriac 6 | * 7 | *************************************************************** 8 | 9 | This program is free software; you can redistribute it and/or modify 10 | it under the terms of the GNU General Public License as published by 11 | the Free Software Foundation; version 2. 12 | 13 | This program is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | GNU General Public License for more details. 17 | 18 | You should have received a copy of the GNU General Public License along 19 | with this program; if not, write to the Free Software Foundation, Inc., 20 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 21 | 22 | */ 23 | 24 | #include 25 | #include "crc16.h" 26 | 27 | uint16_t 28 | crc16_continue (uint16_t crc, const uint8_t * buffer, uint32_t size) 29 | { 30 | if (buffer && size) 31 | while (size--) 32 | { 33 | crc = (crc >> 8) | (crc << 8); 34 | crc ^= *buffer++; 35 | crc ^= ((unsigned char) crc) >> 4; 36 | crc ^= crc << 12; 37 | crc ^= (crc & 0xFF) << 5; 38 | } 39 | return crc; 40 | } 41 | 42 | uint16_t 43 | crc16 (const uint8_t * buffer, uint32_t size) 44 | { 45 | return crc16_continue(0xFFFF, buffer, size); 46 | } 47 | 48 | uint16_t 49 | icrc16 (const uint8_t * buffer, uint32_t size) 50 | { 51 | return crc16 (buffer, size) ^ 0xFFFF; 52 | } 53 | -------------------------------------------------------------------------------- /firmware/nRF51/core/openbeacon/src/crc16.c: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * 3 | * OpenBeacon.org - CRC16 routine 4 | * 5 | * Copyright 2007 Milosch Meriac 6 | * 7 | *************************************************************** 8 | 9 | This program is free software; you can redistribute it and/or modify 10 | it under the terms of the GNU General Public License as published by 11 | the Free Software Foundation; version 2. 12 | 13 | This program is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | GNU General Public License for more details. 17 | 18 | You should have received a copy of the GNU General Public License along 19 | with this program; if not, write to the Free Software Foundation, Inc., 20 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 21 | 22 | */ 23 | 24 | #include 25 | #include "crc16.h" 26 | 27 | uint16_t 28 | crc16_continue (uint16_t crc, const uint8_t * buffer, uint32_t size) 29 | { 30 | if (buffer && size) 31 | while (size--) 32 | { 33 | crc = (crc >> 8) | (crc << 8); 34 | crc ^= *buffer++; 35 | crc ^= ((unsigned char) crc) >> 4; 36 | crc ^= crc << 12; 37 | crc ^= (crc & 0xFF) << 5; 38 | } 39 | return crc; 40 | } 41 | 42 | uint16_t 43 | crc16 (const uint8_t * buffer, uint32_t size) 44 | { 45 | return crc16_continue(0xFFFF, buffer, size); 46 | } 47 | 48 | uint16_t 49 | icrc16 (const uint8_t * buffer, uint32_t size) 50 | { 51 | return crc16 (buffer, size) ^ 0xFFFF; 52 | } 53 | -------------------------------------------------------------------------------- /host/openbeacon-power/Makefile: -------------------------------------------------------------------------------- 1 | CXX :=g++ 2 | TARGET :=openbeacon-power 3 | SOURCES :=src/bmMapHandleToItem.cpp src/main.cpp src/crypto.cpp 4 | LIBS :=-lm 5 | 6 | # determine program version 7 | PROGRAM_VERSION:=$(shell git describe --tags --abbrev=4 --dirty 2>/dev/null | sed s/^v//) 8 | ifeq ("$(PROGRAM_VERSION)","") 9 | PROGRAM_VERSION:='unknown' 10 | endif 11 | 12 | # determine if we have custom encryption keys 13 | ifeq ("$(wildcard src/custom-encryption-keys.h)","") 14 | ENCRYPTION_KEYS:= 15 | else 16 | ENCRYPTION_KEYS:=-DCUSTOM_ENCRYPTION_KEYS 17 | endif 18 | 19 | DEBUG :=-O3 20 | CXXOPT :=$(DEBUG) 21 | INCLUDE :=-I../../firmware/nRF51/tag-power/inc/ 22 | CXXFLAGS:=-Werror -Wall -D_REENTRANT -DPROGRAM_VERSION=\"$(PROGRAM_VERSION)\" -DPROGRAM_NAME=\"$(TARGET)\" $(ENCRYPTION_KEYS) $(INCLUDE) 23 | LDFLAGS :=$(LIBS) 24 | OBJS :=$(SOURCES:%.cpp=%.o) 25 | LOGJSON :=$(LOGFILE:%.bin=%.json.bz2) 26 | PREFIX :=/usr/local 27 | 28 | all: $(TARGET) 29 | 30 | .PHONY: all version run install indent debug dependencies-fedora cleanall clean 31 | 32 | version: 33 | @echo "$(TARGET) version $(PROGRAM_VERSION)" 34 | 35 | run: $(TARGET) 36 | ./$(TARGET) 37 | 38 | install: $(TARGET) 39 | install $(TARGET) $(PREFIX)/bin/ 40 | 41 | indent: $(SOURCES) 42 | find src -iname '*\.[cph]*' -exec indent -c81 -i4 -cli4 -bli0 -ts 4 \{\} \; 43 | rm -f src/*~ 44 | 45 | $(TARGET): .depend $(OBJS) 46 | $(CXX) $(LDOPT) $(OBJS) $(LDFLAGS) -o $@ 47 | 48 | .depend: $(SOURCES) 49 | $(CXX) $(CXXFLAGS) $(CXXOPT) -MM $^ > $@ 50 | 51 | .cpp.o: 52 | $(CXX) $(CXXFLAGS) $(CXXOPT) -c $< -o $@ 53 | 54 | dependencies-fedora: 55 | sudo yum install gcc-c++ 56 | 57 | cleanall: clean 58 | rm -f .depend 59 | 60 | clean: 61 | rm -f $(TARGET) $(OBJS) *~ 62 | 63 | include .depend 64 | -------------------------------------------------------------------------------- /host/openbeacon-cape/helper.c: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * 3 | * OpenBeacon.org - helper functions 4 | * 5 | * Copyright 2015 Milosch Meriac 6 | * 7 | *************************************************************** 8 | 9 | This file is part of the OpenBeacon.org active RFID firmware 10 | 11 | OpenBeacon is free software: you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | OpenBeacon is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with Foobar. If not, see . 23 | 24 | */ 25 | #include 26 | #include 27 | 28 | void 29 | hex_dump (const unsigned char *buf, unsigned int len) 30 | { 31 | unsigned int start, i, j; 32 | char c; 33 | 34 | start = 0; 35 | 36 | for (j = 0; j < len; j += 16) 37 | { 38 | printf ("%08x:", start + j); 39 | 40 | for (i = 0; i < 16; i++) 41 | { 42 | if ((start + i + j) < len) 43 | printf (" %02x", buf[start + i + j]); 44 | else 45 | printf (" "); 46 | } 47 | printf (" |"); 48 | for (i = 0; i < 16; i++) 49 | { 50 | if ((start + i + j) < len) 51 | { 52 | c = buf[start + i + j]; 53 | if (c >= ' ' && c < 127) 54 | printf ("%c", c); 55 | else 56 | printf ("."); 57 | } 58 | else 59 | printf (" "); 60 | } 61 | printf ("|\n\r"); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /firmware/nRF51/tag-power/inc/aes.h: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * 3 | * OpenBeacon.org - nRF51 AES Hardware Encryption & Signing 4 | * 5 | * Copyright 2014 Milosch Meriac 6 | * 7 | *************************************************************** 8 | 9 | This file is part of the OpenBeacon.org active RFID firmware 10 | 11 | OpenBeacon is free software: you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | OpenBeacon is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with Foobar. If not, see . 23 | 24 | */ 25 | #ifndef __AES_H__ 26 | #define __AES_H__ 27 | 28 | #define AES_BLOCK_SIZE 16 29 | #define AES_BLOCKS32 (AES_BLOCK_SIZE/4) 30 | 31 | #define AES_KEYID_ENCRYPTION 0x01 32 | #define AES_KEYID_SIGNATURE 0x02 33 | #define AES_KEYID_AUTH 0x03 34 | 35 | typedef uint8_t TAES[AES_BLOCK_SIZE]; 36 | 37 | typedef struct { 38 | TAES key, in, out; 39 | } PACKED TCryptoEngine; 40 | 41 | extern void aes_init(uint32_t uid); 42 | extern void aes_key_derivation(const TAES* key, uint32_t uid); 43 | extern void aes(TCryptoEngine* engine); 44 | extern TAES* aes_sign(const void* data, uint32_t length); 45 | extern uint8_t aes_encr(const void* in, void* out, uint32_t size, uint8_t mac_len); 46 | extern uint8_t aes_decr(const void* in, void* out, uint32_t length, uint8_t mac_len); 47 | 48 | #endif/*__AES_H__*/ 49 | -------------------------------------------------------------------------------- /firmware/nRF51/tag-proximity/inc/aes.h: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * 3 | * OpenBeacon.org - nRF51 AES Hardware Encryption & Signing 4 | * 5 | * Copyright 2014 Milosch Meriac 6 | * 7 | *************************************************************** 8 | 9 | This file is part of the OpenBeacon.org active RFID firmware 10 | 11 | OpenBeacon is free software: you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | OpenBeacon is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with Foobar. If not, see . 23 | 24 | */ 25 | #ifndef __AES_H__ 26 | #define __AES_H__ 27 | 28 | #define AES_BLOCK_SIZE 16 29 | #define AES_BLOCKS32 (AES_BLOCK_SIZE/4) 30 | 31 | #define AES_KEYID_ENCRYPTION 0x01 32 | #define AES_KEYID_SIGNATURE 0x02 33 | #define AES_KEYID_AUTH 0x03 34 | 35 | typedef uint8_t TAES[AES_BLOCK_SIZE]; 36 | 37 | typedef struct { 38 | TAES key, in, out; 39 | } PACKED TCryptoEngine; 40 | 41 | extern void aes_init(uint32_t uid); 42 | extern void aes_key_derivation(const TAES* key, uint32_t uid); 43 | extern void aes(TCryptoEngine* engine); 44 | extern TAES* aes_sign(const void* data, uint32_t length); 45 | extern uint8_t aes_encr(const void* in, void* out, uint32_t size, uint8_t mac_len); 46 | extern uint8_t aes_decr(const void* in, void* out, uint32_t length, uint8_t mac_len); 47 | 48 | #endif/*__AES_H__*/ 49 | -------------------------------------------------------------------------------- /firmware/nRF51/tag-physical-web/README.md: -------------------------------------------------------------------------------- 1 | ## OpenBeacon Physical Web Beacon 2 | 3 | Our code is hosted on [github.com](https://github.com/meriac/openbeacon-ng). Software development is officially supported for OS X and Linux. Please use the latest [gcc-arm-none-eabi](https://launchpad.net/gcc-arm-embedded) toolchain from launchpad. Thanks a lot to ARM for maintaining [GNU Tools for ARM Embedded Processor](https://launchpad.net/gcc-arm-embedded). 4 | 5 | ### Hello World! 6 | To demonstrate usage of the included 3D acceleration sensor the included hello world example transmits the URL only while facing forward. 7 | 8 | Get the [hardware design](http://get.openbeacon.org/device.html) and [development environment](http://get.openbeacon.org/source/) for creating your own beacons. 9 | 10 | You can find the main loop in [firmware/nRF51/tag-physical-web/entry.c](https://github.com/meriac/openbeacon-ng/blob/master/firmware/nRF51/tag-physical-web/entry.c). 11 | 12 | ### Quick start 13 | For compiling and flashing the firmware source you need to get the [source code](https://github.com/meriac/openbeacon-ng): 14 | ```bash 15 | # get the latest source code 16 | git clone https://github.com/meriac/openbeacon-ng 17 | # change into tag directory 18 | cd openbeacon-ng/firmware/nRF51/tag-physical-web 19 | # compile and flash code 20 | make clean flash 21 | ``` 22 | As you can see the makefile directly supports flashing from command line (under OSX and Linux) by using a [Segger J-Link debug probe](https://www.segger.com/jlink-software.html) from the [Nordic nRF51822 development kit](http://uk.mouser.com/Search/Refine.aspx?Keyword=949-NRF51822-DK). 23 | 24 | ### Support ### 25 | 26 | Please sign up to our [OpenBeacon Group](https://groups.google.com/forum/#!forum/openbeacon) or contact us at [developer@openbeacon.org](mailto:developer@openbeacon.org?subject=Developer%20Support). 27 | 28 | -------------------------------------------------------------------------------- /firmware/nRF51/reader-prox/inc/radio.h: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * 3 | * OpenBeacon.org - nRF51 2.4GHz Radio Routines 4 | * 5 | * Copyright 2013-2015 Milosch Meriac 6 | * 7 | *************************************************************** 8 | 9 | This file is part of the OpenBeacon.org active RFID firmware 10 | 11 | OpenBeacon is free software: you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | OpenBeacon is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with Foobar. If not, see . 23 | 24 | */ 25 | #ifndef __RADIO_H__ 26 | #define __RADIO_H__ 27 | 28 | #ifndef RADIO_MAX_PKT_BUFFERS 29 | #define RADIO_MAX_PKT_BUFFERS 128 30 | #endif/*RADIO_MAX_PKT_BUFFERS*/ 31 | 32 | #ifdef RADIO_OLD_FORMAT 33 | # define NRF_TRACKER_SIZE 16 34 | # define NRF_TRACKER_PREFIX 0x80UL 35 | # define NRF_TRACKER_ADDRESS 0x40C04080UL 36 | #else 37 | # define NRF_TRACKER_SIZE 32 38 | # define NRF_TRACKER_PREFIX 0x46UL //NRF_RADIO->PREFIX0 = 0x46D7UL 39 | //# define NRF_TRACKER_ADDRESS 0xEA8AF0B1UL 40 | # define NRF_TRACKER_ADDRESS 0xCC864569UL 41 | #endif/*RADIO_OLD_FORMAT*/ 42 | 43 | typedef struct 44 | { 45 | int8_t rssi; 46 | uint8_t buf[NRF_TRACKER_SIZE]; 47 | } TBeaconBuffer; 48 | 49 | extern void radio_init(void); 50 | extern int radio_packet_count(void); 51 | extern BOOL radio_rx(TBeaconBuffer *buf); 52 | 53 | 54 | #endif/*__RADIO_H__*/ 55 | -------------------------------------------------------------------------------- /firmware/nRF51/reader-ble/inc/config.h: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * 3 | * OpenBeacon.org - nRF51 board config files 4 | * 5 | * Copyright 2013 Milosch Meriac 6 | * 7 | *************************************************************** 8 | 9 | This file is part of the OpenBeacon.org active RFID firmware 10 | 11 | OpenBeacon is free software: you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | OpenBeacon is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with Foobar. If not, see . 23 | 24 | */ 25 | #ifndef __CONFIG_H__ 26 | #define __CONFIG_H__ 27 | 28 | #define CONFIG_UART_BAUDRATE UART_BAUDRATE_BAUDRATE_Baud115200 29 | #define CONFIG_UART_TXD_PIN 9 30 | #ifdef CONFIG_UART_RX 31 | #define CONFIG_UART_RXD_PIN 8 32 | #else 33 | #define CONFIG_GPIO3_PIN 8 34 | #endif/*CONFIG_UART_RX*/ 35 | 36 | #define CONFIG_LED_PIN 17 37 | #define CONFIG_SWITCH_PIN 29 38 | 39 | /* only two priority bits available ! */ 40 | 41 | #define IRQ_PRIORITY_HIGH 0 42 | #define IRQ_PRIORITY_UART0 (IRQ_PRIORITY_HIGH) 43 | #define IRQ_PRIORITY_POWER_CLOCK (IRQ_PRIORITY_HIGH+1) 44 | #define IRQ_PRIORITY_RADIO (IRQ_PRIORITY_HIGH+2) 45 | 46 | #define IRQ_PRIORITY_LOW (IRQ_PRIORITY_HIGH+3) 47 | #define IRQ_PRIORITY_RTC0 (IRQ_PRIORITY_LOW) 48 | #define IRQ_PRIORITY_RTC1 (IRQ_PRIORITY_LOW) 49 | 50 | #endif/*__CONFIG_H__*/ 51 | -------------------------------------------------------------------------------- /host/openbeacon-rx/src/crypto.h: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * 3 | * OpenBeacon.org - AES Encryption & Signing 4 | * 5 | * Copyright 2014 Milosch Meriac 6 | * 7 | *************************************************************** 8 | 9 | This file is part of the OpenBeacon.org active RFID firmware 10 | 11 | OpenBeacon is free software: you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | OpenBeacon is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with Foobar. If not, see . 23 | 24 | */ 25 | #ifndef __CRYPTO_H__ 26 | #define __CRYPTO_H__ 27 | 28 | #define PACKED __attribute__((packed)) 29 | #include 30 | 31 | #define AES_ROUNDS 10 32 | #define AES_BLOCK_SIZE 16 33 | #define AES_BLOCKS32 (AES_BLOCK_SIZE/4) 34 | 35 | #define AES_KEYID_ENCRYPTION 0x01 36 | #define AES_KEYID_SIGNATURE 0x02 37 | #define AES_KEYID_AUTH 0x03 38 | 39 | typedef uint8_t TAES[AES_BLOCK_SIZE]; 40 | 41 | typedef struct { 42 | TAES key, in, out; 43 | } PACKED TCryptoEngine; 44 | 45 | extern void aes_init(void); 46 | extern void aes_key_derivation(const TAES* key); 47 | extern void aes(TCryptoEngine* engine); 48 | extern TAES* aes_sign(const void* data, uint32_t length); 49 | extern uint8_t aes_encr(const void* in, void* out, uint32_t size, uint8_t mac_len); 50 | extern uint8_t aes_decr(const void* in, void* out, uint32_t length, uint8_t mac_len); 51 | 52 | #endif/*__CRYPTO_H__*/ 53 | -------------------------------------------------------------------------------- /host/openbeacon-power/src/crypto.h: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * 3 | * OpenBeacon.org - AES Encryption & Signing 4 | * 5 | * Copyright 2014 Milosch Meriac 6 | * 7 | *************************************************************** 8 | 9 | This file is part of the OpenBeacon.org active RFID firmware 10 | 11 | OpenBeacon is free software: you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | OpenBeacon is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with Foobar. If not, see . 23 | 24 | */ 25 | #ifndef __CRYPTO_H__ 26 | #define __CRYPTO_H__ 27 | 28 | #define PACKED __attribute__((packed)) 29 | #include 30 | 31 | #define AES_ROUNDS 10 32 | #define AES_BLOCK_SIZE 16 33 | #define AES_BLOCKS32 (AES_BLOCK_SIZE/4) 34 | 35 | #define AES_KEYID_ENCRYPTION 0x01 36 | #define AES_KEYID_SIGNATURE 0x02 37 | #define AES_KEYID_AUTH 0x03 38 | 39 | typedef uint8_t TAES[AES_BLOCK_SIZE]; 40 | 41 | typedef struct { 42 | TAES key, in, out; 43 | } PACKED TCryptoEngine; 44 | 45 | extern void aes_init(void); 46 | extern void aes_key_derivation(const TAES* key); 47 | extern void aes(TCryptoEngine* engine); 48 | extern TAES* aes_sign(const void* data, uint32_t length); 49 | extern uint8_t aes_encr(const void* in, void* out, uint32_t size, uint8_t mac_len); 50 | extern uint8_t aes_decr(const void* in, void* out, uint32_t length, uint8_t mac_len); 51 | 52 | #endif/*__CRYPTO_H__*/ 53 | -------------------------------------------------------------------------------- /firmware/nRF51/tag-physical-web/lib/inc/lib.h: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * 3 | * OpenBeacon.org - nRF51 Timer Routines 4 | * 5 | * Copyright 2013 Milosch Meriac 6 | * 7 | *************************************************************** 8 | 9 | This file is part of the OpenBeacon.org active RFID firmware 10 | 11 | OpenBeacon is free software: you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | OpenBeacon is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with Foobar. If not, see . 23 | 24 | */ 25 | 26 | #ifndef __LIB_H__ 27 | #define __LIB_H__ 28 | 29 | #include 30 | #include 31 | #include 32 | #include 33 | 34 | /* userland entry */ 35 | extern void entry(void); 36 | 37 | /* shortcuts to often used functions */ 38 | #define pin_set nrf_gpio_pin_set 39 | #define pin_clear nrf_gpio_pin_clear 40 | 41 | /* string compression for tah URLs */ 42 | typedef enum { 43 | PROTO_HTTP_WWW = 0, /* http://www. */ 44 | PROTO_HTTPS_WWW = 1, /* https://www. */ 45 | PROTO_HTTP = 2, /* http:// */ 46 | PROTO_HTTPS = 3, /* https:// */ 47 | PROTO_TEL = 4, /* tel: */ 48 | PROTO_MAILTO = 5, /* mailto: */ 49 | PROTO_GEO = 6, /* geo: */ 50 | DOT_COM = 7, /* .com */ 51 | DOT_ORG = 8, /* .org */ 52 | DOT_EDU = 9, /* .edu */ 53 | } TTagURLShortener; 54 | 55 | #endif/*__LIB_H__*/ 56 | -------------------------------------------------------------------------------- /firmware/nRF51/core/nrf/inc/nrf_temp.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved. 2 | * 3 | * The information contained herein is property of Nordic Semiconductor ASA. 4 | * Terms and conditions of usage are described in detail in NORDIC 5 | * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. 6 | * 7 | * Licensees are granted free, non-transferable use of the information. NO 8 | * WARRANTY of ANY KIND is provided. This heading must NOT be removed from 9 | * the file. 10 | * 11 | */ 12 | 13 | #ifndef NRF_TEMP_H__ 14 | #define NRF_TEMP_H__ 15 | 16 | #include "nrf51.h" 17 | 18 | /** 19 | * @defgroup nrf_temperature TEMP (temperature) abstraction 20 | * @{ 21 | * @ingroup nrf_drivers temperature_example 22 | * @brief Temperature module init and read functions. 23 | * 24 | */ 25 | 26 | 27 | 28 | /** 29 | * @brief Function for preparing the temp module for temperature measurement. 30 | * 31 | * This function initializes the TEMP module and writes to the hidden configuration register. 32 | * 33 | * @param none 34 | */ 35 | static __INLINE void nrf_temp_init(void) 36 | { 37 | /**@note Workaround for PAN_028 rev2.0A anomaly 31 - TEMP: Temperature offset value has to be manually loaded to the TEMP module */ 38 | *(uint32_t *) 0x4000C504 = 0; 39 | } 40 | 41 | 42 | 43 | #define MASK_SIGN (0x00000200UL) 44 | #define MASK_SIGN_EXTENSION (0xFFFFFC00UL) 45 | 46 | /** 47 | * @brief Function for reading temperature measurement. 48 | * 49 | * The function reads the 10 bit 2's complement value and transforms it to a 32 bit 2's complement value. 50 | * 51 | * @param none 52 | */ 53 | static __INLINE int32_t nrf_temp_read(void) 54 | { 55 | /**@note Workaround for PAN_028 rev2.0A anomaly 28 - TEMP: Negative measured values are not represented correctly */ 56 | return ((NRF_TEMP->TEMP & MASK_SIGN) != 0) ? (int32_t)(NRF_TEMP->TEMP | MASK_SIGN_EXTENSION) : (int32_t)(NRF_TEMP->TEMP); 57 | } 58 | 59 | /** @} */ 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /firmware/nRF51/reader-prox/inc/config.h: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * 3 | * OpenBeacon.org - nRF51 board config files 4 | * 5 | * Copyright 2013-2015 Milosch Meriac 6 | * 7 | *************************************************************** 8 | 9 | This file is part of the OpenBeacon.org active RFID firmware 10 | 11 | OpenBeacon is free software: you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | OpenBeacon is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with Foobar. If not, see . 23 | 24 | */ 25 | #ifndef __CONFIG_H__ 26 | #define __CONFIG_H__ 27 | 28 | #define CONFIG_RADIO_CHANNEL 81 29 | 30 | #define CONFIG_UART_BAUDRATE UART_BAUDRATE_BAUDRATE_Baud1M 31 | #define CONFIG_UART_BUFFER 2048 32 | #define CONFIG_UART_FORCE_POWERED 1 33 | #define CONFIG_UART_TXD_PIN 9 34 | #ifdef CONFIG_UART_RX 35 | #define CONFIG_UART_RXD_PIN 8 36 | #else 37 | #define CONFIG_GPIO3_PIN 8 38 | #endif/*CONFIG_UART_RX*/ 39 | 40 | #define CONFIG_LED_PIN 17 41 | #define CONFIG_SWITCH_PIN 29 42 | 43 | /* only two priority bits available ! */ 44 | 45 | #define IRQ_PRIORITY_HIGH 0 46 | #define IRQ_PRIORITY_RADIO (IRQ_PRIORITY_HIGH) 47 | #define IRQ_PRIORITY_UART0 (IRQ_PRIORITY_HIGH+1) 48 | #define IRQ_PRIORITY_POWER_CLOCK (IRQ_PRIORITY_HIGH+2) 49 | 50 | #define IRQ_PRIORITY_LOW (IRQ_PRIORITY_HIGH+3) 51 | #define IRQ_PRIORITY_RTC0 (IRQ_PRIORITY_LOW) 52 | #define IRQ_PRIORITY_RTC1 (IRQ_PRIORITY_LOW) 53 | 54 | #endif/*__CONFIG_H__*/ 55 | -------------------------------------------------------------------------------- /host/openbeacon-rx/Makefile: -------------------------------------------------------------------------------- 1 | CXX :=g++ 2 | TARGET :=openbeacon-rx 3 | SOURCES :=src/bmMapHandleToItem.cpp src/main.cpp src/crypto.cpp 4 | FILTERSS:=filter-singularsighting 5 | LIBS :=-lm -pthread 6 | 7 | # determine program version 8 | PROGRAM_VERSION:=$(shell git describe --tags --abbrev=4 --dirty 2>/dev/null | sed s/^v//) 9 | ifeq ("$(PROGRAM_VERSION)","") 10 | PROGRAM_VERSION:='unknown' 11 | endif 12 | 13 | # determine if we have custom encryption keys 14 | ifeq ("$(wildcard src/custom-encryption-keys.h)","") 15 | ENCRYPTION_KEYS:= 16 | else 17 | ENCRYPTION_KEYS:=-DCUSTOM_ENCRYPTION_KEYS 18 | endif 19 | 20 | DEBUG :=-O3 21 | CXXOPT :=$(DEBUG) 22 | INCLUDE :=-I../../firmware/nRF51/tag-proximity/inc/ 23 | CXXFLAGS:=-Werror -Wall -D_REENTRANT -DPROGRAM_VERSION=\"$(PROGRAM_VERSION)\" -DPROGRAM_NAME=\"$(TARGET)\" $(ENCRYPTION_KEYS) $(INCLUDE) 24 | LDFLAGS :=$(LIBS) 25 | OBJS :=$(SOURCES:%.cpp=%.o) 26 | LOGJSON :=$(LOGFILE:%.bin=%.json.bz2) 27 | PREFIX :=/usr/local 28 | 29 | all: $(TARGET) $(FILTERSS) 30 | 31 | demo: all 32 | ./$(TARGET) | ./$(FILTERSS) ~/public_html/test.json 33 | 34 | .PHONY: all version run install indent debug dependencies-fedora cleanall clean 35 | 36 | version: 37 | @echo "$(TARGET) version $(PROGRAM_VERSION)" 38 | 39 | run: $(TARGET) 40 | ./$(TARGET) 41 | 42 | install: $(TARGET) $(FILTER) 43 | install $(TARGET) $(FILTER) $(PREFIX)/bin/ 44 | 45 | $(FILTERSS): src/$(FILTERSS).cpp 46 | $(CXX) $(CXXFLAGS) $(CXXOPT) $(LDOPT) $^ -lz -o $@ 47 | 48 | indent: $(SOURCES) 49 | find src -iname '*\.[cph]*' -exec indent -c81 -i4 -cli4 -bli0 -ts 4 \{\} \; 50 | rm -f src/*~ 51 | 52 | $(TARGET): .depend $(OBJS) 53 | $(CXX) $(LDOPT) $(OBJS) $(LDFLAGS) -o $@ 54 | 55 | .depend: $(SOURCES) $(FILTERS) 56 | $(CXX) $(CXXFLAGS) $(CXXOPT) -MM $^ > $@ 57 | 58 | .cpp.o: 59 | $(CXX) $(CXXFLAGS) $(CXXOPT) -c $< -o $@ 60 | 61 | dependencies-fedora: 62 | sudo yum install gcc-c++ zlib zlib-devel 63 | 64 | cleanall: clean 65 | rm -f .depend 66 | 67 | clean: 68 | rm -f $(TARGET) $(OBJS) $(FILTERSS) *~ 69 | 70 | include .depend 71 | -------------------------------------------------------------------------------- /firmware/nRF51/reader-ble/src/timer.c: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * 3 | * OpenBeacon.org - nRF51 Timer Routines 4 | * 5 | * Copyright 2013 Milosch Meriac 6 | * 7 | *************************************************************** 8 | 9 | This file is part of the OpenBeacon.org active RFID firmware 10 | 11 | OpenBeacon is free software: you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | OpenBeacon is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with Foobar. If not, see . 23 | 24 | */ 25 | #include 26 | #include 27 | 28 | static volatile uint8_t g_timer_wait; 29 | 30 | void timer_wait(uint32_t ticks) 31 | { 32 | g_timer_wait = TRUE; 33 | 34 | /* configure timeout */ 35 | NRF_RTC1->CC[0] = ticks; 36 | /* start timer */ 37 | NRF_RTC1->TASKS_START = 1; 38 | 39 | while(g_timer_wait) 40 | __WFE(); 41 | } 42 | 43 | void RTC1_IRQ_Handler(void) 44 | { 45 | /* allow wait loop to exit */ 46 | g_timer_wait = FALSE; 47 | 48 | /* stop timer */ 49 | NRF_RTC1->TASKS_STOP = 1; 50 | NRF_RTC1->TASKS_CLEAR = 1; 51 | /* acknowledge interrupt */ 52 | NRF_RTC1->EVENTS_COMPARE[0] = 0; 53 | } 54 | 55 | void timer_init(void) 56 | { 57 | /* start 32kHz crystal oscillator */ 58 | NRF_CLOCK->LFCLKSRC = 59 | (CLOCK_LFCLKSRCCOPY_SRC_Xtal << CLOCK_LFCLKSRCCOPY_SRC_Pos); 60 | NRF_CLOCK->EVENTS_LFCLKSTARTED = 0; 61 | NRF_CLOCK->TASKS_LFCLKSTART = 1; 62 | while(!NRF_CLOCK->EVENTS_LFCLKSTARTED); 63 | 64 | /* setup delay routine */ 65 | NRF_RTC1->COUNTER = 0; 66 | NRF_RTC1->PRESCALER = 0; 67 | NRF_RTC1->TASKS_STOP = 1; 68 | NRF_RTC1->INTENSET = 69 | (RTC_INTENSET_COMPARE0_Enabled << RTC_INTENSET_COMPARE0_Pos); 70 | 71 | NVIC_SetPriority(RTC1_IRQn, IRQ_PRIORITY_RTC1); 72 | NVIC_EnableIRQ(RTC1_IRQn); 73 | } 74 | -------------------------------------------------------------------------------- /firmware/nRF51/tag-power/src/timer.c: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * 3 | * OpenBeacon.org - nRF51 Timer Routines 4 | * 5 | * Copyright 2013 Milosch Meriac 6 | * 7 | *************************************************************** 8 | 9 | This file is part of the OpenBeacon.org active RFID firmware 10 | 11 | OpenBeacon is free software: you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | OpenBeacon is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with Foobar. If not, see . 23 | 24 | */ 25 | #include 26 | #include 27 | 28 | static volatile uint8_t g_timer_wait; 29 | 30 | void timer_wait(uint32_t ticks) 31 | { 32 | g_timer_wait = TRUE; 33 | 34 | /* configure timeout */ 35 | NRF_RTC1->CC[0] = ticks; 36 | /* start timer */ 37 | NRF_RTC1->TASKS_START = 1; 38 | 39 | while(g_timer_wait) 40 | __WFE(); 41 | } 42 | 43 | void RTC1_IRQ_Handler(void) 44 | { 45 | /* allow wait loop to exit */ 46 | g_timer_wait = FALSE; 47 | 48 | /* stop timer */ 49 | NRF_RTC1->TASKS_STOP = 1; 50 | NRF_RTC1->TASKS_CLEAR = 1; 51 | /* acknowledge interrupt */ 52 | NRF_RTC1->EVENTS_COMPARE[0] = 0; 53 | } 54 | 55 | void timer_init(void) 56 | { 57 | /* start 32kHz crystal oscillator */ 58 | NRF_CLOCK->LFCLKSRC = 59 | (CLOCK_LFCLKSRCCOPY_SRC_Xtal << CLOCK_LFCLKSRCCOPY_SRC_Pos); 60 | NRF_CLOCK->EVENTS_LFCLKSTARTED = 0; 61 | NRF_CLOCK->TASKS_LFCLKSTART = 1; 62 | while(!NRF_CLOCK->EVENTS_LFCLKSTARTED); 63 | 64 | /* setup delay routine */ 65 | NRF_RTC1->COUNTER = 0; 66 | NRF_RTC1->PRESCALER = 0; 67 | NRF_RTC1->TASKS_STOP = 1; 68 | NRF_RTC1->INTENSET = 69 | (RTC_INTENSET_COMPARE0_Enabled << RTC_INTENSET_COMPARE0_Pos); 70 | 71 | NVIC_SetPriority(RTC1_IRQn, IRQ_PRIORITY_RTC1); 72 | NVIC_EnableIRQ(RTC1_IRQn); 73 | } 74 | -------------------------------------------------------------------------------- /firmware/nRF51/tag-ble-beacon/src/timer.c: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * 3 | * OpenBeacon.org - nRF51 Timer Routines 4 | * 5 | * Copyright 2013 Milosch Meriac 6 | * 7 | *************************************************************** 8 | 9 | This file is part of the OpenBeacon.org active RFID firmware 10 | 11 | OpenBeacon is free software: you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | OpenBeacon is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with Foobar. If not, see . 23 | 24 | */ 25 | #include 26 | #include 27 | 28 | static volatile uint8_t g_timer_wait; 29 | 30 | void timer_wait(uint32_t ticks) 31 | { 32 | g_timer_wait = TRUE; 33 | 34 | /* configure timeout */ 35 | NRF_RTC1->CC[0] = ticks; 36 | /* start timer */ 37 | NRF_RTC1->TASKS_START = 1; 38 | 39 | while(g_timer_wait) 40 | __WFE(); 41 | } 42 | 43 | void RTC1_IRQ_Handler(void) 44 | { 45 | /* allow wait loop to exit */ 46 | g_timer_wait = FALSE; 47 | 48 | /* stop timer */ 49 | NRF_RTC1->TASKS_STOP = 1; 50 | NRF_RTC1->TASKS_CLEAR = 1; 51 | /* acknowledge interrupt */ 52 | NRF_RTC1->EVENTS_COMPARE[0] = 0; 53 | } 54 | 55 | void timer_init(void) 56 | { 57 | /* start 32kHz crystal oscillator */ 58 | NRF_CLOCK->LFCLKSRC = 59 | (CLOCK_LFCLKSRCCOPY_SRC_Xtal << CLOCK_LFCLKSRCCOPY_SRC_Pos); 60 | NRF_CLOCK->EVENTS_LFCLKSTARTED = 0; 61 | NRF_CLOCK->TASKS_LFCLKSTART = 1; 62 | while(!NRF_CLOCK->EVENTS_LFCLKSTARTED); 63 | 64 | /* setup delay routine */ 65 | NRF_RTC1->COUNTER = 0; 66 | NRF_RTC1->PRESCALER = 0; 67 | NRF_RTC1->TASKS_STOP = 1; 68 | NRF_RTC1->INTENSET = 69 | (RTC_INTENSET_COMPARE0_Enabled << RTC_INTENSET_COMPARE0_Pos); 70 | 71 | NVIC_SetPriority(RTC1_IRQn, IRQ_PRIORITY_RTC1); 72 | NVIC_EnableIRQ(RTC1_IRQn); 73 | } 74 | -------------------------------------------------------------------------------- /firmware/nRF51/tag-mischief/src/timer.c: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * 3 | * OpenBeacon.org - nRF51 Timer Routines 4 | * 5 | * Copyright 2013 Milosch Meriac 6 | * 7 | *************************************************************** 8 | 9 | This file is part of the OpenBeacon.org active RFID firmware 10 | 11 | OpenBeacon is free software: you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | OpenBeacon is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with Foobar. If not, see . 23 | 24 | */ 25 | #include 26 | #include 27 | 28 | static volatile uint8_t g_timer_wait; 29 | 30 | void timer_wait(uint32_t ticks) 31 | { 32 | g_timer_wait = TRUE; 33 | 34 | /* configure timeout */ 35 | NRF_RTC1->CC[0] = ticks; 36 | /* start timer */ 37 | NRF_RTC1->TASKS_START = 1; 38 | 39 | while(g_timer_wait) 40 | __WFE(); 41 | } 42 | 43 | void RTC1_IRQ_Handler(void) 44 | { 45 | /* allow wait loop to exit */ 46 | g_timer_wait = FALSE; 47 | 48 | /* stop timer */ 49 | NRF_RTC1->TASKS_STOP = 1; 50 | NRF_RTC1->TASKS_CLEAR = 1; 51 | /* acknowledge interrupt */ 52 | NRF_RTC1->EVENTS_COMPARE[0] = 0; 53 | } 54 | 55 | void timer_init(void) 56 | { 57 | /* start 32kHz crystal oscillator */ 58 | NRF_CLOCK->LFCLKSRC = 59 | (CLOCK_LFCLKSRCCOPY_SRC_Xtal << CLOCK_LFCLKSRCCOPY_SRC_Pos); 60 | NRF_CLOCK->EVENTS_LFCLKSTARTED = 0; 61 | NRF_CLOCK->TASKS_LFCLKSTART = 1; 62 | while(!NRF_CLOCK->EVENTS_LFCLKSTARTED); 63 | 64 | /* setup delay routine */ 65 | NRF_RTC1->COUNTER = 0; 66 | NRF_RTC1->PRESCALER = 0; 67 | NRF_RTC1->TASKS_STOP = 1; 68 | NRF_RTC1->INTENSET = 69 | (RTC_INTENSET_COMPARE0_Enabled << RTC_INTENSET_COMPARE0_Pos); 70 | 71 | NVIC_SetPriority(RTC1_IRQn, IRQ_PRIORITY_RTC1); 72 | NVIC_EnableIRQ(RTC1_IRQn); 73 | } 74 | -------------------------------------------------------------------------------- /firmware/nRF51/tag-proximity/src/timer.c: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * 3 | * OpenBeacon.org - nRF51 Timer Routines 4 | * 5 | * Copyright 2013 Milosch Meriac 6 | * 7 | *************************************************************** 8 | 9 | This file is part of the OpenBeacon.org active RFID firmware 10 | 11 | OpenBeacon is free software: you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | OpenBeacon is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with Foobar. If not, see . 23 | 24 | */ 25 | #include 26 | #include 27 | 28 | static volatile uint8_t g_timer_wait; 29 | 30 | void timer_wait(uint32_t ticks) 31 | { 32 | g_timer_wait = TRUE; 33 | 34 | /* configure timeout */ 35 | NRF_RTC1->CC[0] = ticks; 36 | /* start timer */ 37 | NRF_RTC1->TASKS_START = 1; 38 | 39 | while(g_timer_wait) 40 | __WFE(); 41 | } 42 | 43 | void RTC1_IRQ_Handler(void) 44 | { 45 | /* allow wait loop to exit */ 46 | g_timer_wait = FALSE; 47 | 48 | /* stop timer */ 49 | NRF_RTC1->TASKS_STOP = 1; 50 | NRF_RTC1->TASKS_CLEAR = 1; 51 | /* acknowledge interrupt */ 52 | NRF_RTC1->EVENTS_COMPARE[0] = 0; 53 | } 54 | 55 | void timer_init(void) 56 | { 57 | /* start 32kHz crystal oscillator */ 58 | NRF_CLOCK->LFCLKSRC = 59 | (CLOCK_LFCLKSRCCOPY_SRC_Xtal << CLOCK_LFCLKSRCCOPY_SRC_Pos); 60 | NRF_CLOCK->EVENTS_LFCLKSTARTED = 0; 61 | NRF_CLOCK->TASKS_LFCLKSTART = 1; 62 | while(!NRF_CLOCK->EVENTS_LFCLKSTARTED); 63 | 64 | /* setup delay routine */ 65 | NRF_RTC1->COUNTER = 0; 66 | NRF_RTC1->PRESCALER = 0; 67 | NRF_RTC1->TASKS_STOP = 1; 68 | NRF_RTC1->INTENSET = 69 | (RTC_INTENSET_COMPARE0_Enabled << RTC_INTENSET_COMPARE0_Pos); 70 | 71 | NVIC_SetPriority(RTC1_IRQn, IRQ_PRIORITY_RTC1); 72 | NVIC_EnableIRQ(RTC1_IRQn); 73 | } 74 | -------------------------------------------------------------------------------- /firmware/nRF51/tag-physical-web/lib/src/timer.c: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * 3 | * OpenBeacon.org - nRF51 Timer Routines 4 | * 5 | * Copyright 2013 Milosch Meriac 6 | * 7 | *************************************************************** 8 | 9 | This file is part of the OpenBeacon.org active RFID firmware 10 | 11 | OpenBeacon is free software: you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | OpenBeacon is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with Foobar. If not, see . 23 | 24 | */ 25 | #include 26 | #include 27 | 28 | static volatile uint8_t g_timer_wait; 29 | 30 | void timer_wait(uint32_t ticks) 31 | { 32 | g_timer_wait = TRUE; 33 | 34 | /* configure timeout */ 35 | NRF_RTC1->CC[0] = ticks; 36 | /* start timer */ 37 | NRF_RTC1->TASKS_START = 1; 38 | 39 | while(g_timer_wait) 40 | __WFE(); 41 | } 42 | 43 | void RTC1_IRQ_Handler(void) 44 | { 45 | /* allow wait loop to exit */ 46 | g_timer_wait = FALSE; 47 | 48 | /* stop timer */ 49 | NRF_RTC1->TASKS_STOP = 1; 50 | NRF_RTC1->TASKS_CLEAR = 1; 51 | /* acknowledge interrupt */ 52 | NRF_RTC1->EVENTS_COMPARE[0] = 0; 53 | } 54 | 55 | void timer_init(void) 56 | { 57 | /* start 32kHz crystal oscillator */ 58 | NRF_CLOCK->LFCLKSRC = 59 | (CLOCK_LFCLKSRCCOPY_SRC_Xtal << CLOCK_LFCLKSRCCOPY_SRC_Pos); 60 | NRF_CLOCK->EVENTS_LFCLKSTARTED = 0; 61 | NRF_CLOCK->TASKS_LFCLKSTART = 1; 62 | while(!NRF_CLOCK->EVENTS_LFCLKSTARTED); 63 | 64 | /* setup delay routine */ 65 | NRF_RTC1->COUNTER = 0; 66 | NRF_RTC1->PRESCALER = 0; 67 | NRF_RTC1->TASKS_STOP = 1; 68 | NRF_RTC1->INTENSET = 69 | (RTC_INTENSET_COMPARE0_Enabled << RTC_INTENSET_COMPARE0_Pos); 70 | 71 | NVIC_SetPriority(RTC1_IRQn, IRQ_PRIORITY_RTC1); 72 | NVIC_EnableIRQ(RTC1_IRQn); 73 | } 74 | -------------------------------------------------------------------------------- /firmware/nRF51/reader-prox/src/timer.c: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * 3 | * OpenBeacon.org - nRF51 Timer Routines 4 | * 5 | * Copyright 2013-2015 Milosch Meriac 6 | * 7 | *************************************************************** 8 | 9 | This file is part of the OpenBeacon.org active RFID firmware 10 | 11 | OpenBeacon is free software: you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | OpenBeacon is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with Foobar. If not, see . 23 | 24 | */ 25 | #include 26 | #include 27 | 28 | static volatile uint8_t g_timer_wait; 29 | 30 | void timer_wait(uint32_t ticks) 31 | { 32 | g_timer_wait = TRUE; 33 | 34 | /* configure timeout */ 35 | NRF_RTC1->CC[0] = ticks; 36 | /* start timer */ 37 | NRF_RTC1->TASKS_START = 1; 38 | 39 | while(g_timer_wait) 40 | __WFE(); 41 | } 42 | 43 | void RTC1_IRQ_Handler(void) 44 | { 45 | /* allow wait loop to exit */ 46 | g_timer_wait = FALSE; 47 | 48 | /* stop timer */ 49 | NRF_RTC1->TASKS_STOP = 1; 50 | NRF_RTC1->TASKS_CLEAR = 1; 51 | /* acknowledge interrupt */ 52 | NRF_RTC1->EVENTS_COMPARE[0] = 0; 53 | } 54 | 55 | void timer_init(void) 56 | { 57 | /* start synthesized 32kHz clock source */ 58 | NRF_CLOCK->LFCLKSRC = 59 | (CLOCK_LFCLKSRCCOPY_SRC_Synth << CLOCK_LFCLKSRCCOPY_SRC_Pos); 60 | NRF_CLOCK->EVENTS_LFCLKSTARTED = 0; 61 | NRF_CLOCK->TASKS_LFCLKSTART = 1; 62 | while(!NRF_CLOCK->EVENTS_LFCLKSTARTED); 63 | 64 | /* setup delay routine */ 65 | NRF_RTC1->COUNTER = 0; 66 | NRF_RTC1->PRESCALER = 0; 67 | NRF_RTC1->TASKS_STOP = 1; 68 | NRF_RTC1->INTENSET = 69 | (RTC_INTENSET_COMPARE0_Enabled << RTC_INTENSET_COMPARE0_Pos); 70 | 71 | NVIC_SetPriority(RTC1_IRQn, IRQ_PRIORITY_RTC1); 72 | NVIC_EnableIRQ(RTC1_IRQn); 73 | } 74 | -------------------------------------------------------------------------------- /host/openbeacon-rx/src/bmMapHandleToItem.h: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * 3 | * OpenBeacon.org - OnAir protocol position estimator 4 | * accepts a text file with tag sightings per reader. 5 | * 6 | * See the following website for already decoded Sputnik data: 7 | * http://people.openpcd.org/meri/openbeacon/sputnik/data/24c3/ 8 | * 9 | * Copyright 2009 Milosch Meriac 10 | * 11 | ***************************************************************/ 12 | 13 | /* 14 | This program is free software; you can redistribute it and/or modify 15 | it under the terms of the GNU Affero General Public License as published 16 | by the Free Software Foundation; version 3. 17 | 18 | This program is distributed in the hope that it will be useful, 19 | but WITHOUT ANY WARRANTY; without even the implied warranty of 20 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21 | GNU General Public License for more details. 22 | 23 | You should have received a copy of the GNU Affero General Public License 24 | along with this program; if not, write to the Free Software Foundation, 25 | Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 26 | */ 27 | 28 | #ifndef __BMMAPHANDLETOITEM_H__ 29 | #define __BMMAPHANDLETOITEM_H__ 30 | 31 | #define HASH_MAP_INDEX_SIZE 0x100000 32 | 33 | typedef uint64_t bmHandle; 34 | typedef void (*bmIterationCallback) (void *Item, double timestamp, 35 | bool realtime); 36 | 37 | typedef struct 38 | { 39 | bmHandle handle; 40 | pthread_mutex_t mutex; 41 | void *data; 42 | } bmHandleMap; 43 | 44 | class bmMapHandleToItem 45 | { 46 | private: 47 | int m_ItemSize; 48 | int m_MapIteratePos; 49 | bmHandleMap m_Map[HASH_MAP_INDEX_SIZE]; 50 | bmHandleMap *m_MapIterate[HASH_MAP_INDEX_SIZE]; 51 | bmHandleMap *HashMap (bmHandle handle); 52 | public: 53 | bmMapHandleToItem (void); 54 | ~bmMapHandleToItem (void); 55 | bool SetItemSize (int ItemSize); 56 | int GetItemSize (void); 57 | int GetItemCount (void); 58 | void *Find (bmHandle handle, pthread_mutex_t ** mutex); 59 | void *Add (bmHandle handle, pthread_mutex_t ** mutex); 60 | int IterateLocked (bmIterationCallback Callback, double timestamp, 61 | bool realtime); 62 | }; 63 | 64 | #endif/*__BMMAPHANDLETOITEM_H__*/ 65 | -------------------------------------------------------------------------------- /host/openbeacon-power/src/bmMapHandleToItem.h: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * 3 | * OpenBeacon.org - OnAir protocol position estimator 4 | * accepts a text file with tag sightings per reader. 5 | * 6 | * See the following website for already decoded Sputnik data: 7 | * http://people.openpcd.org/meri/openbeacon/sputnik/data/24c3/ 8 | * 9 | * Copyright 2009 Milosch Meriac 10 | * 11 | ***************************************************************/ 12 | 13 | /* 14 | This program is free software; you can redistribute it and/or modify 15 | it under the terms of the GNU Affero General Public License as published 16 | by the Free Software Foundation; version 3. 17 | 18 | This program is distributed in the hope that it will be useful, 19 | but WITHOUT ANY WARRANTY; without even the implied warranty of 20 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21 | GNU General Public License for more details. 22 | 23 | You should have received a copy of the GNU Affero General Public License 24 | along with this program; if not, write to the Free Software Foundation, 25 | Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 26 | */ 27 | 28 | #ifndef __BMMAPHANDLETOITEM_H__ 29 | #define __BMMAPHANDLETOITEM_H__ 30 | 31 | #define HASH_MAP_INDEX_SIZE 0x100000 32 | 33 | typedef uint64_t bmHandle; 34 | typedef void (*bmIterationCallback) (void *Item, double timestamp, 35 | bool realtime); 36 | 37 | typedef struct 38 | { 39 | bmHandle handle; 40 | pthread_mutex_t mutex; 41 | void *data; 42 | } bmHandleMap; 43 | 44 | class bmMapHandleToItem 45 | { 46 | private: 47 | int m_ItemSize; 48 | int m_MapIteratePos; 49 | bmHandleMap m_Map[HASH_MAP_INDEX_SIZE]; 50 | bmHandleMap *m_MapIterate[HASH_MAP_INDEX_SIZE]; 51 | bmHandleMap *HashMap (bmHandle handle); 52 | public: 53 | bmMapHandleToItem (void); 54 | ~bmMapHandleToItem (void); 55 | bool SetItemSize (int ItemSize); 56 | int GetItemSize (void); 57 | int GetItemCount (void); 58 | void *Find (bmHandle handle, pthread_mutex_t ** mutex); 59 | void *Add (bmHandle handle, pthread_mutex_t ** mutex); 60 | int IterateLocked (bmIterationCallback Callback, double timestamp, 61 | bool realtime); 62 | }; 63 | 64 | #endif/*__BMMAPHANDLETOITEM_H__*/ 65 | -------------------------------------------------------------------------------- /firmware/nRF51/tag-physical-web/lib/src/main.c: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * 3 | * OpenBeacon.org - nRF51 Main Entry 4 | * 5 | * Copyright 2013 Milosch Meriac 6 | * 7 | *************************************************************** 8 | 9 | This file is part of the OpenBeacon.org active RFID firmware 10 | 11 | OpenBeacon is free software: you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | OpenBeacon is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with Foobar. If not, see . 23 | 24 | */ 25 | #include 26 | 27 | void blink(uint8_t times) 28 | { 29 | while(times--) 30 | { 31 | nrf_gpio_pin_set(CONFIG_LED_PIN); 32 | timer_wait_ms(10); 33 | nrf_gpio_pin_clear(CONFIG_LED_PIN); 34 | timer_wait_ms(490); 35 | } 36 | } 37 | 38 | void halt(uint8_t times) 39 | { 40 | while(TRUE) 41 | { 42 | blink(times); 43 | timer_wait(SECONDS(3)); 44 | } 45 | } 46 | 47 | void main_entry(void) 48 | { 49 | uint32_t tag_id; 50 | 51 | /* enabled LED output */ 52 | nrf_gpio_cfg_output(CONFIG_LED_PIN); 53 | nrf_gpio_pin_set(CONFIG_LED_PIN); 54 | 55 | /* enabled input pin */ 56 | nrf_gpio_cfg_input(CONFIG_SWITCH_PIN, NRF_GPIO_PIN_NOPULL); 57 | 58 | /* initialize UART */ 59 | uart_init(); 60 | 61 | /* start timer */ 62 | timer_init(); 63 | 64 | /* initialize flash */ 65 | if(flash_init()) 66 | halt(2); 67 | 68 | /* initialize accelerometer */ 69 | if(acc_init()) 70 | halt(3); 71 | 72 | /* calculate tag ID from NRF_FICR->DEVICEID */ 73 | tag_id = crc32(&NRF_FICR->DEVICEID, sizeof(NRF_FICR->DEVICEID)); 74 | 75 | /* start radio */ 76 | debug_printf("\n\rInitializing Tag[%08X] v" PROGRAM_VERSION "\n\r", 77 | tag_id); 78 | radio_init(tag_id); 79 | 80 | /* enter main loop */ 81 | nrf_gpio_pin_clear(CONFIG_LED_PIN); 82 | entry(); 83 | } 84 | -------------------------------------------------------------------------------- /firmware/nRF51/tag-power/src/adc.c: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * 3 | * OpenBeacon.org - nRF51 ADC Support Routines 4 | * 5 | * Copyright 2014 Milosch Meriac 6 | * 7 | *************************************************************** 8 | 9 | This file is part of the OpenBeacon.org active RFID firmware 10 | 11 | OpenBeacon is free software: you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | OpenBeacon is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with Foobar. If not, see . 23 | 24 | */ 25 | #include 26 | #include 27 | 28 | static volatile uint8_t g_battery_voltage; 29 | 30 | void ADC_IRQ_Handler(void) 31 | { 32 | if(NRF_ADC->EVENTS_END) 33 | { 34 | /* acknowledge event */ 35 | NRF_ADC->EVENTS_END = 0; 36 | 37 | /* read battery voltage */ 38 | g_battery_voltage = (((uint16_t)(NRF_ADC->RESULT & 0xFF))*36)>>8; 39 | 40 | /* disable ADC after sampling voltage */ 41 | NRF_ADC->TASKS_STOP = 1; 42 | NRF_ADC->ENABLE = 0; 43 | } 44 | } 45 | 46 | void adc_start(void) 47 | { 48 | /* start ADC voltage conversion */ 49 | NRF_ADC->ENABLE = 1; 50 | NRF_ADC->TASKS_START = 1; 51 | } 52 | 53 | uint8_t adc_bat(void) 54 | { 55 | return g_battery_voltage; 56 | } 57 | 58 | void adc_init(void) 59 | { 60 | /* initialize batter voltage */ 61 | g_battery_voltage = 0; 62 | 63 | /* setup ADC for capturing battery voltage */ 64 | NRF_ADC->CONFIG = ( 65 | (ADC_CONFIG_REFSEL_VBG << ADC_CONFIG_REFSEL_Pos) | 66 | (ADC_CONFIG_INPSEL_SupplyOneThirdPrescaling << ADC_CONFIG_INPSEL_Pos) | 67 | (ADC_CONFIG_RES_8bit << ADC_CONFIG_RES_Pos) 68 | ); 69 | NRF_ADC->INTENSET = ( 70 | (ADC_INTENSET_END_Enabled << ADC_INTENSET_END_Pos) 71 | ); 72 | NVIC_SetPriority(ADC_IRQn, IRQ_PRIORITY_ADC); 73 | NVIC_EnableIRQ(ADC_IRQn); 74 | } 75 | -------------------------------------------------------------------------------- /firmware/nRF51/tag-ble-beacon/src/adc.c: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * 3 | * OpenBeacon.org - nRF51 ADC Support Routines 4 | * 5 | * Copyright 2014 Milosch Meriac 6 | * 7 | *************************************************************** 8 | 9 | This file is part of the OpenBeacon.org active RFID firmware 10 | 11 | OpenBeacon is free software: you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | OpenBeacon is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with Foobar. If not, see . 23 | 24 | */ 25 | #include 26 | #include 27 | 28 | static volatile uint8_t g_battery_voltage; 29 | 30 | void ADC_IRQ_Handler(void) 31 | { 32 | if(NRF_ADC->EVENTS_END) 33 | { 34 | /* acknowledge event */ 35 | NRF_ADC->EVENTS_END = 0; 36 | 37 | /* read battery voltage */ 38 | g_battery_voltage = (((uint16_t)(NRF_ADC->RESULT & 0xFF))*36)>>8; 39 | 40 | /* disable ADC after sampling voltage */ 41 | NRF_ADC->TASKS_STOP = 1; 42 | NRF_ADC->ENABLE = 0; 43 | } 44 | } 45 | 46 | void adc_start(void) 47 | { 48 | /* start ADC voltage conversion */ 49 | NRF_ADC->ENABLE = 1; 50 | NRF_ADC->TASKS_START = 1; 51 | } 52 | 53 | uint8_t adc_bat(void) 54 | { 55 | return g_battery_voltage; 56 | } 57 | 58 | void adc_init(void) 59 | { 60 | /* initialize batter voltage */ 61 | g_battery_voltage = 0; 62 | 63 | /* setup ADC for capturing battery voltage */ 64 | NRF_ADC->CONFIG = ( 65 | (ADC_CONFIG_REFSEL_VBG << ADC_CONFIG_REFSEL_Pos) | 66 | (ADC_CONFIG_INPSEL_SupplyOneThirdPrescaling << ADC_CONFIG_INPSEL_Pos) | 67 | (ADC_CONFIG_RES_8bit << ADC_CONFIG_RES_Pos) 68 | ); 69 | NRF_ADC->INTENSET = ( 70 | (ADC_INTENSET_END_Enabled << ADC_INTENSET_END_Pos) 71 | ); 72 | NVIC_SetPriority(ADC_IRQn, IRQ_PRIORITY_ADC); 73 | NVIC_EnableIRQ(ADC_IRQn); 74 | } 75 | -------------------------------------------------------------------------------- /firmware/nRF51/tag-mischief/src/adc.c: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * 3 | * OpenBeacon.org - nRF51 ADC Support Routines 4 | * 5 | * Copyright 2014 Milosch Meriac 6 | * 7 | *************************************************************** 8 | 9 | This file is part of the OpenBeacon.org active RFID firmware 10 | 11 | OpenBeacon is free software: you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | OpenBeacon is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with Foobar. If not, see . 23 | 24 | */ 25 | #include 26 | #include 27 | 28 | static volatile uint8_t g_battery_voltage; 29 | 30 | void ADC_IRQ_Handler(void) 31 | { 32 | if(NRF_ADC->EVENTS_END) 33 | { 34 | /* acknowledge event */ 35 | NRF_ADC->EVENTS_END = 0; 36 | 37 | /* read battery voltage */ 38 | g_battery_voltage = (((uint16_t)(NRF_ADC->RESULT & 0xFF))*36)>>8; 39 | 40 | /* disable ADC after sampling voltage */ 41 | NRF_ADC->TASKS_STOP = 1; 42 | NRF_ADC->ENABLE = 0; 43 | } 44 | } 45 | 46 | void adc_start(void) 47 | { 48 | /* start ADC voltage conversion */ 49 | NRF_ADC->ENABLE = 1; 50 | NRF_ADC->TASKS_START = 1; 51 | } 52 | 53 | uint8_t adc_bat(void) 54 | { 55 | return g_battery_voltage; 56 | } 57 | 58 | void adc_init(void) 59 | { 60 | /* initialize batter voltage */ 61 | g_battery_voltage = 0; 62 | 63 | /* setup ADC for capturing battery voltage */ 64 | NRF_ADC->CONFIG = ( 65 | (ADC_CONFIG_REFSEL_VBG << ADC_CONFIG_REFSEL_Pos) | 66 | (ADC_CONFIG_INPSEL_SupplyOneThirdPrescaling << ADC_CONFIG_INPSEL_Pos) | 67 | (ADC_CONFIG_RES_8bit << ADC_CONFIG_RES_Pos) 68 | ); 69 | NRF_ADC->INTENSET = ( 70 | (ADC_INTENSET_END_Enabled << ADC_INTENSET_END_Pos) 71 | ); 72 | NVIC_SetPriority(ADC_IRQn, IRQ_PRIORITY_ADC); 73 | NVIC_EnableIRQ(ADC_IRQn); 74 | } 75 | -------------------------------------------------------------------------------- /firmware/nRF51/tag-proximity/src/adc.c: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * 3 | * OpenBeacon.org - nRF51 ADC Support Routines 4 | * 5 | * Copyright 2014 Milosch Meriac 6 | * 7 | *************************************************************** 8 | 9 | This file is part of the OpenBeacon.org active RFID firmware 10 | 11 | OpenBeacon is free software: you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | OpenBeacon is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with Foobar. If not, see . 23 | 24 | */ 25 | #include 26 | #include 27 | 28 | static volatile uint8_t g_battery_voltage; 29 | 30 | void ADC_IRQ_Handler(void) 31 | { 32 | if(NRF_ADC->EVENTS_END) 33 | { 34 | /* acknowledge event */ 35 | NRF_ADC->EVENTS_END = 0; 36 | 37 | /* read battery voltage */ 38 | g_battery_voltage = (((uint16_t)(NRF_ADC->RESULT & 0xFF))*36)>>8; 39 | 40 | /* disable ADC after sampling voltage */ 41 | NRF_ADC->TASKS_STOP = 1; 42 | NRF_ADC->ENABLE = 0; 43 | } 44 | } 45 | 46 | void adc_start(void) 47 | { 48 | /* start ADC voltage conversion */ 49 | NRF_ADC->ENABLE = 1; 50 | NRF_ADC->TASKS_START = 1; 51 | } 52 | 53 | uint8_t adc_bat(void) 54 | { 55 | return g_battery_voltage; 56 | } 57 | 58 | void adc_init(void) 59 | { 60 | /* initialize batter voltage */ 61 | g_battery_voltage = 0; 62 | 63 | /* setup ADC for capturing battery voltage */ 64 | NRF_ADC->CONFIG = ( 65 | (ADC_CONFIG_REFSEL_VBG << ADC_CONFIG_REFSEL_Pos) | 66 | (ADC_CONFIG_INPSEL_SupplyOneThirdPrescaling << ADC_CONFIG_INPSEL_Pos) | 67 | (ADC_CONFIG_RES_8bit << ADC_CONFIG_RES_Pos) 68 | ); 69 | NRF_ADC->INTENSET = ( 70 | (ADC_INTENSET_END_Enabled << ADC_INTENSET_END_Pos) 71 | ); 72 | NVIC_SetPriority(ADC_IRQn, IRQ_PRIORITY_ADC); 73 | NVIC_EnableIRQ(ADC_IRQn); 74 | } 75 | -------------------------------------------------------------------------------- /firmware/nRF51/tag-physical-web/lib/src/adc.c: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * 3 | * OpenBeacon.org - nRF51 ADC Support Routines 4 | * 5 | * Copyright 2014 Milosch Meriac 6 | * 7 | *************************************************************** 8 | 9 | This file is part of the OpenBeacon.org active RFID firmware 10 | 11 | OpenBeacon is free software: you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | OpenBeacon is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with Foobar. If not, see . 23 | 24 | */ 25 | #include 26 | #include 27 | 28 | static volatile uint8_t g_battery_voltage; 29 | 30 | void ADC_IRQ_Handler(void) 31 | { 32 | if(NRF_ADC->EVENTS_END) 33 | { 34 | /* acknowledge event */ 35 | NRF_ADC->EVENTS_END = 0; 36 | 37 | /* read battery voltage */ 38 | g_battery_voltage = (((uint16_t)(NRF_ADC->RESULT & 0xFF))*36)>>8; 39 | 40 | /* disable ADC after sampling voltage */ 41 | NRF_ADC->TASKS_STOP = 1; 42 | NRF_ADC->ENABLE = 0; 43 | } 44 | } 45 | 46 | void adc_start(void) 47 | { 48 | /* start ADC voltage conversion */ 49 | NRF_ADC->ENABLE = 1; 50 | NRF_ADC->TASKS_START = 1; 51 | } 52 | 53 | uint8_t adc_bat(void) 54 | { 55 | return g_battery_voltage; 56 | } 57 | 58 | void adc_init(void) 59 | { 60 | /* initialize batter voltage */ 61 | g_battery_voltage = 0; 62 | 63 | /* setup ADC for capturing battery voltage */ 64 | NRF_ADC->CONFIG = ( 65 | (ADC_CONFIG_REFSEL_VBG << ADC_CONFIG_REFSEL_Pos) | 66 | (ADC_CONFIG_INPSEL_SupplyOneThirdPrescaling << ADC_CONFIG_INPSEL_Pos) | 67 | (ADC_CONFIG_RES_8bit << ADC_CONFIG_RES_Pos) 68 | ); 69 | NRF_ADC->INTENSET = ( 70 | (ADC_INTENSET_END_Enabled << ADC_INTENSET_END_Pos) 71 | ); 72 | NVIC_SetPriority(ADC_IRQn, IRQ_PRIORITY_ADC); 73 | NVIC_EnableIRQ(ADC_IRQn); 74 | } 75 | -------------------------------------------------------------------------------- /firmware/nRF51/core/startup/inc/nrf5.h: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * 3 | * OpenBeacon.org - nRF51 Exception Handlers 4 | * 5 | * Copyright 2013 Milosch Meriac 6 | * 7 | *************************************************************** 8 | 9 | This file is part of the OpenBeacon.org active RFID firmware 10 | 11 | OpenBeacon is free software: you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | OpenBeacon is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with Foobar. If not, see . 23 | 24 | */ 25 | #ifndef __NRF5_H__ 26 | #define __NRF5_H__ 27 | 28 | /* core exception handlers */ 29 | extern void Reset_Handler(void); 30 | extern void NMI_Handler(void); 31 | extern void HardFault_Handler(void); 32 | extern void SVC_Handler(void); 33 | extern void PendSV_Handler(void); 34 | extern void SysTick_Handler(void); 35 | 36 | /* peripheral exception handlers */ 37 | extern void ADC_IRQ_Handler(void); 38 | extern void CCM_AAR_IRQ_Handler(void); 39 | extern void ECB_IRQ_Handler(void); 40 | extern void GPIOTE_IRQ_Handler(void); 41 | extern void LPCOMP_COMP_IRQ_Handler(void); 42 | extern void POWER_CLOCK_IRQ_Handler(void); 43 | extern void QDEC_IRQ_Handler(void); 44 | extern void RADIO_IRQ_Handler(void); 45 | extern void RNG_IRQ_Handler(void); 46 | extern void RTC0_IRQ_Handler(void); 47 | extern void RTC1_IRQ_Handler(void); 48 | extern void SPI0_TWI0_IRQ_Handler(void); 49 | extern void SPI1_TWI1_IRQ_Handler(void); 50 | extern void SWI0_IRQ_Handler(void); 51 | extern void SWI1_IRQ_Handler(void); 52 | extern void SWI2_IRQ_Handler(void); 53 | extern void SWI3_IRQ_Handler(void); 54 | extern void SWI4_IRQ_Handler(void); 55 | extern void SWI5_IRQ_Handler(void); 56 | extern void TEMP_IRQ_Handler(void); 57 | extern void TIMER0_IRQ_Handler(void); 58 | extern void TIMER1_IRQ_Handler(void); 59 | extern void TIMER2_IRQ_Handler(void); 60 | extern void UART0_IRQ_Handler(void); 61 | extern void WDT_IRQ_Handler(void); 62 | 63 | #endif/*__NRF5_H__*/ 64 | -------------------------------------------------------------------------------- /firmware/nRF51/core/openbeacon/inc/openbeacon.h: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * 3 | * OpenBeacon.org - OpenBeacon.org main include file 4 | * 5 | * Copyright 2013 Milosch Meriac 6 | * 7 | *************************************************************** 8 | 9 | This file is part of the OpenBeacon.org active RFID firmware 10 | 11 | OpenBeacon is free software: you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | OpenBeacon is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with Foobar. If not, see . 23 | 24 | */ 25 | #ifndef __OPENBEACON_H__ 26 | #define __OPENBEACON_H__ 27 | 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | 34 | #define PACKED __attribute__((packed)) 35 | #define WEAK __attribute__ ((weak)) 36 | #define ALIAS(f) __attribute__ ((weak, alias (#f))) 37 | #define LINKTO(f) __attribute__ ((alias (#f))) 38 | #define ALIGN4 __attribute__ ((aligned (4))) 39 | 40 | typedef uint8_t BOOL; 41 | #define TRUE 1 42 | #define FALSE 0 43 | 44 | #include 45 | 46 | /* this definition is linked weakly against uart_tx */ 47 | extern BOOL default_putchar (uint8_t data); 48 | 49 | #ifdef __nrf5__ 50 | #include 51 | #include 52 | #else /*__nrf5__*/ 53 | #error Please specify architecture 54 | #endif/*__nrf5__*/ 55 | 56 | #include 57 | #include 58 | #include 59 | #include 60 | #include 61 | #include 62 | #include 63 | #include 64 | 65 | static inline uint16_t 66 | htons (uint16_t x) 67 | { 68 | __asm__ ("rev16 %0, %1": "=r" (x):"r" (x)); 69 | return x; 70 | } 71 | 72 | static inline uint32_t 73 | htonl (uint32_t x) 74 | { 75 | __asm__ ("rev %0, %1": "=r" (x):"r" (x)); 76 | return x; 77 | } 78 | 79 | #define ntohl(l) htonl(l) 80 | #define ntohs(s) htons(s) 81 | 82 | #define BIT_REVERSE(x) ((unsigned char)(__RBIT(x)>>24)) 83 | 84 | extern void main_entry(void); 85 | 86 | #endif/*__OPENBEACON_H__*/ 87 | -------------------------------------------------------------------------------- /firmware/nRF51/core/openbeacon/src/debug_printf.c: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * 3 | * OpenBeacon.org - debug_printf wrapper for ts_printf 4 | * 5 | * Copyright 2010-2012 Milosch Meriac 6 | * 7 | *************************************************************** 8 | 9 | This program is free software; you can redistribute it and/or modify 10 | it under the terms of the GNU General Public License as published by 11 | the Free Software Foundation; version 2. 12 | 13 | This program is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | GNU General Public License for more details. 17 | 18 | You should have received a copy of the GNU General Public License along 19 | with this program; if not, write to the Free Software Foundation, Inc., 20 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 21 | 22 | */ 23 | 24 | #include 25 | #if !defined UART_DISABLE || defined ENABLE_USB_FULLFEATURED 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | static void 32 | putc_debug (void *p, char c) 33 | { 34 | (void) p; 35 | 36 | default_putchar (c); 37 | } 38 | 39 | void 40 | debug_printf (const char *fmt, ...) 41 | { 42 | va_list va; 43 | 44 | va_start (va, fmt); 45 | tfp_format (NULL, putc_debug, fmt, va); 46 | va_end (va); 47 | } 48 | 49 | char 50 | hex_char (unsigned char hex) 51 | { 52 | hex &= 0xF; 53 | return (hex < 0xA) ? (hex + '0') : ((hex - 0xA) + 'A'); 54 | } 55 | 56 | void 57 | hex_dump (const unsigned char *buf, unsigned int addr, unsigned int len) 58 | { 59 | unsigned int start, i, j; 60 | char c; 61 | 62 | start = addr & ~0xf; 63 | 64 | for (j = 0; j < len; j += 16) 65 | { 66 | debug_printf ("%08x:", start + j); 67 | 68 | for (i = 0; i < 16; i++) 69 | { 70 | if (start + i + j >= addr && start + i + j < addr + len) 71 | debug_printf (" %02x", buf[start + i + j]); 72 | else 73 | debug_printf (" "); 74 | } 75 | debug_printf (" |"); 76 | for (i = 0; i < 16; i++) 77 | { 78 | if (start + i + j >= addr && start + i + j < addr + len) 79 | { 80 | c = buf[start + i + j]; 81 | if (c >= ' ' && c < 127) 82 | debug_printf ("%c", c); 83 | else 84 | debug_printf ("."); 85 | } 86 | else 87 | debug_printf (" "); 88 | } 89 | debug_printf ("|\n\r"); 90 | } 91 | } 92 | #endif /* UART_DISABLE */ 93 | -------------------------------------------------------------------------------- /firmware/nRF51/tag-mischief/inc/acc.h: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * 3 | * OpenBeacon.org - nRF51 3D Accelerometer Routines 4 | * 5 | * Copyright 2013 Milosch Meriac 6 | * 7 | *************************************************************** 8 | 9 | This file is part of the OpenBeacon.org active RFID firmware 10 | 11 | OpenBeacon is free software: you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | OpenBeacon is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with Foobar. If not, see . 23 | 24 | */ 25 | #ifndef __ACC_H__ 26 | #define __ACC_H__ 27 | 28 | /* LIS3DH register definition */ 29 | 30 | #define ACC_REG_STATUS_REG_AUX 0x07 31 | 32 | #define ACC_REG_OUT_ADC1 0x08 33 | #define ACC_REG_OUT_ADC1_L 0x08 34 | #define ACC_REG_OUT_ADC1_H 0x09 35 | 36 | #define ACC_REG_OUT_ADC2 0x0A 37 | #define ACC_REG_OUT_ADC2_L 0x0A 38 | #define ACC_REG_OUT_ADC2_H 0x0B 39 | 40 | #define ACC_REG_OUT_ADC3 0x0C 41 | #define ACC_REG_OUT_ADC3_L 0x0C 42 | #define ACC_REG_OUT_ADC3_H 0x0D 43 | 44 | #define ACC_REG_INT_COUNTER_REG 0x0E 45 | #define ACC_REG_WHO_AM_I 0x0F 46 | #define ACC_REG_TEMP_CFG_REG 0x1F 47 | #define ACC_REG_CTRL_REG1 0x20 48 | #define ACC_REG_CTRL_REG2 0x21 49 | #define ACC_REG_CTRL_REG3 0x22 50 | #define ACC_REG_CTRL_REG4 0x23 51 | #define ACC_REG_CTRL_REG5 0x24 52 | #define ACC_REG_CTRL_REG6 0x25 53 | #define ACC_REG_REFERENCE 0x26 54 | #define ACC_REG_STATUS_REG2 0x27 55 | 56 | #define ACC_REG_OUT_X 0x28 57 | #define ACC_REG_OUT_X_L 0x28 58 | #define ACC_REG_OUT_X_H 0x29 59 | 60 | #define ACC_REG_OUT_Y 0x2A 61 | #define ACC_REG_OUT_Y_L 0x2A 62 | #define ACC_REG_OUT_Y_H 0x2B 63 | 64 | #define ACC_REG_OUT_Z 0x2C 65 | #define ACC_REG_OUT_Z_L 0x2C 66 | #define ACC_REG_OUT_Z_H 0x2D 67 | 68 | #define ACC_REG_FIFO_CTRL_REG 0x2E 69 | #define ACC_REG_FIFO_SRC_REG 0x2F 70 | #define ACC_REG_INT1_CFG 0x30 71 | 72 | extern uint8_t acc_init(void); 73 | extern void acc_write(uint8_t cmd, uint8_t data); 74 | extern void acc_read(uint8_t cmd, uint8_t len, uint8_t *data); 75 | extern uint16_t acc_magnitude(int8_t* angle); 76 | 77 | #endif/*__ACC_H__*/ 78 | -------------------------------------------------------------------------------- /firmware/nRF51/tag-mischief/inc/config.h: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * 3 | * OpenBeacon.org - nRF51 board config files 4 | * 5 | * Copyright 2013 Milosch Meriac 6 | * 7 | *************************************************************** 8 | 9 | This file is part of the OpenBeacon.org active RFID firmware 10 | 11 | OpenBeacon is free software: you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | OpenBeacon is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with Foobar. If not, see . 23 | 24 | */ 25 | #ifndef __CONFIG_H__ 26 | #define __CONFIG_H__ 27 | 28 | /* every CONFIG_PROX_SPACING-RANDOM(2^CONFIG_PROX_SPACING_RNG_BITS) 29 | * listen for CONFIG_PROX_LISTEN - all based on LF_FREQUENCY ticks */ 30 | #define CONFIG_PROX_SPACING_RNG_BITS 9 31 | #define CONFIG_PROX_SPACING MILLISECONDS(25) 32 | #define CONFIG_PROX_LISTEN_RATIO 10 33 | #define CONFIG_PROX_LISTEN MILLISECONDS(5) 34 | 35 | #define CONFIG_UART_BAUDRATE UART_BAUDRATE_BAUDRATE_Baud115200 36 | #define CONFIG_UART_TXD_PIN 9 37 | #ifdef CONFIG_UART_RX 38 | #define CONFIG_UART_RXD_PIN 8 39 | #else 40 | #define CONFIG_GPIO3_PIN 8 41 | #endif/*CONFIG_UART_RX*/ 42 | 43 | #define CONFIG_FLASH_MISO 16 44 | #define CONFIG_FLASH_MOSI 15 45 | #define CONFIG_FLASH_SCK 14 46 | #define CONFIG_FLASH_nRESET 13 47 | #define CONFIG_FLASH_nCS 12 48 | #define SPI_FLASH NRF_SPI0 49 | 50 | #define CONFIG_ADC0 1 51 | #define CONFIG_ADC1 2 52 | 53 | #define CONFIG_ACC_INT1_CH 0 54 | #define CONFIG_ACC_INT1 3 55 | #define CONFIG_ACC_nCS 4 56 | #define CONFIG_ACC_MISO 5 57 | #define CONFIG_ACC_MOSI 6 58 | #define CONFIG_ACC_SCK 7 59 | #define SPI_ACC NRF_SPI1 60 | 61 | #define CONFIG_LED_PIN 17 62 | #define CONFIG_SWITCH_PIN 29 63 | 64 | /* only two priority bits available ! */ 65 | 66 | #define IRQ_PRIORITY_HIGH 0 67 | #define IRQ_PRIORITY_UART0 (IRQ_PRIORITY_HIGH) 68 | #define IRQ_PRIORITY_POWER_CLOCK (IRQ_PRIORITY_HIGH+1) 69 | #define IRQ_PRIORITY_RADIO (IRQ_PRIORITY_HIGH+2) 70 | 71 | #define IRQ_PRIORITY_LOW (IRQ_PRIORITY_HIGH+3) 72 | #define IRQ_PRIORITY_RTC0 (IRQ_PRIORITY_LOW) 73 | #define IRQ_PRIORITY_RTC1 (IRQ_PRIORITY_LOW) 74 | #define IRQ_PRIORITY_ADC (IRQ_PRIORITY_LOW) 75 | 76 | #endif/*__CONFIG_H__*/ 77 | -------------------------------------------------------------------------------- /firmware/nRF51/tag-power/inc/acc.h: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * 3 | * OpenBeacon.org - nRF51 3D Accelerometer Routines 4 | * 5 | * Copyright 2013 Milosch Meriac 6 | * 7 | *************************************************************** 8 | 9 | This file is part of the OpenBeacon.org active RFID firmware 10 | 11 | OpenBeacon is free software: you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | OpenBeacon is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with Foobar. If not, see . 23 | 24 | */ 25 | #ifndef __ACC_H__ 26 | #define __ACC_H__ 27 | 28 | /* LIS3DH register definition */ 29 | 30 | #define ACC_REG_STATUS_REG_AUX 0x07 31 | 32 | #define ACC_REG_OUT_ADC1 0x08 33 | #define ACC_REG_OUT_ADC1_L 0x08 34 | #define ACC_REG_OUT_ADC1_H 0x09 35 | 36 | #define ACC_REG_OUT_ADC2 0x0A 37 | #define ACC_REG_OUT_ADC2_L 0x0A 38 | #define ACC_REG_OUT_ADC2_H 0x0B 39 | 40 | #define ACC_REG_OUT_ADC3 0x0C 41 | #define ACC_REG_OUT_ADC3_L 0x0C 42 | #define ACC_REG_OUT_ADC3_H 0x0D 43 | 44 | #define ACC_REG_INT_COUNTER_REG 0x0E 45 | #define ACC_REG_WHO_AM_I 0x0F 46 | #define ACC_REG_TEMP_CFG_REG 0x1F 47 | #define ACC_REG_CTRL_REG1 0x20 48 | #define ACC_REG_CTRL_REG2 0x21 49 | #define ACC_REG_CTRL_REG3 0x22 50 | #define ACC_REG_CTRL_REG4 0x23 51 | #define ACC_REG_CTRL_REG5 0x24 52 | #define ACC_REG_CTRL_REG6 0x25 53 | #define ACC_REG_REFERENCE 0x26 54 | #define ACC_REG_STATUS_REG2 0x27 55 | 56 | #define ACC_REG_OUT_X 0x28 57 | #define ACC_REG_OUT_X_L 0x28 58 | #define ACC_REG_OUT_X_H 0x29 59 | 60 | #define ACC_REG_OUT_Y 0x2A 61 | #define ACC_REG_OUT_Y_L 0x2A 62 | #define ACC_REG_OUT_Y_H 0x2B 63 | 64 | #define ACC_REG_OUT_Z 0x2C 65 | #define ACC_REG_OUT_Z_L 0x2C 66 | #define ACC_REG_OUT_Z_H 0x2D 67 | 68 | #define ACC_REG_FIFO_CTRL_REG 0x2E 69 | #define ACC_REG_FIFO_SRC_REG 0x2F 70 | #define ACC_REG_INT1_CFG 0x30 71 | 72 | extern uint8_t acc_init(void); 73 | extern void acc_write(uint8_t cmd, uint8_t data); 74 | extern void acc_read(uint8_t cmd, uint8_t len, uint8_t *data); 75 | extern uint16_t acc_magnitude(int8_t* angle); 76 | 77 | #endif/*__ACC_H__*/ 78 | -------------------------------------------------------------------------------- /firmware/nRF51/tag-ble-beacon/inc/acc.h: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * 3 | * OpenBeacon.org - nRF51 3D Accelerometer Routines 4 | * 5 | * Copyright 2013 Milosch Meriac 6 | * 7 | *************************************************************** 8 | 9 | This file is part of the OpenBeacon.org active RFID firmware 10 | 11 | OpenBeacon is free software: you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | OpenBeacon is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with Foobar. If not, see . 23 | 24 | */ 25 | #ifndef __ACC_H__ 26 | #define __ACC_H__ 27 | 28 | /* LIS3DH register definition */ 29 | 30 | #define ACC_REG_STATUS_REG_AUX 0x07 31 | 32 | #define ACC_REG_OUT_ADC1 0x08 33 | #define ACC_REG_OUT_ADC1_L 0x08 34 | #define ACC_REG_OUT_ADC1_H 0x09 35 | 36 | #define ACC_REG_OUT_ADC2 0x0A 37 | #define ACC_REG_OUT_ADC2_L 0x0A 38 | #define ACC_REG_OUT_ADC2_H 0x0B 39 | 40 | #define ACC_REG_OUT_ADC3 0x0C 41 | #define ACC_REG_OUT_ADC3_L 0x0C 42 | #define ACC_REG_OUT_ADC3_H 0x0D 43 | 44 | #define ACC_REG_INT_COUNTER_REG 0x0E 45 | #define ACC_REG_WHO_AM_I 0x0F 46 | #define ACC_REG_TEMP_CFG_REG 0x1F 47 | #define ACC_REG_CTRL_REG1 0x20 48 | #define ACC_REG_CTRL_REG2 0x21 49 | #define ACC_REG_CTRL_REG3 0x22 50 | #define ACC_REG_CTRL_REG4 0x23 51 | #define ACC_REG_CTRL_REG5 0x24 52 | #define ACC_REG_CTRL_REG6 0x25 53 | #define ACC_REG_REFERENCE 0x26 54 | #define ACC_REG_STATUS_REG2 0x27 55 | 56 | #define ACC_REG_OUT_X 0x28 57 | #define ACC_REG_OUT_X_L 0x28 58 | #define ACC_REG_OUT_X_H 0x29 59 | 60 | #define ACC_REG_OUT_Y 0x2A 61 | #define ACC_REG_OUT_Y_L 0x2A 62 | #define ACC_REG_OUT_Y_H 0x2B 63 | 64 | #define ACC_REG_OUT_Z 0x2C 65 | #define ACC_REG_OUT_Z_L 0x2C 66 | #define ACC_REG_OUT_Z_H 0x2D 67 | 68 | #define ACC_REG_FIFO_CTRL_REG 0x2E 69 | #define ACC_REG_FIFO_SRC_REG 0x2F 70 | #define ACC_REG_INT1_CFG 0x30 71 | 72 | extern uint8_t acc_init(void); 73 | extern void acc_write(uint8_t cmd, uint8_t data); 74 | extern void acc_read(uint8_t cmd, uint8_t len, uint8_t *data); 75 | extern uint16_t acc_magnitude(int8_t* angle); 76 | 77 | #endif/*__ACC_H__*/ 78 | -------------------------------------------------------------------------------- /firmware/nRF51/tag-proximity/inc/acc.h: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * 3 | * OpenBeacon.org - nRF51 3D Accelerometer Routines 4 | * 5 | * Copyright 2013 Milosch Meriac 6 | * 7 | *************************************************************** 8 | 9 | This file is part of the OpenBeacon.org active RFID firmware 10 | 11 | OpenBeacon is free software: you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | OpenBeacon is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with Foobar. If not, see . 23 | 24 | */ 25 | #ifndef __ACC_H__ 26 | #define __ACC_H__ 27 | 28 | /* LIS3DH register definition */ 29 | 30 | #define ACC_REG_STATUS_REG_AUX 0x07 31 | 32 | #define ACC_REG_OUT_ADC1 0x08 33 | #define ACC_REG_OUT_ADC1_L 0x08 34 | #define ACC_REG_OUT_ADC1_H 0x09 35 | 36 | #define ACC_REG_OUT_ADC2 0x0A 37 | #define ACC_REG_OUT_ADC2_L 0x0A 38 | #define ACC_REG_OUT_ADC2_H 0x0B 39 | 40 | #define ACC_REG_OUT_ADC3 0x0C 41 | #define ACC_REG_OUT_ADC3_L 0x0C 42 | #define ACC_REG_OUT_ADC3_H 0x0D 43 | 44 | #define ACC_REG_INT_COUNTER_REG 0x0E 45 | #define ACC_REG_WHO_AM_I 0x0F 46 | #define ACC_REG_TEMP_CFG_REG 0x1F 47 | #define ACC_REG_CTRL_REG1 0x20 48 | #define ACC_REG_CTRL_REG2 0x21 49 | #define ACC_REG_CTRL_REG3 0x22 50 | #define ACC_REG_CTRL_REG4 0x23 51 | #define ACC_REG_CTRL_REG5 0x24 52 | #define ACC_REG_CTRL_REG6 0x25 53 | #define ACC_REG_REFERENCE 0x26 54 | #define ACC_REG_STATUS_REG2 0x27 55 | 56 | #define ACC_REG_OUT_X 0x28 57 | #define ACC_REG_OUT_X_L 0x28 58 | #define ACC_REG_OUT_X_H 0x29 59 | 60 | #define ACC_REG_OUT_Y 0x2A 61 | #define ACC_REG_OUT_Y_L 0x2A 62 | #define ACC_REG_OUT_Y_H 0x2B 63 | 64 | #define ACC_REG_OUT_Z 0x2C 65 | #define ACC_REG_OUT_Z_L 0x2C 66 | #define ACC_REG_OUT_Z_H 0x2D 67 | 68 | #define ACC_REG_FIFO_CTRL_REG 0x2E 69 | #define ACC_REG_FIFO_SRC_REG 0x2F 70 | #define ACC_REG_INT1_CFG 0x30 71 | 72 | extern uint8_t acc_init(void); 73 | extern void acc_write(uint8_t cmd, uint8_t data); 74 | extern void acc_read(uint8_t cmd, uint8_t len, uint8_t *data); 75 | extern uint16_t acc_magnitude(int8_t* angle); 76 | 77 | #endif/*__ACC_H__*/ 78 | -------------------------------------------------------------------------------- /firmware/nRF51/tag-physical-web/lib/inc/acc.h: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * 3 | * OpenBeacon.org - nRF51 3D Accelerometer Routines 4 | * 5 | * Copyright 2013 Milosch Meriac 6 | * 7 | *************************************************************** 8 | 9 | This file is part of the OpenBeacon.org active RFID firmware 10 | 11 | OpenBeacon is free software: you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | OpenBeacon is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with Foobar. If not, see . 23 | 24 | */ 25 | #ifndef __ACC_H__ 26 | #define __ACC_H__ 27 | 28 | /* LIS3DH register definition */ 29 | 30 | #define ACC_REG_STATUS_REG_AUX 0x07 31 | 32 | #define ACC_REG_OUT_ADC1 0x08 33 | #define ACC_REG_OUT_ADC1_L 0x08 34 | #define ACC_REG_OUT_ADC1_H 0x09 35 | 36 | #define ACC_REG_OUT_ADC2 0x0A 37 | #define ACC_REG_OUT_ADC2_L 0x0A 38 | #define ACC_REG_OUT_ADC2_H 0x0B 39 | 40 | #define ACC_REG_OUT_ADC3 0x0C 41 | #define ACC_REG_OUT_ADC3_L 0x0C 42 | #define ACC_REG_OUT_ADC3_H 0x0D 43 | 44 | #define ACC_REG_INT_COUNTER_REG 0x0E 45 | #define ACC_REG_WHO_AM_I 0x0F 46 | #define ACC_REG_TEMP_CFG_REG 0x1F 47 | #define ACC_REG_CTRL_REG1 0x20 48 | #define ACC_REG_CTRL_REG2 0x21 49 | #define ACC_REG_CTRL_REG3 0x22 50 | #define ACC_REG_CTRL_REG4 0x23 51 | #define ACC_REG_CTRL_REG5 0x24 52 | #define ACC_REG_CTRL_REG6 0x25 53 | #define ACC_REG_REFERENCE 0x26 54 | #define ACC_REG_STATUS_REG2 0x27 55 | 56 | #define ACC_REG_OUT_X 0x28 57 | #define ACC_REG_OUT_X_L 0x28 58 | #define ACC_REG_OUT_X_H 0x29 59 | 60 | #define ACC_REG_OUT_Y 0x2A 61 | #define ACC_REG_OUT_Y_L 0x2A 62 | #define ACC_REG_OUT_Y_H 0x2B 63 | 64 | #define ACC_REG_OUT_Z 0x2C 65 | #define ACC_REG_OUT_Z_L 0x2C 66 | #define ACC_REG_OUT_Z_H 0x2D 67 | 68 | #define ACC_REG_FIFO_CTRL_REG 0x2E 69 | #define ACC_REG_FIFO_SRC_REG 0x2F 70 | #define ACC_REG_INT1_CFG 0x30 71 | 72 | extern uint8_t acc_init(void); 73 | extern void acc_write(uint8_t cmd, uint8_t data); 74 | extern void acc_read(uint8_t cmd, uint8_t len, uint8_t *data); 75 | 76 | extern void acc_get(int16_t* acc, uint32_t size); 77 | extern uint16_t acc_magnitude(int8_t* angle); 78 | 79 | #endif/*__ACC_H__*/ 80 | -------------------------------------------------------------------------------- /firmware/nRF51/core/openbeacon/src/xxtea.c: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * 3 | * OpenBeacon.org - XXTEA based block encryption 4 | * 5 | * based on "correction to XTEA" by David J. Wheeler and 6 | * Roger M. Needham. 7 | * Computer Laboratory - Cambridge University in 1998 8 | * 9 | * Copyright 2006 Milosch Meriac 10 | * 11 | * ripped into pieces - optimized for the special case 12 | * where 16 bytes are regarded for encryption and decryption 13 | * to increase speed and to decrease memory consumption 14 | * 15 | *************************************************************** 16 | 17 | This program is free software; you can redistribute it and/or modify 18 | it under the terms of the GNU General Public License as published by 19 | the Free Software Foundation; version 2. 20 | 21 | This program is distributed in the hope that it will be useful, 22 | but WITHOUT ANY WARRANTY; without even the implied warranty of 23 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 24 | GNU General Public License for more details. 25 | 26 | You should have received a copy of the GNU General Public License along 27 | with this program; if not, write to the Free Software Foundation, Inc., 28 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 29 | */ 30 | 31 | #include 32 | #include "xxtea.h" 33 | 34 | static const uint32_t DELTA = 0x9e3779b9UL; 35 | 36 | #define MX ( (((z>>5)^(y<<2))+((y>>3)^(z<<4)))^((sum^y)+(tea_key[(p&3)^e]^z)) ); 37 | 38 | static void 39 | xxtea_shuffle (uint32_t * v, uint32_t length) 40 | { 41 | while (length--) 42 | { 43 | *v = htonl (*v); 44 | v++; 45 | } 46 | } 47 | 48 | void 49 | xxtea_encode (uint32_t * v, uint32_t length, const uint32_t * tea_key) 50 | { 51 | uint32_t z, y, sum, e, p, q; 52 | 53 | if (!v || !tea_key) 54 | return; 55 | 56 | xxtea_shuffle (v, length); 57 | 58 | q = 6 + 52 / length; 59 | sum = 0; 60 | z = v[length - 1]; 61 | do 62 | { 63 | sum += DELTA; 64 | e = (sum >> 2) & 3; 65 | 66 | for (p = 0; p < (length - 1); p++) 67 | y = v[p + 1], z = v[p] += MX; 68 | 69 | y = v[0]; 70 | z = v[length - 1] += MX; 71 | } 72 | while (--q); 73 | 74 | xxtea_shuffle (v, length); 75 | } 76 | 77 | void 78 | xxtea_decode (uint32_t * v, uint32_t length, const uint32_t * tea_key) 79 | { 80 | uint32_t z, y, sum, e, p, q; 81 | 82 | if (!v || !tea_key) 83 | return; 84 | 85 | xxtea_shuffle (v, length); 86 | 87 | q = 6 + 52 / length; 88 | sum = q * DELTA; 89 | y = v[0]; 90 | while (sum) 91 | { 92 | e = (sum >> 2) & 3; 93 | for (p = length - 1; p > 0; p--) 94 | z = v[p - 1], y = v[p] -= MX; 95 | 96 | z = v[length - 1]; 97 | y = v[0] -= MX; 98 | sum -= DELTA; 99 | } 100 | 101 | xxtea_shuffle (v, length); 102 | } 103 | -------------------------------------------------------------------------------- /firmware/nRF51/tag-power/src/main.c: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * 3 | * OpenBeacon.org - nRF51 Main Entry 4 | * 5 | * Copyright 2013 Milosch Meriac 6 | * 7 | *************************************************************** 8 | 9 | This file is part of the OpenBeacon.org active RFID firmware 10 | 11 | OpenBeacon is free software: you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | OpenBeacon is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with Foobar. If not, see . 23 | 24 | */ 25 | #include 26 | 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | static int8_t g_tag_angle; 33 | 34 | int8_t tag_angle(void) 35 | { 36 | return g_tag_angle; 37 | } 38 | 39 | void blink(uint8_t times) 40 | { 41 | while(times--) 42 | { 43 | nrf_gpio_pin_set(CONFIG_LED_PIN); 44 | timer_wait(MILLISECONDS(10)); 45 | nrf_gpio_pin_clear(CONFIG_LED_PIN); 46 | timer_wait(MILLISECONDS(490)); 47 | } 48 | } 49 | 50 | void halt(uint8_t times) 51 | { 52 | while(TRUE) 53 | { 54 | blink(times); 55 | timer_wait(SECONDS(3)); 56 | } 57 | } 58 | 59 | void main_entry(void) 60 | { 61 | uint32_t tag_id; 62 | 63 | /* enabled LED output */ 64 | nrf_gpio_cfg_output(CONFIG_LED_PIN); 65 | nrf_gpio_pin_set(CONFIG_LED_PIN); 66 | 67 | /* enabled input pin */ 68 | nrf_gpio_cfg_input(CONFIG_SWITCH_PIN, NRF_GPIO_PIN_NOPULL); 69 | 70 | /* initialize UART */ 71 | uart_init(); 72 | 73 | /* start timer */ 74 | timer_init(); 75 | 76 | /* initialize flash */ 77 | if(flash_init()) 78 | halt(2); 79 | 80 | /* initialize accelerometer */ 81 | if(acc_init()) 82 | halt(3); 83 | 84 | /* calculate tag ID from NRF_FICR->DEVICEID */ 85 | tag_id = crc32(&NRF_FICR->DEVICEID, sizeof(NRF_FICR->DEVICEID)); 86 | 87 | /* start radio */ 88 | debug_printf("\n\rInitializing Tag[%08X] v" PROGRAM_VERSION " @24%02iMHz ...\n\r", 89 | tag_id, 90 | CONFIG_TRACKER_CHANNEL); 91 | radio_init(tag_id); 92 | 93 | /* enter main loop */ 94 | nrf_gpio_pin_clear(CONFIG_LED_PIN); 95 | while(TRUE) 96 | { 97 | /* get tag angle once per second */ 98 | timer_wait(MILLISECONDS(5000)); 99 | 100 | /* blink every 5 seconds */ 101 | nrf_gpio_pin_set(CONFIG_LED_PIN); 102 | timer_wait(MILLISECONDS(0.5)); 103 | nrf_gpio_pin_clear(CONFIG_LED_PIN); 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /firmware/nRF51/tag-power/inc/config.h: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * 3 | * OpenBeacon.org - nRF51 board config files 4 | * 5 | * Copyright 2013 Milosch Meriac 6 | * 7 | *************************************************************** 8 | 9 | This file is part of the OpenBeacon.org active RFID firmware 10 | 11 | OpenBeacon is free software: you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | OpenBeacon is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with Foobar. If not, see . 23 | 24 | */ 25 | #ifndef __CONFIG_H__ 26 | #define __CONFIG_H__ 27 | 28 | /* every CONFIG_PROX_SPACING-RANDOM(2^CONFIG_PROX_SPACING_RNG_BITS) 29 | * listen for CONFIG_PROX_LISTEN - all based on LF_FREQUENCY ticks */ 30 | #define CONFIG_PROX_SPACING_RNG_BITS 9 31 | #define CONFIG_PROX_SPACING MILLISECONDS(25) 32 | #define CONFIG_PROX_LISTEN_RATIO 10 33 | #define CONFIG_PROX_LISTEN MILLISECONDS(5) 34 | 35 | #define CONFIG_UART_BAUDRATE UART_BAUDRATE_BAUDRATE_Baud115200 36 | #define CONFIG_UART_TXD_PIN 9 37 | #ifdef CONFIG_UART_RX 38 | #define CONFIG_UART_RXD_PIN 8 39 | #else 40 | #define CONFIG_GPIO3_PIN 8 41 | #endif/*CONFIG_UART_RX*/ 42 | 43 | #define CONFIG_FLASH_MISO 16 44 | #define CONFIG_FLASH_MOSI 15 45 | #define CONFIG_FLASH_SCK 14 46 | #define CONFIG_FLASH_nRESET 13 47 | #define CONFIG_FLASH_nCS 12 48 | #define SPI_FLASH NRF_SPI0 49 | 50 | #define CONFIG_ADC0 1 51 | #define CONFIG_ADC1 2 52 | 53 | #define CONFIG_ACC_INT1_CH 0 54 | #define CONFIG_ACC_INT1 3 55 | #define CONFIG_ACC_nCS 4 56 | #define CONFIG_ACC_MISO 5 57 | #define CONFIG_ACC_MOSI 6 58 | #define CONFIG_ACC_SCK 7 59 | #define SPI_ACC NRF_SPI1 60 | 61 | #define CONFIG_LED_PIN 17 62 | #define CONFIG_SWITCH_PIN 29 63 | 64 | /* only two priority bits available ! */ 65 | 66 | #define IRQ_PRIORITY_HIGH 0 67 | #define IRQ_PRIORITY_AES (IRQ_PRIORITY_HIGH) 68 | #define IRQ_PRIORITY_RNG (IRQ_PRIORITY_HIGH+1) 69 | #define IRQ_PRIORITY_POWER_CLOCK (IRQ_PRIORITY_HIGH+1) 70 | #define IRQ_PRIORITY_RADIO (IRQ_PRIORITY_HIGH+2) 71 | 72 | #define IRQ_PRIORITY_LOW (IRQ_PRIORITY_HIGH+3) 73 | #define IRQ_PRIORITY_RTC0 (IRQ_PRIORITY_LOW) 74 | #define IRQ_PRIORITY_RTC1 (IRQ_PRIORITY_LOW) 75 | #define IRQ_PRIORITY_ADC (IRQ_PRIORITY_LOW) 76 | #define IRQ_PRIORITY_UART0 (IRQ_PRIORITY_LOW) 77 | 78 | #endif/*__CONFIG_H__*/ 79 | -------------------------------------------------------------------------------- /firmware/nRF51/tag-proximity/inc/config.h: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * 3 | * OpenBeacon.org - nRF51 board config files 4 | * 5 | * Copyright 2013 Milosch Meriac 6 | * 7 | *************************************************************** 8 | 9 | This file is part of the OpenBeacon.org active RFID firmware 10 | 11 | OpenBeacon is free software: you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | OpenBeacon is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with Foobar. If not, see . 23 | 24 | */ 25 | #ifndef __CONFIG_H__ 26 | #define __CONFIG_H__ 27 | 28 | /* every CONFIG_PROX_SPACING-RANDOM(2^CONFIG_PROX_SPACING_RNG_BITS) 29 | * listen for CONFIG_PROX_LISTEN - all based on LF_FREQUENCY ticks */ 30 | #define CONFIG_PROX_SPACING_RNG_BITS 9 31 | #define CONFIG_PROX_SPACING MILLISECONDS(25) 32 | #define CONFIG_PROX_LISTEN_RATIO 10 33 | #define CONFIG_PROX_LISTEN MILLISECONDS(5) 34 | 35 | #define CONFIG_UART_BAUDRATE UART_BAUDRATE_BAUDRATE_Baud115200 36 | #define CONFIG_UART_TXD_PIN 9 37 | #ifdef CONFIG_UART_RX 38 | #define CONFIG_UART_RXD_PIN 8 39 | #else 40 | #define CONFIG_GPIO3_PIN 8 41 | #endif/*CONFIG_UART_RX*/ 42 | 43 | #define CONFIG_FLASH_MISO 16 44 | #define CONFIG_FLASH_MOSI 15 45 | #define CONFIG_FLASH_SCK 14 46 | #define CONFIG_FLASH_nRESET 13 47 | #define CONFIG_FLASH_nCS 12 48 | #define SPI_FLASH NRF_SPI0 49 | 50 | #define CONFIG_ADC0 1 51 | #define CONFIG_ADC1 2 52 | 53 | #define CONFIG_ACC_INT1_CH 0 54 | #define CONFIG_ACC_INT1 3 55 | #define CONFIG_ACC_nCS 4 56 | #define CONFIG_ACC_MISO 5 57 | #define CONFIG_ACC_MOSI 6 58 | #define CONFIG_ACC_SCK 7 59 | #define SPI_ACC NRF_SPI1 60 | 61 | #define CONFIG_LED_PIN 17 62 | #define CONFIG_SWITCH_PIN 29 63 | 64 | /* only two priority bits available ! */ 65 | 66 | #define IRQ_PRIORITY_HIGH 0 67 | #define IRQ_PRIORITY_AES (IRQ_PRIORITY_HIGH) 68 | #define IRQ_PRIORITY_RNG (IRQ_PRIORITY_HIGH+1) 69 | #define IRQ_PRIORITY_POWER_CLOCK (IRQ_PRIORITY_HIGH+1) 70 | #define IRQ_PRIORITY_RADIO (IRQ_PRIORITY_HIGH+2) 71 | 72 | #define IRQ_PRIORITY_LOW (IRQ_PRIORITY_HIGH+3) 73 | #define IRQ_PRIORITY_RTC0 (IRQ_PRIORITY_LOW) 74 | #define IRQ_PRIORITY_RTC1 (IRQ_PRIORITY_LOW) 75 | #define IRQ_PRIORITY_ADC (IRQ_PRIORITY_LOW) 76 | #define IRQ_PRIORITY_UART0 (IRQ_PRIORITY_LOW) 77 | 78 | #endif/*__CONFIG_H__*/ 79 | -------------------------------------------------------------------------------- /firmware/nRF51/tag-ble-beacon/inc/config.h: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * 3 | * OpenBeacon.org - nRF51 board config files 4 | * 5 | * Copyright 2013 Milosch Meriac 6 | * 7 | *************************************************************** 8 | 9 | This file is part of the OpenBeacon.org active RFID firmware 10 | 11 | OpenBeacon is free software: you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | OpenBeacon is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with Foobar. If not, see . 23 | 24 | */ 25 | #ifndef __CONFIG_H__ 26 | #define __CONFIG_H__ 27 | 28 | /* every CONFIG_PROX_SPACING-RANDOM(2^CONFIG_PROX_SPACING_RNG_BITS) 29 | * listen for CONFIG_PROX_LISTEN - all based on LF_FREQUENCY ticks */ 30 | #define CONFIG_PROX_SPACING_RNG_BITS 9 31 | #define CONFIG_PROX_SPACING MILLISECONDS(25) 32 | #define CONFIG_PROX_LISTEN_RATIO 10 33 | #define CONFIG_PROX_LISTEN MILLISECONDS(5) 34 | 35 | #define CONFIG_UART_BAUDRATE UART_BAUDRATE_BAUDRATE_Baud115200 36 | #define CONFIG_UART_TXD_PIN 9 37 | #ifdef CONFIG_UART_RX 38 | #define CONFIG_UART_RXD_PIN 8 39 | #else 40 | #define CONFIG_GPIO3_PIN 8 41 | #endif/*CONFIG_UART_RX*/ 42 | 43 | #define CONFIG_FLASH_MISO 16 44 | #define CONFIG_FLASH_MOSI 15 45 | #define CONFIG_FLASH_SCK 14 46 | #define CONFIG_FLASH_nRESET 13 47 | #define CONFIG_FLASH_nCS 12 48 | #define SPI_FLASH NRF_SPI0 49 | 50 | #define CONFIG_ADC0 1 51 | #define CONFIG_ADC1 2 52 | 53 | #define CONFIG_ACC_INT1_CH 0 54 | #define CONFIG_ACC_INT1 3 55 | #define CONFIG_ACC_nCS 4 56 | #define CONFIG_ACC_MISO 5 57 | #define CONFIG_ACC_MOSI 6 58 | #define CONFIG_ACC_SCK 7 59 | #define SPI_ACC NRF_SPI1 60 | 61 | #define CONFIG_LED_PIN 17 62 | #define CONFIG_SWITCH_PIN 29 63 | 64 | /* only two priority bits available ! */ 65 | 66 | #define IRQ_PRIORITY_HIGH 0 67 | #define IRQ_PRIORITY_AES (IRQ_PRIORITY_HIGH) 68 | #define IRQ_PRIORITY_RNG (IRQ_PRIORITY_HIGH+1) 69 | #define IRQ_PRIORITY_POWER_CLOCK (IRQ_PRIORITY_HIGH+1) 70 | #define IRQ_PRIORITY_RADIO (IRQ_PRIORITY_HIGH+2) 71 | 72 | #define IRQ_PRIORITY_LOW (IRQ_PRIORITY_HIGH+3) 73 | #define IRQ_PRIORITY_RTC0 (IRQ_PRIORITY_LOW) 74 | #define IRQ_PRIORITY_RTC1 (IRQ_PRIORITY_LOW) 75 | #define IRQ_PRIORITY_ADC (IRQ_PRIORITY_LOW) 76 | #define IRQ_PRIORITY_UART0 (IRQ_PRIORITY_LOW) 77 | 78 | #endif/*__CONFIG_H__*/ 79 | -------------------------------------------------------------------------------- /firmware/nRF51/tag-physical-web/lib/inc/config.h: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * 3 | * OpenBeacon.org - nRF51 board config files 4 | * 5 | * Copyright 2013 Milosch Meriac 6 | * 7 | *************************************************************** 8 | 9 | This file is part of the OpenBeacon.org active RFID firmware 10 | 11 | OpenBeacon is free software: you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | OpenBeacon is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with Foobar. If not, see . 23 | 24 | */ 25 | #ifndef __CONFIG_H__ 26 | #define __CONFIG_H__ 27 | 28 | /* every CONFIG_PROX_SPACING-RANDOM(2^CONFIG_PROX_SPACING_RNG_BITS) 29 | * listen for CONFIG_PROX_LISTEN - all based on LF_FREQUENCY ticks */ 30 | #define CONFIG_PROX_SPACING_RNG_BITS 9 31 | #define CONFIG_PROX_SPACING MILLISECONDS(25) 32 | #define CONFIG_PROX_LISTEN_RATIO 10 33 | #define CONFIG_PROX_LISTEN MILLISECONDS(5) 34 | 35 | #define CONFIG_UART_BAUDRATE UART_BAUDRATE_BAUDRATE_Baud115200 36 | #define CONFIG_UART_TXD_PIN 9 37 | #ifdef CONFIG_UART_RX 38 | #define CONFIG_UART_RXD_PIN 8 39 | #else 40 | #define CONFIG_GPIO3_PIN 8 41 | #endif/*CONFIG_UART_RX*/ 42 | 43 | #define CONFIG_FLASH_MISO 16 44 | #define CONFIG_FLASH_MOSI 15 45 | #define CONFIG_FLASH_SCK 14 46 | #define CONFIG_FLASH_nRESET 13 47 | #define CONFIG_FLASH_nCS 12 48 | #define SPI_FLASH NRF_SPI0 49 | 50 | #define CONFIG_ADC0 1 51 | #define CONFIG_ADC1 2 52 | 53 | #define CONFIG_ACC_INT1_CH 0 54 | #define CONFIG_ACC_INT1 3 55 | #define CONFIG_ACC_nCS 4 56 | #define CONFIG_ACC_MISO 5 57 | #define CONFIG_ACC_MOSI 6 58 | #define CONFIG_ACC_SCK 7 59 | #define SPI_ACC NRF_SPI1 60 | 61 | #define CONFIG_LED_PIN 17 62 | #define CONFIG_SWITCH_PIN 29 63 | 64 | /* only two priority bits available ! */ 65 | 66 | #define IRQ_PRIORITY_HIGH 0 67 | #define IRQ_PRIORITY_AES (IRQ_PRIORITY_HIGH) 68 | #define IRQ_PRIORITY_RNG (IRQ_PRIORITY_HIGH+1) 69 | #define IRQ_PRIORITY_POWER_CLOCK (IRQ_PRIORITY_HIGH+1) 70 | #define IRQ_PRIORITY_RADIO (IRQ_PRIORITY_HIGH+2) 71 | 72 | #define IRQ_PRIORITY_LOW (IRQ_PRIORITY_HIGH+3) 73 | #define IRQ_PRIORITY_RTC0 (IRQ_PRIORITY_LOW) 74 | #define IRQ_PRIORITY_RTC1 (IRQ_PRIORITY_LOW) 75 | #define IRQ_PRIORITY_ADC (IRQ_PRIORITY_LOW) 76 | #define IRQ_PRIORITY_UART0 (IRQ_PRIORITY_LOW) 77 | 78 | #include "lib.h" 79 | 80 | #endif/*__CONFIG_H__*/ 81 | -------------------------------------------------------------------------------- /firmware/nRF51/core/openbeacon/src/crc8.c: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * 3 | * OpenBeacon.org - CRC8 routine 4 | * 5 | * Copyright 2011 Milosch Meriac 6 | * 7 | *************************************************************** 8 | 9 | This program is free software; you can redistribute it and/or modify 10 | it under the terms of the GNU General Public License as published by 11 | the Free Software Foundation; version 2. 12 | 13 | This program is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | GNU General Public License for more details. 17 | 18 | You should have received a copy of the GNU General Public License along 19 | with this program; if not, write to the Free Software Foundation, Inc., 20 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 21 | 22 | */ 23 | 24 | #include 25 | #include 26 | 27 | static const uint8_t crc8_table[] = { 28 | 0x00, 0x07, 0x0e, 0x09, 0x1c, 0x1b, 0x12, 0x15, 29 | 0x38, 0x3f, 0x36, 0x31, 0x24, 0x23, 0x2a, 0x2d, 30 | 0x70, 0x77, 0x7e, 0x79, 0x6c, 0x6b, 0x62, 0x65, 31 | 0x48, 0x4f, 0x46, 0x41, 0x54, 0x53, 0x5a, 0x5d, 32 | 0xe0, 0xe7, 0xee, 0xe9, 0xfc, 0xfb, 0xf2, 0xf5, 33 | 0xd8, 0xdf, 0xd6, 0xd1, 0xc4, 0xc3, 0xca, 0xcd, 34 | 0x90, 0x97, 0x9e, 0x99, 0x8c, 0x8b, 0x82, 0x85, 35 | 0xa8, 0xaf, 0xa6, 0xa1, 0xb4, 0xb3, 0xba, 0xbd, 36 | 0xc7, 0xc0, 0xc9, 0xce, 0xdb, 0xdc, 0xd5, 0xd2, 37 | 0xff, 0xf8, 0xf1, 0xf6, 0xe3, 0xe4, 0xed, 0xea, 38 | 0xb7, 0xb0, 0xb9, 0xbe, 0xab, 0xac, 0xa5, 0xa2, 39 | 0x8f, 0x88, 0x81, 0x86, 0x93, 0x94, 0x9d, 0x9a, 40 | 0x27, 0x20, 0x29, 0x2e, 0x3b, 0x3c, 0x35, 0x32, 41 | 0x1f, 0x18, 0x11, 0x16, 0x03, 0x04, 0x0d, 0x0a, 42 | 0x57, 0x50, 0x59, 0x5e, 0x4b, 0x4c, 0x45, 0x42, 43 | 0x6f, 0x68, 0x61, 0x66, 0x73, 0x74, 0x7d, 0x7a, 44 | 0x89, 0x8e, 0x87, 0x80, 0x95, 0x92, 0x9b, 0x9c, 45 | 0xb1, 0xb6, 0xbf, 0xb8, 0xad, 0xaa, 0xa3, 0xa4, 46 | 0xf9, 0xfe, 0xf7, 0xf0, 0xe5, 0xe2, 0xeb, 0xec, 47 | 0xc1, 0xc6, 0xcf, 0xc8, 0xdd, 0xda, 0xd3, 0xd4, 48 | 0x69, 0x6e, 0x67, 0x60, 0x75, 0x72, 0x7b, 0x7c, 49 | 0x51, 0x56, 0x5f, 0x58, 0x4d, 0x4a, 0x43, 0x44, 50 | 0x19, 0x1e, 0x17, 0x10, 0x05, 0x02, 0x0b, 0x0c, 51 | 0x21, 0x26, 0x2f, 0x28, 0x3d, 0x3a, 0x33, 0x34, 52 | 0x4e, 0x49, 0x40, 0x47, 0x52, 0x55, 0x5c, 0x5b, 53 | 0x76, 0x71, 0x78, 0x7f, 0x6a, 0x6d, 0x64, 0x63, 54 | 0x3e, 0x39, 0x30, 0x37, 0x22, 0x25, 0x2c, 0x2b, 55 | 0x06, 0x01, 0x08, 0x0f, 0x1a, 0x1d, 0x14, 0x13, 56 | 0xae, 0xa9, 0xa0, 0xa7, 0xb2, 0xb5, 0xbc, 0xbb, 57 | 0x96, 0x91, 0x98, 0x9f, 0x8a, 0x8d, 0x84, 0x83, 58 | 0xde, 0xd9, 0xd0, 0xd7, 0xc2, 0xc5, 0xcc, 0xcb, 59 | 0xe6, 0xe1, 0xe8, 0xef, 0xfa, 0xfd, 0xf4, 0xf3 60 | }; 61 | 62 | uint8_t 63 | crc8 (const uint8_t * buffer, uint32_t size) 64 | { 65 | uint8_t crc = 0xFF; 66 | while (size--) 67 | crc = crc8_table[crc ^ (*buffer++)]; 68 | return crc ^ 0xFF; 69 | } 70 | -------------------------------------------------------------------------------- /firmware/nRF51/tag-mischief/src/main.c: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * 3 | * OpenBeacon.org - nRF51 Main Entry 4 | * 5 | * Copyright 2013 Milosch Meriac 6 | * 7 | *************************************************************** 8 | 9 | This file is part of the OpenBeacon.org active RFID firmware 10 | 11 | OpenBeacon is free software: you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | OpenBeacon is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with Foobar. If not, see . 23 | 24 | */ 25 | #include 26 | 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | 33 | static int8_t g_tag_angle; 34 | 35 | int8_t tag_angle(void) 36 | { 37 | return g_tag_angle; 38 | } 39 | 40 | void blink(uint8_t times) 41 | { 42 | while(times--) 43 | { 44 | nrf_gpio_pin_set(CONFIG_LED_PIN); 45 | timer_wait(MILLISECONDS(10)); 46 | nrf_gpio_pin_clear(CONFIG_LED_PIN); 47 | timer_wait(MILLISECONDS(490)); 48 | } 49 | } 50 | 51 | void halt(uint8_t times) 52 | { 53 | while(TRUE) 54 | { 55 | blink(times); 56 | timer_wait(SECONDS(3)); 57 | } 58 | } 59 | 60 | void main_entry(void) 61 | { 62 | uint32_t tag_id; 63 | 64 | /* enabled LED output */ 65 | nrf_gpio_cfg_output(CONFIG_LED_PIN); 66 | nrf_gpio_pin_set(CONFIG_LED_PIN); 67 | 68 | /* enabled input pin */ 69 | nrf_gpio_cfg_input(CONFIG_SWITCH_PIN, NRF_GPIO_PIN_NOPULL); 70 | 71 | /* initialize UART */ 72 | uart_init(); 73 | 74 | /* start timer */ 75 | timer_init(); 76 | 77 | /* initialize flash */ 78 | if(flash_init()) 79 | halt(2); 80 | 81 | /* initialize accelerometer */ 82 | if(acc_init()) 83 | halt(3); 84 | 85 | /* calculate tag ID from NRF_FICR->DEVICEID */ 86 | tag_id = crc32(&NRF_FICR->DEVICEID, sizeof(NRF_FICR->DEVICEID)); 87 | 88 | /* start radio */ 89 | debug_printf("\n\rInitializing Tag[%08X] v" PROGRAM_VERSION "\n\r", 90 | tag_id); 91 | radio_init(tag_id); 92 | 93 | /* enter main loop */ 94 | nrf_gpio_pin_clear(CONFIG_LED_PIN); 95 | 96 | while(TRUE) 97 | { 98 | /* get tag angle once per second */ 99 | acc_magnitude(&g_tag_angle); 100 | timer_wait(MILLISECONDS(1000)); 101 | 102 | /* blink every 4 seconds */ 103 | if((g_counter++ & 3) == 0) 104 | { 105 | nrf_gpio_pin_set(CONFIG_LED_PIN); 106 | timer_wait(MILLISECONDS(1)); 107 | nrf_gpio_pin_clear(CONFIG_LED_PIN); 108 | } 109 | } 110 | } 111 | -------------------------------------------------------------------------------- /firmware/nRF51/tag-ble-beacon/src/main.c: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * 3 | * OpenBeacon.org - nRF51 Main Entry 4 | * 5 | * Copyright 2013 Milosch Meriac 6 | * 7 | *************************************************************** 8 | 9 | This file is part of the OpenBeacon.org active RFID firmware 10 | 11 | OpenBeacon is free software: you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | OpenBeacon is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with Foobar. If not, see . 23 | 24 | */ 25 | #include 26 | 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | static int8_t g_tag_angle; 33 | 34 | int8_t tag_angle(void) 35 | { 36 | return g_tag_angle; 37 | } 38 | 39 | void blink(uint8_t times) 40 | { 41 | while(times--) 42 | { 43 | nrf_gpio_pin_set(CONFIG_LED_PIN); 44 | timer_wait(MILLISECONDS(10)); 45 | nrf_gpio_pin_clear(CONFIG_LED_PIN); 46 | timer_wait(MILLISECONDS(490)); 47 | } 48 | } 49 | 50 | void halt(uint8_t times) 51 | { 52 | while(TRUE) 53 | { 54 | blink(times); 55 | timer_wait(SECONDS(3)); 56 | } 57 | } 58 | 59 | void main_entry(void) 60 | { 61 | uint8_t blink; 62 | uint32_t tag_id; 63 | 64 | /* enabled LED output */ 65 | nrf_gpio_cfg_output(CONFIG_LED_PIN); 66 | nrf_gpio_pin_set(CONFIG_LED_PIN); 67 | 68 | /* enabled input pin */ 69 | nrf_gpio_cfg_input(CONFIG_SWITCH_PIN, NRF_GPIO_PIN_NOPULL); 70 | 71 | /* initialize UART */ 72 | uart_init(); 73 | 74 | /* start timer */ 75 | timer_init(); 76 | 77 | /* initialize flash */ 78 | if(flash_init()) 79 | halt(2); 80 | 81 | /* initialize accelerometer */ 82 | if(acc_init()) 83 | halt(3); 84 | 85 | /* calculate tag ID from NRF_FICR->DEVICEID */ 86 | tag_id = crc32(&NRF_FICR->DEVICEID, sizeof(NRF_FICR->DEVICEID)); 87 | 88 | /* start radio */ 89 | debug_printf("\n\rInitializing Tag[%08X] v" PROGRAM_VERSION "\n\r", 90 | tag_id); 91 | radio_init(tag_id); 92 | 93 | /* enter main loop */ 94 | blink = 0; 95 | nrf_gpio_pin_clear(CONFIG_LED_PIN); 96 | while(TRUE) 97 | { 98 | /* get tag angle once per second */ 99 | acc_magnitude(&g_tag_angle); 100 | timer_wait(MILLISECONDS(1000)); 101 | 102 | /* blink every 5 seconds */ 103 | if(blink<5) 104 | blink++; 105 | else 106 | { 107 | blink = 0; 108 | nrf_gpio_pin_set(CONFIG_LED_PIN); 109 | timer_wait(MILLISECONDS(1)); 110 | nrf_gpio_pin_clear(CONFIG_LED_PIN); 111 | } 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /firmware/nRF51/tag-proximity/src/main.c: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * 3 | * OpenBeacon.org - nRF51 Main Entry 4 | * 5 | * Copyright 2013 Milosch Meriac 6 | * 7 | *************************************************************** 8 | 9 | This file is part of the OpenBeacon.org active RFID firmware 10 | 11 | OpenBeacon is free software: you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | OpenBeacon is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with Foobar. If not, see . 23 | 24 | */ 25 | #include 26 | 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | static int8_t g_tag_angle; 33 | 34 | int8_t tag_angle(void) 35 | { 36 | return g_tag_angle; 37 | } 38 | 39 | void blink(uint8_t times) 40 | { 41 | while(times--) 42 | { 43 | nrf_gpio_pin_set(CONFIG_LED_PIN); 44 | timer_wait(MILLISECONDS(10)); 45 | nrf_gpio_pin_clear(CONFIG_LED_PIN); 46 | timer_wait(MILLISECONDS(490)); 47 | } 48 | } 49 | 50 | void halt(uint8_t times) 51 | { 52 | while(TRUE) 53 | { 54 | blink(times); 55 | timer_wait(SECONDS(3)); 56 | } 57 | } 58 | 59 | void main_entry(void) 60 | { 61 | uint8_t blink; 62 | uint32_t tag_id; 63 | 64 | /* enabled LED output */ 65 | nrf_gpio_cfg_output(CONFIG_LED_PIN); 66 | nrf_gpio_pin_set(CONFIG_LED_PIN); 67 | 68 | /* enabled input pin */ 69 | nrf_gpio_cfg_input(CONFIG_SWITCH_PIN, NRF_GPIO_PIN_NOPULL); 70 | 71 | /* initialize UART */ 72 | uart_init(); 73 | 74 | /* start timer */ 75 | timer_init(); 76 | 77 | /* initialize flash */ 78 | if(flash_init()) 79 | halt(2); 80 | 81 | /* initialize accelerometer */ 82 | if(acc_init()) 83 | halt(3); 84 | 85 | /* calculate tag ID from NRF_FICR->DEVICEID */ 86 | tag_id = crc32(&NRF_FICR->DEVICEID, sizeof(NRF_FICR->DEVICEID)); 87 | 88 | /* start radio */ 89 | debug_printf("\n\rInitializing Tag[%08X] v" PROGRAM_VERSION " @24%02iMHz ...\n\r", 90 | tag_id, 91 | CONFIG_TRACKER_CHANNEL); 92 | radio_init(tag_id); 93 | 94 | /* enter main loop */ 95 | blink = 0; 96 | nrf_gpio_pin_clear(CONFIG_LED_PIN); 97 | while(TRUE) 98 | { 99 | /* get tag angle once per second */ 100 | acc_magnitude(&g_tag_angle); 101 | timer_wait(MILLISECONDS(1000)); 102 | 103 | /* blink every 5 seconds */ 104 | if(blink<5) 105 | blink++; 106 | else 107 | { 108 | blink = 0; 109 | nrf_gpio_pin_set(CONFIG_LED_PIN); 110 | timer_wait(MILLISECONDS(1)); 111 | nrf_gpio_pin_clear(CONFIG_LED_PIN); 112 | } 113 | } 114 | } 115 | -------------------------------------------------------------------------------- /firmware/nRF51/tag-proximity/inc/openbeacon-proto.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * 3 | * OpenBeacon.org - OnAir protocol specification and definition 4 | * 5 | * Copyright 2013 Milosch Meriac 6 | * 7 | **************************************************************************** 8 | 9 | This file is part of the OpenBeacon.org active RFID firmware 10 | 11 | OpenBeacon is free software: you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | OpenBeacon is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with Foobar. If not, see . 23 | 24 | */ 25 | 26 | #ifndef __OPENBEACON_PROTO_H__ 27 | #define __OPENBEACON_PROTO_H__ 28 | 29 | #define BEACONLOG_SIGHTING 0x01 30 | 31 | #define CONFIG_TRACKER_CHANNEL 81 32 | #define CONFIG_PROX_CHANNEL 76 33 | 34 | #define CONFIG_SIGNATURE_SIZE 5 35 | #define CONFIG_SIGHTING_SLOTS 3 36 | 37 | #define RFBPROTO_BEACON_NG_SIGHTING 30 38 | #define RFBPROTO_BEACON_NG_STATUS 31 39 | #define RFBPROTO_BEACON_NG_PROX 32 40 | 41 | typedef struct 42 | { 43 | int16_t rx_loss; 44 | int16_t tx_loss; 45 | int16_t px_power; 46 | uint16_t ticks; 47 | } PACKED TBeaconNgStatus; 48 | 49 | typedef struct 50 | { 51 | int8_t rx_power; 52 | uint32_t uid; 53 | } PACKED TBeaconNgSighting; 54 | 55 | typedef union 56 | { 57 | TBeaconNgStatus status; 58 | TBeaconNgSighting sighting[CONFIG_SIGHTING_SLOTS]; 59 | uint8_t raw[15]; 60 | } PACKED TBeaconNgPayload; 61 | 62 | typedef struct 63 | { 64 | uint8_t proto; 65 | int8_t tx_power; 66 | int8_t angle; 67 | uint8_t voltage; 68 | uint32_t uid; 69 | uint32_t epoch; 70 | TBeaconNgPayload p; 71 | uint8_t signature[CONFIG_SIGNATURE_SIZE]; 72 | } PACKED TBeaconNgTracker; 73 | 74 | typedef struct 75 | { 76 | uint32_t uid; 77 | uint32_t epoch; 78 | uint16_t ticks; 79 | } PACKED TBeaconNgProxAnnounce; 80 | 81 | typedef union 82 | { 83 | TBeaconNgProxAnnounce prox; 84 | uint8_t raw[10]; 85 | } PACKED TBeaconNgProxPayload; 86 | 87 | typedef struct 88 | { 89 | TBeaconNgProxPayload p; 90 | uint8_t proto; 91 | uint8_t signature[CONFIG_SIGNATURE_SIZE]; 92 | } PACKED TBeaconNgProx; 93 | 94 | typedef struct 95 | { 96 | uint16_t icrc16; 97 | uint8_t protocol; 98 | uint8_t interface; 99 | uint16_t reader_id; 100 | uint16_t size; 101 | } PACKED TBeaconNetworkHdr; 102 | 103 | /* BEACONLOG_SIGHTING */ 104 | typedef struct 105 | { 106 | TBeaconNetworkHdr hdr; 107 | uint32_t sequence; 108 | uint32_t timestamp; 109 | TBeaconNgTracker log; 110 | } PACKED TBeaconLogSighting; 111 | 112 | #endif/*__OPENBEACON_PROTO_H__*/ 113 | -------------------------------------------------------------------------------- /firmware/nRF51/reader-prox/src/main.c: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * 3 | * OpenBeacon.org - nRF51 Main Entry 4 | * 5 | * Copyright 2013-2015 Milosch Meriac 6 | * 7 | *************************************************************** 8 | 9 | This file is part of the OpenBeacon.org active RFID firmware 10 | 11 | OpenBeacon is free software: you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | OpenBeacon is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with Foobar. If not, see . 23 | 24 | */ 25 | #include 26 | #include 27 | #include 28 | 29 | static int8_t g_tag_angle; 30 | 31 | int8_t tag_angle(void) 32 | { 33 | return g_tag_angle; 34 | } 35 | 36 | void blink(uint8_t times) 37 | { 38 | while(times--) 39 | { 40 | nrf_gpio_pin_set(CONFIG_LED_PIN); 41 | timer_wait(MILLISECONDS(10)); 42 | nrf_gpio_pin_clear(CONFIG_LED_PIN); 43 | timer_wait(MILLISECONDS(490)); 44 | } 45 | } 46 | 47 | void halt(uint8_t times) 48 | { 49 | while(TRUE) 50 | { 51 | blink(times); 52 | timer_wait(SECONDS(3)); 53 | } 54 | } 55 | 56 | void main_entry(void) 57 | { 58 | int i; 59 | uint8_t *p, data; 60 | TBeaconBuffer pkt; 61 | uint32_t tag_id; 62 | 63 | /* enabled LED output */ 64 | nrf_gpio_cfg_output(CONFIG_LED_PIN); 65 | nrf_gpio_pin_set(CONFIG_LED_PIN); 66 | 67 | /* enabled green LED */ 68 | nrf_gpio_cfg_output(18); 69 | nrf_gpio_pin_set(18); 70 | 71 | /* enabled input pin */ 72 | nrf_gpio_cfg_input(CONFIG_SWITCH_PIN, NRF_GPIO_PIN_NOPULL); 73 | 74 | /* initialize UART */ 75 | uart_init(); 76 | 77 | /* start timer */ 78 | timer_init(); 79 | 80 | /* calculate tag ID from NRF_FICR->DEVICEID */ 81 | tag_id = crc32(&NRF_FICR->DEVICEID, sizeof(NRF_FICR->DEVICEID)); 82 | 83 | /* start radio */ 84 | debug_printf("\n\rInitializing Reader[%08X] v" PROGRAM_VERSION "\n\r", 85 | tag_id); 86 | radio_init(); 87 | 88 | /* enter main loop */ 89 | nrf_gpio_pin_clear(CONFIG_LED_PIN); 90 | while(TRUE) 91 | { 92 | if(!radio_rx(&pkt)) 93 | __WFE(); 94 | else 95 | { 96 | nrf_gpio_pin_set(CONFIG_LED_PIN); 97 | 98 | /* output packet, escape 0xFF's by appending 0x01's */ 99 | p = (uint8_t*)&pkt; 100 | for(i=0; i<(int)sizeof(pkt); i++) 101 | { 102 | data = *p++; 103 | default_putchar(data); 104 | /* if data is 0xFF, emit control character */ 105 | if(data == 0xFF) 106 | default_putchar(0x00); 107 | } 108 | 109 | /* issue frame termination indicator */ 110 | default_putchar(0xFF); 111 | default_putchar(0x01); 112 | 113 | nrf_gpio_pin_clear(CONFIG_LED_PIN); 114 | } 115 | } 116 | } 117 | -------------------------------------------------------------------------------- /firmware/nRF51/core/nrf/src/system_nrf5.c: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2009 Nordic Semiconductor. All Rights Reserved. 2 | * 3 | * The information contained herein is property of Nordic Semiconductor ASA. 4 | * Terms and conditions of usage are described in detail in NORDIC 5 | * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. 6 | * 7 | * Licensees are granted free, non-transferable use of the information. NO 8 | * WARRANTY of ANY KIND is provided. This heading must NOT be removed from 9 | * the file. 10 | * 11 | */ 12 | 13 | 14 | 15 | /* NOTE: Template files (including this one) are application specific and therefore expected to 16 | be copied into the application project folder prior to its use! */ 17 | 18 | #include 19 | #include "system_nrf51.h" 20 | 21 | /*lint ++flb "Enter library region" */ 22 | 23 | 24 | #define __SYSTEM_CLOCK (16000000UL) /*!< nRF51 devices use a fixed System Clock Frequency of 16MHz */ 25 | 26 | static bool is_manual_peripheral_setup_needed(void); 27 | static bool is_disabled_in_debug_needed(void); 28 | 29 | 30 | #if defined ( __CC_ARM ) 31 | uint32_t SystemCoreClock __attribute__((used)) = __SYSTEM_CLOCK; 32 | #elif defined ( __ICCARM__ ) 33 | __root uint32_t SystemCoreClock = __SYSTEM_CLOCK; 34 | #elif defined ( __GNUC__ ) 35 | uint32_t SystemCoreClock __attribute__((used)) = __SYSTEM_CLOCK; 36 | #endif 37 | 38 | void SystemCoreClockUpdate(void) 39 | { 40 | SystemCoreClock = __SYSTEM_CLOCK; 41 | } 42 | 43 | void SystemInit(void) 44 | { 45 | /* If desired, switch off the unused RAM to lower consumption by the use of RAMON register. 46 | It can also be done in the application main() function. */ 47 | 48 | /* Prepare the peripherals for use as indicated by the PAN 26 "System: Manual setup is required 49 | to enable the use of peripherals" found at Product Anomaly document for your device found at 50 | https://www.nordicsemi.com/. The side effect of executing these instructions in the devices 51 | that do not need it is that the new peripherals in the second generation devices (LPCOMP for 52 | example) will not be available. */ 53 | if (is_manual_peripheral_setup_needed()) 54 | { 55 | *(uint32_t volatile *)0x40000504 = 0xC007FFDF; 56 | *(uint32_t volatile *)0x40006C18 = 0x00008000; 57 | } 58 | 59 | /* Disable PROTENSET registers under debug, as indicated by PAN 59 "MPU: Reset value of DISABLEINDEBUG 60 | register is incorrect" found at Product Anomaly document four your device found at 61 | https://www.nordicsemi.com/. There is no side effect of using these instruction if not needed. */ 62 | if (is_disabled_in_debug_needed()) 63 | { 64 | NRF_MPU->DISABLEINDEBUG = MPU_DISABLEINDEBUG_DISABLEINDEBUG_Disabled << MPU_DISABLEINDEBUG_DISABLEINDEBUG_Pos; 65 | } 66 | } 67 | 68 | static bool check_value(uint8_t value) 69 | { 70 | return (((*(uint32_t *)0xF0000FE0) & 0x000000FF) == 0x1) && 71 | (((*(uint32_t *)0xF0000FE4) & 0x0000000F) == 0x0) && 72 | (((*(uint32_t *)0xF0000FE8) & 0x000000F0) == value); 73 | } 74 | 75 | static bool is_manual_peripheral_setup_needed(void) 76 | { 77 | return check_value(0x00) || check_value(0x10) || check_value(0x30); 78 | } 79 | 80 | static bool is_disabled_in_debug_needed(void) 81 | { 82 | return check_value(0x40) && (((*(uint32_t *)0xF0000FEC) & 0x000000F0) == 0x0); 83 | } 84 | 85 | /*lint --flb "Leave library region" */ 86 | -------------------------------------------------------------------------------- /firmware/nRF51/tag-power/src/rng.c: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * 3 | * OpenBeacon.org - nRF51 Random Number Generation 4 | * 5 | * Copyright 2014 Milosch Meriac 6 | * 7 | *************************************************************** 8 | 9 | This file is part of the OpenBeacon.org active RFID firmware 10 | 11 | OpenBeacon is free software: you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | OpenBeacon is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with Foobar. If not, see . 23 | 24 | */ 25 | #include 26 | #include 27 | 28 | /* allow overriding RNG pool size */ 29 | #ifndef CONFIG_RNG_POOL_SIZE 30 | #define CONFIG_RNG_POOL_SIZE 32 31 | #endif/*CONFIG_RNG_POOL_SIZE*/ 32 | 33 | static uint8_t g_rng_pool[CONFIG_RNG_POOL_SIZE]; 34 | static uint16_t g_rng_pool_write, g_rng_pool_read; 35 | static volatile uint16_t g_rng_pool_count; 36 | static volatile uint8_t g_rng_pool_stopped; 37 | 38 | void RNG_IRQ_Handler(void) 39 | { 40 | if(NRF_RNG->EVENTS_VALRDY) 41 | { 42 | /* remember value */ 43 | g_rng_pool[g_rng_pool_write++] = (uint8_t)NRF_RNG->VALUE; 44 | if(g_rng_pool_write==CONFIG_RNG_POOL_SIZE) 45 | g_rng_pool_write=0; 46 | 47 | /* disable once pool is filled */ 48 | g_rng_pool_count++; 49 | if(g_rng_pool_count==CONFIG_RNG_POOL_SIZE) 50 | NRF_RNG->TASKS_STOP = 1; 51 | 52 | /* acknowledge event */ 53 | NRF_RNG->EVENTS_VALRDY = 0; 54 | } 55 | } 56 | 57 | uint32_t rng(uint8_t bits) 58 | { 59 | uint8_t bytes,*p; 60 | uint32_t data; 61 | 62 | if(!bits) 63 | return 0; 64 | if(bits>32) 65 | bits=32; 66 | 67 | /* calculate bytes and mask */ 68 | bytes = (bits+7)/8; 69 | /* wait for pool to fill up */ 70 | if(bytes>g_rng_pool_count) 71 | { 72 | /* start refilling pool */ 73 | NRF_RNG->TASKS_START = 1; 74 | /* wait till minimum bytes were aquired */ 75 | while(bytes>g_rng_pool_count) 76 | __WFE(); 77 | } 78 | 79 | data = 0; 80 | p = (uint8_t*)&data; 81 | /* protect counter */ 82 | __disable_irq(); 83 | 84 | /* extract number of bytes needed */ 85 | g_rng_pool_count-=bytes; 86 | while(bytes--) 87 | { 88 | *p++ = g_rng_pool[g_rng_pool_read++]; 89 | if(g_rng_pool_read==CONFIG_RNG_POOL_SIZE) 90 | g_rng_pool_read=0; 91 | } 92 | 93 | /* leave protection */ 94 | __enable_irq(); 95 | 96 | /* refill pool */ 97 | NRF_RNG->TASKS_START = 1; 98 | 99 | /* mask needed bytes */ 100 | return data & ((1UL<CONFIG = 0; 108 | NRF_RNG->TASKS_START = 1; 109 | NRF_RNG->INTENSET = ( 110 | (RNG_INTENSET_VALRDY_Enabled << RNG_INTENSET_VALRDY_Pos) 111 | ); 112 | NVIC_SetPriority(RNG_IRQn, IRQ_PRIORITY_RNG); 113 | NVIC_EnableIRQ(RNG_IRQn); 114 | } 115 | -------------------------------------------------------------------------------- /firmware/nRF51/tag-proximity/src/rng.c: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * 3 | * OpenBeacon.org - nRF51 Random Number Generation 4 | * 5 | * Copyright 2014 Milosch Meriac 6 | * 7 | *************************************************************** 8 | 9 | This file is part of the OpenBeacon.org active RFID firmware 10 | 11 | OpenBeacon is free software: you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | OpenBeacon is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with Foobar. If not, see . 23 | 24 | */ 25 | #include 26 | #include 27 | 28 | /* allow overriding RNG pool size */ 29 | #ifndef CONFIG_RNG_POOL_SIZE 30 | #define CONFIG_RNG_POOL_SIZE 32 31 | #endif/*CONFIG_RNG_POOL_SIZE*/ 32 | 33 | static uint8_t g_rng_pool[CONFIG_RNG_POOL_SIZE]; 34 | static uint16_t g_rng_pool_write, g_rng_pool_read; 35 | static volatile uint16_t g_rng_pool_count; 36 | static volatile uint8_t g_rng_pool_stopped; 37 | 38 | void RNG_IRQ_Handler(void) 39 | { 40 | if(NRF_RNG->EVENTS_VALRDY) 41 | { 42 | /* remember value */ 43 | g_rng_pool[g_rng_pool_write++] = (uint8_t)NRF_RNG->VALUE; 44 | if(g_rng_pool_write==CONFIG_RNG_POOL_SIZE) 45 | g_rng_pool_write=0; 46 | 47 | /* disable once pool is filled */ 48 | g_rng_pool_count++; 49 | if(g_rng_pool_count==CONFIG_RNG_POOL_SIZE) 50 | NRF_RNG->TASKS_STOP = 1; 51 | 52 | /* acknowledge event */ 53 | NRF_RNG->EVENTS_VALRDY = 0; 54 | } 55 | } 56 | 57 | uint32_t rng(uint8_t bits) 58 | { 59 | uint8_t bytes,*p; 60 | uint32_t data; 61 | 62 | if(!bits) 63 | return 0; 64 | if(bits>32) 65 | bits=32; 66 | 67 | /* calculate bytes and mask */ 68 | bytes = (bits+7)/8; 69 | /* wait for pool to fill up */ 70 | if(bytes>g_rng_pool_count) 71 | { 72 | /* start refilling pool */ 73 | NRF_RNG->TASKS_START = 1; 74 | /* wait till minimum bytes were aquired */ 75 | while(bytes>g_rng_pool_count) 76 | __WFE(); 77 | } 78 | 79 | data = 0; 80 | p = (uint8_t*)&data; 81 | /* protect counter */ 82 | __disable_irq(); 83 | 84 | /* extract number of bytes needed */ 85 | g_rng_pool_count-=bytes; 86 | while(bytes--) 87 | { 88 | *p++ = g_rng_pool[g_rng_pool_read++]; 89 | if(g_rng_pool_read==CONFIG_RNG_POOL_SIZE) 90 | g_rng_pool_read=0; 91 | } 92 | 93 | /* leave protection */ 94 | __enable_irq(); 95 | 96 | /* refill pool */ 97 | NRF_RNG->TASKS_START = 1; 98 | 99 | /* mask needed bytes */ 100 | return data & ((1UL<CONFIG = 0; 108 | NRF_RNG->TASKS_START = 1; 109 | NRF_RNG->INTENSET = ( 110 | (RNG_INTENSET_VALRDY_Enabled << RNG_INTENSET_VALRDY_Pos) 111 | ); 112 | NVIC_SetPriority(RNG_IRQn, IRQ_PRIORITY_RNG); 113 | NVIC_EnableIRQ(RNG_IRQn); 114 | } 115 | -------------------------------------------------------------------------------- /firmware/nRF51/tag-power/inc/openbeacon-proto.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * 3 | * OpenBeacon.org - OnAir protocol specification and definition 4 | * 5 | * Copyright 2013 Milosch Meriac 6 | * 7 | **************************************************************************** 8 | 9 | This file is part of the OpenBeacon.org active RFID firmware 10 | 11 | OpenBeacon is free software: you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | OpenBeacon is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with Foobar. If not, see . 23 | 24 | */ 25 | 26 | #ifndef __OPENBEACON_PROTO_H__ 27 | #define __OPENBEACON_PROTO_H__ 28 | 29 | #define BEACONLOG_SIGHTING 0x01 30 | 31 | #define CONFIG_TRACKER_CHANNEL 81 32 | #define CONFIG_PROX_CHANNEL 76 33 | 34 | #define CONFIG_SIGNATURE_SIZE 5 35 | #define CONFIG_SIGHTING_SLOTS 3 36 | 37 | #define RFBPROTO_BEACON_NG_SIGHTING 30 38 | #define RFBPROTO_BEACON_NG_STATUS 31 39 | #define RFBPROTO_BEACON_NG_PROX 32 40 | #define RFBPROTO_BEACON_NG_MARKER 33 41 | 42 | typedef struct 43 | { 44 | int16_t rx_loss; 45 | int16_t tx_loss; 46 | int16_t px_power; 47 | uint16_t ticks; 48 | } PACKED TBeaconNgStatus; 49 | 50 | typedef struct 51 | { 52 | int8_t rx_power; 53 | uint32_t uid; 54 | } PACKED TBeaconNgSighting; 55 | 56 | typedef union 57 | { 58 | TBeaconNgStatus status; 59 | TBeaconNgSighting sighting[CONFIG_SIGHTING_SLOTS]; 60 | uint8_t raw[15]; 61 | } PACKED TBeaconNgPayload; 62 | 63 | typedef struct 64 | { 65 | uint8_t proto; 66 | int8_t tx_power; 67 | int8_t angle; 68 | uint8_t voltage; 69 | uint32_t uid; 70 | uint32_t epoch; 71 | TBeaconNgPayload p; 72 | uint8_t signature[CONFIG_SIGNATURE_SIZE]; 73 | } PACKED TBeaconNgTracker; 74 | 75 | typedef struct 76 | { 77 | uint8_t proto; 78 | int8_t tx_power; 79 | uint32_t uid; 80 | uint32_t counter; 81 | uint8_t voltage; 82 | uint8_t signature[CONFIG_SIGNATURE_SIZE]; 83 | } PACKED TBeaconNgMarker; 84 | 85 | 86 | typedef struct 87 | { 88 | uint32_t uid; 89 | uint32_t epoch; 90 | uint16_t ticks; 91 | } PACKED TBeaconNgProxAnnounce; 92 | 93 | typedef union 94 | { 95 | TBeaconNgProxAnnounce prox; 96 | uint8_t raw[10]; 97 | } PACKED TBeaconNgProxPayload; 98 | 99 | typedef struct 100 | { 101 | TBeaconNgProxPayload p; 102 | uint8_t proto; 103 | uint8_t signature[CONFIG_SIGNATURE_SIZE]; 104 | } PACKED TBeaconNgProx; 105 | 106 | typedef struct 107 | { 108 | uint16_t icrc16; 109 | uint8_t protocol; 110 | uint8_t interface; 111 | uint16_t reader_id; 112 | uint16_t size; 113 | } PACKED TBeaconNetworkHdr; 114 | 115 | /* BEACONLOG_SIGHTING */ 116 | typedef struct 117 | { 118 | TBeaconNetworkHdr hdr; 119 | uint32_t sequence; 120 | uint32_t timestamp; 121 | TBeaconNgTracker log; 122 | } PACKED TBeaconLogSighting; 123 | 124 | #endif/*__OPENBEACON_PROTO_H__*/ 125 | -------------------------------------------------------------------------------- /firmware/nRF51/tag-ipv6/src/main.c: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * 3 | * OpenBeacon.org - nRF51 Main Entry 4 | * 5 | * Copyright 2013-2014 Milosch Meriac 6 | * 7 | *************************************************************** 8 | 9 | This file is part of the OpenBeacon.org active RFID firmware 10 | 11 | OpenBeacon is free software: you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | OpenBeacon is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with Foobar. If not, see . 23 | 24 | */ 25 | #include 26 | #include 27 | #include 28 | 29 | static const eui64_t g_eui = {{0x02, 0x01, 0x02, 0xFF, 0xFE, 0x03, 0x04, 0x05}}; 30 | 31 | int32_t iot_context_manager_get_by_cid( 32 | const iot_interface_t * p_interface, 33 | uint8_t context_id, 34 | iot_context_t ** pp_context) 35 | { 36 | debug_printf("iot_context_manager_get_by_cid (id=%u)\n", context_id); 37 | return NRF_ERROR_NOT_FOUND; 38 | } 39 | 40 | uint32_t nrf51_sdk_mem_alloc(uint8_t ** pp_buffer, uint32_t * p_size) 41 | { 42 | debug_printf("nrf51_sdk_mem_alloc (size=%u)\n", *p_size); 43 | return NRF_ERROR_NO_MEM; 44 | } 45 | 46 | uint32_t nrf51_sdk_mem_free(uint8_t * p_buffer) 47 | { 48 | debug_printf("nrf51_sdk_mem_free: 0x%08X\n", p_buffer); 49 | return NRF_ERROR_INVALID_ADDR; 50 | } 51 | 52 | static void event_handler( 53 | iot_interface_t * p_interface, 54 | ble_6lowpan_event_t * p_6lo_event) 55 | { 56 | debug_printf("event=%i\n", p_6lo_event->event_id); 57 | } 58 | 59 | static void assert_handler( 60 | uint32_t pc, 61 | uint16_t line_number, 62 | const uint8_t * p_file_name) 63 | { 64 | debug_printf("%s:%u (0x%08X)\n", p_file_name, line_number, pc); 65 | } 66 | 67 | void main_entry(void) 68 | { 69 | uint32_t res; 70 | uint8_t enabled; 71 | volatile int t; 72 | ble_6lowpan_init_t ble; 73 | 74 | /* enabled LED output */ 75 | nrf_gpio_cfg_output(CONFIG_LED_PIN); 76 | nrf_gpio_pin_set(CONFIG_LED_PIN); 77 | 78 | /* enabled input pin */ 79 | nrf_gpio_cfg_input(CONFIG_SWITCH_PIN, NRF_GPIO_PIN_NOPULL); 80 | 81 | /* initialize UART */ 82 | uart_init(); 83 | 84 | if((res = sd_softdevice_enable( 85 | NRF_CLOCK_LFCLKSRC_XTAL_20_PPM, 86 | assert_handler))!=NRF_SUCCESS) 87 | { 88 | debug_printf("sd_softdevice_enable failed (0x%02X)\n", res); 89 | while(1); 90 | } 91 | 92 | debug_printf("Hello\n"); 93 | ble.p_eui64 = (eui64_t*)&g_eui; 94 | ble.event_handler = event_handler; 95 | if((res = ble_6lowpan_init(&ble))!=NRF_SUCCESS) 96 | { 97 | debug_printf("ble_6lowpan_init failed (0x%02X)\n", res); 98 | while(1); 99 | } 100 | 101 | while(1) 102 | { 103 | res = sd_softdevice_is_enabled(&enabled); 104 | 105 | debug_printf("Hello World (0x%08X, %i)\n", res, enabled); 106 | for(t=0; t<100000; t++); 107 | 108 | if(nrf_gpio_pin_read(CONFIG_SWITCH_PIN)) 109 | nrf_gpio_pin_set(CONFIG_LED_PIN); 110 | else 111 | nrf_gpio_pin_clear(CONFIG_LED_PIN); 112 | } 113 | } 114 | --------------------------------------------------------------------------------