Compare commits

...

1104 commits
ico ... master

Author SHA1 Message Date
Denis Knauf 1f53447813
Merge pull request #2 from iot-lab/pr/er-coap-dtls/tinydtls_and_er_coap_integration
Pr/er coap dtls/tinydtls and er coap integration
2018-03-10 22:34:41 +01:00
Denis Knauf 76ccd1ea13
Merge pull request #1 from osdomotics/master
level up
2018-03-10 22:29:08 +01:00
Harald Pichler 3f47cb300b change BUSY to PIN D14 2018-03-08 11:48:17 +01:00
Harald Pichler 0007835a5a bugfix timing 2018-03-08 11:24:20 +01:00
Harald Pichler c8bd1acde2 bugfix timing epaper 2018-03-07 09:25:14 +01:00
harald42 9d2f1715df bugfix init e-paper 2018-03-06 22:58:25 +01:00
harald42 02177f65e1 initial upload 2018-03-06 21:42:44 +01:00
harald42 46430fc77a initial upload 2018-03-05 21:28:35 +01:00
Harald 9da22fbec4
Merge pull request #12 from DenisKnauf/master
leds_off only provided, if PLATFORM_HAS_LEDS is 1, not if defined.
2018-03-02 08:24:53 +01:00
Denis Knauf ca431d2e46 leds_off only provided, if PLATFORM_HAS_LEDS is 1, not if defined. 2018-03-01 20:21:09 +01:00
Harald Pichler 3d255ed6f8 initial upload viewconfig 2018-02-28 16:28:46 +01:00
Christian Ratzenhofer 1c8b438bca Fixup osd examples, contiki prints panid and channel on boot 2018-02-14 18:49:37 +01:00
Christian Ratzenhofer 3de5c47802 pan ID and channel are defined on platform level, not example 2018-02-14 18:07:44 +01:00
Harald Pichler ea04534281 remove panid definition 2018-01-04 15:24:18 +01:00
Harald Pichler e62f254e7e bugfix now work with 8 sensors 2017-12-21 15:02:08 +01:00
Harald Pichler 9377759d3b initial upload 2017-12-20 12:02:58 +01:00
Harald Pichler 59b7f37e26 initial upload 2017-12-20 12:01:50 +01:00
Harald Pichler 7fd5b7a6a7 disable rpl quality 2017-12-20 11:40:37 +01:00
Harald Pichler 94f4b19460 update clock 2017-12-15 14:06:32 +01:00
Ralf Schlatterbeck eb68b98cf5 Also output smooth led on pin 3 2017-12-08 20:35:39 +01:00
harald42 196b169fbe remove unused code 2017-12-02 10:16:02 +01:00
Ralf Schlatterbeck d6618ade1a Add soft-blink LED example 2017-12-01 15:51:15 +01:00
Harald Pichler 9b901dd28e initial upload 2017-11-28 11:04:42 +01:00
Harald Pichler 713ffc33f2 add servo resource 2017-11-17 13:43:35 +01:00
Harald Pichler 2247c673fc add compile cpp files for resources 2017-11-17 13:04:38 +01:00
Harald Pichler a44c16a426 initial upload 2017-11-17 12:57:59 +01:00
Harald Pichler fb5fdca66a update readme 2017-11-16 16:20:05 +01:00
Harald Pichler 89d650d87b remove ifdef, merkur plattform have always battery cputemp and led possibility 2017-11-16 16:17:01 +01:00
Harald Pichler e0482d6d1b add arduino-settingsmanager to regression test 2017-11-16 14:29:35 +01:00
Ralf Schlatterbeck 81598323c6 Add Servo example 2017-11-09 11:07:36 +01:00
Harald Pichler 6695835808 bugfix compile error 2017-11-09 10:59:07 +01:00
Harald Pichler b929b419af initial upload 2017-11-09 08:39:35 +01:00
Marcus Priesch 80388188f7 fixed analog pin & compiling issues 2017-11-05 14:22:13 +01:00
Harald Pichler 502842a30b enable reciever always on 2017-10-20 11:19:46 +02:00
Harald Pichler aa9fc5d817 initial upload 2017-10-20 10:47:48 +02:00
Harald Pichler 1ee36e7429 make it possible to switch reviever always on at compile time 2017-10-19 16:00:03 +02:00
Harald Pichler 15039f6b5d cleanup code 2017-10-19 15:44:11 +02:00
Harald Pichler e93083073c expand to tree htu sensors 2017-10-19 14:28:10 +02:00
Harald Pichler 9355f678e3 rename htu to dhta ... c 2017-10-19 14:10:37 +02:00
Harald Pichler 4d90cd2e3f add dht sensor code 2017-10-19 11:35:46 +02:00
Harald Pichler da8cd47dea add arduino macro microsecondsToClockCycles 2017-10-19 11:34:06 +02:00
Harald Pichler e492974415 add ota resources 2017-10-16 16:01:43 +02:00
Harald Pichler 96c5d12e2a initial upload 2017-10-10 11:31:12 +02:00
Marcus Priesch 965ac84918 added 2017-10-10 00:39:53 +02:00
Harald Pichler 325e41ae6a print partition 2017-10-06 13:40:20 +02:00
Harald Pichler a9cb7ab7be Merge branch 'master' of https://github.com/osdomotics/osd-contiki 2017-10-06 13:34:48 +02:00
Harald Pichler 7fffc50d7c show acrive partition 2017-10-06 13:25:53 +02:00
Marcus Priesch 233cb02993 enabled rpl mesh routing 2017-10-05 17:01:09 +02:00
Marcus Priesch 54b72dcf64 update 2017-10-05 16:57:01 +02:00
Marcus Priesch 8c82ce0722 fixed some issues, added ota-update 2017-10-05 16:56:10 +02:00
Marcus Priesch 86596ac92f moved to apps folder 2017-10-05 16:53:26 +02:00
Marcus Priesch 259827b031 added coap:// links for firefox copper plugin 2017-10-05 16:45:30 +02:00
Harald Pichler 3479303454 enable rpl etx messurement 2017-10-02 16:15:16 +02:00
Harald Pichler 3fb61f7695 initial upload 2017-09-26 16:44:02 +02:00
Harald Pichler dd84558cd6 set default mcu sleep 2017-09-26 14:59:55 +02:00
Harald Pichler 297bd14f7b add enable aes hardwre 2017-09-26 14:15:53 +02:00
Harald Pichler 30de144aea save energy 2017-09-20 14:17:26 +02:00
Harald Pichler 13c22c0c71 cleanup code 2017-09-20 13:53:32 +02:00
Harald Pichler d4790c8ede bugfix set mcusleep value 2017-09-20 13:48:01 +02:00
Harald Pichler 5003aca5c7 add settings manager 2017-09-20 11:17:46 +02:00
Harald Pichler cfeb8036e0 bugfix thisplattform 2017-09-20 10:26:23 +02:00
Harald Pichler 2036cda4d9 add example and todos 2017-09-20 09:25:22 +02:00
Harald Pichler 29190681cc disable debug prints, remove rfchannel coap entry 2017-09-20 08:45:01 +02:00
Harald Pichler ba62fd2dd2 cleanup code and save memory 2017-09-20 06:22:07 +02:00
Harald Pichler ecdd101586 add rfsetings function 2017-09-19 16:40:22 +02:00
Harald Pichler 25d38eba2c remove s command from shell, add if typing disable mcusleep 2017-09-19 11:35:45 +02:00
Harald Pichler 927c0b8eac add start stop mcusleep 2017-09-18 15:05:39 +02:00
Harald Pichler 87f433d657 bugfix startup dont sleep 5sec. 2017-09-14 17:19:53 +02:00
Harald Pichler 0b24e047c5 add s command to disable mcusleep 2017-09-14 16:15:43 +02:00
Harald Pichler 31ec8687e4 add resources-common res-rfchannel 2017-09-13 16:50:53 +02:00
Harald Pichler 8b2ee08d55 add shell macconfig 2017-09-13 13:38:46 +02:00
Harald Pichler aaf1e8b2b1 initial upload 2017-09-12 16:28:05 +02:00
Harald Pichler 6694583291 cleanup code, move shell-merkur to apps/shell; move needed function from extended-rf-api to params 2017-09-12 14:39:38 +02:00
Harald Pichler fedd9cb0d7 bugfix set tx power from shell 2017-09-12 11:12:53 +02:00
Harald Pichler df2b297d91 bugix read tx power 2017-09-10 22:13:07 +02:00
Harald 4127d0993b Update README.md 2017-09-08 13:30:28 +02:00
Harald 11525b74ae Update README.md 2017-09-08 13:25:34 +02:00
Harald 8e23d07de4 Update README.md 2017-09-08 13:21:51 +02:00
Harald Pichler 5f8be3e6ea add Plattform documentation 2017-09-08 11:27:17 +02:00
Harald Pichler 07c21e6e7d add radio functions for settings radio parameter 2017-09-08 10:39:40 +02:00
Harald Pichler df282f348c cleanup code 2017-09-08 08:26:36 +02:00
Harald Pichler 3a560c79f9 change name saveparams to saverfparams 2017-09-07 21:07:24 +02:00
Harald Pichler 64b2750de3 set filter to standard 2017-09-07 16:01:42 +02:00
Harald Pichler a2f8424b74 add shell save parameter txpower, channel, panid 2017-09-07 11:44:54 +02:00
Harald Pichler f368875ea2 add params_save_channel 2017-09-06 16:54:56 +02:00
Harald Pichler 17e0b6f2cc add change cca thresholds 2017-09-05 22:48:57 +02:00
Harald Pichler 2ef7438131 add shell-merkur 2017-09-05 22:24:56 +02:00
Harald Pichler 8c5b66d715 work in progress -> rf settings shell 2017-09-05 16:38:55 +02:00
Harald Pichler 3f6cb4e795 Merge branch 'contiki' 2017-09-05 11:14:11 +02:00
Harald Pichler 7a6bab7b10 add shell comands 2017-09-01 11:18:20 +02:00
Harald Pichler 13c4934a37 bugfix settings mananger read EUI64 from bootloader 2017-08-31 16:06:15 +02:00
Harald Pichler 75e8c162ed initial upload settingsmanager example 2017-08-31 11:23:55 +02:00
Ralf Schlatterbeck 0c3a9c6b5a Fix OTA update
Image 0 did not work. We now get rid of bootloader_backup_irq_table and
do this manually: We may not write to address 0 while an image is
running. So for image 0 we write the lower 8 pages to the backup
address. For all other images (ony image 1 currently) we write to
*both*, the original address *and* the backup address. This is done
because some addresses in the lower 8 pages *are* used at the original
address and the bootloader doesn't (want to) know which addresses are
which.
There are more safeguards now: We refuse to write to the active or
boot_next image (if boot_next is not boot_default). We mark the uploaded
partition as not ok.
Needs latest bootloader with commit ID a5771ae033b57.
2017-08-27 15:00:04 +02:00
Harald Pichler 32afc08622 default programmer usb0 2017-08-24 13:56:24 +02:00
Harald Pichler d62fe15a26 bugfix upload to partition 0 2017-08-24 13:55:21 +02:00
Harald Pichler 3b56d718c6 bugfix make ota *.bin file 2017-08-23 13:19:42 +02:00
Harald Pichler 32bbd0cc71 add compile doku and fix compile warnings 2017-08-23 08:59:04 +02:00
Ralf Schlatterbeck 7ea0e3b933 Fix Makefiles, remove/fix flash targets
The target "flash" and related stuff is now in the platform makefiles.
2017-08-22 22:29:03 +02:00
Ralf Schlatterbeck 12ee7b7e39 Update README
Document resources and fix some outdated information.
2017-08-22 21:09:46 +02:00
Ralf Schlatterbeck cc48b88713 New method for determining active partition 2017-08-22 20:20:07 +02:00
Ralf Schlatterbeck 406fb7ea44 Add linker script
Also get rid of genbackupisr hack: We can achieve the same thing with
avr-objcopy which doesn't need additional software.
We use the new bootloader setting for irq-save area of 0x800.
2017-08-22 10:13:36 +02:00
Ralf Schlatterbeck edc7a59091 New make environment for new bootloader
Compatible with old bootloader. Adds an additional section with a copy
of the interrupt vector table to the end of the image. This is needed by
the new bootloader and should be ok for the old bootloader.

Note that for this to work, everybody needs python installed with
the IntelHex python package. On Linux this can be achieved with

pip install IntelHex
2017-08-20 20:57:17 +02:00
Ralf Schlatterbeck d890a492bb Set arduino LOOP_INTERVAL in project-conf.h 2017-08-20 19:42:42 +02:00
Ralf Schlatterbeck 3defa16553 Output min and max address on stderr 2017-08-20 19:41:34 +02:00
Ralf Schlatterbeck 6141e26999 Allow a second upload, reset state 2017-08-20 16:43:11 +02:00
Ralf Schlatterbeck dd9ba9e0ef Add missing resources.h 2017-08-20 15:09:22 +02:00
Ralf Schlatterbeck e3784fa9c7 Add query parameter to generic resouce macros
Modify all callback functions to use new signature.
ota-update now uses this to pass the partition to some get/put methods.
2017-08-20 15:01:30 +02:00
Ralf Schlatterbeck 954da749eb Factor irq methods
Now methods that need interrupts turned off are wrapped.
Make genbackupisr.py executable.
New resources for bootloader-related information.
2017-08-20 11:47:13 +02:00
Marcus Priesch 6eced34422 fixed size_t, irq 2017-08-20 00:12:57 +02:00
Marcus Priesch 140f43f4c1 work in progress 2017-08-19 22:11:13 +02:00
Ralf Schlatterbeck ed638a5f5a Add genbackupisr 2017-08-19 21:05:39 +02:00
Ralf Schlatterbeck b774d61713 First sketch of image uploader 2017-08-19 19:26:27 +02:00
Harald Pichler bfdae2a7a7 bugfix compile example settings-example 2017-08-16 16:13:34 +02:00
Marcus Priesch 0859e3442c added 2017-08-08 14:36:44 +02:00
Harald Pichler 5e20a17131 initial upload 2017-08-07 15:46:53 +02:00
Harald Pichler f576ef27ce update redme 2017-08-02 10:26:54 +02:00
Ralf Schlatterbeck c35be7c066 First stab at OTA-update
Introduce new testing-app example.
Add a new coap error code for blockwise transfer.
Add include-file for bootloader callbacks (jumptable).
Note that only the bootloader for osd-merkur-256 will support
OTA-update, the -128 simply has not enough flash memory, so only
in the -256 we have the bootloader functions in the jump-table
of the bootloader and in the bootloader-if.h include-file.
2017-07-31 13:26:29 +02:00
Marcus Priesch 1a57b55d8f added bootloader_write_page_to_flash symbol 2017-07-30 13:05:09 +02:00
Marcus Priesch 1384aad51a fixed leds 2017-07-30 13:04:56 +02:00
Ralf Schlatterbeck 181e2c436e Add description of new H-brigde breakout-board 2017-07-29 14:42:13 +02:00
Harald Pichler fd442fb9da set direction 2017-07-25 20:16:55 +02:00
George Oikonomou 719f712307 Merge pull request #2259 from arurke/cc26xxcc13xx_uart_optional_txrx_support
CC26xx/CC13xx: Support uni-directional UART
2017-07-23 14:06:50 +01:00
Harald Pichler 4b1580cc70 init arduino pwm driver 2017-07-21 13:31:44 +02:00
Harald Pichler a6670d99a8 set speed 2017-07-20 17:00:16 +02:00
Harald Pichler 38430ac259 set speed 2017-07-20 16:26:38 +02:00
Harald Pichler 60c6495fa3 initial upload 2017-07-20 15:16:01 +02:00
Harald Pichler 578dbaa431 add joystick, add BB-L Bridge 2017-07-20 15:14:45 +02:00
Harald Pichler 223ea26eb4 add led bar 2017-07-20 14:03:42 +02:00
Harald Pichler c39e10b2e7 initial upload 2017-07-20 10:33:19 +02:00
Andreas Urke 770bbfc6f6 Allow UART TX or RX to not be configured 2017-06-30 02:50:24 +02:00
Nicolas Tsiftes a08fc6a381 Merge pull request #2251 from arurke/RPL_debug_cleanup
Minor cleanup to RPL debug output
2017-06-22 16:41:55 +02:00
Andreas Urke a986ecf7c3 Remove minor duplicates in RPL printouts 2017-06-22 15:52:43 +02:00
Nicolas Tsiftes f0bddb277c Merge pull request #2203 from herjulf/AES128HW
Atmel radio AES128 crypto engine support.
2017-06-22 14:14:17 +02:00
Andreas Urke 5c0094cbd6 Minor cleanup to RPL debug output 2017-06-17 23:32:04 +02:00
Robert Olsson e97f3bca26 Fix misspelled copyright for AES128HW_test pointed out by Nicolas Tsiftes 2017-06-16 10:48:52 +02:00
Nicolas Tsiftes d53b6ad23e Merge pull request #2249 from nfi/coap-boundary-checks
Added boundary checks when parsing CoAP packets.
2017-06-15 14:56:58 +02:00
Niclas Finne 576ca6457f Added boundary checks when parsing CoAP packets.
Thanks to Stephan Zeisberg for reporting this issue.
2017-06-14 17:00:53 +02:00
George Oikonomou ea4e080bae Merge pull request #2245 from alexstanoev/mqtt-html-sanitize
Validate MQTT broker IP and escape quotes when displaying
2017-06-03 13:28:23 +01:00
alexstanoev 3a53d96526 Validate MQTT broker IP and escape quotes when displaying
This commit implements address validation for the broker address in the MQTT configuration page of the CC26XX web demo example. Additionally, the Type ID, Org ID, Auth Token, Command Type and Event Type ID fields have quotes escaped (" -> ") to prevent XSS/broken page issues when displaying user-sourced input in HTML input fields.
2017-06-03 00:04:01 +01:00
George Oikonomou 6e3387c830 Merge pull request #2244 from contiki-os/revert-2213-mqtt-html-sanitize
Revert "Validate MQTT broker IP and escape quotes when displaying"
2017-06-03 00:00:22 +01:00
George Oikonomou c558e1a559 Revert "Validate MQTT broker IP and escape quotes when displaying" 2017-06-02 23:02:54 +01:00
George Oikonomou 3800cb18a9 Merge pull request #2216 from herjulf/CCA
Atmel radio; Support for RADIO_PARAM_CCA_THRESHOLD plus rf_environment example
2017-06-02 22:40:27 +01:00
George Oikonomou 007f9c9798 Merge pull request #2213 from alexstanoev/mqtt-html-sanitize
Validate MQTT broker IP and escape quotes when displaying
2017-06-02 22:37:53 +01:00
alexstanoev 6b78ee9a4e MQTT: Validate broker IP and escape quotes when displaying
This commit implements address validation for the broker address in the
MQTT configuration page. Additionally, the Type ID, Org ID, Auth Token,
Command Type and Event Type ID fields have quotes escaped (" -> ")
to prevent XSS issues when displaying user-sourced input.
2017-06-02 15:13:58 +01:00
Robert Olsson bb5d5546ce Atmel radio bug fix when setting tx-power. Spotted by Voravit Tanyingyong 2017-06-02 08:42:43 +02:00
Robert Olsson bb90d50ba1 RADIO_PARAM_POWER_MODE for Atmel radio
modified:   cpu/avr/radio/rf230bb/rf230bb.c
	modified:   cpu/avr/radio/rf230bb/rf230bb.h
2017-06-01 17:30:30 +02:00
Simon Duquennoy ed47d47155 Merge pull request #2217 from g-oikonomou/doxy
Fix Doxygen PPA location
2017-06-01 14:22:08 +02:00
Robert Olsson b4ef18b2fa Keep cca scan function separated
modified:   examples/rf_environment/rf_environment.c
2017-05-23 21:07:59 +02:00
Robert Olsson 18cfaf7fa2 Reformat of table text for README
modified:   examples/rf_environment/README.md
2017-05-19 09:28:46 +02:00
Robert Olsson ef9b00103e Optimizing channel table size for CCA in rf_environment example
modified:   examples/rf_environment/rf_environment.c
2017-05-11 14:20:12 +02:00
Robert Olsson 71167f0ba6 Retrigger PR after Doxigen fix 2017-05-09 15:26:14 +02:00
George Oikonomou 9ed56b1485 Fix Doxygen PPA location 2017-05-09 09:11:20 +01:00
Robert Olsson 4040005056 Retrigger regression test
modified:   examples/rf_environment/README.md
2017-05-08 14:25:59 +02:00
Robert Olsson 91928592d0 Updated README for rf_environment example 2017-05-08 13:11:22 +02:00
Robert Olsson 22975df423 examples/rf_environment for rf CCA (non-intrusive) monitoring added 2017-05-05 12:57:18 +02:00
Robert Olsson c2560498b6 Atmel radio; Support for RADIO_PARAM_CCA_THRESHOLD added 2017-05-05 12:55:03 +02:00
Harald Pichler 5e15ec6488 bugfix store value to d_temp_s and enable debug prints as degfault 2017-05-04 16:29:55 +02:00
George Oikonomou 3c150a5e99 Merge pull request #2150 from posjodin/PR2
Several changes to fix and harden mqtt code.
2017-04-24 16:04:56 +01:00
George Oikonomou 3cc5505b69 Merge pull request #1787 from g-oikonomou/contrib/cc26xx/improve-cca-monitoring
Use `ccaInfo.ccaState` to decide whether CCA is complete
2017-04-24 16:02:47 +01:00
George Oikonomou 7b193ee014 Merge pull request #1932 from g-oikonomou/contrib/cc1350/lp-and-st
Add support for the CC1350 LP and Sensortag
2017-04-24 15:34:22 +01:00
George Oikonomou 6a36a398bd Merge pull request #1931 from g-oikonomou/contrib/cc26xx-cc13xx/update-rf-api
Use TI-Provided CC13xx/CC26xx RF API
2017-04-24 15:33:14 +01:00
Robert Olsson e9aed001bc Example project for Atmel radio AES128 cryto engine 2017-04-24 14:40:33 +02:00
Robert Olsson 58517dfcbd AES128 HW crypto engine support for Atmel radios
modified:   cpu/avr/radio/rf230bb/atmega128rfa1_registermap.h
modified:   cpu/avr/radio/rf230bb/atmega256rfr2_registermap.h
modified:   cpu/avr/radio/rf230bb/rf230bb.c
modified:   cpu/avr/radio/rf230bb/rf230bb.h
2017-04-24 14:34:01 +02:00
Nicolas Tsiftes ddf723f88d Merge pull request #2180 from atiselsts/bugfix/coap-observe-option
Keep CoAP 'observe' option length <= 3 bytes
2017-04-21 17:59:40 +02:00
Nicolas Tsiftes 66fe7abf79 Merge pull request #2188 from tonnenpinguin/pr/uninitialized_variables
Fix several uninitialized variables
2017-04-21 17:59:12 +02:00
Bernhard Hackl 848f801460 Fix several uninitialized variables 2017-04-19 01:55:27 -07:00
Nicolas Tsiftes 38b82aeeeb Merge pull request #2189 from tonnenpinguin/pr/unterminated_strings
Fix potentially unterminated strings
2017-04-18 16:39:34 +02:00
Nicolas Tsiftes 52c709bdb7 Merge pull request #2101 from yatch/pr/bugfix-rpl-icmp6
RPL: fix a bug accessing an uninitialized pointer
2017-04-18 16:09:06 +02:00
Nicolas Tsiftes 391a84726f Merge pull request #2148 from niziak/master
native-border-router: fix for disappearing timer 'uip_ds6_timer_perio…
2017-04-18 15:19:57 +02:00
Bernhard Hackl ae91d6b4b1 Fix potentially unterminated strings 2017-04-14 08:33:40 -07:00
Peter Sjödin a08adccfd5 Untabify mqtt.c 2017-04-11 17:19:43 +02:00
Peter 1fa9dde049 Merge remote-tracking branch 'contiki/master' into PR2 2017-04-11 17:00:38 +02:00
Oliver Schmidt 078359127b Merge pull request #2182 from oliverschmidt/master
Adjusted cc65 compiler options to recent cc65 option handling change.
2017-04-10 11:46:08 +02:00
Oliver Schmidt fa618ad86c Adjusted cc65 compiler options to recent cc65 option handling change. 2017-04-10 11:09:28 +02:00
Atis Elsts f83f035855 Keep CoAP 'observe' option length <= 3 bytes 2017-04-08 15:02:52 +01:00
George Oikonomou d0ddb7221e Merge pull request #2176 from atiselsts/bugfix/hdc_sensor
Fix HDC sensor reading conversion
2017-04-08 00:11:05 +01:00
Nicolas Tsiftes 0b85b76778 Merge pull request #2173 from simonduq/pr/tsch-readme
Updating TSCH readme file
2017-04-06 16:06:29 +02:00
Atis Elsts f6a2c4ea3f Fix HDC sensor reading conversion 2017-04-05 12:23:26 +01:00
Simon Duquennoy a330f59b8e TSCH readme: update with 802.15.4-2015 and 6TiSCH 2017-04-04 14:15:48 +02:00
Simon Duquennoy 51205eb809 TSCH readme: link to reference paper on implem and eval 2017-04-04 14:12:35 +02:00
George Oikonomou fbffcc2dfc Merge pull request #2109 from chenek/cc26xx-web-demo-adc-demo
add ADC example to cc26xx-web-demo
2017-04-03 12:21:03 +01:00
Yasuyuki Tanaka faeb71de00 RPL: fix a bug accessing an uninitialized pointer
This bug is uncovered when RPL_WITH_MULTICAST is enabled.
2017-04-03 17:54:25 +09:00
Yasuyuki Tanaka 3559402781 RPL: add regression test for multicast
This test aims to reproduce the issue #2031:

  https://github.com/contiki-os/contiki/issues/2031

Test nodes are built from the code under example/ipv6/multicast with
WITH_SMRF=1 and WITH_DAO_ACK=1.

If the simulation runs through for one hour, the test is regarded as
success. Otherwise, when it crashes, the test fails.
2017-04-03 17:54:18 +09:00
Yasuyuki Tanaka b7b23b712f RPL: fix indentation (rpl-icmp6.c) 2017-04-03 17:52:58 +09:00
George Oikonomou e9ee15efde Merge pull request #2166 from posjodin/TSCH-N1
Updates for Atmel radio part II
2017-04-02 21:31:59 +01:00
George Oikonomou e823ead4b0 Tidy up web demo ADC code style 2017-04-02 13:44:02 +01:00
George Oikonomou 474dc33e12 Wrap web demo ADC functionality inside #if blocks 2017-04-02 13:43:21 +01:00
chenek 22b262ce73 Add ADC example to cc26xx-web-demo 2017-04-02 13:43:12 +01:00
George Oikonomou 55f3a92211 Merge pull request #2168 from tarakanov/sensortag-spi
Correct SPI pins
2017-04-02 13:26:30 +01:00
Robert Olsson aed5457332 Correct names for Atmel previous radio fixes plus static declarations. 2017-04-02 11:32:52 +02:00
tarakanov f564e6bb5f Correct SPI pins 2017-04-02 13:14:09 +05:00
George Oikonomou e4da7c66e0 Merge pull request #2165 from alexandruioanp/check-ipv6addrconv-mqtt
Check broker IP conversion. Adjust state machine accordingly
2017-04-02 00:33:43 +01:00
George Oikonomou 6eac73103d Merge pull request #2164 from alexstanoev/web-demo-crash-fix
Zero out httpd_state before deallocating
2017-04-02 00:32:53 +01:00
George Oikonomou 12f17211e6 Merge pull request #2167 from posjodin/sensniff-new
Adding sensniff support for Atmel via avr-rss2 platform
2017-04-02 00:29:09 +01:00
Robert Olsson 417f32c65d Adding sensniff support for Atmel via avr-rss2 platform 2017-03-31 20:00:20 +02:00
Robert Olsson 093550ecbf Update for Atmel radio part II
modified:   cpu/avr/radio/rf230bb/halbb.c
	modified:   cpu/avr/radio/rf230bb/rf230bb.c
2017-03-31 18:38:27 +02:00
Alexandru-Ioan Pop f15b86158b Check broker IP conversion. Adjust state machine accordingly
The result of converting the IP address of the broker wasn't checked. As a result, the pointer was left uninitialised and the IPv6 address used for connecting was some random data. The function now returns an error. Before connect_to_broker is called, mqtt_register is executed, which memsets conn to 0, making its state 0 (MQTT_CONN_STATE_ERROR). In order to recover from this error state, the extra check was added in the MQTT_CLIENT_STATE_NEWCONFIG state.

This was discovered using [CodeSonar](https://www.grammatech.com/products/codesonar)
2017-03-31 17:33:29 +01:00
alexstanoev a30364189a Zero out httpd_state before deallocating
When a connection is aborted by the HTTP server while it's still being processed it is possible to hit a null pointer dereference issue by jumping back to a protothread (outputpt) after its httpd_state has been freed. This can be triggered by sending a POST to any form in the CC26xx web demo server using Firefox.
This patch prevents that by zeroing out httpd_state structs before freeing them, thus also clearing the httpd_state->outputpt field.
Tested using Firefox 55.0a1 on a CC2650 LaunchPad.
2017-03-31 16:44:11 +01:00
George Oikonomou 4425a67433 Merge pull request #2162 from posjodin/PR4
Updates for  Atmel radio
2017-03-31 12:24:55 +01:00
Nicolas Tsiftes 69c2e7e2b6 Merge pull request #2159 from posjodin/PR3
avr-rss2 platform fixes
2017-03-30 16:30:46 +02:00
Robert Olsson 399150b142 Minor spell fix in ANNOUNCE_BOOT
modified:   platform/avr-rss2/contiki-main.c
2017-03-30 15:24:19 +02:00
Nicolas Tsiftes 9d003fe52f Merge pull request #2155 from iot-lab/pr/er-coap/stylecleanup
er-coap: Fix style and add missing `addr` argument
2017-03-30 14:14:03 +02:00
Robert Olsson d6128852b2 Added missing register definitions in at86rf230_registermap.h
modified:   cpu/avr/radio/rf230bb/at86rf230_registermap.h
2017-03-29 11:32:39 +02:00
Robert Olsson 55daec98dc Added missing registers in
modified:   cpu/avr/radio/rf230bb/atmega128rfa1_registermap.h
2017-03-28 22:16:50 +02:00
Robert Olsson 94defe6ba2 Updates for Atmel RF233 radio in AtMega256rfr2 including register
update for MAC symbol counter. Basic functions for get/set-value
parameter setting added. SPI radios needs to be tested.

	modified:   cpu/avr/radio/rf230bb/atmega256rfr2_registermap.h
	modified:   cpu/avr/radio/rf230bb/rf230bb.c
2017-03-28 18:53:56 +02:00
Ralf Schlatterbeck dca85a7b6b Add valve example
Used for gardena valves with 9V power supply.
2017-03-24 20:10:37 +01:00
Robert Olsson 3829dd2f20 Leds toggle added
modified:   platform/avr-rss2/dev/leds.c
2017-03-24 17:37:37 +01:00
Robert Olsson e77dba152d Removing avr-rss2 private sniffer app. Better use examples/sensniff. 2017-03-24 17:29:50 +01:00
Robert Olsson bf8e77ea4e Added missing prototype
modified:   cpu/avr/radio/rf230bb/rf230bb.h
2017-03-24 17:07:35 +01:00
Robert Olsson c0239b41c9 Cleand-up _CONF for ROUTES, NEIGHBOR and BUFFER_SIZE
modified:   platform/avr-rss2/contiki-conf.h
2017-03-24 16:57:53 +01:00
Robert Olsson e09bdc0c07 Increasing route table from 4 to 20
modified:   platform/avr-rss2/examples/ipv6/mqtt-demo/project-conf.h
2017-03-24 16:57:27 +01:00
Robert Olsson 29914b5a1f Fixing input serial line initialization pointed by Peter Sjödin/KTH
For avr-rss2 platform
2017-03-24 16:57:03 +01:00
Peter Sjödin fa6c52633f Use RS232_BAUDRATE to define baudrate from projekt config file.
Removed serial initialization from contiki-main.c. It seems to be
too soon.
2017-03-24 16:56:42 +01:00
Robert Olsson 9e5aed5df6 Support for changing PANID and channel from project-conf.h
modified:   cpu/avr/radio/rf230bb/rf230bb.c
	modified:   platform/avr-rss2/contiki-conf.h
	modified:   platform/avr-rss2/contiki-main.c
2017-03-24 16:56:22 +01:00
Harald Pichler c56142ccec add save energie 2017-03-24 16:11:28 +01:00
Harald Pichler afde635051 initial upload 2017-03-24 11:08:45 +01:00
Gaëtan Harter c7de205029 er-coap/dtls: allow overwriting the default tinydtls specific functions 2017-03-23 17:23:22 +01:00
Gaëtan Harter 1addd8da3a apps/tinydtls: disable doxygen generation 2017-03-23 16:33:25 +01:00
Gaëtan Harter e24f500e57 er-rest-dtls: add rest dtls examples 2017-03-23 16:33:25 +01:00
Gaëtan Harter fcc4f6d39f er-coap-dtls: use tinydtls app if "WITH_DTLS_COAP" is set 2017-03-23 16:33:25 +01:00
Gaëtan Harter 59dc4413bb er-coap-dtls: rename wrongly name IDENTITY_"HINT"
It's not IDENTITY_HINT but only IDENTITY here.
IDENTITY_HINT is not handled in any ways.
2017-03-23 16:33:25 +01:00
Gaëtan Harter 612cb23759 er-coap: COPIED FROM CETIC 6LBR add cetic tinydtls 'er-coap' communication layer
I would rather have a different way of configuring the communication layer.
A way which would not require modifiying the er-coap application.

Maybe more like a "disable udp" communication layer thing.
And overwrite with something else.
2017-03-23 16:32:44 +01:00
Gaëtan Harter d94efe528a tinydtls: add tinydtls as an app submodule
Currently, I'm providing my version for the submodule, but patches have been
proposed upstream to make tinydtls work out of the box.
2017-03-23 16:30:27 +01:00
Gaëtan Harter 5640293e8f er-coap: separate the communication layer
This code was copied and adapted from: https://github.com/cetic/6lbr
Licensed under the same license as Contiki.
2017-03-23 15:33:50 +01:00
Gaëtan Harter f70adde9a9 er-coap-observe-client: missing 'addr' parameter 2017-03-23 15:12:42 +01:00
Gaëtan Harter c932ff45a3 er-coap: run uncrustify-fix-style.sh
Clean style before modifying.
2017-03-23 15:12:39 +01:00
Nicolas Tsiftes 7342a3f8a7 Merge pull request #2103 from stringr9/bugfix/non-storing-drop-fix
Don't drop packets bound for outside the RPL mesh in non-storing mode
2017-03-23 14:27:06 +01:00
Nicolas Tsiftes 90ea58e206 Merge pull request #2145 from g-oikonomou/bugfix/multicast-config
Don't force RPL MOP configuration in contiki-default-conf.h
2017-03-23 13:43:08 +01:00
Robert Olsson 34fa389054 Whitespace change to force new travis-check.
modified:   apps/mqtt/mqtt.h
2017-03-22 13:15:58 +01:00
Peter 432f12e156 Several changes to fix bugs and harden mqtt code.
1. The PT_MQTT_WAIT_SEND() macro has several issues:

- It does not check the return value from process_post(), which
  sometimes returns an error code. See next issue.

- Each time the macro is called, is posts an event to itself. The idea
seems to be that the event should be absorbed by the macro itself, so
when the macro terminates there is NOT a net growth of the event
queue. This does not work.  The reason is that the
PROCESS_WAIT_EVENT() sometimes absorbs a broadcast event instead of
its own event, and then the number of events in the event queue
increases. This leads to event explosions and overflow in the event
queue.

- The macro cannot call PT_EXIT(). This will expand to a return
statement, causing a return from the function calling the macro
(mqtt_process), rather then exiting the protothread (which was
probably the intention). Protothreads have lexical scope...

Fixes: 1) Check return value from process_post() 2) Loop until the
event posted to itself is absorbed (rather than just absorbing the
next event) 3) Replace PT_EXIT() with PT_INIT() (doesn't really make a
difference, could probably just be removed).

2. Change order of the checks in the protothread-calling loops in
mqtt_process().  Reason: When a protothread has been cleared by
PT_MQTT_WAIT_SEND(), it will not return a value, so checking against
PT_EXITED does not make sense.

3. PT_MQTT_WRITE_BYTES() should initialize conn->out_write_pos to 0.
When PT_MQTT_WRITE_BYTES() does not finish (due to TCP disconnect for
instance), it may leave conn->out_write_pos with a non-zero
value. Next time PT_MQTT_WRITE_BYTES() is called, it will take data
from the wrong place.

4. Put MQTT_CONN_STATE_ABORT_IMMEDIATE before
MQTT_CONN_STATE_NOT_CONNECTED in the enum list, so that the check
if(conn->state > MQTT_CONN_STATE_NOT_CONNECTED) in mqtt_connect()
fails when in state MQTT_CONN_STATE_ABORT_IMMEDIATE. Otherwise, it
will deadlock and not reattempt connections while in this state.
2017-03-21 16:43:15 +01:00
Wojciech Nizinski 5a0d085451 native-border-router: fix for disappearing timer 'uip_ds6_timer_periodic'
When UIP_ND6_SEND_NS is enabled, I've noticed that unreachable
neighbours still remains in REACHABLE state even if lifetime
(nbr->reachable) expired.

During network init 'tcpip_process' is scheduling
'uip_ds6_timer_periodic' is to tick every 100ms and make necessary
expirations.

When MAC addres is received from slip-radio (from 'etimer_process'
context), network is "reinitialized" and timer 'uip_ds6_timer_periodic'
is set again with wrong process.
2017-03-21 13:13:10 +01:00
Harald Pichler 0e861e76a3 Merge branch 'master' of https://github.com/osdomotics/osd-contiki 2017-03-18 20:43:10 +01:00
Harald Pichler 918b20f3cf set loop to 30 2017-03-18 20:42:47 +01:00
George Oikonomou 99402348eb Merge pull request #2147 from g-oikonomou/bugfix/1972
Add missing variable declaration
2017-03-18 17:23:41 +00:00
Oliver Schmidt 356814fe9c Merge pull request #2146 from oliverschmidt/slip
Add SLIP support to retro platforms.
2017-03-18 15:56:06 +01:00
George Oikonomou 739b901e0d Add missing variable declaration
#1972 removed the declaration of `i` from various locations. In one of those locations it is still needed. This commit puts it back
2017-03-18 14:01:10 +00:00
George Oikonomou 758d9aa168 Merge pull request #1972 from MohamedSeliem/patch-11
update httpd_cgi to enable the compilation of webserver-ipv6 example
2017-03-18 13:50:52 +00:00
Oliver Schmidt 7f3fcbd8e7 Made it somewhat more obvious that this is SLIP-only. 2017-03-18 14:19:36 +01:00
George Oikonomou dc782732e0 Merge pull request #2132 from JoaoS/energest_avr_rss2
add CPU energest measurements that were lacking in this platform
2017-03-18 13:17:51 +00:00
Oliver Schmidt a0134ff35e Beautified SLIP macros. 2017-03-18 14:06:11 +01:00
Oliver Schmidt 79855ff02d Beautified SLIP macros. 2017-03-18 14:05:36 +01:00
George Oikonomou 6d51c1a9f9 Merge pull request #2138 from atiselsts/bugfix/cc26xx/limited_busywait
CC26xx IEEE mode driver fixes and robustness improvements
2017-03-17 23:09:11 +00:00
George Oikonomou 905356da13 Merge pull request #2093 from thomas-blank/fix-mqtt-connection-refused
Fix Bug in MQTT App: Refused Connections should not be pursued.
2017-03-17 23:08:45 +00:00
George Oikonomou 21d6abe30b Merge pull request #2139 from atiselsts/sensortag-i2c/limited_busywait
CC26xx SensorTag I2C: add and use LIMITED_BUSYWAIT macro
2017-03-17 23:04:19 +00:00
George Oikonomou b91448dfa4 Merge pull request #1348 from g-oikonomou/bugfix/cc26xx/wait-for-rssi-valid
Wait for a valid RSSI reading in CC13xx/CC26xx RF drivers
2017-03-17 22:52:51 +00:00
George Oikonomou 7e6d5c2971 Don't force RPL MOP configuration in contiki-default-conf.h
rpl-private.h handles the default MOP correctly, whereas the block in `contiki-default-conf.h` is not only redundant but also fails to handle situations where RPL multicast is required.
2017-03-17 22:33:17 +00:00
George Oikonomou fbb682ae15 Merge pull request #2144 from MohamedSeliem/patch-12
fix a macro related to multicast, which are not user configuration
2017-03-17 22:19:49 +00:00
Ralf Schlatterbeck 3545f1fab5 Update README and LICENSE
Add comments about new Github Terms of Service (new since 2017-03-01)
and clarify the purpose of this project, point to LICENSE file in
README.md
2017-03-17 19:32:51 +01:00
Mohamed Seliem 08b12f2346 fix a macro related to multicast, which are not user configuration
fix a macro related to multicast, which are not user configuration
- RPL_CONF_MULTICAST      -> RPL_WITH_MULTICAST
2017-03-17 20:21:56 +02:00
Atis Elsts a0a2881ab0 CC26xx SensorTag I2C: add and use LIMITED_BUSYWAIT macro 2017-03-14 18:52:10 +00:00
Atis Elsts c850bae186 CC26xx IEEE mode: introduce and use LIMITED_BUSYWAIT macro; avoids watchdog reboots in cases when the radio fails to turn off 2017-03-14 18:42:09 +00:00
Atis Elsts 3b090d97c7 CC26xx IEEE mode: more robust radio timer handling: do not crash the system in case the radio timer failed to start; allow the overflow checker to be called when the radio is off 2017-03-14 18:41:05 +00:00
Atis Elsts dbd9d32daf CC26xx RF core: don't bail out from restarting the radio timer if just stopping it failed 2017-03-14 18:36:23 +00:00
root cc4aa440a0 moved energest init to after the rtimer init 2017-03-13 13:54:40 +00:00
Nicolas Tsiftes b756841522 Merge pull request #2102 from yatch/pr/rpl-leaf-only-debug-msg
RPL: move a debug message for RPL_LEAF_ONLY to a correct place
2017-03-10 15:11:31 +01:00
Thomas Blank ed1b27e40b Fix Bug in MQTT App: Refused Connections should not be pursued.
No means no.
2017-03-09 19:35:20 +01:00
Simon Duquennoy a24ac862de Merge pull request #2046 from yatch/pr/ringbufindex-bugfix
Bugfix in ringbufindex
2017-03-09 13:06:33 +01:00
Simon Duquennoy c5c1979d37 Merge pull request #2012 from cetic/jn516-hw-mac
JN516x: Add support for hardware MAC
2017-03-09 08:53:47 +01:00
Yasuyuki Tanaka 9acf177036 Enable TSCH regression testing 2017-03-09 16:47:54 +09:00
Yasuyuki Tanaka 2d42b91c7b ringbufindex: fix bugs of ringbufindex_peek_{put,get} 2017-03-09 16:47:24 +09:00
Yasuyuki Tanaka fbf9bb9e64 ringbufindex: explain return values by the APIs 2017-03-09 16:47:24 +09:00
Yasuyuki Tanaka baaa3da23e ringbufindex: fix a typo in a comment 2017-03-09 16:47:24 +09:00
Yasuyuki Tanaka 8df0f7dd01 Add a regression test for ringbufindex APIs 2017-03-09 16:47:24 +09:00
George Oikonomou b70677cce6 Merge pull request #2131 from t-than/master
Adjust CC26xx/CC13xx ADC reading for gain and offset
2017-03-08 22:18:57 +00:00
root 42cbe85a49 add CPU energest measurements that were lacking in this platform 2017-03-08 16:13:27 +00:00
Thanos Tsakiris dbcac67aab Normalize code style with uncrustify 2017-03-08 17:09:53 +02:00
andrewbrannan 0a85ccdc56 prevent the rpl root from dropping packets bound for outside the dodag while in NS mode 2017-03-08 14:34:25 +00:00
Laurent Deru da45afdf27 Add basic contikimac parameters for jn516x 2017-03-08 15:25:55 +01:00
Laurent Deru 79b06879fe Add to jn516x micromac driver full MAC layer support 2017-03-08 15:25:55 +01:00
Laurent Deru 9b6ba3c009 Make frame fcf creation and parsing standalone functions 2017-03-08 15:25:55 +01:00
Simon Duquennoy 0ceb45ee78 Merge pull request #2129 from simonduq/pr/update-jn516x-sdk
jn516x: update SDK
2017-03-08 15:20:31 +01:00
Thanos Tsakiris d80f362a2b Adjust CC26xx/CC13xx ADC reading for gain and offset 2017-03-08 15:55:28 +02:00
Simon Duquennoy 04bce213e6 jn516x: remove redundant declaration 2017-03-08 12:13:37 +01:00
Simon Duquennoy ae554aa256 jn516x: update SDK 2017-03-08 11:24:35 +01:00
Simon Duquennoy c37e7cfb0e Merge pull request #2108 from yatch/pr/poc-tsch-queue-flush-nbr-queue
TSCH: POC of a bug in tsch_queue_flush_nbr_queue()
2017-03-08 10:18:41 +01:00
Harald Pichler 2942868799 bugfix format 2017-03-03 11:45:46 +01:00
Harald Pichler 362eadd821 bugfix format 2017-03-03 11:40:13 +01:00
Harald Pichler 14baf5df6c bugfix format 2017-03-03 11:37:09 +01:00
Harald Pichler c954d22d81 bugfix format 2017-03-03 11:29:32 +01:00
Harald Pichler f36183f2b5 Merge branch 'master' of https://github.com/osdomotics/osd-contiki 2017-03-03 11:26:28 +01:00
Harald Pichler 314c46b91a bugfix format 2017-03-03 11:24:32 +01:00
Harald Pichler 6af70ee511 bugfix warning -Wwrite-strings 2017-03-03 11:21:43 +01:00
Harald Pichler 7000323c74 bugfix format 2017-03-03 11:17:33 +01:00
Oliver Schmidt a38cfc889e Merge pull request #2118 from oliverschmidt/master
Made rest of Microsoft-specific chat optional.
2017-02-24 20:53:55 +01:00
Harald Pichler ae6375d900 add humidity resource, bugfix pressure string variable 2017-02-24 10:28:35 +01:00
Harald Pichler 2137a12971 Merge branch 'master' of https://github.com/osdomotics/osd-contiki 2017-02-24 10:07:20 +01:00
Harald Pichler 4151c09e2c cleanup code 2017-02-23 22:36:32 +01:00
Harald Pichler 6677fac2ab bugfix use bmp280 and not bme280 2017-02-23 22:22:40 +01:00
Oliver Schmidt be9711d92e Made rest of Microsoft-specific chat optional.
Made code rest of the code in the SLIP driver optional that takes care of the Microsoft-specific CLIENT / SERVER / CLIENTSERVER chat.
2017-02-23 21:43:51 +01:00
Harald Pichler 8e07bab71f initial upload 2017-02-23 16:48:37 +01:00
Harald Pichler 85f3814f67 add i2c address 2017-02-23 08:59:49 +01:00
Harald Pichler 42dee52e65 initial upload 2017-02-23 08:49:02 +01:00
Harald Pichler 352f078be7 initial upload 2017-02-22 14:53:05 +01:00
Antonio Lignan f5f13c968c Merge pull request #2061 from cetic/pr-nat64-small-updates
Various updates for NAT64
2017-02-21 21:52:18 +01:00
Harald Pichler 5ea65cab08 temperature convert time is to short set from 50ms to 60ms 2017-02-21 20:06:15 +01:00
George Oikonomou 809ca640a1 Merge pull request #2090 from atiselsts/bugfix/cc26xx_lqi
CC26xx IEEE mode radio: fix LQI reading
2017-02-18 22:25:01 +00:00
Oliver Schmidt 91beb8670f Added SLIP support to retro platforms.
The cc65 tool chain comes with V.24 drivers so it seems reasonable to use the existing Contiki SLIP driver to implement network access via SLIP as alternative to Ethernet.

Some notes:
- The Ethernet configuration was simplified in order to allow share it with SLIP.
- The Contiki SLIP driver presumes an interrupt driven serial receiver to write into the SLIP buffer. However the cc65 V.24 drivers aren't up to that. Therefore the main loops were extended to pull received data from the V.24 buffers and push it into the SLIP buffer.
- As far as I understand the serial sender is supposed to block until the data is sent. Therefore a loop calls the non-blocking V.24 driver until the data is sent.

On all platforms there's only one V.24 driver available. Therefore V.24 drivers are always loaded statically.

On the Apple][ the mouse driver is now loaded statically - independently from SLIP vs. Ethernet. After all there's only one mouse driver available. However there's a major benefit with SLIP: Here all drivers are loaded statically. Therefore the dynamic module loader isn't necessary at all. And without the loader the heap manager isn't necessary at all. This allows for a reduction in code size roughly compensating for the size of the SLIP buffer.
2017-02-15 23:43:28 +01:00
Oliver Schmidt a26ee64dc0 Merge pull request #2097 from oliverschmidt/master
Removed artifacts of former uip_appdata handling.
2017-02-13 20:05:57 +01:00
Yasuyuki Tanaka 8b77c5ef4c TSCH: add a regression test for tsch_queue_flush_nbr_queue() 2017-02-10 17:37:33 +01:00
Yasuyuki Tanaka effdc6e212 TSCH: add debug messages to track queued packet addresses 2017-02-10 16:56:14 +01:00
Yasuyuki Tanaka 25ac43dae9 RPL: move a debug message for RPL_LEAF_ONLY to a correct place 2017-02-08 00:02:26 +01:00
Oliver Schmidt 6463c91a4f Removed artifacts of former uip_appdata handling.
Adam Dunkels writes on 2/5/2017 on the Contiki mailing list:
[...] the original idea was that the application could just point the uip_appdata pointer to wherever the data was, but we then changed it so that the data actually had to be copied into the uip_aligned_buf buffer. So, yes, the network device driver should only need to read from this buffer. [...]

This change removes comments on the possibility of uip_appdata pointing somewhere outside the uip_aligned_buf. And it removes code in the SLIP drivers not necessary anymore.

Additionally it makes code in a SLIP driver optional that takes care of the Microsoft-specific CLIENT / SERVER / CLIENTSERVER chat.
2017-02-05 23:20:39 +01:00
Simon Duquennoy 263af6f642 Merge pull request #2023 from OpenMote/master
Adding support for OpenMote-CC2538 Rev.A1 and OpenUSB
2017-02-02 08:47:07 +01:00
Harald Pichler 201a8174c6 print buffer text and hex format 2017-02-01 16:17:48 +01:00
Harald Pichler 6a9b6ae77b initial upload 2017-02-01 11:26:50 +01:00
Harald Pichler 9fb2352b08 bugfix buffer overflow 2017-02-01 10:28:02 +01:00
Harald Pichler 2f8549aaae Merge branch 'contiki'
Conflicts:
	cpu/cc26xx-cc13xx/lib/cc13xxware
	cpu/cc26xx-cc13xx/lib/cc26xxware
2017-01-31 15:00:59 +01:00
Oliver Schmidt 8248f524f5 Merge pull request #2091 from oliverschmidt/master
Revert to static Ethernet driver for the ATARI.
2017-01-27 11:34:44 +01:00
Oliver Schmidt a6472c8dd9 Revert to static Ethernet driver for the ATARI.
After all there's no momentum for a W5100-based Ethernet solution on the ATARI. So I revert to static linkage of the CS8900A driver as this improves program load times.
2017-01-27 00:18:25 +01:00
Atis Elsts cd1bcb101d CC26xx IEEE mode radio: fix reading lqi 2017-01-26 13:31:15 +00:00
George Oikonomou 7b7781360f Merge pull request #2071 from g-oikonomou/bugfix/cc13xx/no-acks
Make the number of Prop Mode RX Buffers easy to configure
2017-01-21 00:17:49 +00:00
Nicolas Tsiftes 5eb2ac15ff Merge pull request #2073 from cetic/pr-fix-send-na
Fix semantic of UIP_ND6_SEND_NA and add UIP_ND6_SEND_NS
2017-01-20 13:18:43 +01:00
Nicolas Tsiftes 0cfda4c026 Merge pull request #2053 from cetic/pr-fix-dag-lifetime
Use RPL_DAG_LIFETIME when computing dag lifetime
2017-01-20 11:08:43 +01:00
Simon Duquennoy d59bbcf86c Merge pull request #2080 from yatch/pr/tsch-reenable-regression-test
TSCH: re-enable TSCH regression tests
2017-01-19 16:53:21 +01:00
Yasuyuki Tanaka 2d44b47050 Print an entry for the root node as well as other entries 2017-01-19 14:36:59 +01:00
Yasuyuki Tanaka 651147df57 TSCH: Fix incorrect test criteria for regression-tests
The tests are recognized as success when a return value by
rpl_ns_num_nodes(), the number of entries in the nodelist, tells all the
routes for the nodes in the network are installed.

There are eight nodes in addition to one root node. Therefore, the value
for test success should not be eight but nine since we have to take into
account an nodelist entry for the root.
2017-01-19 14:35:37 +01:00
Yasuyuki Tanaka ac937eda24 TSCH: re-enable TSCH regression tests with Cooja mote 2017-01-19 14:25:06 +01:00
Yasuyuki Tanaka 83f2382791 Orchestra: avoid a link error for nbr_routes 2017-01-19 13:55:08 +01:00
Nicolas Tsiftes 2e754c7832 Merge pull request #2063 from cetic/pr-ndp-config
Make all NDP configuration parameters user configurable
2017-01-17 08:22:52 +01:00
Nicolas Tsiftes f80f673e21 Merge pull request #2062 from cetic/pr-add-defrt_list_head
Adding uip_ds6_defrt_list_head()
2017-01-17 08:21:50 +01:00
Laurent Deru 0fb597f2fa Use RPL_DAG_LIFETIME when computing dag lifetime 2017-01-16 16:56:22 +01:00
Laurent Deru 12c930893c Fix semantic of UIP_ND6_SEND_NA and add UIP_ND6_SEND_NS 2017-01-16 15:48:14 +01:00
Laurent Deru e5a604552e Allow modification of IP64 prefix 2017-01-16 14:38:35 +01:00
Laurent Deru 10be59cc15 Update nameserver using DHCP info 2017-01-16 14:38:35 +01:00
Laurent Deru 37fe6a2fa6 Use uip-debug in ip64-ipv4-dhcp.c 2017-01-16 14:37:52 +01:00
Laurent Deru 63ac4d2a3d Adding uip_ds6_defrt_head() 2017-01-16 13:54:36 +01:00
Laurent Deru 88d0003b75 Make all NDP configuration parameters user configurable 2017-01-16 13:50:56 +01:00
Antonio Lignan a7b5050382 Merge pull request #2047 from contiki-os/orion-update-motelist-string
Orion: update motelist string
2017-01-15 16:06:23 +01:00
George Oikonomou 5fb226f4c9 Make the count of prop mode RX buffers configurable 2017-01-15 12:31:09 +00:00
George Oikonomou 07de8b238b Easy manipulation of CC13xx Prop Mode RX buffers 2017-01-15 12:25:10 +00:00
George Oikonomou ba12ed2cce Re-initialise RX buffers each time we turn the RF on 2017-01-15 12:24:30 +00:00
George Oikonomou 82fd325b7a Merge pull request #2069 from alignan/pull/light-example-verbatim
Explicitly specify light sensor model in example
2017-01-15 11:52:09 +00:00
Antonio Lignan 999b246fd2 Explicitly specify light sensor model in example 2017-01-14 22:57:08 +01:00
Antonio Lignan 3d40056f4f Merge pull request #2054 from cetic/pr-check-incoming-rank
Reject parents with invalid rank
2017-01-13 16:08:00 +01:00
Antonio Lignan 0fb4a68332 Merge pull request #2052 from cetic/pr-rpl-route-infinite-lifetime
Make RPL route lifetime RFC compliant
2017-01-13 16:07:09 +01:00
Laurent Deru 0da6e128eb Remove servername from DHCP request 2017-01-13 13:35:25 +01:00
Laurent Deru f9ffa252f6 Reject parents with invalid rank 2017-01-13 12:32:33 +01:00
Laurent Deru d866e6bd34 Make RPL route lifetime RFC compliant 2017-01-13 10:54:06 +01:00
Antonio Lignan 10d54f228b Orion: update motelist string
Updates the expected motelist string
2017-01-12 11:23:20 +01:00
Nicolas Tsiftes c1f11cfaa9 Merge pull request #2034 from Vinggui/patch-1
Fixing Avr-Zigbit Makefile not compiling.
2017-01-12 07:49:30 +01:00
Vinicius Guimaraes 5e05a951f2 Fixing Avr-Zigbit Makefile not compiling
Fixed two errors in Zigbit's makefile:
-Compiling "frame.c" here is not necessary (already done in radio's makefile) and brings up an error. Removing it.
-Fixed undefined reference to "link_stats_input_callback" in "../../core/net/ipv6/sicslowpan.c:1521". Module "core/net" was missing.
Compiling working now.
2017-01-11 15:56:20 -02:00
Simon Duquennoy bb4f2e5678 Merge pull request #2043 from e120guru/master
Fixed rime-tsch sync problem in Cooja
2017-01-11 18:15:43 +01:00
Michael Karlsson 22d10ba03a Added Cooja target config to rime-tsch example 2017-01-11 16:35:16 +01:00
Simon Duquennoy fe210b05f0 Merge pull request #2002 from yatch/pr/tsch-misc-update
TSCH Miscelleneous updates
2017-01-10 14:05:36 +01:00
Yasuyuki Tanaka 1d5fc88ae9 TSCH: fix indentation in tsch-packet.c 2017-01-10 11:45:59 +01:00
Yasuyuki Tanaka 3dc74dc632 TSCH: fix a wrong return value
tsch_security_secure_frame() returns the length of MIC in case of
success. Otherwise, it is supposed to return 0. There was one case where
it returns 1 in an error handling block.
2017-01-10 11:45:59 +01:00
Yasuyuki Tanaka 4069ac5262 TSCH: add a regression test for tsch-packet.c 2017-01-10 11:45:59 +01:00
Yasuyuki Tanaka 35a1701236 TSCH: handle error cases returning -1 properly
- tsch_send_eb_process() in tsch-slot-operation.c
- tsch_rx_slot()         in tsch.c
2017-01-10 11:45:59 +01:00
Yasuyuki Tanaka 0b81c0de18 TSCH: make *dest_addr const (tsch_packet_create_eack) 2017-01-10 11:45:59 +01:00
Yasuyuki Tanaka 667dd6a210 TSCH: put tsch_ prefix to definitions in the global scope
struct asn_t         -> struct tsch_asn_t
  struct asn_divisor_t -> tsch_asn_divisor_t
  ASN_ macros          -> TSCH_ASN_ macros
  current_asn          -> tsch_current_asn
2017-01-10 11:45:59 +01:00
Antonio Lignan 7d9134757f Merge pull request #2004 from yatch/pr/tsch-security-update
Trivial Updates on tsch-security.[ch]
2017-01-10 11:23:55 +01:00
Pere Tuset 361cb612a7 Reduce bootloader baudrate to be on the safe side. 2017-01-10 10:59:06 +01:00
Antonio Lignan 82f3ce392e Merge pull request #2028 from joakimeriksson/minimal-net-ND-fix
added support for 6-bytes link-layer address
2017-01-10 09:07:50 +01:00
Antonio Lignan 247d79ea7c Merge pull request #2011 from jdede/z1-llsec
Enable llsec on Z1 nodes
2017-01-10 09:07:27 +01:00
Antonio Lignan bfef0b5d6a Merge pull request #2032 from simonduq/pr/tsch-ka-fix
TSCH bugfix: reset keep-alive timeout when switching time source
2017-01-10 08:47:30 +01:00
George Oikonomou 960b81d484 Merge pull request #2024 from alignan/pull/eth-gw
Zolertia Orion ethernet router with active POE support
2017-01-09 21:03:45 +00:00
George Oikonomou 14757201a5 Merge pull request #2027 from alignan/pull/fix-adc-channels
zoul: fix a bitmask bug in channels used
2017-01-09 21:02:20 +00:00
Nicolas Tsiftes 1537488e74 Merge pull request #2035 from simonduq/pr/csma-fix
CSMA bugfix: do not use field on a struct that may have been deallocated
2017-01-09 08:45:49 +01:00
Simon Duquennoy 0de3563ddb CSMA bugfix: do not use field on a struct that may have been deallocated 2017-01-05 10:47:11 +01:00
Vinicius Guimaraes 42557bf484 Fixing Avr-Zigbit Makefile not compiling.
I just tried to compile this platform for my Zigbit mote (AT86RF230) here in a hello-world example, but it didn't work.
I reviewed this makefile and found that the request to compile "frame.c" was not necessary and bring up a missing error:
"make: *** No rule to make target `obj_avr-zigbit/frame.o', needed by `contiki-avr-zigbit.a'.  Stop."
Frame.c is already inserted in radio's makefile.

Another problem was the undefined reference created by the missing module "core/net":
"contiki-avr-zigbit.a(sicslowpan.o): In function `input':"
"contiki/examples/hello-world/../../core/net/ipv6/sicslowpan.c:1521: undefined reference to `link_stats_input_callback'"

Both solved now. Hope it helps anyone else.
2017-01-04 16:58:53 -02:00
Antonio Lignan 53efcec1fa Merge pull request #1994 from yatch/pr/bugfix-framer802154-sender-addr
Bugfix on source address setting in framer_802154.create()
2017-01-04 14:10:57 +01:00
Simon Duquennoy fe99f1144a TSCH bugfix: reset keep-alive timeout when switching time source 2017-01-04 11:01:46 +01:00
Antonio Lignan 6e07fd7019 Merge pull request #2001 from joakimeriksson/cooja-quick-ui-fix
fixed so that Cooja can run in quick mode when having UI
2017-01-03 10:26:52 +01:00
Antonio Lignan 6aaf1c356c Merge pull request #2029 from t-than/master
Minor typo change
2017-01-02 09:18:54 +01:00
Thanos Tsakiris 92ad29ab33 Minor typo change 2016-12-30 13:13:53 +02:00
Joakim Eriksson cbf4a843e2 fixed comment. 2016-12-29 22:49:01 +01:00
Antonio Lignan 9d12801f01 Merge pull request #2026 from alignan/pull/fix-firefly-doc
Minor documentation fixes
2016-12-29 18:00:49 +01:00
Antonio Lignan a7e617657a zoul: fix a bitmask bug in channels used 2016-12-29 14:19:32 +01:00
Antonio Lignan fb9c6009a2 Fixed Firefly revision A image links 2016-12-29 13:40:50 +01:00
Antonio Lignan a98792a79f Updated ARM toolchain information 2016-12-29 13:38:09 +01:00
Antonio Lignan 6bda852052 Updated maintainer info 2016-12-29 13:32:35 +01:00
Antonio Lignan 579620ce0e Added Zolertia Orion ethernet router with active POE support 2016-12-29 13:07:53 +01:00
Pere Tuset 93828d867e Updated OpenMote-CC2538 README.md file with new features. 2016-12-29 12:30:58 +01:00
Pere Tuset b72110fe8a Add support for the OpenMote-CC2538 Rev.A1 board that uses the CC2538SF23 (256 KB) chip instead of the CC2538SF53 (512 KB) chip. 2016-12-29 12:10:21 +01:00
Pere Tuset 1a993da8fc Add support for automatic bootloading with the cc2538-bsl.py script on the OpenUSB carrier board. 2016-12-29 12:09:07 +01:00
Antonio Lignan 9befc02331 Merge pull request #1997 from yatch/pr/packetbuf-remaininglen
Introduce packetbuf_remaininglen()
2016-12-27 22:38:14 +01:00
Antonio Lignan 2464cdadc9 Merge pull request #1973 from g-oikonomou/contrib/sensniff-submodule
Add sensniff as a submodule
2016-12-25 19:42:18 +01:00
Antonio Lignan cf2b24971b Merge pull request #1978 from makrog/pr/cc1200-fixes
Added NullRDC and ContikiMAC timings for Zolertia RE-Mote.
2016-12-23 18:31:47 +01:00
Jens Dede 7b2c687789 Use hardware-AES on z1 as default 2016-12-22 20:08:19 +01:00
Jens Dede 0b68334e95 Enable llsec on Z1 nodes 2016-12-21 14:54:15 +01:00
George Oikonomou edec34f684 Merge pull request #2008 from alignan/pull/change-baudrate-zoul
zoul: default cc2538-bsl baudrate to 460800
2016-12-21 02:30:19 +00:00
Antonio Lignan 3594cf5167 zoul: default cc2538-bsl baudrate to 460800 2016-12-20 18:18:28 +01:00
Antonio Lignan 7927af021e Minor cosmetic change 2016-12-16 15:47:13 +01:00
Harald Pichler 1ec48fcf37 bugfix repalce the same tag 2016-12-16 13:03:44 +01:00
Yasuyuki Tanaka 4faf139523 TSCH: change the return type of the APIs (tsch-security.h)
The return type is changed to "int" to "unsigned int" because APIs
provided by tsch-security are supposed to return an integer larger than
or equal to zero. This change clarifies that.
2016-12-15 19:32:22 +01:00
Yasuyuki Tanaka da853386a6 TSCH: fix indentation in tsch-packet.c 2016-12-15 19:32:04 +01:00
Yasuyuki Tanaka 38ff8e5283 TSCH: add brief API explanations (tsch-security.h) 2016-12-15 19:16:28 +01:00
Yasuyuki Tanaka 5186fa2ef1 TSCH: set PACKETBUF_ADDR_SENDER before NETSTACK_framer.create() 2016-12-15 15:10:15 +01:00
Yasuyuki Tanaka da29a5f8e3 ContikiMAC: set PACKET_ADDR_SENDER in qsend_list() 2016-12-15 15:10:15 +01:00
Yasuyuki Tanaka 586fb9a7fe framer-802154: bugfix on source address setting 2016-12-15 15:10:15 +01:00
Joakim Eriksson f069cef73a fixed so that Cooja can run in quick mode when having UI 2016-12-15 13:52:05 +01:00
Nicolas Tsiftes 9ef28c7eae Merge pull request #1993 from yatch/pr/bugfix-rime-sky-collect
Bugfix on regression-tests/04-rime/07-sky-collect.csc
2016-12-15 10:46:04 +01:00
Simon Duquennoy bba5a973ba Merge pull request #1987 from joakimeriksson/cooja-fix
Fixed COOJA to avoid using UI based message list when not using UI.
2016-12-15 08:40:03 +01:00
Yasuyuki Tanaka aa1f408825 packetbuf: add packetbuf_remaininglen()
packetbuf_freelen() returns the length of free space in packetbuf.
2016-12-14 14:19:46 +01:00
Yasuyuki Tanaka c48cfb6b9d Fix indentation in packetbuf.h 2016-12-14 14:16:55 +01:00
Yasuyuki Tanaka a3417b82b0 Fix indentation in packetbuf.c 2016-12-14 14:16:55 +01:00
Yasuyuki Tanaka 8b3f29325d Update example-collect.c
- bugfix: more frequent transmissions than expected (every 30 seconds)
- indentation: replace tabs with spaces
2016-12-14 12:38:55 +01:00
Yasuyuki Tanaka 5d19196e54 Update 04-rime/07-sky-collect.csc
- decrease timeout value to 450,000 msec, which is enough to send 10
  messages at 30 seconds interval after 2 minutes start-up wait
- handle the case of receiving seqno out of range
2016-12-14 12:38:55 +01:00
Joakim Eriksson fb0607f0f8 Merge pull request #3 from nfi/cooja-messagelist-ui
Fixed more MessageListUI to respect visualized in Cooja
2016-12-14 10:24:37 +01:00
Niclas Finne a02481bc99 Fixed more MessageListUI to respect visualized in Cooja 2016-12-14 10:10:25 +01:00
Nicolas Tsiftes 8fca9ced8e Merge pull request #1976 from yatch/pr/missing-single-quote
Resolve  "unmatched single quote" error in Travis CI failed tests
2016-12-12 17:06:16 +01:00
George Oikonomou a6b14a0731 Add documentation for the new boards 2016-12-11 20:44:26 +00:00
George Oikonomou 08439a878d Add travis tests for CC1350 boards 2016-12-11 20:44:26 +00:00
George Oikonomou fd3d733e4b Add support for the CC1350 Launchpad 2016-12-11 20:44:25 +00:00
George Oikonomou a864ebbce4 Re-organise sensortag documentation modules
Many of those doxygen blocks are now applicable to both sensortags, with only a couple of them being different between the CC1350 and CC2650 tags
2016-12-11 20:44:25 +00:00
George Oikonomou d291ec53e6 Add support for the CC1350 sensortag 2016-12-11 20:44:25 +00:00
George Oikonomou 7603e104c4 Allow band-specific RSSI offset override 2016-12-11 20:44:25 +00:00
George Oikonomou 47bda9b6be Provide additional overrides for the 470MHz frequency band 2016-12-11 20:44:25 +00:00
George Oikonomou c745199d53 Allow frequency band-specific overrides 2016-12-11 20:44:25 +00:00
George Oikonomou 5756248949 Factor-out CC13xx PROP mode TX power table
The CC13xx PROP mode TX power table can differ between boards as well as across frequency bands. This commit provides defaults for all bands and allows the board to override.
2016-12-11 20:41:00 +00:00
George Oikonomou 7ca3bea701 Make LNA bias trim offset configurable 2016-12-11 20:40:24 +00:00
Joakim Eriksson 2a3edc9136 Fixed so that COOJA sends in isVisible instead of quick as visibility parameter to plugins to get compile info back into COOJA - and fixed CoreComm to use MessageList text if no UI 2016-12-11 20:52:03 +01:00
George Oikonomou 6694e69788 Make Launchpad unused pins configurable 2016-12-11 16:54:11 +00:00
George Oikonomou 6b7681c516 Extend the RF core to support RF switches 2016-12-11 16:54:11 +00:00
George Oikonomou e0e6f82c46 Allow boards to explicitly provide an RSSI offset 2016-12-11 16:54:10 +00:00
George Oikonomou 00944ec677 Allow boards to append to overrides 2016-12-11 16:54:10 +00:00
George Oikonomou d9ea888323 Delegate RF Front End and Bias settings to board.h 2016-12-11 16:54:10 +00:00
George Oikonomou d6e8e7dab4 Adjust ContikiMAC timings to compensate for new patches/overrides 2016-12-11 16:51:48 +00:00
Jonas Olsson a56b520215 Make sure correct clocks is running in the RF Core (RFE). 2016-12-11 16:51:48 +00:00
Jonas Olsson 43b9679bcc Move setting of RF mode to correct place, needs to be called on every boot. 2016-12-11 16:51:48 +00:00
George Oikonomou e73ac7d26f Update to latest overrides and patches 2016-12-11 16:51:48 +00:00
Jonas Olsson db54175d8d Add missing structure from radio setup command. 2016-12-11 16:51:48 +00:00
George Oikonomou f07ed3fc01 Allow CC13xxware to automatically configure RTRIM for us 2016-12-11 16:51:48 +00:00
George Oikonomou 2934c6bbe7 Define RFC-related ccxxware macros 2016-12-11 16:51:48 +00:00
George Oikonomou 3a070bd332 Fix typo in TX power settings for prop mode (12.5 dBm) 2016-12-11 16:51:48 +00:00
George Oikonomou f9e6a78882 Update CMD_FS' fields to the current API 2016-12-11 16:51:47 +00:00
George Oikonomou a3c80cedb9 Adjust TX power settings to use current API fields 2016-12-11 16:51:47 +00:00
George Oikonomou 4d0051ad4d Switch to xxware-provided RF API headers 2016-12-11 16:51:47 +00:00
George Oikonomou b67d3cc6ea Remove RF API header files
xxwares ship these headers now, so we will switch to using those versions. The exceptions are IEEE API headers, which are for not part of xxwares, so we have to keep them locally for now.
2016-12-11 16:51:47 +00:00
Antonio Lignan ac2a31455e Merge pull request #1957 from alignan/pull/bme280-sensor
sensors: bme280 weather sensor
2016-12-10 18:37:21 +01:00
Antonio Lignan bd3f8fa3c5 Merge pull request #1939 from bthebaudeau/re-mote-sd-fat
Add global SD/MMC and FAT support, with RE-Mote as an example
2016-12-10 18:32:39 +01:00
Nicolas Tsiftes 9bb6286bb2 Merge pull request #1982 from nvt/coffee-io-semantics
Always enable the I/O semantics function in Coffee.
2016-12-09 16:09:32 +01:00
Harald Pichler 0812b89909 bugfix only one event if pressed 2016-12-09 15:59:22 +01:00
Harald Pichler d41197e1e7 add button code 2016-12-08 22:22:56 +01:00
Nicolas Tsiftes 3030422830 Merge pull request #1854 from mdlemay/fix-efi-align
x86: Fix section alignment for EFI binaries
2016-12-08 20:18:50 +01:00
Nicolas Tsiftes ece7cfee38 Merge pull request #1835 from mdlemay/gp-exc-handler
galileo: Add general protection exception handler
2016-12-08 20:12:45 +01:00
Nicolas Tsiftes 1249d9cf8d Merge pull request #1855 from MohamedSeliem/patch-5
DAD: Remove useless "if" that tests if the source address is unspecified
2016-12-08 20:08:58 +01:00
Nicolas Tsiftes d133ed898f Merge pull request #1914 from yatch/pr/802154-panid-handling
frame802154: comply with IEEE 802.15.4-2015 on PAN ID Field Handling
2016-12-08 18:37:58 +01:00
Harald Pichler 52c26d31c4 initial upload 2016-12-07 09:20:49 +01:00
Harald Pichler 5fc05b102b add sencond button 2016-12-07 09:18:10 +01:00
Harald Pichler 95b8c2683e cleanup examples 2016-12-06 21:37:58 +01:00
Harald Pichler 994badaef9 cleanup code 2016-12-06 21:37:03 +01:00
Harald Pichler 16e6a20b31 add button function 2016-12-06 21:36:22 +01:00
Harald Pichler 353cfe723c initial upload 2016-12-06 21:32:33 +01:00
Antonis Makrogiannakis ba241db968 Added NullRDC and ContikiMAC timings for Zolertia RE-Mote.
CC1200 SubGHz 50 Kbps mode.
2016-12-06 13:34:26 +02:00
Yasuyuki Tanaka 5fdd731166 frame802154: fix a typo in a comment 2016-12-05 22:45:07 +01:00
Yasuyuki Tanaka 3872965362 frame802154: comply with IEEE 802.15.4-2015 on PAN ID Field Handling
This patch changes the behaviors of frame802154_has_panid() for frames
of frame version 0b10 so that it complies with the PAN ID Field Handling
specification in IEEE 802.15.4-2015. For the other frame versions, 0b00
and 0b01, no change is made in frame802154_has_panid().

For more information, please refer to:
https://github.com/contiki-os/contiki/pull/1914/
2016-12-05 22:45:07 +01:00
Nicolas Tsiftes f09e84976a Merge pull request #1950 from yatch/pr/update-for-tsch-cooja-mote
Miscellaneous updates for tsch-cooja-mote
2016-12-05 18:40:28 +01:00
Yasuyuki Tanaka f5d6b7ed0f ContikiMoteType: add a missing single quote in a log message
This resolves the error of "unmatched single quote" by xargs seen in a
failed log of Travis CI.
2016-12-05 18:07:39 +01:00
Simon Duquennoy f6439121b4 Merge pull request #1963 from yatch/pr/code-style
Update doc/code-style.c
2016-12-05 13:40:36 +01:00
Antonio Lignan 95f69d92a8 Merge pull request #1918 from adamdunkels/pr-websocket-2
Contiki websocket client
2016-12-05 06:46:43 +01:00
Antonio Lignan 027f1c3e64 Merge pull request #1924 from g-oikonomou/contrib/cc26xx-cc13xx/update-ccxxwares
Update to latest CC13xxware/CC26xxware
2016-12-04 23:55:31 +01:00
George Oikonomou bad3384365 Update sensniff example documentation 2016-12-04 19:07:40 +00:00
George Oikonomou aaf0d1eb86 Automatically specify a correct baudrate for jn516x 2016-12-04 19:07:40 +00:00
George Oikonomou 7ef5902c3d Add the sniff make target
We can now run make sniff and this will provide correct command line arguments for all supported devices.
2016-12-04 18:51:57 +00:00
George Oikonomou 44edc187bc Specify default baudrate for CC2538DK 2016-12-04 18:43:41 +00:00
George Oikonomou 11877b4b6b Add sensniff as a submodule 2016-12-04 18:43:17 +00:00
Mohamed Seliem 88fdc46e03 update httpd_cgi to enable the compilation of webserver-ipv6 example
this simple change fixes the bug reported in @#1541.
../../apps/webserver/httpd.h:63:9: note: expected ‘uip_ip6addr_t’ but argument is of type ‘union uip_ipaddr_t *’
2016-12-04 19:03:15 +02:00
Harald Pichler 938aa0db71 bugfix type 2016-12-04 16:09:55 +01:00
Harald Pichler 4f7476c084 bugfix type 2016-12-04 15:49:14 +01:00
Harald Pichler f8a399d346 initial upload 2016-12-04 15:47:40 +01:00
Harald Pichler aa1670e5d4 add used serial lines 2016-12-04 15:45:09 +01:00
George Oikonomou 367104166e Update to latest CC13xxware/CC26xxware 2016-12-04 13:33:40 +00:00
Antonio Lignan af4f1e1c30 Merge pull request #1866 from yschroeder/pull-req/serialdump
Improved serialdump.c
2016-12-04 13:17:39 +01:00
Antonio Lignan 2be999c707 Merge pull request #1967 from MohamedSeliem/patch-9
Fix the leftover mentions of aaaa as a prefix to be UIP_DS6_DEFAULT_PREFIX (now fd00)
2016-12-04 12:46:07 +01:00
Antonio Lignan 36519a9742 Merge pull request #1969 from g-oikonomou/contrib/fix-typo
Fix minor typo
2016-12-04 12:45:04 +01:00
Mohamed seliem 4a93babb58 fix msg.dst.sin6_addr.__u6_addr.__u6_addr16 2016-12-04 03:29:50 +02:00
Mohamed seliem 452666b43e add missing include 2016-12-04 03:29:49 +02:00
Mohamed Seliem 82b5fb5073 Fix the leftover mentions of aaaa as a prefix to be UIP_DS6_DEFAULT_PREFIX (now fd00) 2016-12-04 03:29:49 +02:00
George Oikonomou d6656ccde1 Fix minor typo 2016-12-03 23:26:25 +00:00
Yasuyuki Tanaka 49808b8f1c Update code-style.c
- mention Uncrustify instead of GNU Indent
- add a missing argument of code_style_example_function()
- make the function return 0 or 1 as per doxygen comment
- replace tab with spaces
- correct case() to switch() in a comment
- add an indentation example for switch statement
2016-12-03 12:21:04 +01:00
Antonio Lignan 9ccc1697cf Merge pull request #1966 from yatch/pr/travis-jdk
travis: workaround for the Java issue on Travis CI
2016-12-03 12:13:40 +01:00
Yasuyuki Tanaka 120632b4a8 travis: workaround for the Java issue on Travis CI
References:
https://docs.travis-ci.com/user/build-environment-updates/2016-12-01/
https://github.com/travis-ci/travis-ci/issues/6928#issuecomment-264227708
2016-12-02 16:48:57 +01:00
Antonio Lignan 94854177e2 Merge pull request #1961 from jdede/uart-init
Do not initialize and use the wrong UART (z1)
2016-12-02 15:41:32 +01:00
Antonio Lignan 6565652e43 Merge pull request #1962 from MohamedSeliem/patch-8
update contiki-conf to avoid redfintion of UIP_CONF_RECEIVE_WINDOW
2016-12-02 09:52:48 +01:00
Mohamed seliem 0ef0a21d9e update for all platforms 2016-12-01 21:26:32 +02:00
Mohamed Seliem 0c65a4db9c update contiki-conf to avoid redfintion of UIP_CONF_RECEIVE_WINDOW
in case of compiling any example that contains the definition of UIP_CONF_RECEIVE_WINDOW over Z1 mote.
i receive this warning: 
 In file included from ../../../core/./contiki.h:38:0,
                   from ../../../core/./contiki-net.h:37,
                   from httpd-simple.c:43:
  ../../../platform/z1/./contiki-conf.h:225:0: warning: "UIP_CONF_RECEIVE_WINDOW" redefined
 ./project-conf.h:60:0: note: this is the location of the previous definition
2016-12-01 20:35:29 +02:00
Antonio Lignan 63322fdfb2 Merge pull request #1960 from pablocorbalan/rm-rpl-conf-of
Remove definitions of outdated RPL_CONF_OF
2016-12-01 16:30:46 +01:00
Nicolas Tsiftes 238e8b4dcf Merge pull request #1949 from simonduq/pr/non-storing-fix-dtsn
RPL non-storing: more conservative DTSN update
2016-12-01 16:27:38 +01:00
Simon Duquennoy 7bb50da178 Merge pull request #1271 from drugo72/pr-rpl
RPL: fix clock_time_t calculations
2016-12-01 16:22:43 +01:00
Jens Dede 0d3ff7b785 Rm unnecessary uart commands 2016-12-01 15:12:23 +01:00
Pablo Corbalán 983d858570 Remove definitions of outdated RPL_CONF_OF 2016-12-01 13:13:41 +01:00
Antonio Lignan 5e7acd4dc2 Merge pull request #1643 from akshaypm/zoul-uart-example
Zoul UART example
2016-12-01 11:42:44 +01:00
akshaypm cd75e50c28 cc2538 uart example 2016-12-01 12:45:10 +05:30
George Oikonomou 7c54b7cd50 Merge pull request #1867 from MohamedSeliem/patch-6
update uart1.c to include Special function registers bits definitions
2016-11-30 16:37:49 +01:00
Antonio Lignan a8acaf08d5 Merge pull request #1938 from makrog/pr/cc1200-fixes
Fixed checking of the cc1200 GPIO0 pin status.
2016-11-30 14:24:48 +01:00
Robert Olsson 4ef4bdd0a5 bme280 delay fixes plus Makefile for avr-rss2 2016-11-30 12:04:57 +01:00
Antonio Lignan f9b32f8139 bme280: reworked to allow platform-specific I2C implementations 2016-11-30 12:04:57 +01:00
Antonio Lignan bd1a6bf94e zoul: Added bme280 example 2016-11-30 12:04:57 +01:00
Robert Olsson 23a481600a BME280 fixes, codestyle, return code for bme280_init added, Unneeded header files removed 2016-11-30 12:04:57 +01:00
Robert Olsson 1c0e33be79 Update README.bme280 2016-11-30 12:04:57 +01:00
Robert Olsson cfed856720 I2C fixes
modified:   examples/avr-rss2/hello-sensors/hello-sensors.c
2016-11-30 12:04:57 +01:00
Robert Olsson dcbb5f6271 BME280 I2C integration fixes 2016-11-30 12:04:57 +01:00
Robert Olsson 5c25ec4d11 Example modified to use BME280 2016-11-30 12:04:57 +01:00
Robert Olsson cfabf0e6a2 Support for BME280 added.
new file:   dev/bme280/README.bme280
	new file:   dev/bme280/bme280-sensor.c
	new file:   dev/bme280/bme280-sensor.h
	new file:   dev/bme280/bme280.c
	new file:   dev/bme280/bme280.h
2016-11-30 12:04:57 +01:00
MakA 91a6ce6576 Fixed checking of the cc1200 GPIO0 pin status. 2016-11-29 12:16:03 +02:00
Antonio Lignan 1abc95a08e Merge pull request #1952 from arurke/fix_rf_channel_cc13xx
Move RF_CHANNEL check in cc13xx/cc26xx such that it applies for cc13xx prop mode
2016-11-28 09:37:00 +01:00
Benoît Thébaudeau a6d348917d Add FAT example
Zoul RE-Mote revision B is supported.

Signed-off-by: Benoît Thébaudeau <benoit@wsystem.com>
2016-11-27 22:50:45 +01:00
Benoît Thébaudeau 3cd7b7efd1 zoul: remote: Add support for FAT
Signed-off-by: Benoît Thébaudeau <benoit@wsystem.com>
2016-11-27 22:50:45 +01:00
Benoît Thébaudeau 12ea1bd492 zoul: remote: Factor out duplicate RTC init
Signed-off-by: Benoît Thébaudeau <benoit@wsystem.com>
2016-11-27 22:50:44 +01:00
Benoît Thébaudeau 2866ae0555 Add support for the FAT file system
The FatFs generic FAT file system module is used.

Signed-off-by: Benoît Thébaudeau <benoit@wsystem.com>
2016-11-27 22:50:44 +01:00
Benoît Thébaudeau 062a8535ec zoul: remote: Add support for SD/MMC
This change adds SD/MMC support at block level, by porting the SD/MMC
driver.

Signed-off-by: Benoît Thébaudeau <benoit@wsystem.com>
2016-11-27 22:50:43 +01:00
Benoît Thébaudeau 8b57670121 cc2538: spi: Add support for dynamic clock frequency
This changes makes it possible to change the SPI clock frequency at
runtime.

Signed-off-by: Benoît Thébaudeau <benoit@wsystem.com>
2016-11-27 22:50:43 +01:00
Benoît Thébaudeau c76b8235f4 cc2538: spi: Add support for dynamic instances
Previously, only constants could be used to pass SPI instances to the
SPI driver. This change makes it possible to use SPI instances from
variables.

Signed-off-by: Benoît Thébaudeau <benoit@wsystem.com>
2016-11-27 22:50:43 +01:00
Benoît Thébaudeau 0e5b18635b cc2538: gpio: Add macro to get pin direction
Signed-off-by: Benoît Thébaudeau <benoit@wsystem.com>
2016-11-27 22:50:42 +01:00
Benoît Thébaudeau faf22609f4 disk: Add SD/MMC driver
Only SPI is supported.

Signed-off-by: Benoît Thébaudeau <benoit@wsystem.com>
2016-11-27 22:50:42 +01:00
Benoît Thébaudeau 92ecbf7064 Add disk API
Signed-off-by: Benoît Thébaudeau <benoit@wsystem.com>
2016-11-27 22:15:34 +01:00
Andreas Urke 835a6aa6e6 Move RF_CHANNEL such that it is applied for prop mode as well 2016-11-27 16:13:58 +01:00
Simon Duquennoy 728e417e04 Merge pull request #1502 from yatch/pr-radiologger
Fix timestamps of packets recorded in pcap files
2016-11-27 11:58:03 +01:00
Yasuyuki Tanaka a4adc257e8 Add RTIMERTICKS_TO_US_64() macro (platform/cooja) 2016-11-26 11:47:59 +01:00
Yasuyuki Tanaka 106731cec1 TSCH: update README.md
- add cooja / Cooja mote as supported platform
- correct Rx mode requirements
2016-11-26 11:47:59 +01:00
Yasuyuki Tanaka 87337e12fc Revert coordinator selection based on node-id for Cooja mote
(example/ipv6/rpl-tsch/node.c)
2016-11-26 11:47:59 +01:00
Antonio Lignan 58243bc14a Merge pull request #1827 from alignan/pull/rf-channel
Harmonize RF_CHANNEL definition
2016-11-25 21:11:20 +01:00
George Oikonomou 610eefc2ff Merge pull request #1741 from simonduq/pr/tsch-adaptive-control-traffic
TSCH adaptive control traffic
2016-11-25 15:53:32 +00:00
Simon Duquennoy 3e00adacc0 RPL non-storing: more conservative DTSN update, as per RFC 6550, section 9.6. 2016-11-25 16:30:08 +01:00
Nicolas Tsiftes edf3a27920 Merge pull request #1879 from pernin/master
Change on DIO trickle timer condition for DIO sending
2016-11-25 16:15:08 +01:00
Nicolas Tsiftes a69d78ac73 Merge pull request #1948 from zhitaoh/zoul-example-readme
correct shell arguments
2016-11-25 16:13:02 +01:00
Nicolas Tsiftes 5281908018 Always enable the I/O semantics function in Coffee. 2016-11-25 16:02:44 +01:00
Zhitao He 7ba88a6800 correct shell arguments 2016-11-25 14:59:30 +01:00
Antonio Lignan fc582606f2 Harmonize RF_CHANNEL definition 2016-11-25 10:37:14 +01:00
Benoît Thébaudeau 52a8dcc65b Merge pull request #1816 from bthebaudeau/cm-cc2538-mt
Cortex-M and CC2538 multi-threading
2016-11-24 23:28:05 +01:00
Benoît Thébaudeau 9c47f874c4 CC2538: Enable Cortex-M mtarch implementation
Signed-off-by: Benoît Thébaudeau <benoit.thebaudeau.dev@gmail.com>
2016-11-24 22:30:26 +01:00
Benoît Thébaudeau 3f676a5a16 ARM: Add common Cortex-M mtarch implementation
This includes support for preemption ready to be integrated into
exception handlers.

Signed-off-by: Benoît Thébaudeau <benoit.thebaudeau.dev@gmail.com>
2016-11-24 22:30:26 +01:00
Benoît Thébaudeau 81805129f8 mt: Fix preemption
Preemption was supposed to be supported, but it had no means of safely
updating the state of a thread, so mt_exec() could fail to resume a
preempted thread.

mt_exec() is allowed to be called only from the main Contiki thread, so
the mt threads passed to it may be only ready or exited, not running.
Consequently, there is no need for a distinction between the ready and
running states, so merge them as a started state, which avoids having to
update the state of a thread upon preemption.

Signed-off-by: Benoît Thébaudeau <benoit.thebaudeau.dev@gmail.com>
2016-11-24 22:30:26 +01:00
Benoît Thébaudeau 927e9b8150 mt: Fix missing call to mtarch_pstop()
If mt_yield() needs it, then mt_exit() too. A thread could indeed be
preempted while calling mt_exit().

Signed-off-by: Benoît Thébaudeau <benoit.thebaudeau.dev@gmail.com>
2016-11-24 22:30:26 +01:00
Benoît Thébaudeau 82afa72c13 mt: Remove unused code
Signed-off-by: Benoît Thébaudeau <benoit.thebaudeau.dev@gmail.com>
2016-11-24 22:30:26 +01:00
Benoît Thébaudeau ab1491be69 CC2538: Use CMSIS-CORE
Switch to CMSIS-CORE and remove the duplicate code.

Signed-off-by: Benoît Thébaudeau <benoit.thebaudeau.dev@gmail.com>
2016-11-24 22:30:26 +01:00
Benoît Thébaudeau 9195b49c18 ARM: CMSIS-CORE: Introduce NVIC_IsIRQEnabled()
This function returns the enable state of an interrupt.

Signed-off-by: Benoît Thébaudeau <benoit.thebaudeau.dev@gmail.com>
2016-11-24 22:30:26 +01:00
Benoît Thébaudeau d3158897c2 ARM: CMSIS-CORE: Fix doxygen warnings
Signed-off-by: Benoît Thébaudeau <benoit.thebaudeau.dev@gmail.com>
2016-11-24 22:30:26 +01:00
Benoît Thébaudeau 280dc091d2 ARM: CMSIS-CORE: Bump version to 4.30
Signed-off-by: Benoît Thébaudeau <benoit.thebaudeau.dev@gmail.com>
2016-11-24 22:30:26 +01:00
Benoît Thébaudeau ca86d5febf ARM: Fix doxygen style
The rule in Contiki is to use backslashes, not at signs.

Signed-off-by: Benoît Thébaudeau <benoit.thebaudeau.dev@gmail.com>
2016-11-24 22:30:26 +01:00
Luca Pernini 5803971adc Changing DIO timer condition - merge 2016-11-24 10:52:10 +01:00
Simon Duquennoy 86dbd590db Merge pull request #1400 from pablocorbalan/nud-with-acks
Refresh nbr reachable state after received IPv6 unicast message
2016-11-23 12:00:13 +01:00
Simon Duquennoy ecd1d57eec Merge pull request #1661 from yatch/pr-tsch-cooja-mote
TSCH on Cooja mote
2016-11-23 11:59:29 +01:00
Harald Pichler 6a1a4b62a0 add more arduino osd examples 2016-11-15 09:37:06 +01:00
Harald Pichler f9f923d29c bugfix SPI 2016-11-15 09:36:30 +01:00
Harald Pichler b708fac68d Merge branch 'contiki' 2016-11-15 08:29:23 +01:00
Harald Pichler 9f40b0734c add rfid resources 2016-11-14 11:13:07 +01:00
Harald Pichler ceb4fb3298 initial upload 2016-11-14 07:44:34 +01:00
Antonio Lignan efde9132a8 Merge pull request #1769 from gebart/pr/rest-engine-periodic-add-poll
rest-engine: Allow adding periodic resources after starting REST engine
2016-11-11 09:01:32 +01:00
Harald Pichler 1398ff0de6 print date to serial1 2016-11-09 15:39:24 +01:00
Harald Pichler c666b18a12 add hardware serial1 to use with arduino api 2016-11-09 15:14:45 +01:00
Harald Pichler d2a1f8937e add coap resoure ip 2016-11-06 16:17:16 +01:00
Cristiano De Alti 1bdec853e1 Prevent interger overflow on the AVR
Compiling examples/er-rest-example for the avr-raven gives:

  integer overflow in expression [-Woverflow]

On the AVR int is 16 bit and some calculations may overflow.
This happens for example with multiplications involving
CLOCK_SECOND where all the operands are of type int.
Casting one of the operands to clock_time_t forces
the arithmetic to clock_time_t without increasing the size
of the program (the calculation is performed at compile time).
2016-11-05 22:46:42 +01:00
Harald Pichler d8bb685989 bugfix post led/RGB 2016-11-05 19:34:07 +01:00
Harald Pichler 646bb077ef move res_red .. to resources folder 2016-11-04 08:40:58 +01:00
Harald Pichler d66e402cad bugfix linker problem mix c cpp function 2016-11-03 16:20:22 +01:00
Harald Pichler 5ea437c170 initial upload 2016-11-03 15:46:00 +01:00
Harald Pichler 20820a11e0 move rgb resource to resource folder 2016-11-03 11:27:42 +01:00
Harald Pichler d2a650f514 cleanup code 2016-11-03 08:38:21 +01:00
Harald Pichler 79b69334df cleanup code 2016-11-03 08:11:42 +01:00
Adam Dunkels 36afb693b0 Removed left-over debug printout 2016-11-02 21:54:15 +01:00
Adam Dunkels 869df3bc36 Updated copyright statements 2016-11-02 21:54:02 +01:00
Adam Dunkels 937fddbedf Removed blanks 2016-11-02 21:53:43 +01:00
Adam Dunkels c484ee4998 Added comments 2016-11-02 21:53:31 +01:00
Antonio Lignan 1ebceb8f23 Merge pull request #1897 from mdlemay/shrink-pinmux-array
galileo: Shrink pinmux array
2016-11-02 21:40:42 +01:00
Adam Dunkels ae4801bba6 Bugfix: make sure the TCP connection is polled immediately after tcp_socket_send() is called so that the TCP segment goes out directly 2016-11-02 15:16:00 +01:00
Adam Dunkels f11d344d4d Add a tcp_socket_queuelen() function that returns the length of the current TCP output queue 2016-11-02 15:16:00 +01:00
Adam Dunkels 6ab9822fc2 Make debug printouts be PRINTF() statements to avoid including them in non-debug builds 2016-11-02 15:16:00 +01:00
Adam Dunkels bb071a7fba Contiki websocket HTTP client code 2016-11-02 15:16:00 +01:00
Adam Dunkels a7cbbe496f Contiki websocket client code 2016-11-02 15:16:00 +01:00
Adam Dunkels 5625a01baf Example node.js websocket server, to be used with the Contiki websocket client 2016-11-02 15:16:00 +01:00
Adam Dunkels 4f13d637e6 Example code for the Contiki websocket client 2016-11-02 15:16:00 +01:00
Benoît Thébaudeau 4d61e8f997 Merge pull request #1906 from bthebaudeau/fix-cc2538-disabled-lpm-warnings
cc2538: lpm: Fix build warnings with LPM_CONF_ENABLE == 0
2016-10-31 21:38:16 +01:00
Benoît Thébaudeau 6cdba10b1d Merge pull request #1895 from alignan/pull/fix-cc2538-cca
cpu/cc2538: CCA threshold was fixed
2016-10-28 23:42:18 +02:00
Harald Pichler 0556557d8b remove unneeded code 2016-10-28 11:43:55 +02:00
Harald Pichler 17520dc4e0 add resource res_rgb 2016-10-27 14:17:26 +02:00
Antonio Lignan 0bb9052840 Merge pull request #1896 from alignan/pull/tsl-256x-rework
Renamed driver and reworked to support both TSL2561/TSL2563
2016-10-27 09:29:49 +02:00
Harald Pichler e6dbb8c3f2 Merge branch 'master' into osd
Conflicts:
	examples/osd/triggerbaord/sketch.pde
2016-10-26 17:03:37 +02:00
Benoît Thébaudeau 0e7750489a Merge pull request #1905 from nfi/compiler-warnings-cc2538
Fixed compiler warnings for CC2538-based platforms
2016-10-26 13:12:47 +02:00
Niclas Finne 3982aee329 Added missing include 2016-10-26 00:04:58 +02:00
Benoît Thébaudeau 14ccffd9d4 cc2538: lpm: Fix build warnings with LPM_CONF_ENABLE == 0
Some arguments passed to the functions disabled with
LPM_CONF_ENABLE == 0 could trigger build warnings because they became
unused with this configuration option. Disable these functions by using
empty static inline functions instead of empty macros, so that the
function arguments are always considered by the compiler as used,
without having to #if-out code in many places.

Signed-off-by: Benoît Thébaudeau <benoit.thebaudeau.dev@gmail.com>
2016-10-25 22:18:37 +02:00
George Oikonomou 1d59651632 Merge pull request #1903 from morphal/mqtt-debug-printf-fix
Fixed debug PRINTF definition in mqtt client
2016-10-25 12:23:43 +01:00
aho 8306aded79 fixed typo in debug PRINTF definition 2016-10-25 12:38:15 +03:00
Nicolas Tsiftes d690dcae31 Merge pull request #1864 from sumanpanchal/wismote-battery-voltage
Wismote: Added support for Battery voltage measurement
2016-10-24 14:41:23 +02:00
Harald Pichler 54e676343f set reciever amplifier to -90dB if use nullmac 2016-10-20 15:41:26 +02:00
Antonio Lignan 94174be708 Renamed driver and reworked to support both TSL2561/TSL2563 2016-10-19 23:13:25 +02:00
Michael LeMay 5c4cc2722e galileo: Shrink pinmux array
The pins array in galileo-gen2-pinmux.c:galileo_brd_to_cpu_gpio_pin is
unnecessarily large.  This patch reduces its size.
2016-10-19 09:31:50 -07:00
Harald Pichler 8891a0ec44 reduce power consumtion 2016-10-19 09:45:45 +02:00
Harald Pichler b7b3f0a33a add mcusleep set parameter to save energie 2016-10-19 08:32:21 +02:00
Antonio Lignan 2f76fc1f77 Merge pull request #1784 from g-oikonomou/contrib/cc1350
Add CC1350 support
2016-10-18 12:04:48 +02:00
Antonio Lignan 2a84e68e6d cpu/cc2538: CCA threshold was fixed 2016-10-18 09:35:04 +02:00
Harald Pichler ed1ae480f1 initial uplaod 2016-10-17 08:24:14 +02:00
Harald Pichler fd37296cdf more range, we have power 2016-10-17 08:22:38 +02:00
Harald Pichler 3b28df58da eliminate c++ string warnings 2016-10-17 08:20:16 +02:00
Harald Pichler 47760c57e6 add parameter to save more power 2016-10-16 22:08:18 +02:00
Harald Pichler 0fd28e0585 remove PT_YIELD to habe better ping sync 2016-10-16 22:02:54 +02:00
Oliver Schmidt b8d753d35e Merge pull request #1889 from oliverschmidt/master
Several retrotarget changes
2016-10-16 13:12:24 +02:00
Oliver Schmidt fb4c42a357 Added custom log function for CBM machines.
The log function writes directly to the screen. Combined with the usage of PFS this means that the POSIX layer of the C library isn't referenced anymore thus reducing the memory requirements.
2016-10-15 23:36:53 +02:00
Oliver Schmidt d864e73579 Added directory functions to the Commodore Platform File System.
They reduce the Telnet server's run size by 1231 bytes.
2016-10-15 18:36:54 +02:00
Oliver Schmidt c25e965b0c Avoid unnecessary key presses.
The recently added doesclrscrafterexit() allows cc65 programs to determine if the screen will be cleared after exit(). If that isn't the case then there's no need to ask the user to press a key in order to allow him to read the final program output.
2016-10-15 15:27:42 +02:00
Harald Pichler a152a30958 add mac layer security 2016-10-13 12:41:02 +02:00
Harald Pichler e4ab78369e initial upload 2016-10-13 12:36:53 +02:00
Simon Duquennoy 14bfaffe00 Merge pull request #1883 from zhitaoh/fix-6LoWPAN-typo
fix comment with 6LoWPAN typo and break long lines
2016-10-12 15:05:24 +02:00
Harald Pichler 8f5a033c48 move arduino app code to project 2016-10-12 10:16:41 +02:00
Harald Pichler 548bf32990 initial upload 2016-10-12 10:02:59 +02:00
Oliver Schmidt 957ac63a7c Improved dicarding of text in the HTML header.
Plain text in the HTML header (think of <title>text</title>) is collected as usual. The decision to discard it is triggered by the first withspace following. In the usual case of the <body> no preceeded by any whitespace this means that by the point the first whitespace is encountered we're not in "discard mode" anymore and therefore incorrectly render the text.

Explicitly calling do_word() just before leaving "discard mode" discards all text collected so far.
2016-10-11 11:25:31 +02:00
Oliver Schmidt 72cc19c680 Fixed ProDOS 800kB image.
The 800kB file claimed to be a 32MB image. Now the logical size and pysical size match.
2016-10-11 11:18:23 +02:00
Harald Pichler e410b2ddd2 add WCHaracter 2016-10-07 15:29:03 +02:00
g.oikonomou@bristol.ac.uk ec4b403e77 Allow and document IEEE mode for CC13xx 2016-10-07 10:05:14 +01:00
Zhitao He 7bb10dc2a0 fix comment with 6LoWPAN typo and break long lines 2016-10-03 15:53:28 +02:00
Harald Pichler 34adab3210 remove redefine routing warning 2016-10-02 22:50:10 +02:00
Harald Pichler 9226facda8 remove warnings 2016-10-02 22:49:22 +02:00
Harald Pichler fa11a55a45 initial upload 2016-10-02 22:35:56 +02:00
Harald Pichler 5d76c0a6af add rgb resource 2016-10-02 22:32:58 +02:00
Harald Pichler dfea93b2ff add spi and eeprom arduino libs 2016-10-02 18:53:44 +02:00
Antonio Lignan 6157dce0b5 Merge pull request #1877 from alignan/pull/fix-zoul-doc
Zoul: updated pin-out images
2016-09-28 23:05:17 +02:00
Antonio Lignan fd881bec19 Merge pull request #1874 from alignan/pull/zolertia-firefly-reva1
Zoul: added new Firefly revision A
2016-09-28 17:01:19 +02:00
Antonio Lignan 1758eaa08c Zoul: updated pin-out images 2016-09-28 16:54:51 +02:00
Harald Pichler cfca07489d coap client test 2016-09-27 18:13:03 +02:00
Nicolas Tsiftes 272c7b92d0 Merge pull request #1875 from mdlemay/fix-dhcp-ipv6
galileo: Omit DHCP code when IPv6 is enabled
2016-09-27 17:04:23 +02:00
Harald Pichler 8302b1f762 bugfix constrain return value 2016-09-27 17:03:15 +02:00
Harald Pichler ee5cd039a1 add ChainableLED 2016-09-27 09:51:26 +02:00
Harald Pichler a37fd79426 disable mcusleep 2016-09-26 21:06:14 +02:00
Harald Pichler 916bebd102 reduce power consumtion 2016-09-26 21:04:05 +02:00
Michael LeMay 04446e8da5 galileo: Omit DHCP code when IPv6 is enabled 2016-09-24 17:37:07 -07:00
Harald Pichler ae79061182 bugfix powercyle and sleep mcu timing 2016-09-23 14:59:30 +02:00
Nicolas Tsiftes ef78b44a86 Merge pull request #1871 from gkelly/fix-rpl-debug
rpl: fix debugging PRINTF in find_removable_dio
2016-09-23 13:34:49 +02:00
Simon Duquennoy 75090f648a Merge pull request #1870 from simonduq/pr/cc1200-1.2kbps
CC1200 added config for 1.2 kbps
2016-09-23 13:13:26 +02:00
Antonio Lignan 75e260b2fc Zoul: added new Firefly revision A 2016-09-23 11:44:33 +02:00
Simon Duquennoy ba739f679e cc1200: configurable tx-rx turaround time 2016-09-23 09:41:20 +02:00
Simon Duquennoy 5dd3d03699 cc1200: call watchdog_periodic while in busy-wait 2016-09-23 09:10:42 +02:00
Simon Duquennoy 086499a864 cc1200: added configuration for 868 MHz 2-FSK at 1.2 kbps 2016-09-23 09:06:14 +02:00
Simon Duquennoy 622d576439 cc1200: configure RSSI offset as part of cc1200_rf_cfg 2016-09-23 09:06:13 +02:00
Simon Duquennoy 97843ed322 cc1200: use Hz instead of kHz for channel spacing 2016-09-23 09:06:05 +02:00
Antonio Lignan e206984d90 Merge pull request #1873 from MohamedSeliem/patch-7
Doxygen Fix
2016-09-23 08:31:41 +02:00
Antonio Lignan e658bdfcfe Merge pull request #1860 from alignan/pull/remote-power-mgmt
Zoul: power management driver for the RE-Mote revision B
2016-09-23 08:30:56 +02:00
Antonio Lignan 95ed9a9a91 Merge pull request #1859 from alignan/pull/remote-rtcc-update
Zoul: RTCC with trigger selection and second-based time increase
2016-09-23 08:30:20 +02:00
Mohamed Seliem 150b97879d Doxygen Fix
this minor fixation to avoid Doxygen bug, which appears when doing this in the documented code:
/**
* \exception \c text
*/
void foo();
2016-09-22 22:30:54 +02:00
Antonio Lignan 268330c7e5 Zoul: power management driver for the RE-Mote revision B 2016-09-22 21:45:54 +02:00
Garret Kelly 42c4cb94e0 rpl: fix debugging PRINTF in find_removable_dio 2016-09-22 10:54:55 -04:00
Antonio Lignan 6aa5890e73 Merge pull request #1869 from nfi/cooja-export-simulations-with-wismote-and-z1
Added support in Cooja to include Wismote and Z1 motes when exporting simulations
2016-09-22 12:26:11 +02:00
Niclas Finne e648373677 Cooja now supports Wismote and Z1 motes when exporting simulations as
executable JAR.
2016-09-22 10:56:56 +02:00
Harald Pichler a5b59e8cbb Merge branch 'contiki'
Conflicts:
	.gitmodules
	core/net/mac/contikimac/contikimac.c
	cpu/cc26xx-cc13xx/lib/cc13xxware
2016-09-21 21:09:29 +02:00
Mohamed Seliem 682abac7b7 update uart1.c to include Special function registers bits
including "sfr-bits.h" to define PERCFG_U1CFG, and UCSR_MODE
2016-09-21 14:32:09 +02:00
Harald Pichler 6f7e68c3d4 make it possible to config node as host in project.conf 2016-09-20 21:56:32 +02:00
Harald Pichler 2fd23f99ed config as hostnode, add coap client 2016-09-20 21:49:52 +02:00
Harald Pichler 8b1745214c bugfix answear speed 2016-09-20 21:22:11 +02:00
Harald Pichler 28f2b2caa8 add coap client function 2016-09-20 21:20:34 +02:00
Yannic Schröder d524211c2a Clean exit of serialdump when hitting Ctrl-C
Ctrl-C is the best way to close serialdump after using make login.
With a clean exit it will signal to make that the make run was successful.
2016-09-20 14:18:21 +02:00
Yannic Schröder 9e080e8aa5 Terminate serialdump when serial device disconnects
The running serialdump does not recover from a disconnected device but
runs indefinitely with outputting anything. This makes it quit with a
proper error message.
2016-09-20 14:16:40 +02:00
Yannic Schröder 2974b796d1 Initialize serialdump termios properly
termios i_flags were not initialized and could be set to arbitrary values
this resulted in unpredicted behaviour of the output like additional
newlines
2016-09-20 14:14:14 +02:00
Sumankumar Panchal 7803131ea8 Wismote: Added support for Battery voltage measurement 2016-09-17 11:41:30 +05:30
Harald Pichler 5de29079ae bugfix switch netstack mode 2016-09-16 16:18:02 +02:00
Harald Pichler fd12dcccf0 bugfix minimal push button time 2016-09-16 14:31:38 +02:00
Harald Pichler c663bb527e add UIP_CONF_ROUTER to project.conf 2016-09-16 14:12:37 +02:00
Antonio Lignan 3f4436bac9 Merge pull request #1846 from alignan/pull/msp430-uart0-baud-ubr-fix
MSP430/F2xxx: fix ubr msb byte being hardcoded to zero
2016-09-14 09:08:25 +02:00
George Oikonomou be1f19ad73 Merge pull request #1851 from kqorany/patch-1
Improve multicast documentation
2016-09-14 06:53:14 +01:00
George Oikonomou 94d900a76f Merge pull request #1857 from alignan/pull/remote-revb
Zoul: RE-Mote revision B
2016-09-14 06:52:02 +01:00
Antonio Lignan 072bf74aa2 Added RTCC function to increase current time in seconds 2016-09-13 15:16:54 +02:00
Antonio Lignan d1a7740a2c Updated RTCC driver with selectable INT1/INT2 trigger 2016-09-13 15:16:54 +02:00
Antonio Lignan 980de99472 Zoul: Removed misplaced project target 2016-09-13 15:15:24 +02:00
Mohamed Seliem f6795b4972 Neighbor Solicitation Processing (ns_input)
In the newest version of contiki, the function uip_nd6_ns_input() is obsolete.
ns_input function is defined static to be restrictively used in uip-nd6.c file, so removing the obsolete function requires moving the function description to the new function
2016-09-13 09:24:46 +02:00
Nicolas Tsiftes 2d49edfc57 Merge pull request #1849 from MohamedSeliem/patch3
Make UIP_CONF_DS6_ROUTE_NBU and DS6_NBR_NBU, DS6_ROUTE_NBU obsolete
2016-09-12 14:25:59 +02:00
Mohamed Seliem 675d9325b9 DAD: Remove useless "if" that tests if the source address is unspecified
No need to do the unspecified address twice.

#if UIP_ND6_DEF_MAXDADNS > 0
    if(uip_is_addr_unspecified(&UIP_IP_BUF->srcipaddr)) {
      /* DAD CASE */
       ..........
#else /* UIP_ND6_DEF_MAXDADNS > 0 */
    if(uip_is_addr_unspecified(&UIP_IP_BUF->srcipaddr)) {
      /* DAD CASE */
      goto discard; 
#endif /* UIP_ND6_DEF_MAXDADNS > 0 */

this logic will bring confusion, especially if you analyze the other ND functions (NUD, address resolution)  .
2016-09-10 10:56:19 +02:00
Nicolas Tsiftes 8bf235ef86 Merge pull request #1836 from mdlemay/dhcp
galileo: Add process to perform DHCP configuration
2016-09-09 16:55:05 +02:00
Nicolas Tsiftes 2c5c7d4f26 Merge pull request #1719 from jcook/master
RPL: Remove useless `else' block as def_route will be removed before if ex…
2016-09-09 16:48:01 +02:00
Michael LeMay 24f23588dd x86: Fix section alignment for EFI binaries
This patch fixes the section alignment specification in the linker script for
the Intel Quark X1000 SoC so that the UEFI GenFw program generates correct EFI
binaries.  See the added comment in quarkX1000.ld for details.
2016-09-08 12:13:28 -07:00
Harald Pichler 5b288a5777 Merge branch 'osd' 2016-09-08 10:33:24 +02:00
Nicolas Tsiftes fa6771f058 Merge pull request #1677 from gebart/pr/lwm2m-instance-list
oma-lwm2m: Add functionality to send object instance list as core link format
2016-09-06 16:50:11 +02:00
Yasuyuki Tanaka 30ddd97124 TSCH: add a sample .csc file and configuration for Cooja mote 2016-09-06 15:14:10 +02:00
Yasuyuki Tanaka 0ff474e393 Fix indentation in nullrdc.c 2016-09-06 15:14:10 +02:00
Yasuyuki Tanaka 6869dc7004 Yield inside busywaiting loops under cooja-ip64 (nullrdc.c)
The while loops waiting ACK_WAIT_TIME and AFTER_ACK_DETECTED_WAIT_TIME
cause infinite loop under the cooja-ip64 platform. This is because
RTIMER_NOW(), rtimer_arch_now(), has been changed not to call
cooja_mt_yield() in it since rtimer was reimplemented as a higher
resolution timer.

In order to avoid the infinite loop, cooja_mt_yield() needs to be
called inside the while loops under the platform as well as the cooja
platform.
2016-09-06 15:14:10 +02:00
Yasuyuki Tanaka 6d51c5f58e Reimplement Rtimer of Cooja mote as a microsecond resolution timer 2016-09-06 15:14:10 +02:00
Yasuyuki Tanaka 0201208664 TSCH: manage busy waiting on Cooja motes 2016-09-06 15:14:10 +02:00
Yasuyuki Tanaka 958ff6e4f6 Fix indentation in cooja-radio.c 2016-09-06 15:14:10 +02:00
Yasuyuki Tanaka 38c5382054 Add timing macros required for TSCH 2016-09-06 15:14:10 +02:00
Yasuyuki Tanaka 671b1cd9b8 Support the radio features required for TSCH 2016-09-06 15:14:10 +02:00
Yasuyuki Tanaka 830753f360 cooja-radio: enable to turn off the turnaround and CCA features 2016-09-06 15:14:10 +02:00
Yasuyuki Tanaka 33e86042e5 Support RADIO_PARAM_LAST_PACKET_TIMESTAMP with get_object() 2016-09-06 15:14:10 +02:00
Yasuyuki Tanaka ca715fdd6b Use appropriate types for "value" of setInt{16,32,64}ValueOf() 2016-09-06 15:14:10 +02:00
Khaled Qorany ddae68bce3 Referring to the ESMRF engine that was recently merged 2016-09-06 11:24:17 +02:00
Simon Duquennoy 406e517d52 Merge pull request #1848 from afonsomota/noprobingfix
fix misplaced bracket causing compilation error when probing is disabled
2016-09-06 08:50:08 +02:00
Mohamed Seliem 1d32a00ebd Fix uip-ds.h table configuration comment
this PR to update uip-ds.h comments, this small change is made to ease the track of Tables implementation places

remove definition of UIP_CONF_DS6_ROUTE_NBU

retire 2 old macros DS6_NBR_NBU, DS6_ROUTE_NBU

Update uip-ds6.h

Update contiki-conf.h

Update contiki-conf.h

Update contiki-conf.h

fix doxygen comment

Update uip-ds6.h
2016-09-05 20:59:36 +02:00
Simon Duquennoy 042d077784 Merge pull request #1768 from mguc/jn516x_exception_handler
JN516x: Exception handler causing infinite loop
2016-09-05 20:50:35 +02:00
Marko Gucanin 93757e810d added space between ) and { 2016-09-05 17:36:33 +02:00
Afonso Oliveira 0217776d6e fixed identantion on code below alteration 2016-09-05 16:24:55 +01:00
Nicolas Tsiftes 8e0ecf9b3a Merge pull request #1802 from marcas756/PullReq-SWITCH_BITS_IN_BYTE_STATIC
Make set_bits_in_byte() static (like for get_bits_in_byte)
2016-09-05 16:50:25 +02:00
Simon Duquennoy 41d2851a55 Merge pull request #1822 from yatch/pr/fix-rpl-udp-for-non-storing
Make it easier to use the Non-Storing mode with the rpl-udp example
2016-09-05 16:48:54 +02:00
Nicolas Tsiftes 7cfbbe97af Merge pull request #1740 from simonduq/pr/tsch-minor
TSCH minor enhancements
2016-09-05 16:33:48 +02:00
Nicolas Tsiftes b69e0f6c66 Merge pull request #1833 from sumanpanchal/cc2520-rssi-issue
CC2520: Added offset to calculate correct RSSI value
2016-09-05 16:18:26 +02:00
Nicolas Tsiftes 61c9c21c5c Merge pull request #1834 from mdlemay/gpio-refactor
galileo: Simplify GPIO APIs and add support for gen. 1
2016-09-05 16:13:20 +02:00
Afonso Oliveira 4c5b70e628 fix misplaced bracket causing compilation error when probing is deactivated (RPL_WITH_PROBING=0) 2016-09-05 14:49:41 +01:00
Antonio Lignan 448c78da5f Zoul: updated ADC[4-5] info and link to wiki with RevA-B delta 2016-09-05 10:34:37 +02:00
Antonio Lignan 5d4b7de426 Zoul: created RE-Mote rev.B platform 2016-09-02 16:53:09 +02:00
Antonio Lignan 3e5b5dca12 Zoul: Updated READMEs 2016-09-01 16:45:16 +02:00
Antonio Lignan e25a62997d Zoul: cleaned headers, doxygen tags and uncrustified 2016-09-01 16:08:01 +02:00
Antonio Lignan 3227360b92 Zoul: Moved specific rev.A examples 2016-09-01 15:16:31 +02:00
Antonio Lignan 89c507f509 Zoul: created RE-Mote rev.A specific profile 2016-09-01 15:04:54 +02:00
Antonio Lignan 6dd17f5eec MSP430/F2xxx: fix ubr msb byte being hardcoded to zero 2016-09-01 10:25:38 +02:00
Harald Pichler 34a9135f83 activate reciver on 2016-09-01 09:34:57 +02:00
Antonio Lignan 26ed666948 Merge pull request #1844 from alignan/pull/zoul-dimmer-ac
Zoul: added driver to control an AC light dimmer with zero-crossing
2016-08-31 17:04:44 +02:00
Antonio Lignan 5e400dd43b Zoul: fixed ac-dimmer interrupt disable pin/port and check interrupt source 2016-08-31 15:36:48 +02:00
Antonio Lignan 8d4888c495 Zoul: added driver to control an AC light dimmer with zero-crossing 2016-08-31 12:20:04 +02:00
Antonio Lignan 4ce322b7b0 Merge pull request #1837 from alignan/pull/servo
Zoul: generic servo driver
2016-08-31 12:00:31 +02:00
Joakim Eriksson 616b65c962 added support for 6-bytes link-layer address 2016-08-27 22:30:32 +02:00
Antonio Lignan bc2ff5b352 Merge pull request #1838 from alignan/pull/fix-tmp102-calc
Zoul: fix TMP102 value conversion
2016-08-26 00:00:59 +02:00
Antonio Lignan 61e8a174db Merge pull request #1828 from alignan/pull/z1-libraries-cleanup
Z1: cleaned up non-required libraries from builds and moved SENSORS d…
2016-08-25 10:54:17 +02:00
Antonio Lignan 32385b2910 Zoul: fix TMP102 value conversion 2016-08-24 16:34:02 +02:00
Antonio Lignan 26c4a81331 Z1: cleaned up non-required libraries from builds and moved SENSORS declaration to its own file 2016-08-24 16:05:38 +02:00
Antonio Lignan 8cc1870663 Zoul: generic servo driver 2016-08-24 14:27:41 +02:00
Harald Pichler 37ea128d65 Merge branch 'osd'
Conflicts:
	cpu/avr/dev/button-sensor.c
2016-08-24 08:07:33 +02:00
Harald c7de6343d9 Merge pull request #5 from piccaso/max-age
Triggerboard: set max-age header
2016-08-24 07:54:13 +02:00
Sumankumar Panchal 25dea7264a CC2520: Added offset to calculate correct RSSI value 2016-08-24 10:21:14 +05:30
Flo eeb90bab77 gets rid of 'deprecated conversion from string constant to char*' 2016-08-24 00:59:47 +02:00
Michael LeMay c276081150 galileo: Add process to perform DHCP configuration
This patch adds a process that is started automatically to request DHCP
configuration.  It also moves the IP configuration ahead of autostart processes
in case some autostart process depends on the IP configuration.
2016-08-23 13:16:39 -07:00
Michael LeMay 4181179985 galileo: Add support for Gen. 1 pinmux and GPIO
This patch adds support for IO pinmuxing and GPIO on first generation
Intel Galileo boards.
2016-08-23 13:02:39 -07:00
Michael LeMay b17a936bf7 galileo: Add board-level abstraction layer for GPIO
This patch adds a HAL for GPIOs so that users of the API can specify
board-level IO pin numbers rather than CPU-level pin numbers.
2016-08-23 13:02:36 -07:00
Michael LeMay 2912559061 galileo: Revise pinmux API to be more intuitive
This patch replaces the pinmux APIs that require users to look up an arbitrary
function number for the desired function of each pin.  The replacement API
functions have intuitive names and permit users to pass board-level IO port
numbers.  The API functions internally convert those to CPU-level port numbers
when necessary.  Furthermore, when configuring a pin to be a digital input or
output, those API functions also perform the corresponding configuration
operation on the CPU-level GPIO port.  The revised APIs halt when users attempt
to configure a currently-unsupported GPIO, specifically those in the GPIO_SUS
port range and those implemented on the expander chip EXP2.  This also means
that such ports are left unconfigured during initialization, whereas the
pinmuxing for them was setup by the old implementation.
2016-08-23 13:02:32 -07:00
Michael LeMay 3043f3956c galileo: Simplify pinmux configuration
This patch refactors the pinmux configuration code for Intel Galileo to simplify
it. This patch also corrects an off-by-one error in how the pin number is
checked in galileo_pinmux_set_pin.
2016-08-23 12:39:21 -07:00
Harald Pichler ec34b8640c bugfix dallas remove first space 2016-08-23 20:51:21 +02:00
Michael LeMay 6a3ce86e10 galileo: Add general protection exception handler
This patch adds a general protection exception handler that prints a
message indicating the faulting instruction and the error code. This is
useful when debugging general protection exceptions.
2016-08-23 11:34:32 -07:00
Flo 3af0cc460c set max-age header 2016-08-22 22:53:01 +02:00
Harald Pichler 0190c261e2 use led1_on 2016-08-22 22:15:41 +02:00
Harald Pichler 6cf4e147ed add noncoresec 2016-08-20 14:32:26 +02:00
Harald Pichler 8b887ca429 add button led bled to project 2016-08-20 14:09:44 +02:00
Harald Pichler a70a51acc2 fake return value to 0 for better range, function rf230_cca have a bug 2016-08-19 18:18:09 +02:00
Harald Pichler 1d2447d69d add noncorsec section 2016-08-18 17:30:39 +02:00
Harald Pichler 12e77a1e58 bugfix cca threshold 2016-08-18 17:26:37 +02:00
Antonio Lignan 6947fc7381 Merge pull request #1826 from alignan/pull/crossval-fix
Zoul: fixed voltage divider relationship
2016-08-17 17:33:07 +02:00
George Oikonomou 6f44fb8c44 Merge pull request #1783 from g-oikonomou/bugfix/cc13xx/contikimac-timings
Adjust ContikiMAC timings for CC13xx PROP mode
2016-08-17 14:06:07 +01:00
Antonio Lignan cb42bafbfb Merge pull request #1756 from g-oikonomou/contrib/cc26xx/new-ccxxwares
Update to latest TI CC13xxware/CC26xxware
2016-08-16 15:44:41 +02:00
Nicolas Tsiftes 4c7d8d0214 Merge pull request #1739 from simonduq/pr/tsch-seqno
Improved TSCH sequence number handling
2016-08-16 14:49:21 +02:00
Nicolas Tsiftes 9fa777d4f4 Merge pull request #1738 from simonduq/pr/mac-seqno-timeout
mac-seqno: add a lifetime to sequence numbers in history
2016-08-16 14:48:21 +02:00
Antonio Lignan 7ddbe640be Merge pull request #1795 from g-oikonomou/contrib/sensniff
Add generic sensniff example and remove legacy sniffers
2016-08-16 14:47:17 +02:00
Antonio Lignan 0a02f0ac7c Zoul: fixed voltage divider relationship 2016-08-16 14:24:13 +02:00
Antonio Lignan 3550d43b47 Merge pull request #1794 from g-oikonomou/bugfix/cc13xx/prop-set-channel
Fix PROP mode channel switching
2016-08-16 12:57:43 +02:00
Harald Pichler 6c7dc58574 make it more flexible to user in other projects 2016-08-16 11:13:57 +02:00
Harald Pichler d3431a0b54 bugfix contiki mac layer droped packets 2016-08-16 11:11:32 +02:00
Harald Pichler 91fcc28b12 Merge branch 'osd' of https://github.com/osdomotics/osd-contiki into osd
Conflicts:
	cpu/avr/dev/button-sensor.c
2016-08-16 10:38:46 +02:00
George Oikonomou acbc482e55 Merge pull request #1824 from bthebaudeau/cc2538-fix-garbled-uart
cc2538: uart: Fix garbled output occurring upon lpm_enter()
2016-08-16 08:47:09 +01:00
Harald Pichler cf40f59843 add pin status 2016-08-15 20:22:49 +02:00
Harald Pichler 265d4e8723 shorter button deflipping time 2016-08-15 18:34:37 +02:00
Benoît Thébaudeau a52a3d94d3 cc2538: uart: Fix garbled output occurring upon lpm_enter()
lpm_enter() must not enter PM1+ if the UART is transmitting. Otherwise,
the UART clock gets disabled, and its TX is broken.

The commit b8b54a033c had already
partially fixed this issue, but it could still occur while transmitting
stop bits because, contrary to UART_FR.BUSY, UART_FR.TXFE takes only the
data bits into account, not the stop bits.

Signed-off-by: Benoît Thébaudeau <benoit.thebaudeau.dev@gmail.com>
2016-08-15 03:07:52 +02:00
Ralf Schlatterbeck 28cb276c70 Merge branch 'osd'
Conflicts:
	apps/arduino/arduino-process.c
	apps/arduino/arduino-process.h
	apps/json-resource/generic_resource.c
	apps/json-resource/generic_resource.h
	apps/time/Makefile.time
	apps/time/resource_gmtime.c
	apps/time/resource_timestamp.c
	apps/time/time.c
	apps/time/time_resource.h
	core/dev/leds.c
	core/lib/petsciiconv.c
	core/net/ip/resolv.c
	core/net/ip/slipdev.c
	core/net/ip/tcpip.c
	core/net/ipv4/uip.c
	core/net/ipv6/uip-ds6.c
	core/net/mac/contikimac/contikimac.c
	core/net/mac/frame802154.h
	core/net/mac/framer-802154.c
	core/net/mac/nullrdc.c
	core/net/rpl/rpl-dag.c
	core/net/rpl/rpl-ext-header.c
	core/net/rpl/rpl-icmp6.c
	core/net/rpl/rpl-mrhof.c
	core/net/rpl/rpl-of0.c
	core/net/rpl/rpl-timers.c
	core/net/rpl/rpl.c
	cpu/avr/Makefile.avr
	cpu/avr/dev/lanc111.c
	cpu/avr/radio/rf230bb/halbb.c
	dev/arduino/arduino-compat.h
	examples/osd/.gitignore
	examples/osd/arduino-dooralert/Makefile
	examples/osd/arduino-dooralert/flash.sh
	examples/osd/arduino-dooralert/run.sh
	examples/osd/arduino-dooralert/sketch.pde
	examples/osd/arduino-merkurboard/Makefile
	examples/osd/arduino-merkurboard/README.md
	examples/osd/arduino-merkurboard/flash.sh
	examples/osd/arduino-merkurboard/project-conf.h
	examples/osd/arduino-merkurboard/run.sh
	examples/osd/arduino-plantobserving/Makefile
	examples/osd/arduino-plantobserving/flash.sh
	examples/osd/arduino-plantobserving/project-conf.h
	examples/osd/arduino-plantobserving/run.sh
	examples/osd/arduino-plantobserving/sketch.pde
	examples/osd/arduino-roomalert/Makefile
	examples/osd/arduino-roomalert/flash.sh
	examples/osd/arduino-roomalert/run.sh
	examples/osd/arduino-roomalert/sketch.pde
	examples/osd/arduino-sketch/Makefile
	examples/osd/arduino-sketch/flash.sh
	examples/osd/arduino-sketch/led_pwm.h
	examples/osd/arduino-sketch/resource_led_pwm.c
	examples/osd/arduino-sketch/run.sh
	examples/osd/arduino-sketch/sketch.pde
	examples/osd/arduino-wateralert/Makefile
	examples/osd/arduino-wateralert/flash.sh
	examples/osd/arduino-wateralert/run.sh
	examples/osd/arduino-wateralert/sketch.pde
	examples/osd/climate/Makefile
	examples/osd/climate/er-example-server.c
	examples/osd/climate/flash.sh
	examples/osd/climate/project-conf.h
	examples/osd/climate/run.sh
	examples/osd/climate/server-only.csc
	examples/osd/climate2/Makefile
	examples/osd/climate2/er-example-server.c
	examples/osd/climate2/flash.sh
	examples/osd/climate2/project-conf.h
	examples/osd/climate2/run.sh
	examples/osd/climate2/server-only.csc
	examples/osd/dual-rgbw-actor/Makefile
	examples/osd/dual-rgbw-actor/flash.sh
	examples/osd/dual-rgbw-actor/run.sh
	examples/osd/dual-rgbw-actor/server-client.csc
	examples/osd/dual-rgbw-actor/server-only.csc
	examples/osd/embedd-vm-merkurboard/Makefile
	examples/osd/embedd-vm-merkurboard/embedd-vm-server.c
	examples/osd/embedd-vm-merkurboard/flash.sh
	examples/osd/embedd-vm-merkurboard/run.sh
	examples/osd/embedd-vm-merkurboard/server-only.csc
	examples/osd/er-rest-example-merkurboard/Makefile
	examples/osd/er-rest-example-merkurboard/README.md
	examples/osd/er-rest-example-merkurboard/er-example-client.c
	examples/osd/er-rest-example-merkurboard/er-example-server.c
	examples/osd/er-rest-example-merkurboard/er-plugtest-server.c
	examples/osd/er-rest-example-merkurboard/flash.sh
	examples/osd/er-rest-example-merkurboard/flashclient.sh
	examples/osd/er-rest-example-merkurboard/project-conf.h
	examples/osd/er-rest-example-merkurboard/run.sh
	examples/osd/er-rest-example-merkurboard/runclient.sh
	examples/osd/er-rest-example-merkurboard/server-client.csc
	examples/osd/light-actor/Makefile
	examples/osd/light-actor/er-example-server.c
	examples/osd/light-actor/flash.sh
	examples/osd/light-actor/pcintkey.c
	examples/osd/light-actor/project-conf.h
	examples/osd/light-actor/run.sh
	examples/osd/light-actor/server-only.csc
	examples/osd/light-shutter-control/Makefile
	examples/osd/light-shutter-control/flash.sh
	examples/osd/light-shutter-control/pcintkey.c
	examples/osd/light-shutter-control/run.sh
	examples/osd/light-shutter-control/server-only.csc
	examples/osd/merkurboard/Makefile
	examples/osd/merkurboard/README.md
	examples/osd/merkurboard/er-example-client.c
	examples/osd/merkurboard/er-example-server.c
	examples/osd/merkurboard/er-plugtest-server.c
	examples/osd/merkurboard/flash.sh
	examples/osd/merkurboard/flashclient.sh
	examples/osd/merkurboard/project-conf.h
	examples/osd/merkurboard/run.sh
	examples/osd/merkurboard/runclient.sh
	examples/osd/native-border-router/Makefile
	examples/osd/native-border-router/border-router-cmds.c
	examples/osd/native-border-router/border-router-cmds.h
	examples/osd/native-border-router/border-router-rdc.c
	examples/osd/native-border-router/border-router.c
	examples/osd/native-border-router/border-router.h
	examples/osd/native-border-router/project-conf.h
	examples/osd/native-border-router/slip-config.c
	examples/osd/native-border-router/slip-dev.c
	examples/osd/native-border-router/tun-bridge.c
	examples/osd/pingtheplug/Makefile
	examples/osd/pingtheplug/er-example-server.c
	examples/osd/pingtheplug/flash.sh
	examples/osd/pingtheplug/pcintkey.c
	examples/osd/pingtheplug/run.sh
	examples/osd/pingtheplug/server-only.csc
	examples/osd/pir-sensor/Makefile
	examples/osd/pir-sensor/flash.sh
	examples/osd/pir-sensor/run.sh
	examples/osd/pir-sensor/server-client.csc
	examples/osd/pir-sensor/server-only.csc
	examples/osd/powerbox/Makefile
	examples/osd/powerbox/er-example-server.c
	examples/osd/powerbox/flash.sh
	examples/osd/powerbox/run.sh
	examples/osd/powerbox/server-only.csc
	examples/osd/pwm-example/Makefile
	examples/osd/pwm-example/er-example-server.c
	examples/osd/pwm-example/flash.sh
	examples/osd/pwm-example/led_pwm.h
	examples/osd/pwm-example/resource_led_pwm.c
	examples/osd/pwm-example/run.sh
	examples/osd/rpl-border-router/Makefile
	examples/osd/rpl-border-router/border-router.c
	examples/osd/rpl-border-router/flash.sh
	examples/osd/rpl-border-router/project-conf.h
	examples/osd/rpl-border-router/run.sh
	examples/osd/rpl-border-router/slip-bridge.c
	examples/osd/runall.sh
	examples/osd/servo-sensor/Makefile
	examples/osd/servo-sensor/er-example-server.c
	examples/osd/servo-sensor/flash.sh
	examples/osd/servo-sensor/project-conf.h
	examples/osd/servo-sensor/run.sh
	examples/osd/servo-sensor/server-client.csc
	examples/osd/servo-sensor/server-only.csc
	examples/osd/slip-radio/Makefile
	examples/osd/slip-radio/flash.sh
	examples/osd/slip-radio/no-framer.c
	examples/osd/slip-radio/project-conf.h
	examples/osd/slip-radio/run.sh
	examples/osd/slip-radio/slip-net.c
	examples/osd/slip-radio/slip-radio-cc2420.c
	examples/osd/slip-radio/slip-radio-sky-sensors.c
	examples/osd/slip-radio/slip-radio.c
	examples/osd/slip-radio/slip-radio.h
	examples/osd/wallclock-time/Makefile
	examples/osd/wallclock-time/flash.sh
	examples/osd/wallclock-time/run.sh
	examples/osd/wirelessplug/Makefile
	examples/osd/wirelessplug/flash.sh
	examples/osd/wirelessplug/run.sh
	examples/osd/wirelessplug/server-client.csc
	examples/osd/wirelessplug/server-only.csc
	platform/avr-atmega128rfa1/apps/raven-lcd-interface/raven-lcd.c
	platform/avr-raven/apps/raven-lcd-interface/raven-lcd.c
	tools/tunslip6.c
2016-08-12 22:04:56 +02:00
Ralf Schlatterbeck 50a34d1235 Fix whitespace 2016-08-12 22:03:44 +02:00
George Oikonomou 3e7177dcc8 Add sensniff example README 2016-08-12 15:58:02 +01:00
George Oikonomou 20dc86c039 Add sensniff travis tests 2016-08-12 15:58:02 +01:00
George Oikonomou ac2dcb8b03 Add sensniff example Makefile 2016-08-12 15:58:02 +01:00
George Oikonomou 4922925c07 Add sensniff support: ev-aducrf101mkxz 2016-08-12 15:58:02 +01:00
George Oikonomou 166f90e4df Add sensniff support: zoul 2016-08-12 15:58:02 +01:00
George Oikonomou 9e91a3832d Merge pull request #1820 from alignan/pull/motelist-firefly
Zoul: added firefly to motelist targets
2016-08-12 13:38:12 +01:00
Yasuyuki Tanaka 8bca703282 Remove RPL_CONF_WITH_NON_STORING definition 2016-08-12 14:05:14 +02:00
Antonio Lignan 23eb3756c0 Zoul: added firefly to motelist targets 2016-08-12 13:21:09 +02:00
Antonio Lignan 1cd39a2621 Merge pull request #1780 from g-oikonomou/bugfix/cc2538/sniffer
Don't flush the CC2538 RF RX FIFO unconditionally
2016-08-12 12:09:12 +02:00
Harald Pichler 70172a9eb8 Merge branch 'osd' of https://github.com/osdomotics/osd-contiki into osd 2016-08-12 07:50:23 +02:00
Harald Pichler 9408743938 move to arduino app 2016-08-12 07:50:17 +02:00
Harald Pichler 6e67d1415c shorter button flipping test 2016-08-12 07:46:30 +02:00
George Oikonomou d8fcaf9dec Add sensniff support: z1 2016-08-12 01:23:51 +01:00
George Oikonomou 3cebc42a2a Add sensniff support: cc13xx/cc26xx 2016-08-12 01:23:51 +01:00
George Oikonomou 525bafcc3c Add sensniff support: openmote-cc2538 2016-08-12 01:23:51 +01:00
George Oikonomou 63941d849a Add sensniff support: jn516x 2016-08-12 01:23:51 +01:00
George Oikonomou 690c299bb0 Add sensniff support: cc2538dk 2016-08-12 01:23:51 +01:00
George Oikonomou 1e6730758d Add sensniff support: cc2530dk 2016-08-12 01:23:51 +01:00
George Oikonomou c5a3a4e05e Add off-the-shelf sensniff drivers
Can be re-used by any platform that uses any of those CPUs
2016-08-12 01:23:51 +01:00
George Oikonomou a8dcb6566e Add sensniff example core files 2016-08-12 01:23:51 +01:00
George Oikonomou 39e8435141 Add 460800 baud rate support to Z1 2016-08-12 01:23:50 +01:00
George Oikonomou 983a618a36 Extend CC13xx PROP mode driver
We now write a dummy LQI in read() and we also add support for `RADIO_PARAM_RX_MODE` in `set_value()`
2016-08-12 01:23:50 +01:00
George Oikonomou d7028652fe Remove legacy sniffer configuration: zoul 2016-08-12 01:23:50 +01:00
George Oikonomou 35c37f356c Remove legacy sniffer configuration: openmote-cc2538 2016-08-12 01:23:50 +01:00
George Oikonomou 4a4b3a344d Remove legacy sniffer configuration: cc2538dk 2016-08-12 01:23:50 +01:00
George Oikonomou 07f984eec2 Remove legacy sniffer references: Docs 2016-08-12 01:23:50 +01:00
George Oikonomou 63417cba0e Remove legacy zoul/CC1200 sniffer example 2016-08-12 01:23:50 +01:00
George Oikonomou 32e4f0f432 Remove legacy CC2538 sniffer example 2016-08-12 01:23:50 +01:00
George Oikonomou fa769b98e9 Remove legacy CC2530 sniffer example 2016-08-12 01:23:49 +01:00
George Oikonomou b0672713bb Remove built-in sniffer support: aducrf101 2016-08-12 01:23:49 +01:00
George Oikonomou a932dfa6df Remove built-in sniffer support: CC2538 2016-08-12 01:23:49 +01:00
George Oikonomou a52d50f332 Remove built-in sniffer support: CC1200 2016-08-12 01:23:49 +01:00
George Oikonomou dbd4f630fd Remove built-in sniffer support: CC13xx PROP mode 2016-08-12 01:23:49 +01:00
George Oikonomou 0de1dc1025 Remove built-in sniffer support: CC2530 2016-08-12 01:23:49 +01:00
George Oikonomou 1a4947499c Merge pull request #1819 from bthebaudeau/cc2538-en-32k-xtal
CC2538: Use the 32.768-kHz crystal if present
2016-08-11 23:48:04 +01:00
George Oikonomou 47265c9305 Merge pull request #1813 from arurke/cc26xx_cc13xx_i2c_fixes
CC26xx/CC13xx fix for burst TX followed by burst RX
2016-08-11 23:47:42 +01:00
Harald Pichler c42a75d9d6 optimize power consumtion 2016-08-11 23:49:45 +02:00
Benoît Thébaudeau 9e03df6cb7 CC2538: Use the 32.768-kHz crystal if present
Enable the 32.768-kHz crystal on all the CC2538 platforms where it is
present in order to get a better time accuracy.

Signed-off-by: Benoît Thébaudeau <benoit.thebaudeau.dev@gmail.com>
2016-08-11 23:49:03 +02:00
Harald Pichler 6a2d13216a add mcu_sleep_off and on 2016-08-11 19:46:33 +02:00
Nicolas Tsiftes 209e16890b Merge pull request #1815 from bthebaudeau/fix-dox-orphan-mods
doxygen: Fix orphan modules
2016-08-11 15:14:35 +02:00
Harald Pichler 542a921e3f initial uplaod 2016-08-11 14:04:29 +02:00
Benoît Thébaudeau ae5205f9e2 doxygen: Fix orphan modules
Signed-off-by: Benoît Thébaudeau <benoit.thebaudeau.dev@gmail.com>
2016-08-10 04:56:15 +02:00
Andreas Urke 8128986ccd Remove unecessary bool 2016-08-09 22:56:53 +02:00
Andreas Urke e1359519ab Fix i2c multiple write bug, as reported by Ron Segal: https://sourceforge.net/p/contiki/mailman/message/34633862/ 2016-08-09 22:56:28 +02:00
Nicolas Tsiftes 2e4c6eef54 Merge pull request #1804 from mdlemay/docker
galileo: Add support for containerized build environment
2016-08-09 15:19:28 +02:00
Nicolas Tsiftes 956497a672 Merge pull request #1805 from mdlemay/ipv6-link-stats
galileo: Build link-stats.c when IPv6 is enabled
2016-08-08 11:39:42 +02:00
Nicolas Tsiftes d43f2e2a34 Merge pull request #1797 from gebart/pr/rpl-func-prototype
core/net/rpl: Fix function declaration isn’t a prototype
2016-08-08 11:38:38 +02:00
Nicolas Tsiftes c535c5b82f Merge pull request #1810 from mdlemay/conf-serial-baud
x86: Support configurable UART baud rate and fix initialization
2016-08-08 11:36:55 +02:00
Michael LeMay bde8eb35ae x86, galileo: Fix UART system call authorization initialization
This patch fixes UART system call authorization initialization (when
protection domain support is enabled) to only initialize the system call
entrypoint and authorization data structures once, prior to per-port
setup. Previously, if two UARTs were configured, the setup procedure for
the second UART would erase the system call authorization for the
first (console) UART, resulting in a crash upon the next attempt to
perform console output.
2016-08-04 16:09:44 -07:00
Harald Pichler 8402b1c151 initial upload, add button 2016-08-03 21:58:02 +02:00
George Oikonomou e0fcbe672f Merge pull request #1809 from simonduq/pr/fix-travis
Fixes https://github.com/contiki-os/contiki/issues/1808
2016-08-03 16:06:53 +01:00
Michael LeMay 31ad67abd7 x86: Support configurable UART baud rate
This patch extends the Intel Quark X1000 SoC UART initialization API to
accept a numeric baud rate specification.
2016-08-03 07:58:51 -07:00
Simon Duquennoy a3c8fe6724 Travis: remove all tests involving TSCH compilation on z1, which resulted in stochastic off-by-2-bytes linker errors 2016-08-03 16:00:31 +02:00
Michael LeMay e50b73c9b1 galileo: Add support for containerized build environment
This patch adds a Dockerfile for building a container configured as a
build environment for Intel Galileo boards.  This patch also provides
documentation for using the containerized build environment.  Finally, it
streamlines the instructions for booting Contiki on Galileo and includes
other documentation refinements.
2016-08-02 20:54:41 -07:00
George Oikonomou 2657c45f07 Merge pull request #1807 from simonduq/pr/tsch-readme
Updated TSCH readme
2016-08-02 21:28:23 +01:00
Simon Duquennoy e4241fbeb9 Updated TSCH readme 2016-08-02 18:07:20 +02:00
Michael LeMay 836fa4d6fa galileo: Build link-stats.c when IPv6 is enabled
This is required by the IPv6 implementation in Contiki OS.
2016-07-31 17:03:42 -07:00
marcas756 520117b188 Make set_bits_in_byte() static (like for get_bits_in_byte) 2016-07-30 12:57:09 +02:00
Joakim Nohlgård e37c522c2f core/net/rpl: Fix more function declaration isn’t a prototype 2016-07-26 15:21:59 +02:00
Simon Duquennoy dbb82f2439 Merge pull request #1158 from bkozak-scanimetrics/contikimac_fix_first_cycle_start
Fixed wrong first cycle_start
2016-07-25 14:57:38 +02:00
Simon Duquennoy cda89aaaf2 Merge pull request #1217 from tiagoshibata/c64_compilation_fixes
Fixes compilation targeting c64
2016-07-25 14:57:24 +02:00
Simon Duquennoy efcf38601c Merge pull request #1429 from wbober/sicslowpan_fixed_header
Allow for using a fixed frame header length in sicslowpan.c
2016-07-25 14:56:49 +02:00
Simon Duquennoy 21387b954f Merge pull request #1493 from simonduq/pr/add-missing-ext-hdr
Insert RPL ext header before sending ICMP, UDP and TCP messages
2016-07-25 14:56:25 +02:00
Simon Duquennoy ff5a4751c8 Merge pull request #1610 from simonduq/pr/tsch-rime
TSCH with Rime
2016-07-25 14:55:37 +02:00
George Oikonomou 9d3e4bc591 Merge pull request #1789 from tidyjiang8/tidy.0718
Update comments: RFC3513 is obsoleted by RFC4921
2016-07-24 15:18:56 +01:00
George Oikonomou 8ab0522cec Fix PROP mode channel switching
If `NETSTACK_CONF_RADIO.set_value(RADIO_PARAM_CHANNEL, ...)` is called when radio is on, it will fail to apply the channel change, because it won't re-send `CMD_PROP_RADIO_DIV_SETUP` and `CMD_PROP_FS`. This commit fixes this condition, by making sure the correct commands are sent to the radio.
2016-07-24 03:39:13 +01:00
Benoît Thébaudeau 901c45e687 Merge pull request #1793 from sumanpanchal/cc2538-i2c
Minor data type correction.
2016-07-22 22:02:20 +02:00
Sumankumar Panchal 3bb58b7c82 Minor data type correction. 2016-07-22 22:49:49 +05:30
Simon Duquennoy f23c59644c Merge pull request #1721 from sumanpanchal/openmote-tsch
TSCH port for CC2538 based platforms.
2016-07-22 16:56:43 +02:00
Sumankumar Panchal 6dfd358821 TSCH port for CC2538 based platforms. 2016-07-22 09:38:25 +05:30
Kitty(chun hua) Jiang b5bc140680 Update comments: RFC3513 is obsoleted by RFC4921 2016-07-18 17:29:16 +08:00
George Oikonomou 2039b3a552 Use ccaInfo.ccaState to decide whether CCA is complete
This commit changes the logic of `get_cca_info()` in the CC26xx IEEE mode driver. We now use the command's return status bits to determine whether the radio's CCA monitoring function has concluded, instead of drawing conclusions based on RSSI readings.
2016-07-17 20:19:13 +01:00
George Oikonomou 16f56abfad Wait for a valid RSSI reading in CC13xx/CC26xx RF drivers
As discussed in #1341, the current CC13xx/CC26xx IEEE mode driver sends `CMD_GET_RSSI` once and returns the RSSI reading uncondtionally. This happens within the `get_rssi()` function.

This logic is broken if `get_rssi()` is called with the radio off. The function will make sure to turn on the radio first, but it does not make sure the RSSI reading is valid, which only happens a number of symbol periods after the radio enters RX. The outcome is that `NETSTACK_RADIO.get_value(RADIO_PARAM_RSSI, ...)` will always return -128 (meaning that RSSI is unavailable) if the radio was off at the time of calling the function.

The same condition affects the prop mode driver.

This commit changes the logic of `get_rssi()`:
* For PROP mode, if `CMD_GET_RSSI` returns an invalid RSSI, we send it again. For unknown reasons, `CMD_GET_RSSI` on occasion returns 0, so we ignore that value too.
* For IEEE mode, we use `CMD_IEEE_CCA_REQ` and we inspect the value of `ccaInfo.ccaEnergy` of the return structure. If the value is 0x02 (Invalid), we send the command again.

Fixes #1341
2016-07-17 18:20:22 +01:00
George Oikonomou 94413f99fe Shrink ND cache and routing table for the CC26xx web demo 2016-07-17 01:31:21 +01:00
George Oikonomou e7c5c36090 Change CCxxware submodule URLs
We now host both CCxxware repos under contiki-os, so we change the submodule URLs accordingly.
2016-07-17 00:26:52 +01:00
George Oikonomou eec890d60e Update CC26xxware to v2.24.02.17202 2016-07-17 00:26:52 +01:00
George Oikonomou fd82603786 Update CC13xxware to v2.04.02.17240 2016-07-17 00:26:52 +01:00
George Oikonomou dc1f9fe010 Simplify MODESEL value determination 2016-07-17 00:26:52 +01:00
George Oikonomou 9839b91be5 Enable the ROM bootloader in our examples 2016-07-17 00:26:52 +01:00
George Oikonomou 4495d14702 Make ROM bootloader configurable through contiki- or project-conf.h 2016-07-17 00:26:52 +01:00
George Oikonomou 01590088d3 Update to latest CCxxwares: Srf06+EM drivers 2016-07-17 00:26:52 +01:00
George Oikonomou f6437b6086 Update to latest CCxxwares: Sensortag drivers 2016-07-17 00:26:52 +01:00
George Oikonomou 5de7b1bbac Update to latest CCxxwares: Launchpad drivers 2016-07-17 00:26:51 +01:00
George Oikonomou c42cb2b0cb Update to latest CCxxwares: common drivers 2016-07-17 00:26:51 +01:00
George Oikonomou ccba6bdb20 Update cpu files to reflect API in latest CCxxware versions 2016-07-17 00:26:51 +01:00
George Oikonomou 0e4c02bf3b Update ChipInfo and OSC macros 2016-07-17 00:25:18 +01:00
George Oikonomou f68b77fdfa Remove ROM AUX timer macros
They have been undefined in CCxxwares
2016-07-17 00:25:17 +01:00
George Oikonomou 171fe8d08e Adjust GPIO macros to reflect API in latest CCxxware 2016-07-17 00:25:17 +01:00
George Oikonomou 788cb1e119 Move ROM function macros to separate file 2016-07-17 00:25:17 +01:00
George Oikonomou 568973f6ec Don't flush the CC2538 RF RX FIFO unconditionally
After reading a frame, `read()` checks the status of the RX FIFO:

* If an overflow is detected, the FIFO gets flushed
* If there are more frames in the FIFO, the `cc2538_rf_process` will get polled again in order to read out the next frame.

#1550 changed `read()`, which now performs the above check for non-poll mode, but it then flushes the FIFO unconditionally. Therefore, if there are two or more frames in the FIFO, they will get flushed before the `cc2538_rf_process` has had a chance to read them out. This results in missed frames.

Reproducing this is trivial: Build a CC2538 sniffer and see how it will never show you .15.4 ACK frames. ACK reception completes while `read()` is still streaming the previous captured frame to the host. Upon completion, the FIFO will get flushed and the ACK will get lost.

This pull proposes removing the unconditional flush and reverting to the original logic for non-TSCH operation.

Pinging @thomas-ha here for input regarding poll mode.

This pull sits on top of #1778
2016-07-17 00:24:47 +01:00
Benoît Thébaudeau c05665a16b Merge pull request #1778 from g-oikonomou/contrib/cc2538/rf-driver-code-style
Improve code style of the CC2538 RF driver
2016-07-17 01:22:21 +02:00
George Oikonomou c87e579b06 Adjust ContikiMAC timings for CC13xx PROP mode
#1684 slightly varied RF startup time and, as a result, threw ContikiMAC timing configuration off. This manifests itself with very poor CC13xx PROP mode radio performance, as documented in #1747.

This pull fixes this bug by slightly increasing ContikiMAC's inter-packet interval. This gives the receiver a little more time to respond with an ACK to unicast frames.

Fixes #1747
2016-07-17 00:04:07 +01:00
George Oikonomou dcad5e7e3f Merge pull request #1727 from g-oikonomou/contrib/cc26xx/trng
Add CC13xx/CC26xx TRNG Support
2016-07-16 23:34:53 +01:00
George Oikonomou 7fdb9849de Remove unnecessary parentheses 2016-07-16 22:35:23 +01:00
George Oikonomou f1c37b309a Merge pull request #1779 from atiselsts/bugfix/cc26xx/rf_poll_mode
CC26xx: enable MCU sleeping while transmitting if and only if not in poll mode
2016-07-16 20:02:43 +01:00
George Oikonomou fe571c7dc3 Merge pull request #1754 from atiselsts/enhancement/cc26xx_reduced_guard_time
CC26xx: change default TSCH guard time to 1.8ms
2016-07-16 19:47:16 +01:00
George Oikonomou f1637ba74d Merge pull request #1781 from atiselsts/bugfix/tsch/delayed_detection
TSCH: add RADIO_DELAY_BEFORE_DETECT to rx guard time when waiting for a packet to be received
2016-07-16 19:46:09 +01:00
Atis Elsts 2fe4b4d5bb CC26xx: enable MCU sleeping while transmitting if and only if not in poll mode 2016-07-16 18:22:20 +01:00
Atis Elsts 081ec100a4 TSCH: add RADIO_DELAY_BEFORE_DETECT to rx guard time when waiting for a packet to be received 2016-07-16 18:08:41 +01:00
George Oikonomou c359e98bf1 Change mac_timer_init() to static
We also move the function to a different location so we won't have to provide the prototype separately
2016-07-16 17:11:58 +01:00
George Oikonomou 6ef9509dfb Change get_sfd_timestamp() to static
We also move the function to a different location so we won't have to provide the prototype separately
2016-07-16 17:11:57 +01:00
George Oikonomou 833dc89f7c Fix code style 2016-07-16 17:11:57 +01:00
George Oikonomou 0313f9abf1 Merge pull request #1751 from atiselsts/bugfix/cc26xx_etimer_sleep
CC26xx: fix a regression in and refactor LPM code
2016-07-16 14:45:56 +01:00
Nicolas Tsiftes 8a5886dfa1 Merge pull request #1767 from simonduq/pr/missing-return
RPL: added missing return, to not join instances with unsupported MOP
2016-07-15 21:10:57 +02:00
Nicolas Tsiftes afa8125913 Merge pull request #1777 from herjulf/master
Fix README.md not reference GPL
2016-07-15 20:30:06 +02:00
Antonio Lignan 0d0e726b38 Merge pull request #1764 from alignan/pull/zoul-dht22
Added DHT22 sensor to Zoul-based platforms
2016-07-15 12:50:34 -05:00
Robert Olsson fbf3daa564 Fix README.md not reference GPL 2016-07-15 17:44:20 +02:00
George Oikonomou d36c8762c1 Merge pull request #1776 from herjulf/master
Removed unused file platform/avr-rss2/dev/ds18b20.c
2016-07-15 15:51:51 +01:00
Robert Olsson a8aa778b31 Removed unused file platform/avr-rss2/dev/ds18b20.c 2016-07-15 13:17:40 +02:00
Joakim Nohlgård f16f5b5241 squash clean up left overs 2016-07-09 10:39:23 +02:00
Joakim Nohlgård 6b238873ef squash move rest-engine timers to activate timer 2016-07-09 10:34:23 +02:00
Marko Gucanin 1fc9bbe315 added { } 2016-07-08 16:25:34 +02:00
Joakim Nohlgård e7070a5f79 rest-engine: Allow adding periodic resources after starting REST engine
Without this fix, any periodic resources added after the REST engine was
already running were never started.
2016-07-06 19:18:34 +02:00
Marko Gucanin 1a1d17143b return from exception handler if E_EXC_SYSCALL is generated 2016-07-06 16:28:47 +02:00
Marko Gucanin 74d04562df Revert "removed exception handler for SYSCALL, causing an infinite loop after calling vAHI_SwReset()"
This reverts commit c4def60cdd.
2016-07-06 15:45:15 +02:00
Oliver Schmidt 98a795b967 Merge pull request #1730 from groessler/something_to_pull
Some 6502 target changes
2016-07-06 09:17:39 +02:00
Simon Duquennoy 80b9bfea93 Merge pull request #1723 from gebart/pr/ieee802154-addr-mode-bugfix
core/net/mac/frame802154: Fix typo in PAN ID compression condition
2016-07-05 18:10:21 +02:00
Marko Gucanin c4def60cdd removed exception handler for SYSCALL, causing an infinite loop after calling vAHI_SwReset() 2016-07-05 16:44:24 +02:00
Simon Duquennoy 4ceaaba4bd RPL: added missing return, to not join instances with unsupported MOP 2016-07-05 12:13:46 +02:00
Christian Groessler 4373aecec2 Tag non-file goals as ".PHONY" 2016-07-05 00:47:52 +02:00
Harald Pichler e534bcaa25 bugfix dht11 config 2016-07-04 20:26:06 +02:00
Joakim Nohlgård 6f8306a465 core/net/mac/frame802154: Fix typo in PAN ID compression condition 2016-07-04 18:18:55 +02:00
Antonio Lignan d5e2a779d4 Added DHT22 sensor to Zoul-based platforms 2016-07-04 18:00:09 +02:00
Nicolas Tsiftes c9deeb443a Merge pull request #1757 from simonduq/pr/br-http-nonstoring
RPL border HTTP server: support for non-storing
2016-07-01 15:39:17 +02:00
Simon Duquennoy 5d7ce4e9f2 Merge pull request #920 from cetic/pr-slip-queue
Support more than one pending slip message
2016-07-01 13:50:18 +02:00
Simon Duquennoy 5230562f1f Merge pull request #1761 from MohamedSeliem/patch-1
remove duplicate include
2016-07-01 13:38:10 +02:00
Mohamed Seliem 5d99008afb remove duplicate include
Update uip-ds6-nbr.h
2016-07-01 11:12:52 +02:00
Antonio Lignan 23a0449a97 Merge pull request #1753 from g-oikonomou/bugfix/cc26xx/missing-include
Add missing include
2016-06-30 22:53:45 +02:00
Simon Duquennoy 7a1576815e rpl-tsch example: use RPL non-storing mode 2016-06-30 18:15:23 +02:00
Antonio Lignan 6360a09cc7 Merge pull request #1726 from feshie/pr-zoul-motes-flash-fix
zoul: Add support for flashing to multiple devices
2016-06-30 12:13:41 +02:00
Antonio Lignan 17d784ead3 Merge pull request #1745 from alignan/pull/z1-contiki-conf
Minor changes to z1/contiki-conf.h
2016-06-30 09:47:16 +02:00
George Oikonomou 66a2ecb19e Merge pull request #1755 from atiselsts/bugfix/cc26xx/fast_startup
CC26xx: always request HF crystal oscillator at radio on()
2016-06-29 23:51:04 +01:00
Simon Duquennoy 00f2344b4a RPL insert_srh_header: return success when no SRH is needed because the destination is a direct child 2016-06-29 17:26:01 +02:00
Simon Duquennoy d73b229624 Fix and cleanup RPL ext header handling 2016-06-29 17:26:01 +02:00
Simon Duquennoy e584a54608 Insert RPL ext header in tcpip_ipv6_output for consistency 2016-06-29 17:25:10 +02:00
Simon Duquennoy 3e987ec138 Border router: include RPL links in HTTP reply when non-storing mode is enabled 2016-06-29 17:07:00 +02:00
Atis Elsts b6617f17c5 CC26xx: always request HF crystal oscillator at radio on() 2016-06-29 16:41:33 +03:00
Simon Duquennoy 5eb022fdd8 Merge pull request #1750 from yatch/pr/improve-rpl-ext-hdr
Improve RPL extension headers handling
2016-06-29 10:38:17 +02:00
Atis Elsts 1e4141b589 CC26xx: change default TSCH guard time to 1.8ms 2016-06-29 01:14:12 +03:00
Atis Elsts 9caaf26012 CC26xx: fix a regression in and refactor LPM code 2016-06-29 01:03:06 +03:00
Yasuyuki Tanaka ffdc53718d RPL: code cleanup (rpl-ext-header.c) 2016-06-27 20:57:48 +02:00
Yasuyuki Tanaka 13f18fd842 RPL: update uip_ext_len whenever moving to next header (rpl-ext-header.c) 2016-06-27 20:57:48 +02:00
Yasuyuki Tanaka 5a79bad4b1 RPL: prevent unintended memory access (rpl_remove_header)
When it goes to the default label in the switch statement of
rpl_remove_header(), UIP_EXT_BUF does not always point to an IPv6 extension
header. "Move to next header" process should be done only in case of
UIP_PROTO_DESTO. Otherwise, it returns with doing nothing.
2016-06-27 20:57:48 +02:00
Yasuyuki Tanaka e361c49f14 RPL non-storing: fix a bug causing an infinite loop
It falls into an infinite loop if it goes to the default label in the switch
statement of rpl_srh_get_next_hop() or rpl_process_srh_header().
2016-06-27 20:57:48 +02:00
Arthur Fabre ab1652648e zoul: Add support for flashing to multiple devices
This adds support for flashing to multiple devices, by implementing the
$MOTES option used by the Z1.
This replaces the $PORT interface, as it only allowed flashing to one
device at a time, and the $MOTES interface was still used for other
tasks (such as getting a list of connected devices).

A foreach loop is used to dynamically create an upload rule per device
that needs to be flashed.
The "main" upload rule depends on the device specific ones.
This allows for parallel flashing.

The PORT variable can still be sued for backwards compatibility.

Changed the MOTES variable that makes a $(shell) call to not be
recursively expanded.
2016-06-27 11:23:45 +01:00
Antonio Lignan 108e43b103 Made configuration parameters easily overridable to be consistent with Travis CI tests 2016-06-25 23:17:26 +02:00
Antonio Lignan 99822545c5 Added BOARD_STRING to the Z1 platform 2016-06-24 23:58:32 +02:00
Antonio Lignan 0034322fe0 Made configuration parameters easily overridable from project-conf.h (without having to undef first) 2016-06-24 23:54:08 +02:00
Antonio Lignan 1002b7ffee Fixed spacing 2016-06-24 23:36:40 +02:00
Antonio Lignan 442e1be391 Moved project-conf.h inclusion to the top of contiki-conf.h 2016-06-24 23:34:23 +02:00
Simon Duquennoy 54957e4e03 mac-seqno: add a lifetime to sequence numbers in history 2016-06-24 11:23:19 +02:00
Simon Duquennoy 27b20b09a3 TSCH: enable adaptive time synchronization by default 2016-06-23 22:39:54 +02:00
Simon Duquennoy 15dc86aeb1 TSCH: reduce keep-alive traffic as we get more accurate drift estimates 2016-06-23 22:39:44 +02:00
Simon Duquennoy beb532e7e8 TSCH: use sequence number only for unicast data frames 2016-06-23 22:36:00 +02:00
Simon Duquennoy ab706a6f33 TSCH: map RPL trickle interval to TSCH EB period 2016-06-23 18:48:01 +02:00
Simon Duquennoy ee60355c9c TSCH: implement off() 2016-06-23 18:38:12 +02:00
Simon Duquennoy b1dc8205f0 TSCH: minor logging enhancement 2016-06-23 18:37:42 +02:00
Simon Duquennoy 5a1a8e84d8 TSCH: start scheduling keep-alives only after tsch_is_associated is set 2016-06-23 18:36:04 +02:00
Simon Duquennoy 1acb69e280 TSCH: keep track of Rx channel as packetbuf attribute 2016-06-23 18:35:16 +02:00
Simon Duquennoy f1922c13b6 TSCH: use standard-compliant mac-squence module rather than custom duplicate detection 2016-06-23 18:21:05 +02:00
Christian Groessler c26085ec8c Some 6502 target changes
- platform/atarixl/Makefile.atarixl: put two more objects into high memory
- platform/atarixl/contiki-conf.h: define WWW_CONF_WGET_EXEC
- tools/6502/Makefile: add 'clean' target; remove unused CONTIKI define
2016-06-17 16:42:50 +02:00
George Oikonomou de18c16c9f Add CC13xx/CC26xx RNG support to the build 2016-06-15 10:32:03 +01:00
George Oikonomou fd9d878e1d Implement random.h API for the CC13xx/CC26xx 2016-06-15 10:32:03 +01:00
George Oikonomou bb4056903c Add CC13xx/CC26xx TRNG driver 2016-06-15 10:32:03 +01:00
George Oikonomou adfeaa5500 Add missing include 2016-06-15 10:31:55 +01:00
George Oikonomou f8864c67fd Add TRNG CCxxware macros 2016-06-15 10:30:17 +01:00
George Oikonomou 678f4344d2 Add missing include 2016-06-13 12:04:47 +01:00
Tiago Koji Castro Shibata c2a0f739f7 Compilation targeting c64
Adds some casts required by cc65 compiler and small fixes
2016-06-12 21:16:01 -03:00
Pablo Corbalán 910f828975 Remove unneeded state refresh and set reachable timer upon adding a nbr 2016-06-12 18:40:13 +01:00
Pablo Corbalán 373e5653e6 uIPv6: Make sure dest address is not multicast before refreshing the state of a neighbor 2016-06-12 18:40:12 +01:00
Pablo Corbalán 0fb47d0a2d Refresh nbr reachable state after received IPv6 unicast message 2016-06-12 18:40:04 +01:00
jcook d52cf767e5 Remove useless `else' block as def_route will be removed before if existed. 2016-06-12 06:45:04 +02:00
Simon Duquennoy 63565b109d Fix TSCH_AUTOSELECT_TIME_SOURCE to work with 2-byte addresses and with the new nbr_table_add_lladdr interface 2016-06-10 20:59:42 +02:00
Simon Duquennoy 809883e632 Making example tsch-rime more flexible 2016-06-10 20:59:40 +02:00
Simon Duquennoy 78f04fda83 Added example of TSCH used with Rime 2016-06-10 20:58:57 +02:00
Simon Duquennoy ac16fb9e2b TSCH fixes for the short-address case 2016-06-10 20:58:40 +02:00
Billy Kozak ac6a1c5255 Fixed wrong first cycle_start
The first time that powercycle() runs, cycle_start is incremented
by CHECK_TIME twice which causes the second cycle to be late.

This commit fixes this.
2016-06-07 08:13:18 -06:00
Joakim Nohlgård 14cdb30886 oma-lwm2m: Only send active instances 2016-05-24 20:00:56 +02:00
Joakim Nohlgård 84cd7a4e92 oma-lwm2m: Add functionality to send object instance list as core link format 2016-05-24 20:00:56 +02:00
Yasuyuki Tanaka 15d30b1125 Make PcapExporter record timestamps with preserving packet intervals 2016-03-30 18:26:20 +02:00
Wojciech Bober c946c1ccbb Fixed unsused variable warning when SICSLOWPAN_CONF_FRAG is undefined 2016-02-15 09:35:27 +01:00
Wojciech Bober 7d60fdc8b5 Allow for using a fixed frame header length.
When SICSLOWPAN_FRAMER_HDRLEN is defined its value is used
as a frame header length. This allows for using sicslowpan
without calling a framer. This is usefull if framer is not
used on a given platform or when header length is always
the same.

In addition this commit also fixes an inline define.
2016-02-15 09:35:27 +01:00
Laurent Deru b6139aabe3 Support more than one pending slip message 2014-12-19 11:25:19 +01:00
harald42 19561efacb update project to coap 13 2014-11-14 15:59:22 +01:00
harald42 dfa4da2e98 initial upload 2014-11-14 11:02:45 +01:00
harald42 ee1759ba4a initial upload 2014-11-14 10:46:30 +01:00
harald42 114d7e883a Merge branch 'master' of https://github.com/osdomotics/osd-contiki 2014-10-23 11:07:48 +02:00
harald42 408d1cabfe initial upload 2014-10-23 11:06:25 +02:00
harald42 8ed94bf819 initial upload 2014-10-11 22:53:08 +02:00
Billy Everyteen 9f4f828976 initial upload 2014-09-18 15:08:55 +02:00
harald42 2ae3d60203 Merge pull request #1 from powermik/UNSUPPORTED_MADIA_TYPE
UNSUPPORTED_MADIA_TYPE is a typo
2014-08-05 07:17:04 +02:00
powermik d7a6d8560a UNSUPPORTED_MADIA_TYPE is a typo 2014-08-04 20:14:40 +02:00
Jim Paris e09abcaa96 Increase fixed filename sizes in SLIP tunnels
Long serial port names like
  /dev/serial/by-id/usb-FTDI_FT230X_Basic_UART_DN0038W8-if00-port0
cause crashes.  This is the simplest fix to avoid the problem.
2014-07-28 11:49:45 +02:00
harald fa53bc3241 use Arduino like optotriac driver 2014-07-15 13:35:31 +02:00
harald c25dc70d26 simplify code, bugfixes PE3 2014-07-15 08:23:33 +02:00
harald ccaae9cd5c set all colors to the same pin PE5 2014-07-15 08:20:46 +02:00
harald cead73a4d6 optriac sensors use Arduino API 2014-07-14 20:31:04 +02:00
harald ff8b6d933b change port manipulation to ardino commands and lets change the pin at runtime possible 2014-07-11 11:25:22 +02:00
Ralf Schlatterbeck 1aa694bba2 Turn off JTAG in adc_init 2014-06-30 14:25:33 +02:00
Ralf Schlatterbeck f61d0b2e1e Use PROCESS_PAUSE macro 2014-06-30 10:25:47 +02:00
Ralf Schlatterbeck 4b984153ab Fix A0-A5 ADC constants, use in example sketch 2014-06-30 10:24:49 +02:00
Ralf Schlatterbeck 60156d1c48 Fix off-by-one error in digitalPinToTimer 2014-06-29 18:06:48 +02:00
Ralf Schlatterbeck d8bc9f761c Remove obsolet macro in example 2014-06-29 17:32:00 +02:00
Ralf Schlatterbeck 77c02d58f8 Refactor A/D conversion in adc.c
Now the necessary settings are in adc.h. Refactored to allow repeated
ADC reads without reinitialization. Arduino allows setting
analogReference, this is now also implemented.
ADC is now initialized to sane values in apps/arduino/arduino-process.c
dev/arduino/arduino-compat.h now has all hardware independent settings
for arduino (some moved from platform/osd-merkur/dev/hw-arduino.h).
turnOffPWM re-implemented with hw_timer, removed from wiring_digital.c
ADC-specific arduino stuff moved to arduino-compat.h
Arduinos wiring_analog no longer necessary.
arduino-sketch example now reads analog inputs 1 and 5 using analogRead.
2014-06-29 17:26:15 +02:00
Ralf Schlatterbeck 6c06f43417 Minor optimisations of timer init 2014-06-29 17:12:13 +02:00
Ralf Schlatterbeck 4643c5d02d Factor resources, fix time
Now there is a generic resource that can generate and parse
application/json as well as text/plain. It can be re-used, only the
from_string and to_string routines have to be written and the resource
properly set up. A new resource format is specified, see
GENERIC_RESOURCE in, e.g., examples/osd/pwm-example. This is now used in
all my examples, namely pwm-example, arduino-sketch, wallclock-time.

There was an off by one error for the month in time formatting (in
gmtime and localtime). And the leap-year computation was broken. Both
fixed now, so we get a correct date. For localtime we are still 2 hours
off because daylight saving isn't implemented yet.

Also renamed gmtime to utc.
2014-06-27 22:25:51 +02:00
Ralf Schlatterbeck 9df7ab3875 Fix leap year computation 2014-06-27 22:10:19 +02:00
Ralf Schlatterbeck 72da6659ed Inline timer init functions, no static storage
Hardware init function profit a great deal from being inlined if the
given parameters are constant -- which is the common use-case, we could
probably call this for all timers and still have less overhead. The
hwtimer_pwm_ini (which calls hwtimer_ini) gets completely computed at
compile-time resulting only in the register settings of hwtimer_ini.

This is now possible because we get rid of static storage for the
max_ticks and instead compute this in hwtimer_pwm_max_ticks from the
timer register settings.
2014-06-26 20:37:34 +02:00
Ralf Schlatterbeck c5d25f5bfe Last minute bug-fix of arduino-sketch
... happens when not completing testing before pushing commit :-)
2014-06-26 19:07:48 +02:00
Ralf Schlatterbeck f0f5391409 Make Arduino timer stuff work on Contiki
New discovery: Contiki also uses timer 0. With almost the same interface
as Arduino. So we now completely get rid of wiring.c (only the main
file, the other wiring_xxx stay) and implement Arduino timer, delay, etc
in terms of the corresponding Contiki routines. Verified that now delay
works as expected. The LED in examples/osd/arduino-sketch blinks!

Before this, the arduino_init routine in wiring.c destroyed the timer-0
initialization of contiki, making both, contiki timer implementation
*and* contiki timer implementation fail if the arduino_init routine was
called. Now both work.
2014-06-26 18:37:13 +02:00
Ralf Schlatterbeck b6e20bf6c0 Fixes for platform timer code
Some platforms are missing timer channels, this is now left to the
(missing) preprocessor definitions on those platforms, no
platform-specific defines needed anymore.
Also fix usage of timer counter register 3 (hardcoded) in
cpu/avr/dev/clock.c -- this code isn't used on many platforms as it
requires a very special quartz clock frequency but this now also uses
the platform timer specification.
2014-06-26 18:00:30 +02:00
Ralf Schlatterbeck e65dabb119 Add Arduino compatibility layer
We can now directly compile arduino sketches (.pde) files.
Arduino compatible analogWrite works now.
But there is still a long way to go, serial I/O and timer stuff (delay,
millis etc) currently don't work (not tested but I don't expect this to
work).
It can be used in an arduino sketch or in a normal contiki program.
We get a PWM frequency of 490.2 Hz (a period of 2.040 ms), that's
Arduino compatible. If you need different frequencies see native timer
usage in examples/osd/pwm-example
In a contiki program you have to call arduino_pwm_timer_init to
initialize the timer before pwm works. The arduino sketch wrapper
already does this.
For running a sketch, see examples/osd/arduino-sketch
2014-06-26 11:00:01 +02:00
Ralf Schlatterbeck 87903b2e89 Allow compilation of c++ files (extension .cpp) 2014-06-26 08:37:19 +02:00
Ralf Schlatterbeck 5991c3e3db Initial implementation of avr hardware timer
Mainly for PWM use for now.
With example to set the LED to different brightness via COAP.
We switch the LED with 50 kHz (20µs) in this example.
2014-06-22 13:32:05 +02:00
harald d192553309 add i2c driver from Ingo 2014-06-21 21:30:48 +02:00
Benoît Thébaudeau db60afb2fb leds: Add the leds_set() function
The leds_set() function is added on top of leds_arch_set() in order to have a
means of displaying a pattern on a set of LEDs, while keeping the ENERGEST
information up to date, which would be missing with a direct call to
leds_arch_set().

Signed-off-by: Benoît Thébaudeau <benoit.thebaudeau@advansee.com>
2014-06-18 12:39:02 +02:00
Nicolas Tsiftes df0cc061f6 Do not copy more bytes than the filename string contains. 2014-06-18 11:37:34 +02:00
Rémy Léone a952a96b6e Closing doxygen groups
(cherry picked from commit 25c8b0835d)
2014-06-02 14:54:17 +02:00
harald 45dee77092 bugfix read analog 2014-06-02 13:46:54 +02:00
harald b398ab9288 set 0xABCD default panid 2014-06-02 13:44:54 +02:00
Ralf Schlatterbeck e88f60feee Make HW timer for contiki rtimer configurable
... and configure osd platform to use timer 5. With the new
configuration we can use timer 3 for generating hardware PWM.
2014-05-31 16:17:07 +02:00
Ralf Schlatterbeck 478d91ac53 Fix lots of compiler warnings 2014-05-31 15:52:33 +02:00
Ralf Schlatterbeck 47d1c2a74d Merge branch 'master' of github.com:osdomotics/osd-contiki 2014-05-29 17:37:00 +02:00
Ralf Schlatterbeck f48566d51f Add wallclock time handling
New application and new example.
We use the built-in timer routines and add an offset to get the
wallclock time. The offset can be set by time-changing routines
(currently only settimeofday).
We also maintain an offset for timezone handling but this isn't
currently fully implemented.
2014-05-29 17:31:19 +02:00
harald 0c29b2b7db initial upload 2014-05-27 11:34:10 +02:00
harald 2d424bd259 initial upload 2014-05-27 11:33:10 +02:00
harald 078faa39d4 cleanup code 2014-05-27 11:31:54 +02:00
harald 90ed9d14d2 add Arduino pin definition and commands 2014-05-22 16:25:15 +02:00
harald 2a63d0a972 bugfix define panid 2014-05-15 15:34:05 +02:00
Ralf Schlatterbeck be01bf77a9 Allow changing bootloader_get_mac address
Current default in the Makefile is the *new* bootloader address.
But for backward compatibility we've modified the run*.sh files
to use the old address. The run*.sh also now explain how to change
the default.
2014-05-13 16:56:59 +02:00
harald 0a5872e261 change resources to simple and make climate2 default 2014-05-08 13:04:27 +02:00
harald 5fcac26e80 get s/button ->show button status 0/1 2014-04-30 15:20:25 +02:00
harald 40bd9950d1 add 0.5s delay between off and on 2014-04-24 13:55:21 +02:00
harald 59bd18df7d add timer and shutter functionality 2014-04-23 16:13:58 +02:00
harald 598a0da30d change to port F6,F7 2014-04-23 16:13:23 +02:00
harald ac79f1b596 change battery and cpttem format to xx.xx 2014-04-16 09:31:48 +02:00
harald b0c8597dbc add shutter control resources, reset,timer 2014-04-15 17:29:05 +02:00
harald b6e0ef1d95 add contiki led, remove led1,led2 2014-04-15 07:27:33 +02:00
harald f77717158d simplify project-conf.h 2014-04-15 07:27:33 +02:00
harald f9d67ed10c bugfix statusled include 2014-04-15 07:27:33 +02:00
harald f40bf6d803 bugfix includes and names 2014-04-15 07:27:33 +02:00
harald 59713f6d3b adapt new names and api 2014-04-15 07:27:33 +02:00
harald 67dba47c23 remove not needed binary files 2014-04-15 07:27:33 +02:00
harald aa568a28a3 add /s/cputemp resource 2014-04-15 07:27:32 +02:00
harald f9abb44d6e add /p/name and p/model resource, remove info 2014-04-15 07:27:32 +02:00
harald 86cd1ec02f remove t4 driver at the moment, config problem 2014-04-15 07:27:32 +02:00
Marcus Priesch 992e54fe25 Factored to support configurable amount of pwm's, fixes 2014-04-15 07:27:32 +02:00
Marcus Priesch bf6f388691 initial check in 2014-04-15 07:27:32 +02:00
harald 67783600aa compile all osd-examples 2014-04-15 07:27:32 +02:00
harald 251abdda29 simplified led resource to one led actuator 2014-04-15 07:27:32 +02:00
harald d87287b745 initial upload 2014-04-15 07:27:32 +02:00
harald d8d0a507e1 remove link status and bugfix params.c 2014-04-15 07:27:32 +02:00
harald 11b7022ce6 add patch milligrad ds1820 from Jan-Benedict Glaw 2014-04-15 07:27:32 +02:00
harald 87028c1f60 temp and hum sensors values xxxx -> xx.xx 2014-04-15 07:27:32 +02:00
harald f8c298a495 add dhtxx temp coap 2014-04-15 07:27:32 +02:00
harald 51f179eacf config panid over defines 2014-04-15 07:27:32 +02:00
harald 1f586c7735 define new tria pins, configurable type ligt or shutter or plug 2014-04-15 07:27:32 +02:00
harald42 7d354d8a37 initial upload 2014-04-15 07:27:32 +02:00
harald42 2ddd2ba38a cleanup code add coap13 support 2014-04-15 07:27:32 +02:00
harald42 b50f4e2119 remove xmac config 2014-04-15 07:27:32 +02:00
harald42 806de3f204 cleanup code, add coap13 support 2014-04-15 07:27:32 +02:00
harald42 15167d541e del unused files 2014-04-15 07:27:31 +02:00
harald42 39a830d9a9 del unused file 2014-04-15 07:27:31 +02:00
harald42 116ce888c4 code cleanup 2014-04-15 07:27:31 +02:00
harald42 184dee491e cleanup code 2014-04-15 07:27:31 +02:00
harald42 4f05557905 remove old project use climate instead 2014-04-15 07:27:31 +02:00
harald42 1b56526fe0 delete old example 2014-04-15 07:27:31 +02:00
harald42 aac4fcc8e1 cleanup code 2014-04-15 07:27:31 +02:00
harald42 3c0908f2da cleanup code 2014-04-15 07:27:31 +02:00
harald42 1464292188 bugfix nbr name xmac 2014-04-15 07:27:31 +02:00
harald42 d3eb7da297 20 neighbors with status and routes 2014-04-15 07:27:31 +02:00
harald42 0a14fd6a18 update boarder router to new rpl tables 2014-04-15 07:27:31 +02:00
harald42 337be76b26 bugfix server client demo 2014-04-15 07:27:31 +02:00
harald42 da39da39dc initial upload 2014-04-15 07:27:31 +02:00
harald42 afa20ee0ae cleanup plattform defines, disable energest, radiostatistics 2014-04-15 07:27:31 +02:00
harald42 aea396e542 bugfix blockmode, 8 Hz dutycyle as standard 2014-04-15 07:27:31 +02:00
harald42 0ef2ce8e5c bugfix CS cast to uint8_t 2014-04-15 07:27:31 +02:00
harald42 7b46026b52 bugfix RH03 sensor 2014-04-15 07:27:31 +02:00
harald42 310234e0dc add dht22 and RHT03 support 2014-04-15 07:27:30 +02:00
harald42 7001e8fa33 bugfix new dresden module 32khz 2014-04-15 07:27:30 +02:00
harald a58322a62b with coap13 2014-04-15 07:27:30 +02:00
harald ffae9fce58 update coap13 2014-04-15 07:27:30 +02:00
harald42 4a981f1c47 bugfix wrong define 2014-04-15 07:27:30 +02:00
harald42 b6bea56c27 use batmon in battery_sensor 2014-04-15 07:27:30 +02:00
harald42 ff227b7a04 initial upload 2014-04-15 07:27:30 +02:00
harald42 7ee65e72a5 add coap 13 support 2014-04-15 07:27:30 +02:00
Harald Pichler 16c8c3853d initial upload 2014-04-15 07:27:30 +02:00
harald42 015a6a3c65 bugfix buffers 2014-04-15 07:27:30 +02:00
harald42 1968ebc626 bugfix buffers 2014-04-15 07:27:30 +02:00
harald42 58504df2c4 bugfix packet loss 2014-04-15 07:27:30 +02:00
Andreas Reder d5eda89c39 changed char c to signed char c to be compatible to armhf architecture 2014-04-15 07:27:30 +02:00
harald42 9c1b87bbb9 add coap 13 2014-04-15 07:27:30 +02:00
harald42 5c3303eef0 bugfix compile error 2014-04-15 07:27:30 +02:00
harald42 cd715cb222 bugfix hw_init() 2014-04-15 07:27:29 +02:00
harald42 2441cc38ee bugfix led button battery 2014-04-15 07:27:29 +02:00
harald42 11d4c9553e update to caop 13 2014-04-15 07:27:29 +02:00
harald42 312a88ad39 update for new contiki fetch 2014-04-15 07:27:29 +02:00
harald42 243fd6f11e bugfix binarys 2014-04-15 07:27:29 +02:00
harald42 ae7b37d1c3 add binarys 2014-04-15 07:27:29 +02:00
harald42 7478d719cf initial upload 2014-04-15 07:27:29 +02:00
harald42 611e358ad9 add BOOTLOADER_GET_MAC 2014-04-15 07:27:29 +02:00
harald42 b27469d218 initial upload 2014-04-15 07:27:29 +02:00
harald42 ec5210b562 periodic prints configurable 2014-04-15 07:27:29 +02:00
Harald Pichler 080eadc79b remove unused code, bugfix const 2014-04-15 07:27:29 +02:00
Harald Pichler ef5b9474fd bugfix accept type const 2014-04-15 07:27:29 +02:00
harald42 71f8352876 bugfix pullup key_init 2014-04-15 07:27:28 +02:00
harald42 c265e72b24 add button logic 2014-04-15 07:27:28 +02:00
harald42 8628af93e1 cleanup debug prints 2014-04-15 07:27:28 +02:00
Andreas Reder 19ec02773f corrected bug when changing panid 2014-04-15 07:27:28 +02:00
harald42 765129fde2 bugfix ->startup led red off 2014-04-15 07:27:28 +02:00
harald42 32d077790f remove debug code 2014-04-15 07:27:28 +02:00
harald42 cdf4da8461 add merkurboard coap client demo 2014-04-15 07:27:28 +02:00
harald42 797c3da239 add isr 2014-04-15 07:27:28 +02:00
harald42 25fb513164 etimer read buttons 2014-04-15 07:27:28 +02:00
harald42 ae3d5e4966 add pcint buttons 2014-04-15 07:27:28 +02:00
Andreas Reder 6184e5715b corrected border-router resources, added run.sh and flash.sh 2014-04-15 07:27:28 +02:00
harald42 d8d1550400 cleanup er-rest-example-merkurboard 2014-04-15 07:27:28 +02:00
harald42 7383f6708b timer4 servo pwm from Priesch Markus 2014-04-15 07:27:28 +02:00
harald42 3d10f4d0d1 timer4 servo pwm from Priesch Markus 2014-04-15 07:27:28 +02:00
harald42 0deca185bb many bugfixes, add cputemp 2014-04-15 07:27:28 +02:00
harald42 6d30a5b66e add relay 2014-04-15 07:27:28 +02:00
harald42 8cdf981c8f add debug led code 2014-04-15 07:27:27 +02:00
Andreas Reder 8d5f623b6a turned off debugging 2014-04-15 07:27:27 +02:00
Andreas Reder 85fb0b1e48 added info resource 2014-04-15 07:27:27 +02:00
Andreas Reder 3783d5f059 created osd native border router with coap server to get rpl table and change panid 2014-04-15 07:27:27 +02:00
andreas@reder.eu 86a6d88799 PARAMS_PANID is now defined in contiki-conf and no longer in params.h to be able
to change framer panid
2014-04-15 07:27:27 +02:00
andreas@reder.eu 46010cbbd6 bugfix: panid is now correctly loaded from eeprom and set in mac framer and radio on startup 2014-04-15 07:27:27 +02:00
AndreasReder 20e8eba08b changed slip-radio to be able to change panid over slip command 2014-04-15 07:27:27 +02:00
AndreasReder 033adfa678 changed mac framer to be able to change panid during runtime
example:
#include "net/mac/framer-802154.h"
uint16_t panid = 1234;
framer_802154_set_panid(panid);

attention: this only changes the framer panid, you need to change
the radio panid too, e.g. with rf230_set_pan_addr on avr atmega128rfa1
2014-04-15 07:27:27 +02:00
harald42 057a3c3345 add light-actor 2014-04-15 07:27:27 +02:00
harald42 bba7b84a15 add servo example 2014-04-15 07:27:27 +02:00
harald42 36e0dcf22f bugfix compile and flash 2014-04-15 07:27:27 +02:00
harald42 c8604b5a70 add merkur board example 2014-04-15 07:27:27 +02:00
harald42 43b9f7a23d remove platform/osd-er-lp24 2014-04-15 07:27:27 +02:00
harald42 2a495ace3b change plattform to osd-merkur 2014-04-15 07:27:27 +02:00
harald42 5ee13bf528 change plattform to osd-merkur 2014-04-15 07:27:27 +02:00
harald42 33639c15e1 change plattform to osd-merkur 2014-04-15 07:27:27 +02:00
harald42 618a516182 change plattform to osd-merkur 2014-04-15 07:27:26 +02:00
harald42 b6c7cc8672 change plattform to osd-merkur 2014-04-15 07:27:26 +02:00
harald42 4d93071bf9 change plattform to osd-merkur 2014-04-15 07:27:26 +02:00
harald42 6d0bdab9f0 change plattform to osd-merkur 2014-04-15 07:27:26 +02:00
harald42 7f776ee918 add climate example 2014-04-15 07:27:26 +02:00
harald42 a6634acc50 add platform osd-merkur 2014-04-15 07:27:26 +02:00
harald42 b31a3397e0 remove merkur 2014-04-15 07:27:26 +02:00
harald42 b6f96951be add merkur platform 2014-04-15 07:27:26 +02:00
harald42 23394cd1f5 remove old files 2014-04-15 07:27:26 +02:00
harald42 252454c016 remove debug, minimize code size 2014-04-15 07:27:26 +02:00
harald42 a2387f43af cleanup project 2014-04-15 07:27:26 +02:00
harald42 641aad70a9 initial upload 2014-04-15 07:27:26 +02:00
harald42 32ab451fff add pir sensor, sensor events 2014-04-15 07:27:26 +02:00
harald42 a1152fd96e cleanup code 2014-04-15 07:27:26 +02:00
harald42 356ea01a8d add button sensor with debug 2014-04-15 07:27:26 +02:00
harald42 48217bcf80 initial upload 2014-04-15 07:27:26 +02:00
harald42 104be3acfb initial upload 2014-04-15 07:27:26 +02:00
harald42 ac235b9c57 make easyer experiments 2014-04-15 07:27:25 +02:00
harald42 b2040a6cd9 change rt tag and disable energest and radio stat 2014-04-15 07:27:25 +02:00
harald42 2e35f2225d cleanup code 2014-04-15 07:27:25 +02:00
harald42 ff022fce05 add battery sensor 2014-04-15 07:27:25 +02:00
harald42 538bb6075c setup 15 NBR 50 DS6-Route 2014-04-15 07:27:25 +02:00
harald42 86c4214014 update to latest version 2014-04-15 07:27:25 +02:00
harald42 1f12531618 remove if attribute 2014-04-15 07:27:25 +02:00
harald42 65341d8d3b use ds1820.c from /dev directory 2014-04-15 07:27:25 +02:00
harald42 90885f2168 new dht11 uri schema 2014-04-15 07:27:25 +02:00
harald42 e92678a847 add sensors, internal temperature, battery 2014-04-15 07:27:25 +02:00
harald 17c93b259e add DHT11 humidity sensor 2014-04-15 07:27:25 +02:00
harald 56807ee75a initial upload 2014-04-15 07:27:25 +02:00
harald 2b7e7b8f8c bugfix ds1820 2014-04-15 07:27:25 +02:00
harald 92b835080b initial upload 2014-04-15 07:27:25 +02:00
1381 changed files with 159619 additions and 15317 deletions

14
.gitmodules vendored
View file

@ -4,13 +4,15 @@
[submodule "tools/cc2538-bsl"]
path = tools/cc2538-bsl
url = https://github.com/JelmerT/cc2538-bsl.git
[submodule "cpu/cc26xx-cc13xx/lib/cc26xxware"]
path = cpu/cc26xx-cc13xx/lib/cc26xxware
url = https://github.com/g-oikonomou/cc26xxware.git
[submodule "cpu/cc26xx-cc13xx/lib/cc13xxware"]
path = cpu/cc26xx-c../.gitmodulesc13xx/lib/cc13xxware
url = https://github.com/g-oikonomou/cc13xxware.git
path = cpu/cc26xx-cc13xx/lib/cc13xxware
url = https://github.com/contiki-os/cc13xxware.git
[submodule "platform/stm32nucleo-spirit1/stm32cube-lib"]
path = platform/stm32nucleo-spirit1/stm32cube-lib
url = https://github.com/STclab/stm32nucleo-spirit1-lib
[submodule "tools/sensniff"]
path = tools/sensniff
url = https://github.com/g-oikonomou/sensniff.git
[submodule "apps/tinydtls"]
path = apps/tinydtls
url = https://github.com/iot-lab/armour-tinydtls.git

View file

@ -1,3 +1,7 @@
# Workaround for the issue found in the stable image promoted on Dec 1, 2016.
# See https://github.com/travis-ci/travis-ci/issues/6928#issuecomment-264227708
group: deprecated
notifications:
email: false
language: c #NOTE: this will set CC=gcc which might cause trouble
@ -10,7 +14,7 @@ before_script:
## Install doxygen
- if [ ${BUILD_CATEGORY:-0} = doxygen ] ; then
sudo add-apt-repository ppa:libreoffice/libreoffice-4-4 -y && sudo apt-get -qq update &&
sudo add-apt-repository ppa:libreoffice/ppa -y && sudo apt-get -qq update &&
sudo apt-get --no-install-suggests --no-install-recommends -qq install doxygen &&
doxygen --version ;
fi
@ -81,7 +85,7 @@ before_script:
- if [ ${BUILD_ARCH:-0} = jn516x ] ; then
$WGET http://simonduq.github.io/resources/ba-elf-gcc-4.7.4-part1.tar.bz2 &&
$WGET http://simonduq.github.io/resources/ba-elf-gcc-4.7.4-part2.tar.bz2 &&
$WGET http://simonduq.github.io/resources/jn516x-sdk-4163.tar.bz2 &&
$WGET http://simonduq.github.io/resources/jn516x-sdk-4163-1416.tar.bz2 &&
mkdir /tmp/jn516x-sdk /tmp/ba-elf-gcc &&
tar xjf jn516x-sdk-*.tar.bz2 -C /tmp/jn516x-sdk &&
tar xjf ba-elf-gcc-*part1.tar.bz2 -C /tmp/ba-elf-gcc &&
@ -158,3 +162,5 @@ env:
- BUILD_TYPE='slip-radio' MAKE_TARGETS='cooja'
- BUILD_TYPE='llsec' MAKE_TARGETS='cooja'
- BUILD_TYPE='compile-avr' BUILD_CATEGORY='compile' BUILD_ARCH='avr-rss2'
- BUILD_TYPE='ieee802154'
- BUILD_TYPE='tsch'

494
LICENSE
View file

@ -1,3 +1,37 @@
A note on Licensing (2017-03-17):
Github has recently (2017-03-01) changed their license terms:
https://help.github.com/articles/github-terms-of-service/
There were comments that this may violate some GPL and creative commons
licenses:
http://joeyh.name/blog/entry/removing_everything_from_github/
https://www.mirbsd.org/permalinks/wlog-10_e20170301-tg.htm
But also voices that don't see a problem:
https://www.earth.li/~noodles/blog/2017/03/github-tos-change.html
If your're german-speaking you may also want to read the two Heise
articles:
https://www.heise.de/developer/meldung/GitHub-eckt-mit-neuen-Nutzungsbedingungen-an-3647980.html
https://www.heise.de/developer/meldung/FSF-aeussert-sich-zu-den-GitHub-Nutzungsbedingungen-3657040.html
We trust that the problematic part in section D.5:
"If you set your pages and repositories to be viewed publicly, you grant
each User of GitHub a nonexclusive, worldwide license to access your
Content through the GitHub Service, and to use, display and perform your
Content, and to reproduce your Content solely on GitHub as permitted
through GitHub's functionality." that the part "solely on GitHub as
permitted through GitHub's functionality" also applies to "display and
perform your Content". If the latter part of the sentence would stand
alone it could be interpreted that we would grant *everybody*
essentially an unlimited license (which we cannot because the authors
from whom we forked applied other licenses). This interpretation is
further supported by the fact that Github writes "You may grant further
rights if you adopt a license." that in fact the statements above only
apply to the rendering on Github.
Note that in the following we have two licenses, the 3-clause BSD and
the LGPL license in short:
- Contiki OS (and our modification to it) are 3-clause BSD
- Our Arduino compatibility Layer on top of Contiki OS is LGPL
Contiki is licensed under the 3-clause BSD license. This license gives
everyone the right to use and distribute the code, either in binary or
source code format, as long as the copyright license is retained in
@ -36,3 +70,463 @@ of license. The license text is:
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
Arduino-compatibility layer if not otherwise noted is under the
following license:
GNU LESSER GENERAL PUBLIC LICENSE
Version 2.1, February 1999
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
[This is the first released version of the Lesser GPL. It also counts
as the successor of the GNU Library Public License, version 2, hence
the version number 2.1.]
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
Licenses are intended to guarantee your freedom to share and change
free software--to make sure the software is free for all its users.
This license, the Lesser General Public License, applies to some
specially designated software packages--typically libraries--of the
Free Software Foundation and other authors who decide to use it. You
can use it too, but we suggest you first think carefully about whether
this license or the ordinary General Public License is the better
strategy to use in any particular case, based on the explanations below.
When we speak of free software, we are referring to freedom of use,
not price. Our General Public Licenses are designed to make sure that
you have the freedom to distribute copies of free software (and charge
for this service if you wish); that you receive source code or can get
it if you want it; that you can change the software and use pieces of
it in new free programs; and that you are informed that you can do
these things.
To protect your rights, we need to make restrictions that forbid
distributors to deny you these rights or to ask you to surrender these
rights. These restrictions translate to certain responsibilities for
you if you distribute copies of the library or if you modify it.
For example, if you distribute copies of the library, whether gratis
or for a fee, you must give the recipients all the rights that we gave
you. You must make sure that they, too, receive or can get the source
code. If you link other code with the library, you must provide
complete object files to the recipients, so that they can relink them
with the library after making changes to the library and recompiling
it. And you must show them these terms so they know their rights.
We protect your rights with a two-step method: (1) we copyright the
library, and (2) we offer you this license, which gives you legal
permission to copy, distribute and/or modify the library.
To protect each distributor, we want to make it very clear that
there is no warranty for the free library. Also, if the library is
modified by someone else and passed on, the recipients should know
that what they have is not the original version, so that the original
author's reputation will not be affected by problems that might be
introduced by others.
Finally, software patents pose a constant threat to the existence of
any free program. We wish to make sure that a company cannot
effectively restrict the users of a free program by obtaining a
restrictive license from a patent holder. Therefore, we insist that
any patent license obtained for a version of the library must be
consistent with the full freedom of use specified in this license.
Most GNU software, including some libraries, is covered by the
ordinary GNU General Public License. This license, the GNU Lesser
General Public License, applies to certain designated libraries, and
is quite different from the ordinary General Public License. We use
this license for certain libraries in order to permit linking those
libraries into non-free programs.
When a program is linked with a library, whether statically or using
a shared library, the combination of the two is legally speaking a
combined work, a derivative of the original library. The ordinary
General Public License therefore permits such linking only if the
entire combination fits its criteria of freedom. The Lesser General
Public License permits more lax criteria for linking other code with
the library.
We call this license the "Lesser" General Public License because it
does Less to protect the user's freedom than the ordinary General
Public License. It also provides other free software developers Less
of an advantage over competing non-free programs. These disadvantages
are the reason we use the ordinary General Public License for many
libraries. However, the Lesser license provides advantages in certain
special circumstances.
For example, on rare occasions, there may be a special need to
encourage the widest possible use of a certain library, so that it becomes
a de-facto standard. To achieve this, non-free programs must be
allowed to use the library. A more frequent case is that a free
library does the same job as widely used non-free libraries. In this
case, there is little to gain by limiting the free library to free
software only, so we use the Lesser General Public License.
In other cases, permission to use a particular library in non-free
programs enables a greater number of people to use a large body of
free software. For example, permission to use the GNU C Library in
non-free programs enables many more people to use the whole GNU
operating system, as well as its variant, the GNU/Linux operating
system.
Although the Lesser General Public License is Less protective of the
users' freedom, it does ensure that the user of a program that is
linked with the Library has the freedom and the wherewithal to run
that program using a modified version of the Library.
The precise terms and conditions for copying, distribution and
modification follow. Pay close attention to the difference between a
"work based on the library" and a "work that uses the library". The
former contains code derived from the library, whereas the latter must
be combined with the library in order to run.
GNU LESSER GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any software library or other
program which contains a notice placed by the copyright holder or
other authorized party saying it may be distributed under the terms of
this Lesser General Public License (also called "this License").
Each licensee is addressed as "you".
A "library" means a collection of software functions and/or data
prepared so as to be conveniently linked with application programs
(which use some of those functions and data) to form executables.
The "Library", below, refers to any such software library or work
which has been distributed under these terms. A "work based on the
Library" means either the Library or any derivative work under
copyright law: that is to say, a work containing the Library or a
portion of it, either verbatim or with modifications and/or translated
straightforwardly into another language. (Hereinafter, translation is
included without limitation in the term "modification".)
"Source code" for a work means the preferred form of the work for
making modifications to it. For a library, complete source code means
all the source code for all modules it contains, plus any associated
interface definition files, plus the scripts used to control compilation
and installation of the library.
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running a program using the Library is not restricted, and output from
such a program is covered only if its contents constitute a work based
on the Library (independent of the use of the Library in a tool for
writing it). Whether that is true depends on what the Library does
and what the program that uses the Library does.
1. You may copy and distribute verbatim copies of the Library's
complete source code as you receive it, in any medium, provided that
you conspicuously and appropriately publish on each copy an
appropriate copyright notice and disclaimer of warranty; keep intact
all the notices that refer to this License and to the absence of any
warranty; and distribute a copy of this License along with the
Library.
You may charge a fee for the physical act of transferring a copy,
and you may at your option offer warranty protection in exchange for a
fee.
2. You may modify your copy or copies of the Library or any portion
of it, thus forming a work based on the Library, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) The modified work must itself be a software library.
b) You must cause the files modified to carry prominent notices
stating that you changed the files and the date of any change.
c) You must cause the whole of the work to be licensed at no
charge to all third parties under the terms of this License.
d) If a facility in the modified Library refers to a function or a
table of data to be supplied by an application program that uses
the facility, other than as an argument passed when the facility
is invoked, then you must make a good faith effort to ensure that,
in the event an application does not supply such function or
table, the facility still operates, and performs whatever part of
its purpose remains meaningful.
(For example, a function in a library to compute square roots has
a purpose that is entirely well-defined independent of the
application. Therefore, Subsection 2d requires that any
application-supplied function or table used by this function must
be optional: if the application does not supply it, the square
root function must still compute square roots.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Library,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Library, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote
it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Library.
In addition, mere aggregation of another work not based on the Library
with the Library (or with a work based on the Library) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may opt to apply the terms of the ordinary GNU General Public
License instead of this License to a given copy of the Library. To do
this, you must alter all the notices that refer to this License, so
that they refer to the ordinary GNU General Public License, version 2,
instead of to this License. (If a newer version than version 2 of the
ordinary GNU General Public License has appeared, then you can specify
that version instead if you wish.) Do not make any other change in
these notices.
Once this change is made in a given copy, it is irreversible for
that copy, so the ordinary GNU General Public License applies to all
subsequent copies and derivative works made from that copy.
This option is useful when you wish to copy part of the code of
the Library into a program that is not a library.
4. You may copy and distribute the Library (or a portion or
derivative of it, under Section 2) in object code or executable form
under the terms of Sections 1 and 2 above provided that you accompany
it with the complete corresponding machine-readable source code, which
must be distributed under the terms of Sections 1 and 2 above on a
medium customarily used for software interchange.
If distribution of object code is made by offering access to copy
from a designated place, then offering equivalent access to copy the
source code from the same place satisfies the requirement to
distribute the source code, even though third parties are not
compelled to copy the source along with the object code.
5. A program that contains no derivative of any portion of the
Library, but is designed to work with the Library by being compiled or
linked with it, is called a "work that uses the Library". Such a
work, in isolation, is not a derivative work of the Library, and
therefore falls outside the scope of this License.
However, linking a "work that uses the Library" with the Library
creates an executable that is a derivative of the Library (because it
contains portions of the Library), rather than a "work that uses the
library". The executable is therefore covered by this License.
Section 6 states terms for distribution of such executables.
When a "work that uses the Library" uses material from a header file
that is part of the Library, the object code for the work may be a
derivative work of the Library even though the source code is not.
Whether this is true is especially significant if the work can be
linked without the Library, or if the work is itself a library. The
threshold for this to be true is not precisely defined by law.
If such an object file uses only numerical parameters, data
structure layouts and accessors, and small macros and small inline
functions (ten lines or less in length), then the use of the object
file is unrestricted, regardless of whether it is legally a derivative
work. (Executables containing this object code plus portions of the
Library will still fall under Section 6.)
Otherwise, if the work is a derivative of the Library, you may
distribute the object code for the work under the terms of Section 6.
Any executables containing that work also fall under Section 6,
whether or not they are linked directly with the Library itself.
6. As an exception to the Sections above, you may also combine or
link a "work that uses the Library" with the Library to produce a
work containing portions of the Library, and distribute that work
under terms of your choice, provided that the terms permit
modification of the work for the customer's own use and reverse
engineering for debugging such modifications.
You must give prominent notice with each copy of the work that the
Library is used in it and that the Library and its use are covered by
this License. You must supply a copy of this License. If the work
during execution displays copyright notices, you must include the
copyright notice for the Library among them, as well as a reference
directing the user to the copy of this License. Also, you must do one
of these things:
a) Accompany the work with the complete corresponding
machine-readable source code for the Library including whatever
changes were used in the work (which must be distributed under
Sections 1 and 2 above); and, if the work is an executable linked
with the Library, with the complete machine-readable "work that
uses the Library", as object code and/or source code, so that the
user can modify the Library and then relink to produce a modified
executable containing the modified Library. (It is understood
that the user who changes the contents of definitions files in the
Library will not necessarily be able to recompile the application
to use the modified definitions.)
b) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (1) uses at run time a
copy of the library already present on the user's computer system,
rather than copying library functions into the executable, and (2)
will operate properly with a modified version of the library, if
the user installs one, as long as the modified version is
interface-compatible with the version that the work was made with.
c) Accompany the work with a written offer, valid for at
least three years, to give the same user the materials
specified in Subsection 6a, above, for a charge no more
than the cost of performing this distribution.
d) If distribution of the work is made by offering access to copy
from a designated place, offer equivalent access to copy the above
specified materials from the same place.
e) Verify that the user has already received a copy of these
materials or that you have already sent this user a copy.
For an executable, the required form of the "work that uses the
Library" must include any data and utility programs needed for
reproducing the executable from it. However, as a special exception,
the materials to be distributed need not include anything that is
normally distributed (in either source or binary form) with the major
components (compiler, kernel, and so on) of the operating system on
which the executable runs, unless that component itself accompanies
the executable.
It may happen that this requirement contradicts the license
restrictions of other proprietary libraries that do not normally
accompany the operating system. Such a contradiction means you cannot
use both them and the Library together in an executable that you
distribute.
7. You may place library facilities that are a work based on the
Library side-by-side in a single library together with other library
facilities not covered by this License, and distribute such a combined
library, provided that the separate distribution of the work based on
the Library and of the other library facilities is otherwise
permitted, and provided that you do these two things:
a) Accompany the combined library with a copy of the same work
based on the Library, uncombined with any other library
facilities. This must be distributed under the terms of the
Sections above.
b) Give prominent notice with the combined library of the fact
that part of it is a work based on the Library, and explaining
where to find the accompanying uncombined form of the same work.
8. You may not copy, modify, sublicense, link with, or distribute
the Library except as expressly provided under this License. Any
attempt otherwise to copy, modify, sublicense, link with, or
distribute the Library is void, and will automatically terminate your
rights under this License. However, parties who have received copies,
or rights, from you under this License will not have their licenses
terminated so long as such parties remain in full compliance.
9. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Library or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Library (or any work based on the
Library), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Library or works based on it.
10. Each time you redistribute the Library (or any work based on the
Library), the recipient automatically receives a license from the
original licensor to copy, distribute, link with or modify the Library
subject to these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties with
this License.
11. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Library at all. For example, if a patent
license would not permit royalty-free redistribution of the Library by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Library.
If any portion of this section is held invalid or unenforceable under any
particular circumstance, the balance of the section is intended to apply,
and the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
12. If the distribution and/or use of the Library is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Library under this License may add
an explicit geographical distribution limitation excluding those countries,
so that distribution is permitted only in or among countries not thus
excluded. In such case, this License incorporates the limitation as if
written in the body of this License.
13. The Free Software Foundation may publish revised and/or new
versions of the Lesser General Public License from time to time.
Such new versions will be similar in spirit to the present version,
but may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Library
specifies a version number of this License which applies to it and
"any later version", you have the option of following the terms and
conditions either of that version or of any later version published by
the Free Software Foundation. If the Library does not specify a
license version number, you may choose any version ever published by
the Free Software Foundation.
14. If you wish to incorporate parts of the Library into other free
programs whose distribution conditions are incompatible with these,
write to the author to ask for permission. For software which is
copyrighted by the Free Software Foundation, write to the Free
Software Foundation; we sometimes make exceptions for this. Our
decision will be guided by the two goals of preserving the free status
of all derivatives of our free software and of promoting the sharing
and reuse of software generally.
NO WARRANTY
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.

View file

@ -304,6 +304,25 @@ endif
%.flashprof: %.$(TARGET)
$(NM) -S -td --size-sort $< | grep -i " [t] " | cut -d' ' -f2,4
viewconf:
@echo "----------------- Make variables: --------------"
@echo "##### \"TARGET\": ________________________________ $(TARGET)"
@echo "##### \"BOARD\": _________________________________ $(BOARD)"
@echo "##### \"MAKE_MAC\": ______________________________ $(MAKE_MAC)"
@echo "##### \"MAKE_NET\": ______________________________ $(MAKE_NET)"
@echo "##### \"MAKE_ROUTING\": __________________________ $(MAKE_ROUTING)"
ifdef MAKE_COAP_DTLS_KEYSTORE
@echo "##### \"MAKE_COAP_DTLS_KEYSTORE\": _______________ $(MAKE_COAP_DTLS_KEYSTORE)"
endif
@echo "----------------- C variables: -----------------"
$(Q)$(CC) $(CFLAGS) -E $(CONTIKI)/tools/viewconf.c | grep \#\#\#\#\#
@echo "------------------------------------------------"
@echo "'==' Means the flag is set to a given a value"
@echo "'->' Means the flag is unset, but will default to a given value"
@echo "'><' Means the flag is unset and has no default value"
@echo "To view more Make variables, edit $(CONTIKI)/Makefile.include, rule 'viewconf'"
@echo "To view more C variables, edit $(CONTIKI)/tools/viewconf.c"
# Don't treat %.$(TARGET) as an intermediate file because it is
# in fact the primary target.
.PRECIOUS: %.$(TARGET)

View file

@ -1,8 +1,6 @@
The Contiki Operating System
============================
[![Build Status](https://travis-ci.org/contiki-os/contiki.svg?branch=master)](https://travis-ci.org/contiki-os/contiki/branches)
Contiki is an open source operating system that runs on tiny low-power
microcontrollers and makes it possible to develop applications that
make efficient use of the hardware while providing standardized
@ -17,3 +15,12 @@ and so on.
For more information, see the Contiki website:
[http://contiki-os.org](http://contiki-os.org)
This fork of the Contiki Operating System adds support for our Merkur
Board, adds a lot of examples (with different hardware) and puts an
Arduino compatibility layer on top of Contiki-OS that allows Arduino
Sketches -- and a lot of drivers for Arduino compatible hardware -- to
run under Contiki-OS.
For the licensing terms (also in the light of recent debates of Github
changed Terms of Service on 2017-03-01) see the file LICENSE.

View file

@ -49,37 +49,77 @@
*
*/
#include <stdlib.h>
#include <string.h>
#include "arduino-process.h"
#include "hw_timer.h"
#include "adc.h"
#include "hw-arduino.h"
#include "contiki.h"
#include "project-conf.h"
#define DEBUG 0
#if DEBUG
#include <stdio.h>
#define PRINTF(...) printf(__VA_ARGS__)
#define PRINT6ADDR(addr) PRINTF("[%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x]", ((uint8_t *)addr)[0], ((uint8_t *)addr)[1], ((uint8_t *)addr)[2], ((uint8_t *)addr)[3], ((uint8_t *)addr)[4], ((uint8_t *)addr)[5], ((uint8_t *)addr)[6], ((uint8_t *)addr)[7], ((uint8_t *)addr)[8], ((uint8_t *)addr)[9], ((uint8_t *)addr)[10], ((uint8_t *)addr)[11], ((uint8_t *)addr)[12], ((uint8_t *)addr)[13], ((uint8_t *)addr)[14], ((uint8_t *)addr)[15])
#define PRINTLLADDR(lladdr) PRINTF("[%02x:%02x:%02x:%02x:%02x:%02x]", (lladdr)->addr[0], (lladdr)->addr[1], (lladdr)->addr[2], (lladdr)->addr[3], (lladdr)->addr[4], (lladdr)->addr[5])
#else
#define PRINTF(...)
#define PRINT6ADDR(addr)
#define PRINTLLADDR(addr)
#endif
extern volatile uint8_t mcusleepcycle;
volatile uint8_t mcusleepcycleval;
#if PLATFORM_HAS_BUTTON
#include "rest-engine.h"
#include "dev/button-sensor.h"
extern resource_t res_event, res_separate;
#endif /* PLATFORM_HAS_BUTTON */
volatile uint8_t mcusleepcycleval;
/* 0 dont sleep; 1 sleep */
uint8_t mcusleep;
/*-------------- enabled sleep mode ----------------------------------------*/
void
mcu_sleep_init(void)
{
mcusleepcycleval=mcusleepcycle;
mcusleepcycleval=mcusleepcycle;
mcu_sleep_disable(); // if a shell is active we can type
}
void
mcu_sleep_disable(void)
{
mcusleep=2;
mcu_sleep_off();
}
void
mcu_sleep_enable(void)
{
mcusleep=0;
}
void
mcu_sleep_on(void)
{
mcusleepcycle= mcusleepcycleval;
if(mcusleep == 0){
mcusleepcycle= mcusleepcycleval;
}
}
/*--------------- disable sleep mode ---------------------------------------*/
void
mcu_sleep_off(void)
{
mcusleepcycle=0;
mcusleepcycle=0;
}
/*---------------- set duty cycle value ------------------------------------*/
void
mcu_sleep_set(uint8_t value)
{
mcusleepcycleval= value;
mcusleepcycle = mcusleepcycleval;
// mcusleepcycle = mcusleepcycleval;
}
PROCESS(arduino_sketch, "Arduino Sketch Wrapper");
@ -87,28 +127,54 @@ PROCESS(arduino_sketch, "Arduino Sketch Wrapper");
#ifndef LOOP_INTERVAL
#define LOOP_INTERVAL (1 * CLOCK_SECOND)
#endif
#define START_MCUSLEEP (10 * CLOCK_SECOND)
PROCESS_THREAD(arduino_sketch, ev, data)
{
static struct etimer loop_periodic_timer;
static struct etimer start_mcusleep_timer;
PROCESS_BEGIN();
adc_init ();
mcu_sleep_init ();
setup ();
/* Define application-specific events here. */
etimer_set(&loop_periodic_timer, LOOP_INTERVAL);
etimer_set(&start_mcusleep_timer, START_MCUSLEEP);
while (1) {
PROCESS_WAIT_EVENT();
if(etimer_expired(&loop_periodic_timer)) {
loop ();
etimer_reset(&loop_periodic_timer);
#if PLATFORM_HAS_BUTTON
if(ev == sensors_event && data == &button_sensor) {
mcu_sleep_off();
PRINTF("*******BUTTON*******\n");
button ();
mcu_sleep_on();
}
#endif /* PLATFORM_HAS_BUTTON */
if(etimer_expired(&start_mcusleep_timer)) {
PRINTF("mcusleep_timer %d\n",mcusleep);
if(mcusleep == 1){
PRINTF("mcu sleep on\n");
mcu_sleep_enable();
mcu_sleep_on();
}
if (mcusleep > 0) {
mcusleep--;
}
etimer_reset(&start_mcusleep_timer);
}
if(etimer_expired(&loop_periodic_timer)) {
mcu_sleep_off();
loop ();
mcu_sleep_on();
etimer_reset(&loop_periodic_timer);
}
}
PROCESS_END();
}
/*
* VI settings, see coding style
* ex:ts=8:et:sw=2

View file

@ -52,8 +52,12 @@
#include "contiki.h"
/*--------------- enable sleep mode ---------------------------------------*/
void mcu_sleep_on(void);
void mcu_sleep_enable(void);
/*--------------- disable sleep mode ---------------------------------------*/
void mcu_sleep_disable(void);
/*--------------- sleep mode on---------------------------------------*/
void mcu_sleep_on(void);
/*--------------- sleep mode off---------------------------------------*/
void mcu_sleep_off(void);
/*---------------- set sleep value ------------------------------------*/
void mcu_sleep_set(uint8_t value);
@ -61,6 +65,7 @@ void mcu_sleep_set(uint8_t value);
extern void loop (void);
extern void setup (void);
extern void arduino_init (void);
extern void button (void);
extern struct process arduino_sketch;

View file

@ -4,3 +4,18 @@ er-coap_src = er-coap.c er-coap-engine.c er-coap-transactions.c \
# Erbium will implement the REST Engine
CFLAGS += -DREST=coap_rest_implementation
ifeq ($(WITH_DTLS_COAP),1)
er-coap_src += er-coap-dtls.c
# Load tinydtls
APPS += tinydtls
$(CONTIKI)/apps/tinydtls/Makefile.tinydtls:
@echo " You should run 'git submodule update --init' to clone 'app/tinydtls'"
@exit 1
include $(CONTIKI)/apps/tinydtls/Makefile.tinydtls
PROJECTDIRS+=$(CONTIKI)/apps/tinydtls/aes $(CONTIKI)/apps/tinydtls/sha2 $(CONTIKI)/apps/tinydtls/ecc
else
er-coap_src += er-coap-udp.c
endif

View file

@ -0,0 +1,15 @@
#ifndef _ER_COAP_COMMUNICATION_H_
#define _ER_COAP_COMMUNICATION_H_
#include "contiki.h"
void
coap_init_communication_layer(uint16_t port);
void
coap_send_message(uip_ipaddr_t *addr, uint16_t port, uint8_t *data, uint16_t length);
void
coap_handle_receive(void);
#endif

View file

@ -94,6 +94,7 @@ typedef enum {
NOT_FOUND_4_04 = 132, /* NOT_FOUND */
METHOD_NOT_ALLOWED_4_05 = 133, /* METHOD_NOT_ALLOWED */
NOT_ACCEPTABLE_4_06 = 134, /* NOT_ACCEPTABLE */
REQUEST_ENTITY_INCOMPLETE_4_08 = 136, /* REQUEST_ENTITY_INCOMPLETE */
PRECONDITION_FAILED_4_12 = 140, /* BAD_REQUEST */
REQUEST_ENTITY_TOO_LARGE_4_13 = 141, /* REQUEST_ENTITY_TOO_LARGE */
UNSUPPORTED_MEDIA_TYPE_4_15 = 143, /* UNSUPPORTED_MEDIA_TYPE */

161
apps/er-coap/er-coap-dtls.c Normal file
View file

@ -0,0 +1,161 @@
#include "contiki.h"
#include "contiki-net.h"
#include "er-coap.h"
#include "er-coap-engine.h"
#include "dtls.h"
#include <string.h>
#define DEBUG DEBUG_NONE
#include "dtls_debug.h"
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
static struct dtls_context_t *dtls_ctx = NULL;
static dtls_handler_t coap_dtls_callback = {
.write = coap_dtls_send_to_peer,
.read = coap_dtls_read_from_peer,
.event = NULL,
#ifdef DTLS_PSK
.get_psk_info = coap_dtls_get_psk_info,
#endif
#ifdef DTLS_ECC
.get_ecdsa_key = NULL,
.verify_ecdsa_key = NULL,
#endif
};
/*-----------------------------------------------------------------------------------*/
void
coap_init_communication_layer(uint16_t port)
{
struct uip_udp_conn *udp_conn = NULL;
dtls_init();
dtls_set_log_level(DTLS_LOG_DEBUG);
udp_conn = udp_new(NULL, 0, NULL);
udp_bind(udp_conn, port);
dtls_ctx = dtls_new_context(udp_conn);
if(dtls_ctx) {
dtls_set_handler(dtls_ctx, &COAP_DTLS_CALLBACK);
}
/* new connection with remote host */
printf("COAP-DTLS listening on port %u\n", uip_ntohs(udp_conn->lport));
}
/*-----------------------------------------------------------------------------------*/
void
coap_send_message(uip_ipaddr_t *addr, uint16_t port,
uint8_t *data, uint16_t length)
{
session_t session;
dtls_session_init(&session);
uip_ipaddr_copy(&session.addr, addr);
session.port = port;
dtls_write(dtls_ctx, &session, data, length);
}
/*-----------------------------------------------------------------------------------*/
void
coap_handle_receive()
{
session_t session;
if(uip_newdata()) {
dtls_session_init(&session);
uip_ipaddr_copy(&session.addr, &UIP_IP_BUF->srcipaddr);
session.port = UIP_UDP_BUF->srcport;
dtls_handle_message(dtls_ctx, &session, uip_appdata, uip_datalen());
}
}
/* DTLS Specific functions */
/*-----------------------------------------------------------------------------------*/
#ifdef DTLS_PSK
/* This function is the "key store" for tinyDTLS. It is called to
* retrieve a key for the given identiy within this particular
* session. */
int
coap_dtls_get_psk_info(struct dtls_context_t *ctx, const session_t *session,
dtls_credentials_type_t type,
const unsigned char *id, size_t id_len,
unsigned char *result, size_t result_length)
{
struct keymap_t {
unsigned char *id;
size_t id_length;
unsigned char *key;
size_t key_length;
} psk[1] = {
{ (unsigned char *)DTLS_IDENTITY, DTLS_IDENTITY_LENGTH, (unsigned char *)DTLS_PSK_KEY_VALUE, DTLS_PSK_KEY_VALUE_LENGTH },
};
if(type == DTLS_PSK_IDENTITY) {
if(id_len) {
dtls_debug("got psk_identity_hint: '%.*s'\n", id_len, id);
}
if(result_length < psk[0].id_length) {
dtls_warn("cannot set psk_identity -- buffer too small\n");
return dtls_alert_fatal_create(DTLS_ALERT_INTERNAL_ERROR);
}
memcpy(result, psk[0].id, psk[0].id_length);
return psk[0].id_length;
} else if(type == DTLS_PSK_KEY) {
if(id) {
int i;
for(i = 0; i < sizeof(psk) / sizeof(struct keymap_t); i++) {
if(id_len == psk[i].id_length && memcmp(id, psk[i].id, id_len) == 0) {
if(result_length < psk[i].key_length) {
dtls_warn("buffer too small for PSK");
return dtls_alert_fatal_create(DTLS_ALERT_INTERNAL_ERROR);
}
memcpy(result, psk[i].key, psk[i].key_length);
return psk[i].key_length;
}
}
}
} else {
return 0;
}
return dtls_alert_fatal_create(DTLS_ALERT_DECRYPT_ERROR);
}
#endif
/*-----------------------------------------------------------------------------------*/
int
coap_dtls_send_to_peer(struct dtls_context_t *ctx,
session_t *session, uint8 *data, size_t len)
{
struct uip_udp_conn *conn = (struct uip_udp_conn *)dtls_get_app_data(ctx);
uip_ipaddr_copy(&conn->ripaddr, &session->addr);
conn->rport = session->port;
uip_udp_packet_send(conn, data, len);
/* Restore server connection to allow data from any node */
memset(&conn->ripaddr, 0, sizeof(conn->ripaddr));
memset(&conn->rport, 0, sizeof(conn->rport));
return len;
}
/*-----------------------------------------------------------------------------------*/
int
coap_dtls_read_from_peer(struct dtls_context_t *ctx,
session_t *session, uint8 *data, size_t len)
{
uip_len = len;
memmove(uip_appdata, data, len);
coap_receive(ctx);
return 0;
}

View file

@ -0,0 +1,47 @@
#ifndef COAP_DTLS_H_
#define COAP_DTLS_H_
/* Internal configuration of tinydtls for er-coap-dtls */
#if defined DTLS_CONF_IDENTITY && defined DTLS_CONF_IDENTITY_LENGTH
#define DTLS_IDENTITY DTLS_CONF_IDENTITY
#define DTLS_IDENTITY_LENGTH DTLS_CONF_IDENTITY_LENGTH
#else
#define DTLS_IDENTITY "Client_identity"
#define DTLS_IDENTITY_LENGTH 15
#endif
#if defined DTLS_CONF_PSK_KEY && defined DTLS_CONF_PSK_KEY_LENGTH
#define DTLS_PSK_KEY_VALUE DTLS_CONF_PSK_KEY
#define DTLS_PSK_KEY_VALUE_LENGTH DTLS_CONF_PSK_KEY_LENGTH
#else
#warning "DTLS: Using default secret key !"
#define DTLS_PSK_KEY_VALUE "secretPSK"
#define DTLS_PSK_KEY_VALUE_LENGTH 9
#endif
/* Structure that hold tinydtls callbacks, has type 'dtls_handler_t'. */
#ifndef COAP_DTLS_CALLBACK
#ifdef COAP_DTLS_CONF_CALLBACK
#define COAP_DTLS_CALLBACK COAP_DTLS_CONF_CALLBACK
#else /* COAP_DTLS_CONF_CALLBACK */
#define COAP_DTLS_CALLBACK coap_dtls_callback
#endif /* COAP_DTLS_CALLBACK */
/* Send 'data' to peer defined by session */
int coap_dtls_send_to_peer(struct dtls_context_t *ctx,
session_t *session, uint8 *data, size_t len);
/* Read 'data' from peer */
int coap_dtls_read_from_peer(struct dtls_context_t *ctx,
session_t *session, uint8 *data, size_t len);
#ifdef DTLS_PSK
/* Retrieve the key for given identity withing this session */
int coap_dtls_get_psk_info(struct dtls_context_t *ctx,
const session_t *session,
dtls_credentials_type_t type,
const unsigned char *id, size_t id_len,
unsigned char *result, size_t result_length);
#endif
#endif /* COAP_DTLS_H_ */

View file

@ -41,6 +41,7 @@
#include <stdlib.h>
#include <string.h>
#include "er-coap-engine.h"
#include "er-coap-communication.h"
#define DEBUG 0
#if DEBUG
@ -64,8 +65,8 @@ static service_callback_t service_cbk = NULL;
/*---------------------------------------------------------------------------*/
/*- Internal API ------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
static int
coap_receive(void)
int
coap_receive()
{
erbium_status_code = NO_ERROR;
@ -256,12 +257,12 @@ coap_receive(void)
transaction = NULL;
#if COAP_OBSERVE_CLIENT
/* if observe notification */
/* if observe notification */
if((message->type == COAP_TYPE_CON || message->type == COAP_TYPE_NON)
&& IS_OPTION(message, COAP_OPTION_OBSERVE)) {
&& IS_OPTION(message, COAP_OPTION_OBSERVE)) {
PRINTF("Observe [%u]\n", message->observe);
coap_handle_notification(&UIP_IP_BUF->srcipaddr, UIP_UDP_BUF->srcport,
message);
message);
}
#endif /* COAP_OBSERVE_CLIENT */
} /* request or response */
@ -346,7 +347,7 @@ PROCESS_THREAD(coap_engine, ev, data)
PROCESS_YIELD();
if(ev == tcpip_event) {
coap_receive();
coap_handle_receive();
} else if(ev == PROCESS_EVENT_TIMER) {
/* retransmissions are handled here */
coap_check_transactions();
@ -482,6 +483,7 @@ const struct rest_implementation coap_rest_implementation = {
NOT_FOUND_4_04,
METHOD_NOT_ALLOWED_4_05,
NOT_ACCEPTABLE_4_06,
REQUEST_ENTITY_INCOMPLETE_4_08,
REQUEST_ENTITY_TOO_LARGE_4_13,
UNSUPPORTED_MEDIA_TYPE_4_15,
INTERNAL_SERVER_ERROR_5_00,

View file

@ -52,6 +52,7 @@ typedef coap_packet_t rest_request_t;
typedef coap_packet_t rest_response_t;
void coap_init_engine(void);
int coap_receive();
/*---------------------------------------------------------------------------*/
/*- Client Part -------------------------------------------------------------*/

View file

@ -107,7 +107,7 @@ int coap_obs_remove_observee_by_token(uip_ipaddr_t *addr, uint16_t port,
int coap_obs_remove_observee_by_url(uip_ipaddr_t *addr, uint16_t port,
const char *url);
void coap_handle_notification(uip_ipaddr_t *, uint16_t port,
void coap_handle_notification(uip_ipaddr_t *addr, uint16_t port,
coap_packet_t *notification);
coap_observee_t *coap_obs_request_registration(uip_ipaddr_t *addr,

View file

@ -249,6 +249,8 @@ coap_notify_observers_sub(resource_t *resource, const char *subpath)
if(notification->code < BAD_REQUEST_4_00) {
coap_set_header_observe(notification, (obs->obs_counter)++);
/* mask out to keep the CoAP observe option length <= 3 bytes */
obs->obs_counter &= 0xffffff;
}
coap_set_token(notification, obs->token, obs->token_len);
@ -266,7 +268,7 @@ coap_observe_handler(resource_t *resource, void *request, void *response)
{
coap_packet_t *const coap_req = (coap_packet_t *)request;
coap_packet_t *const coap_res = (coap_packet_t *)response;
coap_observer_t * obs;
coap_observer_t *obs;
if(coap_req->code == COAP_GET && coap_res->code < 128) { /* GET request and response without error code */
if(IS_OPTION(coap_req, COAP_OPTION_OBSERVE)) {
@ -274,8 +276,10 @@ coap_observe_handler(resource_t *resource, void *request, void *response)
obs = add_observer(&UIP_IP_BUF->srcipaddr, UIP_UDP_BUF->srcport,
coap_req->token, coap_req->token_len,
coap_req->uri_path, coap_req->uri_path_len);
if(obs) {
if(obs) {
coap_set_header_observe(coap_res, (obs->obs_counter)++);
/* mask out to keep the CoAP observe option length <= 3 bytes */
obs->obs_counter &= 0xffffff;
/*
* Following payload is for demonstration purposes only.
* A subscription should return the same representation as a normal GET.

View file

@ -0,0 +1,42 @@
#include "contiki.h"
#include "contiki-net.h"
#include "er-coap-engine.h"
#include "er-coap-communication.h"
#include <string.h>
#define DEBUG DEBUG_NONE
#include "uip-debug.h"
static struct uip_udp_conn *udp_conn = NULL;
/*-----------------------------------------------------------------------------------*/
void
coap_init_communication_layer(uint16_t port)
{
/* new connection with remote host */
udp_conn = udp_new(NULL, 0, NULL);
udp_bind(udp_conn, port);
PRINTF("Listening on port %u\n", uip_ntohs(udp_conn->lport));
}
/*-----------------------------------------------------------------------------------*/
void
coap_send_message(uip_ipaddr_t *addr, uint16_t port, uint8_t *data, uint16_t length)
{
/* Configure connection to reply to client */
uip_ipaddr_copy(&udp_conn->ripaddr, addr);
udp_conn->rport = port;
uip_udp_packet_send(udp_conn, data, length);
PRINTF("-sent UDP datagram (%u)-\n", length);
/* Restore server connection to allow data from any node */
memset(&udp_conn->ripaddr, 0, sizeof(udp_conn->ripaddr));
udp_conn->rport = 0;
}
/*-----------------------------------------------------------------------------------*/
void
coap_handle_receive()
{
coap_receive();
}

View file

@ -44,6 +44,7 @@
#include "er-coap.h"
#include "er-coap-transactions.h"
#include "er-coap-communication.h"
#define DEBUG 0
#if DEBUG
@ -60,7 +61,6 @@
/*---------------------------------------------------------------------------*/
/*- Variables ---------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
static struct uip_udp_conn *udp_conn = NULL;
static uint16_t current_mid = 0;
coap_status_t erbium_status_code = NO_ERROR;
@ -178,7 +178,7 @@ coap_serialize_array_option(unsigned int number, unsigned int current_number,
size_t i = 0;
PRINTF("ARRAY type %u, len %zu, full [%.*s]\n", number, length,
(int)length, array);
(int)length, array);
if(split_char != '\0') {
int j;
@ -279,9 +279,7 @@ void
coap_init_connection(uint16_t port)
{
/* new connection with remote host */
udp_conn = udp_new(NULL, 0, NULL);
udp_bind(udp_conn, port);
PRINTF("Listening on port %u\n", uip_ntohs(udp_conn->lport));
coap_init_communication_layer(port);
/* initialize transaction ID */
current_mid = random_rand();
@ -422,23 +420,6 @@ coap_serialize_message(void *packet, uint8_t *buffer)
return (option - buffer) + coap_pkt->payload_len; /* packet length */
}
/*---------------------------------------------------------------------------*/
void
coap_send_message(uip_ipaddr_t *addr, uint16_t port, uint8_t *data,
uint16_t length)
{
/* configure connection to reply to client */
uip_ipaddr_copy(&udp_conn->ripaddr, addr);
udp_conn->rport = port;
uip_udp_packet_send(udp_conn, data, length);
PRINTF("-sent UDP datagram (%u)-\n", length);
/* restore server socket to allow data from any node */
memset(&udp_conn->ripaddr, 0, sizeof(udp_conn->ripaddr));
udp_conn->rport = 0;
}
/*---------------------------------------------------------------------------*/
coap_status_t
coap_parse_message(void *packet, uint8_t *data, uint16_t data_len)
{
@ -529,8 +510,21 @@ coap_parse_message(void *packet, uint8_t *data, uint16_t data_len)
++current_option;
}
if(current_option + option_length > data + data_len) {
/* Malformed CoAP - out of bounds */
PRINTF("BAD REQUEST: options outside data packet: %u > %u\n",
(unsigned)(current_option + option_length - data), data_len);
return BAD_REQUEST_4_00;
}
option_number += option_delta;
if(option_number > COAP_OPTION_SIZE1) {
/* Malformed CoAP - out of bounds */
PRINTF("BAD REQUEST: option number too large: %u\n", option_number);
return BAD_REQUEST_4_00;
}
PRINTF("OPTION %u (delta %u, len %zu): ", option_number, option_delta,
option_length);
@ -602,7 +596,7 @@ coap_parse_message(void *packet, uint8_t *data, uint16_t data_len)
coap_pkt->uri_host = (char *)current_option;
coap_pkt->uri_host_len = option_length;
PRINTF("Uri-Host [%.*s]\n", (int)coap_pkt->uri_host_len,
coap_pkt->uri_host);
coap_pkt->uri_host);
break;
case COAP_OPTION_URI_PORT:
coap_pkt->uri_port = coap_parse_int_option(current_option,

View file

@ -61,8 +61,8 @@
(REST_MAX_CHUNK_SIZE < 128 ? 64 : \
(REST_MAX_CHUNK_SIZE < 256 ? 128 : \
(REST_MAX_CHUNK_SIZE < 512 ? 256 : \
(REST_MAX_CHUNK_SIZE < 1024 ? 512 : \
(REST_MAX_CHUNK_SIZE < 2048 ? 1024 : 2048)))))))
(REST_MAX_CHUNK_SIZE < 1024 ? 512 : \
(REST_MAX_CHUNK_SIZE < 2048 ? 1024 : 2048)))))))
#endif /* COAP_MAX_BLOCK_SIZE */
/* direct access into the buffer */
@ -135,7 +135,7 @@ typedef struct {
/* option format serialization */
#define COAP_SERIALIZE_INT_OPTION(number, field, text) \
if(IS_OPTION(coap_pkt, number)) { \
PRINTF(text " [%u]\n", (unsigned int)coap_pkt->field); \
PRINTF(text " [%u]\n", (unsigned int)coap_pkt->field); \
option += coap_serialize_int_option(number, current_number, option, coap_pkt->field); \
current_number = number; \
}
@ -167,7 +167,7 @@ typedef struct {
uint32_t block = coap_pkt->field##_num << 4; \
if(coap_pkt->field##_more) { block |= 0x8; } \
block |= 0xF & coap_log_2(coap_pkt->field##_size / 16); \
PRINTF(text " encoded: 0x%lX\n", (unsigned long)block); \
PRINTF(text " encoded: 0x%lX\n", (unsigned long)block); \
option += coap_serialize_int_option(number, current_number, option, block); \
current_number = number; \
}

View file

@ -119,6 +119,20 @@ static const char *get_uri (void *request)
return buf;
}
static const char *get_query (void *request)
{
static char buf [MAX_QUERY_STRING_LENGTH];
const char *query;
size_t len = coap_get_header_uri_query (request, &query);
if (len > sizeof (buf) - 1) {
*buf = '\0';
} else {
strncpy (buf, query, len);
buf [len] = '\0';
}
return buf;
}
void generic_get_handler
( void *request
, void *response
@ -127,14 +141,20 @@ void generic_get_handler
, int32_t *offset
, char *name
, int is_str
, size_t (*to_str)(const char *name, const char *uri, char *buf, size_t bsize)
, size_t (*to_str)
( const char *name
, const char *uri
, const char *query
, char *buf, size_t bsize
)
)
{
int success = 1;
char temp [MAX_GET_STRING_LENGTH];
size_t len = 0;
unsigned int accept = -1;
const char *uri = get_uri (request);
const char *uri = get_uri (request);
const char *query = get_query (request);
REST.get_header_accept (request, &accept);
if ( accept != -1
@ -160,7 +180,7 @@ void generic_get_handler
success = 0;
goto out;
}
len += to_str (name, uri, temp + len, sizeof (temp) - len);
len += to_str (name, uri, query, temp + len, sizeof (temp) - len);
if (len > sizeof (temp)) {
success = 0;
goto out;
@ -176,7 +196,7 @@ void generic_get_handler
goto out;
}
} else { // TEXT Format
len += to_str (name, uri, temp + len, sizeof (temp) - len);
len += to_str (name, uri, query, temp + len, sizeof (temp) - len);
if (len > sizeof (temp)) {
success = 0;
goto out;
@ -203,7 +223,8 @@ void generic_put_handler
, uint16_t preferred_size
, int32_t *offset
, char *name
, int (*from_str)(const char *name, const char *uri, const char *s)
, int (*from_str)
(const char *name, const char *uri, const char *query, const char *s)
)
{
int success = 1;
@ -212,6 +233,7 @@ void generic_put_handler
const uint8_t *bytes = NULL;
unsigned int c_ctype;
const char *uri = get_uri (request);
const char *query = get_query (request);
REST.get_header_content_type (request, &c_ctype);
if (from_str && (len = coap_get_payload (request, &bytes))) {
@ -226,7 +248,7 @@ void generic_put_handler
goto out;
}
}
if (from_str (name, uri, temp) < 0) {
if (from_str (name, uri, query, temp) < 0) {
success = 0;
} else {
REST.set_response_status (response, REST.status.CHANGED);

View file

@ -50,8 +50,9 @@
#define STR__(s) #s
#define STR_(s) STR__(s)
#define MAX_GET_STRING_LENGTH 100
#define MAX_URI_STRING_LENGTH 30
#define MAX_GET_STRING_LENGTH 100
#define MAX_URI_STRING_LENGTH 30
#define MAX_QUERY_STRING_LENGTH 30
/*
* A macro that extends the resource definition and also sets up the
@ -124,11 +125,8 @@ extern int8_t json_parse_variable
*
* The callback functions get the name of the parameter as a first
* argument, this allows to re-use the same function for different
* parameters.
* For the to_str function the is_json flag allows to generate a
* different string depending on the content-type. In addition it gets a
* buffer and the size of the buffer. It needs to return the number of
* bytes output, similar to sprintf.
* parameters. In addition it gets a buffer and the size of the buffer.
* It needs to return the number of bytes output, similar to sprintf.
*/
extern void generic_get_handler
( void *request
@ -138,7 +136,13 @@ extern void generic_get_handler
, int32_t *offset
, char *name
, int is_str
, size_t (*to_str)(const char *name, const char *uri, char *buf, size_t bsize)
, size_t (*to_str)
( const char *name
, const char *uri
, const char *query
, char *buf
, size_t bsize
)
);
/**
@ -161,7 +165,8 @@ extern void generic_put_handler
, uint16_t preferred_size
, int32_t *offset
, char *name
, int (*from_str)(const char *name, const char *uri, const char *s)
, int (*from_str)
(const char *name, const char *uri, const char *query, const char *s)
);
/*

View file

@ -65,7 +65,7 @@
/*---------------------------------------------------------------------------*/
#define DEBUG 0
#if DEBUG
#define PRINTF(...) PRINTF(__VA_ARGS__)
#define PRINTF(...) printf(__VA_ARGS__)
#else
#define PRINTF(...)
#endif
@ -130,6 +130,7 @@ typedef enum {
/*---------------------------------------------------------------------------*/
/* Protothread send macros */
#define PT_MQTT_WRITE_BYTES(conn, data, len) \
conn->out_write_pos = 0; \
while(write_bytes(conn, data, len)) { \
PT_WAIT_UNTIL(pt, (conn)->out_buffer_sent); \
}
@ -147,14 +148,18 @@ typedef enum {
*/
#define PT_MQTT_WAIT_SEND() \
do { \
process_post(PROCESS_CURRENT(), mqtt_continue_send_event, NULL); \
PROCESS_WAIT_EVENT(); \
if(ev == mqtt_abort_now_event) { \
conn->state = MQTT_CONN_STATE_ABORT_IMMEDIATE; \
PT_EXIT(&conn->out_proto_thread); \
process_post(PROCESS_CURRENT(), ev, data); \
} else if(ev >= mqtt_event_min && ev <= mqtt_event_max) { \
process_post(PROCESS_CURRENT(), ev, data); \
if (PROCESS_ERR_OK == \
process_post(PROCESS_CURRENT(), mqtt_continue_send_event, NULL)) { \
do { \
PROCESS_WAIT_EVENT(); \
if(ev == mqtt_abort_now_event) { \
conn->state = MQTT_CONN_STATE_ABORT_IMMEDIATE; \
PT_INIT(&conn->out_proto_thread); \
process_post(PROCESS_CURRENT(), ev, data); \
} else if(ev >= mqtt_event_min && ev <= mqtt_event_max) { \
process_post(PROCESS_CURRENT(), ev, data); \
} \
} while (ev != mqtt_continue_send_event); \
} \
} while(0)
/*---------------------------------------------------------------------------*/
@ -751,6 +756,8 @@ handle_connack(struct mqtt_connection *conn)
call_event(conn,
MQTT_EVENT_CONNECTION_REFUSED_ERROR,
&conn->in_packet.payload[1]);
abort_connection(conn);
return;
}
conn->out_packet.qos_state = MQTT_QOS_STATE_GOT_ACK;
@ -1186,8 +1193,8 @@ PROCESS_THREAD(mqtt_process, ev, data)
if(conn->state == MQTT_CONN_STATE_SENDING_MQTT_DISCONNECT) {
if(conn->out_buffer_sent == 1) {
PT_INIT(&conn->out_proto_thread);
while(disconnect_pt(&conn->out_proto_thread, conn) < PT_EXITED &&
conn->state != MQTT_CONN_STATE_ABORT_IMMEDIATE) {
while(conn->state != MQTT_CONN_STATE_ABORT_IMMEDIATE &&
disconnect_pt(&conn->out_proto_thread, conn) < PT_EXITED) {
PT_MQTT_WAIT_SEND();
}
abort_connection(conn);
@ -1204,8 +1211,8 @@ PROCESS_THREAD(mqtt_process, ev, data)
if(conn->out_buffer_sent == 1 &&
conn->state == MQTT_CONN_STATE_CONNECTED_TO_BROKER) {
PT_INIT(&conn->out_proto_thread);
while(pingreq_pt(&conn->out_proto_thread, conn) < PT_EXITED &&
conn->state == MQTT_CONN_STATE_CONNECTED_TO_BROKER) {
while(conn->state == MQTT_CONN_STATE_CONNECTED_TO_BROKER &&
pingreq_pt(&conn->out_proto_thread, conn) < PT_EXITED) {
PT_MQTT_WAIT_SEND();
}
}
@ -1217,8 +1224,8 @@ PROCESS_THREAD(mqtt_process, ev, data)
if(conn->out_buffer_sent == 1 &&
conn->state == MQTT_CONN_STATE_CONNECTED_TO_BROKER) {
PT_INIT(&conn->out_proto_thread);
while(subscribe_pt(&conn->out_proto_thread, conn) < PT_EXITED &&
conn->state == MQTT_CONN_STATE_CONNECTED_TO_BROKER) {
while(conn->state == MQTT_CONN_STATE_CONNECTED_TO_BROKER &&
subscribe_pt(&conn->out_proto_thread, conn) < PT_EXITED) {
PT_MQTT_WAIT_SEND();
}
}
@ -1230,8 +1237,8 @@ PROCESS_THREAD(mqtt_process, ev, data)
if(conn->out_buffer_sent == 1 &&
conn->state == MQTT_CONN_STATE_CONNECTED_TO_BROKER) {
PT_INIT(&conn->out_proto_thread);
while(unsubscribe_pt(&conn->out_proto_thread, conn) < PT_EXITED &&
conn->state == MQTT_CONN_STATE_CONNECTED_TO_BROKER) {
while(conn->state == MQTT_CONN_STATE_CONNECTED_TO_BROKER &&
unsubscribe_pt(&conn->out_proto_thread, conn) < PT_EXITED) {
PT_MQTT_WAIT_SEND();
}
}
@ -1243,8 +1250,8 @@ PROCESS_THREAD(mqtt_process, ev, data)
if(conn->out_buffer_sent == 1 &&
conn->state == MQTT_CONN_STATE_CONNECTED_TO_BROKER) {
PT_INIT(&conn->out_proto_thread);
while(publish_pt(&conn->out_proto_thread, conn) < PT_EXITED &&
conn->state == MQTT_CONN_STATE_CONNECTED_TO_BROKER) {
while(conn->state == MQTT_CONN_STATE_CONNECTED_TO_BROKER &&
publish_pt(&conn->out_proto_thread, conn) < PT_EXITED) {
PT_MQTT_WAIT_SEND();
}
}
@ -1331,7 +1338,9 @@ mqtt_connect(struct mqtt_connection *conn, char *host, uint16_t port,
conn->connect_vhdr_flags |= MQTT_VHDR_CLEAN_SESSION_FLAG;
/* convert the string IPv6 address to a numeric IPv6 address */
uiplib_ip6addrconv(host, &ip6addr);
if(uiplib_ip6addrconv(host, &ip6addr) == 0) {
return MQTT_STATUS_ERROR;
}
uip_ipaddr_copy(&(conn->server_ip), ipaddr);

View file

@ -196,7 +196,7 @@ typedef enum {
MQTT_CONN_STATE_ERROR,
MQTT_CONN_STATE_DNS_ERROR,
MQTT_CONN_STATE_DISCONNECTING,
MQTT_CONN_STATE_ABORT_IMMEDIATE,
MQTT_CONN_STATE_NOT_CONNECTED,
MQTT_CONN_STATE_DNS_LOOKUP,
MQTT_CONN_STATE_TCP_CONNECTING,
@ -204,7 +204,6 @@ typedef enum {
MQTT_CONN_STATE_CONNECTING_TO_BROKER,
MQTT_CONN_STATE_CONNECTED_TO_BROKER,
MQTT_CONN_STATE_SENDING_MQTT_DISCONNECT,
MQTT_CONN_STATE_ABORT_IMMEDIATE,
} mqtt_conn_state_t;
/*---------------------------------------------------------------------------*/
struct mqtt_string {

View file

@ -587,6 +587,40 @@ get_resource(const lwm2m_instance_t *instance, lwm2m_context_t *context)
return NULL;
}
/*---------------------------------------------------------------------------*/
/**
* @brief Write a list of object instances as a CoRE Link-format list
*/
static int
write_object_instances_link(const lwm2m_object_t *object,
char *buffer, size_t size)
{
const lwm2m_instance_t *instance;
int len, rdlen, i;
PRINTF("</%d>", object->id);
rdlen = snprintf(buffer, size, "</%d>",
object->id);
if(rdlen < 0 || rdlen >= size) {
return -1;
}
for(i = 0; i < object->count; i++) {
if((object->instances[i].flag & LWM2M_INSTANCE_FLAG_USED) == 0) {
continue;
}
instance = &object->instances[i];
PRINTF(",</%d/%d>", object->id, instance->id);
len = snprintf(&buffer[rdlen], size - rdlen,
",<%d/%d>", object->id, instance->id);
rdlen += len;
if(len < 0 || rdlen >= size) {
return -1;
}
}
return rdlen;
}
/*---------------------------------------------------------------------------*/
static int
write_rd_link_data(const lwm2m_object_t *object,
const lwm2m_instance_t *instance,
@ -1052,6 +1086,23 @@ lwm2m_engine_handler(const lwm2m_object_t *object,
REST.set_header_content_type(response, LWM2M_JSON);
}
}
} else if(depth == 1) {
/* produce a list of instances */
if(method != METHOD_GET) {
REST.set_response_status(response, METHOD_NOT_ALLOWED_4_05);
} else {
int rdlen;
PRINTF("Sending instance list for object %u\n", object->id);
/* TODO: if(accept == APPLICATION_LINK_FORMAT) { */
rdlen = write_object_instances_link(object, (char *)buffer, preferred_size);
if(rdlen < 0) {
PRINTF("Failed to generate object response\n");
REST.set_response_status(response, SERVICE_UNAVAILABLE_5_03);
return;
}
REST.set_header_content_type(response, REST.type.APPLICATION_LINK_FORMAT);
REST.set_response_payload(response, buffer, rdlen);
}
}
}
/*---------------------------------------------------------------------------*/

View file

@ -45,6 +45,14 @@
#include "net/ipv6/uip-ds6-route.h"
#include "net/packetbuf.h"
#include "net/rpl/rpl-conf.h"
#include "net/rpl/rpl-private.h"
/*
* The body of this rule should be compiled only when "nbr_routes" is available,
* otherwise a link error causes build failure. "nbr_routes" is compiled if
* UIP_CONF_MAX_ROUTES != 0. See uip-ds6-route.c.
*/
#if UIP_CONF_MAX_ROUTES != 0
#if ORCHESTRA_UNICAST_SENDER_BASED && ORCHESTRA_COLLISION_FREE_HASH
#define UNICAST_SLOT_SHARED_FLAG ((ORCHESTRA_UNICAST_PERIOD < (ORCHESTRA_MAX_HASH + 1)) ? LINK_OPTION_SHARED : 0)
@ -211,3 +219,5 @@ struct orchestra_rule unicast_per_neighbor_rpl_storing = {
child_added,
child_removed,
};
#endif /* UIP_MAX_ROUTES */

View file

@ -0,0 +1 @@
ota-update_src = res_bootloader.c res_reboot.c res_upload_image.c

View file

@ -0,0 +1,22 @@
extern resource_t res_upload_image;
extern resource_t res_part_count;
extern resource_t res_part_size;
extern resource_t res_boot_default;
extern resource_t res_boot_next;
extern resource_t res_active_part;
extern resource_t res_part_start;
extern resource_t res_part_ok;
extern resource_t res_reboot;
#define OTA_ACTIVATE_RESOURCES() \
static char resname[] = "ota/update";\
rest_activate_resource (&res_upload_image, resname);\
rest_activate_resource (&res_part_count, (char *)"ota/part_count");\
rest_activate_resource (&res_part_size, (char *)"ota/part_size");\
rest_activate_resource (&res_boot_default, (char *)"ota/boot_default");\
rest_activate_resource (&res_boot_next, (char *)"ota/boot_next");\
rest_activate_resource (&res_active_part, (char *)"ota/active_part");\
rest_activate_resource (&res_part_start, (char *)"ota/part_start");\
rest_activate_resource (&res_part_ok, (char *)"ota/part_ok");\
rest_activate_resource (&res_reboot, (char *)"ota/reboot");

View file

@ -0,0 +1,260 @@
/*
* Copyright (c) 2015, Ralf Schlatterbeck Open Source Consulting
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* This file is part of the Contiki operating system.
*/
/**
* \file
* Bootloader ressources
* \author
* Ralf Schlatterbeck <rsc@runtux.com>
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include "contiki.h"
#include "contiki-net.h"
#include "rest-engine.h"
#include "er-coap-engine.h"
#include "uiplib.h"
#include "generic_resource.h"
#include "bootloader_if.h"
#include "Arduino.h"
/*
* Resources to be activated need to be imported through the extern keyword.
* The build system automatically compiles the resources in the
* corresponding sub-directory.
*/
static size_t
part_count
( const char *name
, const char *uri
, const char *query
, char *buf
, size_t bsize
)
{
return snprintf (buf, bsize, "%ld", bootloader_get_part_count ());
}
GENERIC_RESOURCE
( part_count
, Partition Count
, count
, 0
, NULL
, part_count
);
static size_t
part_size
( const char *name
, const char *uri
, const char *query
, char *buf
, size_t bsize
)
{
return snprintf (buf, bsize, "%ld", bootloader_get_part_size ());
}
GENERIC_RESOURCE
( part_size
, Partition Size
, count
, 0
, NULL
, part_size
);
static size_t
get_boot_default
( const char *name
, const char *uri
, const char *query
, char *buf
, size_t bsize
)
{
return snprintf (buf, bsize, "%ld", bootloader_get_boot_default ());
}
static int
set_boot_default
(const char *name, const char *uri, const char *query, const char *s)
{
uint32_t tmp = strtoul (s, NULL, 10);
bootloader_set_boot_default (tmp);
return 0;
}
GENERIC_RESOURCE
( boot_default
, Default boot partition
, count
, 0
, set_boot_default
, get_boot_default
);
static size_t
get_boot_next
( const char *name
, const char *uri
, const char *query
, char *buf
, size_t bsize
)
{
return snprintf (buf, bsize, "%ld", bootloader_get_boot_next ());
}
static int
set_boot_next
(const char *name, const char *uri, const char *query, const char *s)
{
uint32_t tmp = strtoul (s, NULL, 10);
bootloader_set_boot_next (tmp);
return 0;
}
GENERIC_RESOURCE
( boot_next
, Next boot partition
, count
, 0
, set_boot_next
, get_boot_next
);
static size_t
get_active_part
( const char *name
, const char *uri
, const char *query
, char *buf
, size_t bsize
)
{
return snprintf (buf, bsize, "%ld", bootloader_get_active_part ());
}
GENERIC_RESOURCE
( active_part
, Currently active partition
, count
, 0
, NULL
, get_active_part
);
/*
* Parse query info. We insist that the query starts with 'part='
* Then we parse the integer following the part= string and return the
* number. The number is always positive, if something goes wrong we
* return a negative number.
*/
static int get_query_partition (const char *query)
{
if (strncmp (query, "part=", 5)) {
return -1;
}
return strtoul (query + 5, NULL, 10);
}
static size_t
get_part_start
( const char *name
, const char *uri
, const char *query
, char *buf
, size_t bsize
)
{
int idx = get_query_partition (query);
if (idx < 0) {
return snprintf (buf, bsize, "Invalid: \"%s\" use part=N query", query);
}
return snprintf (buf, bsize, "%ld", bootloader_get_part_start (idx));
}
GENERIC_RESOURCE
( part_start
, Start of partition
, count
, 0
, NULL
, get_part_start
);
static int
set_part_ok
(const char *name, const char *uri, const char *query, const char *s)
{
uint32_t tmp = strtoul (s, NULL, 10);
int idx = get_query_partition (query);
if (idx < 0) {
return -1;
}
if (tmp) {
bootloader_set_part_ok (idx);
} else {
bootloader_clr_part_ok (idx);
}
return 0;
}
static size_t
get_part_ok
( const char *name
, const char *uri
, const char *query
, char *buf
, size_t bsize
)
{
int idx = get_query_partition (query);
if (idx < 0) {
return snprintf (buf, bsize, "Invalid: \"%s\" use part=N query", query);
}
return snprintf (buf, bsize, "%ld", bootloader_get_part_ok (idx));
}
GENERIC_RESOURCE
( part_ok
, Set/Clear Partition OK flag
, count
, 0
, set_part_ok
, get_part_ok
);

View file

@ -0,0 +1,108 @@
/*
* Copyright (c) 2017, Marcus Priesch Open Source Consulting
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* This file is part of the Contiki operating system.
*/
/**
* \file
* Reboot ressource
* \author
* Marcus Priesch <marcus@priesch.co.at>
*/
#include <stdio.h>
#include <string.h>
#include "contiki.h"
#include "er-coap-engine.h"
#include "generic_resource.h"
#include "dev/watchdog.h"
PROCESS(reboot_process, "reboot");
PROCESS_THREAD(reboot_process, ev, data)
{
static struct etimer etimer;
//PROCESS_EXITHANDLER(leds_off(LEDS_ALL);)
PROCESS_BEGIN();
//shell_output_str(&reboot_command,
// "Rebooting the node in four seconds...", "");
etimer_set(&etimer, CLOCK_SECOND * 4);
PROCESS_WAIT_UNTIL(etimer_expired(&etimer));
//leds_on(LEDS_RED);
//etimer_reset(&etimer);
//PROCESS_WAIT_UNTIL(etimer_expired(&etimer));
//leds_on(LEDS_GREEN);
//etimer_reset(&etimer);
//PROCESS_WAIT_UNTIL(etimer_expired(&etimer));
//leds_on(LEDS_BLUE);
//etimer_reset(&etimer);
//PROCESS_WAIT_UNTIL(etimer_expired(&etimer));
watchdog_reboot();
PROCESS_END();
}
static size_t
get_reboot
( const char *name
, const char *uri
, const char *query
, char *buf
, size_t bsize
)
{
return snprintf (buf, bsize, "put 'OK' to reboot.");
}
static int
do_reboot
(const char *name, const char *uri, const char *query, const char *s)
{
if (strncmp (s, "OK", 2) == 0) {
process_start (&reboot_process, NULL);
return 0;
}
return 0;
}
GENERIC_RESOURCE
( reboot
, Reboot node
, count
, 0
, do_reboot
, get_reboot
);

View file

@ -0,0 +1,243 @@
/*
* Copyright (C) 2017, Marcus Priesch, Ralf Schlatterbeck
* with code from the res-plugtest-large-update.c by
* Copyright (c) 2013, Institute for Pervasive Computing, ETH Zurich
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* This file is part of the Contiki operating system.
*/
/**
* \file
* Over-the-air update using blockwise transfer
* \author
* Marcus Priesch <marcus@priesch.co.at>
* Ralf Schlatterbeck <rsc@runtux.com>
*/
#include <string.h>
#include "sys/cc.h"
#include "rest-engine.h"
#include "er-coap.h"
#include "contiki.h"
#include "contiki-net.h"
#include "er-coap.h"
#include "Arduino.h"
#include <avr/interrupt.h>
#include "bootloader_if.h"
#if 1
#include <stdio.h>
#define PRINTF(x) printf x
#else
#define PRINTF(x)
#endif
// We allocate this statically, otherwise we cannot flash a new image
// when ram is exhausted!
static uint8_t current_page [256];
static uint32_t current_offset = 0;
#define PAGESIZE (sizeof (current_page))
/*
* Note that the current code relies on the fact that the bootloader
* used only supports two images. This may change in the future. We
* mainly need to relax some of the checks and use a different algorithm
* for computing imgidx, the index of the partition to be overwritten.
* If the bootloader supports more than two partitions at some point we
* may want the uploader to explicitly define the partition to be used.
*/
static void
res_put_handler
( void *request
, void *response
, uint8_t *buffer
, uint16_t preferred_size
, int32_t *offset
)
{
coap_packet_t *const packet = (coap_packet_t *)request;
uint8_t *in_data = NULL;
size_t len = 0;
uint32_t partition_start = 0;
const uint32_t partition_size = bootloader_get_part_size ();
uint32_t imgidx = 0;
unsigned int ct = -1;
/* If the currently-booted partition is not the default partition we
* do not allow overwriting a partition: Neither the currently-booted
* one (this would crash) nor the only partition that is marked
* bootable. We also insist that boot_next == boot_default.
*/
if (bootloader_get_boot_default () != bootloader_get_boot_next ()) {
REST.set_response_status (response, REST.status.BAD_REQUEST);
const char *error_msg = "Won't overwrite boot_next";
REST.set_response_payload (response, error_msg, strlen (error_msg));
return;
}
if (bootloader_get_boot_default () != bootloader_get_active_part ()) {
REST.set_response_status (response, REST.status.BAD_REQUEST);
const char *error_msg = "Won't overwrite current";
REST.set_response_payload (response, error_msg, strlen (error_msg));
return;
}
imgidx = !bootloader_get_active_part ();
partition_start = bootloader_get_part_start (imgidx);
REST.get_header_content_type (request, &ct);
/* Require content_type APPLICATION_OCTET_STREAM */
if (ct != REST.type.APPLICATION_OCTET_STREAM) {
REST.set_response_status (response, REST.status.BAD_REQUEST);
const char *error_msg = "ContentType";
REST.set_response_payload (response, error_msg, strlen (error_msg));
return;
}
len = REST.get_request_payload (request, (const uint8_t **)&in_data);
PRINTF (("cur: %lu len: %lu, offset: %lu\n",
(uint32_t)current_offset, (uint32_t)len, (uint32_t)*offset));
PRINTF (("b1-offs: %lu, b1-size: %u, b1-num: %lu b1-more: %d b1-size1: %lu\n",
packet->block1_offset, packet->block1_size, packet->block1_num,
packet->block1_more, packet->size1));
if (len == 0 || NULL == in_data) {
REST.set_response_status (response, REST.status.BAD_REQUEST);
const char *error_msg = "NoPayload";
REST.set_response_payload (response, error_msg, strlen (error_msg));
return;
}
/* if the block1_offset is 0 a new transmission has started */
if (!packet->block1_offset) {
current_offset = 0;
}
if (packet->block1_offset > current_offset) {
REST.set_response_status (response, REST.status.REQUEST_ENTITY_INCOMPLETE);
const char *error_msg = "OutOfSequence";
REST.set_response_payload (response, error_msg, strlen (error_msg));
return;
}
/* Old packet or retransmission, immediately confirm */
if (packet->block1_offset && packet->block1_offset + len <= current_offset) {
REST.set_response_status (response, REST.status.CHANGED);
coap_set_header_block1
(response, packet->block1_num, 0, packet->block1_size);
return;
}
// FIXME: blocksize may be larger than our flash page size
if (len > PAGESIZE) {
REST.set_response_status (response, REST.status.INTERNAL_SERVER_ERROR);
const char *error_msg = "GRMPF: PageSize";
REST.set_response_payload (response, error_msg, strlen (error_msg));
return;
}
// FIXME: blocksize may be larger than our flash page size
// So we should handle this case and repeatedly flash a block until the
// received data is written.
if (current_offset % PAGESIZE + len > PAGESIZE) {
REST.set_response_status (response, REST.status.INTERNAL_SERVER_ERROR);
const char *error_msg = "GRMPF: blocksize";
REST.set_response_payload (response, error_msg, strlen (error_msg));
return;
}
// Should never happen, we test for < and > earlier.
if (packet->block1_offset != current_offset) {
REST.set_response_status (response, REST.status.INTERNAL_SERVER_ERROR);
const char *error_msg = "GRMPF: Offset";
REST.set_response_payload (response, error_msg, strlen (error_msg));
return;
}
if (packet->block1_offset + len > partition_size) {
REST.set_response_status
(response, REST.status.REQUEST_ENTITY_TOO_LARGE);
REST.set_response_payload
(response, buffer, sprintf ((char *)buffer, "%luB max.", partition_size));
return;
}
memcpy (current_page + current_offset % PAGESIZE, in_data, len);
/* Whenever an upload is started for a partition mark it as not ok */
if (current_offset == 0) {
PRINTF (("Clear partition_ok: %ld\n", imgidx));
bootloader_clr_part_ok (imgidx);
}
current_offset += len;
if (current_offset % PAGESIZE == 0) {
uint32_t dst_address = partition_start + current_offset - PAGESIZE;
/* Special case: Flash irq vectors to backup position */
if (current_offset - PAGESIZE < PART_IRQVEC_SIZE) {
/* Only for images not at position 0 write first PART_IRQVEC_SIZE
* bytes also to original position. For partition 0 it will be
* copied there anyway *and* we would crash if we wrote to the
* active memory!
*/
if (partition_start != 0) {
PRINTF (("Flashing: %lx to %lx\n", (uint32_t)PAGESIZE, dst_address));
bootloader_write_page_to_flash (dst_address, PAGESIZE, current_page);
}
/* Note: The partition_size returned by the bootloader does *NOT*
* include the PART_IRQVEC_SIZE
*/
dst_address = partition_start + partition_size
+ current_offset - PAGESIZE;
}
PRINTF (("Flashing: %lx to %lx\n", (uint32_t)PAGESIZE, dst_address));
bootloader_write_page_to_flash (dst_address, PAGESIZE, current_page);
} else if (!packet->block1_more) {
uint32_t dst_address =
partition_start + (current_offset / PAGESIZE) * PAGESIZE;
PRINTF (("Flashing: last %lx to %lx\n", (uint32_t)PAGESIZE, dst_address));
bootloader_write_page_to_flash (dst_address, PAGESIZE, current_page);
}
if (!packet->block1_more) {
// we are finished
bootloader_set_boot_next (imgidx);
current_offset = 0;
}
REST.set_response_status (response, REST.status.CHANGED);
coap_set_header_block1 (response, packet->block1_num, 0, packet->block1_size);
}
RESOURCE(
res_upload_image
, "title=\"Flash memory upgrade\";rt=\"block\""
, NULL
, NULL
, res_put_handler
, NULL
);

View file

@ -56,6 +56,7 @@ struct rest_implementation_status {
const unsigned int NOT_FOUND; /* NOT_FOUND_4_04, NOT_FOUND_404 */
const unsigned int METHOD_NOT_ALLOWED; /* METHOD_NOT_ALLOWED_4_05, METHOD_NOT_ALLOWED_405 */
const unsigned int NOT_ACCEPTABLE; /* NOT_ACCEPTABLE_4_06, NOT_ACCEPTABLE_406 */
const unsigned int REQUEST_ENTITY_INCOMPLETE; /* REQUEST_ENTITY_INCOMPLETE_4_08, REQUEST_ENTITY_INCOMPLETE_408 */
const unsigned int REQUEST_ENTITY_TOO_LARGE; /* REQUEST_ENTITY_TOO_LARGE_4_13, REQUEST_ENTITY_TOO_LARGE_413 */
const unsigned int UNSUPPORTED_MEDIA_TYPE; /* UNSUPPORTED_MEDIA_TYPE_4_15, UNSUPPORTED_MEDIA_TYPE_415 */

View file

@ -113,6 +113,14 @@ rest_activate_resource(resource_t *resource, char *path)
PRINTF("Periodic resource: %p (%s)\n", resource->periodic,
resource->periodic->resource->url);
list_add(restful_periodic_services, resource->periodic);
if(process_is_running(&rest_engine_process)) {
PRINTF("Periodic: Set timer for /%s to %lu\n",
resource->url, resource->periodic->period);
PROCESS_CONTEXT_BEGIN(&rest_engine_process);
etimer_set(&resource->periodic->periodic_timer,
resource->periodic->period);
PROCESS_CONTEXT_END(&rest_engine_process);
}
}
}
/*---------------------------------------------------------------------------*/

View file

@ -49,7 +49,7 @@
#include <stdio.h>
#include <string.h>
#include "arduino-process.h"
/*---------------------------------------------------------------------------*/
PROCESS(serial_shell_process, "Contiki serial shell");
@ -58,6 +58,8 @@ void
shell_default_output(const char *text1, int len1, const char *text2, int len2)
{
int i;
mcu_sleep_disable();
if(text1 == NULL) {
text1 = "";
len1 = 0;
@ -89,6 +91,7 @@ void
shell_exit(void)
{
}
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(serial_shell_process, ev, data)
{
@ -98,6 +101,7 @@ PROCESS_THREAD(serial_shell_process, ev, data)
while(1) {
PROCESS_WAIT_EVENT_UNTIL(ev == serial_line_event_message && data != NULL);
mcu_sleep_disable();
shell_input(data, strlen(data));
}

View file

@ -66,3 +66,11 @@ endif
ifeq ($(TARGET),z1)
shell_src += shell-sky.c shell-exec.c
endif
ifeq ($(TARGET),osd-merkur-256)
shell_src += shell-merkur.c
endif
ifeq ($(TARGET),osd-merkur-128)
shell_src += shell-merkur.c
endif

237
apps/shell/shell-merkur.c Normal file
View file

@ -0,0 +1,237 @@
/*
* Copyright (c) 2008, Swedish Institute of Computer Science.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* This file is part of the Contiki operating system.
*
*/
/**
* \file
* Merkurboard-specific Contiki shell commands
* \author
* Harald Pichler <harald@the-develop.net>
*/
#include "contiki.h"
#include <stdio.h>
#include <stdlib.h> /* strtol */
#include "sys/cc.h"
#include "dev/radio.h"
#include "shell-merkur.h"
#include "params.h"
#include "arduino-process.h"
/*---------------------------------------------------------------------------*/
PROCESS(shell_txpower_process, "txpower");
SHELL_COMMAND(txpower_command,
"txpower",
"txpower <power>: change transmission power 0 (3dbm, default) to 15 (-17.2dbm)",
&shell_txpower_process);
PROCESS(shell_panid_process, "panid");
SHELL_COMMAND(panid_command,
"panid",
"panid <0xabcd>: change panid (default 0xabcd)",
&shell_panid_process);
PROCESS(shell_rfchannel_process, "rfchannel");
SHELL_COMMAND(rfchannel_command,
"rfchannel",
"rfchannel <channel>: change radio channel (11 - 26)",
&shell_rfchannel_process);
PROCESS(shell_ccathresholds_process, "ccathresholds");
SHELL_COMMAND(ccathresholds_command,
"ccathresholds",
"ccathresholds <threshold: change cca thresholds -91 to -61 dBm (default -77)",
&shell_ccathresholds_process);
PROCESS(shell_macconf_process, "macconf");
SHELL_COMMAND(macconf_command,
"macconf",
"macconf <conf>: change mac layer 0 -> do nothing; 1 -> Radio allways on",
&shell_macconf_process);
PROCESS(shell_saverfparam_process, "saverfparam");
SHELL_COMMAND(saverfparam_command,
"saverfparam",
"saverfparam <> save radio parameters txpower, channel, panid to eeprom settingsmanager",
&shell_saverfparam_process);
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(shell_txpower_process, ev, data)
{
radio_value_t value;
char buf[10];
const char *newptr;
PROCESS_BEGIN();
value = shell_strtolong(data, &newptr);
/* If no transmission power was given on the command line, we print
out the current txpower. */
if(newptr == data) {
if(get_param(RADIO_PARAM_TXPOWER, &value) == RADIO_RESULT_OK) {
}
} else {
set_param(RADIO_PARAM_TXPOWER, value);
}
snprintf(buf, sizeof(buf), "%3d", value);
shell_output_str(&txpower_command, "TX Power: ", buf);
PROCESS_END();
}
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(shell_rfchannel_process, ev, data)
{
radio_value_t value;
char buf[10];
const char *newptr;
PROCESS_BEGIN();
value = shell_strtolong(data, &newptr);
/* If no channel was given on the command line, we print out the
current channel. */
if(newptr == data) {
if(get_param(RADIO_PARAM_CHANNEL, &value) == RADIO_RESULT_OK) {
}
} else {
set_param(RADIO_PARAM_CHANNEL, value);
}
snprintf(buf, sizeof(buf), "%d", value);
shell_output_str(&rfchannel_command, "Channel: ", buf);
PROCESS_END();
}
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(shell_ccathresholds_process, ev, data)
{
radio_value_t value;
char buf[10];
const char *newptr;
PROCESS_BEGIN();
value = shell_strtolong(data, &newptr);
/* If no channel was given on the command line, we print out the
current channel. */
if(newptr == data) {
if(get_param(RADIO_PARAM_CCA_THRESHOLD, &value) == RADIO_RESULT_OK) {
}
} else {
set_param(RADIO_PARAM_CCA_THRESHOLD, value);
}
snprintf(buf, sizeof(buf), "%d dBm", value);
shell_output_str(&rfchannel_command, "CCA Threshold: ", buf);
PROCESS_END();
}
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(shell_macconf_process, ev, data)
{
radio_value_t value;
char buf[10];
const char *newptr;
PROCESS_BEGIN();
value = shell_strtolong(data, &newptr);
/* If no transmission power was given on the command line, we print
out the current macconf. */
if(newptr == data) {
value = params_get_macconf();
} else {
params_set_macconf(value);
}
snprintf(buf, sizeof(buf), "%3d", value);
shell_output_str(&txpower_command, "macconf: ", buf);
PROCESS_END();
}
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(shell_panid_process, ev, data)
{
radio_value_t value;
char buf[10];
char *newptr;
PROCESS_BEGIN();
value = strtol(data, &newptr, 0);
/* If no channel was given on the command line, we print out the
current channel. */
if(newptr == data) {
if(get_param(RADIO_PARAM_PAN_ID, &value) != RADIO_RESULT_OK) {
// printf("error: get_param RADIO_PARAM_PAN_ID\n");
}
} else {
set_param(RADIO_PARAM_PAN_ID, value);
}
snprintf(buf, sizeof(buf),"0x%02x%02x\n", (value >> 8) & 0xFF, value & 0xFF);
shell_output_str(&panid_command, "panid: ", buf);
PROCESS_END();
}
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(shell_saverfparam_process, ev, data)
{
PROCESS_BEGIN();
/* Save txpower */
params_save_txpower();
/* Save rfchannel */
params_save_channel();
/* Save ccathresholds */
// todo
/* Save panid */
params_save_panid();
/* Save macconf */
params_save_macconf();
shell_output_str(&rfchannel_command, "saverfparam done ", 0);
PROCESS_END();
}
/*---------------------------------------------------------------------------*/
void
shell_merkur_init(void)
{
// shell_ps_init();
shell_reboot_init();
shell_register_command(&txpower_command);
shell_register_command(&rfchannel_command);
shell_register_command(&ccathresholds_command);
shell_register_command(&panid_command);
shell_register_command(&macconf_command);
shell_register_command(&saverfparam_command);
// shell_register_command(&s_command);
}
/*---------------------------------------------------------------------------*/

47
apps/shell/shell-merkur.h Normal file
View file

@ -0,0 +1,47 @@
/*
* Copyright (c) 2008, Swedish Institute of Computer Science.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* This file is part of the Contiki operating system.
*
*/
/**
* \file
* Header file for Tmote Sky-specific Contiki shell commands
* \author
* harald pichler <harald@the-develop.net>
*/
#ifndef SHELL_MERKUR_H_
#define SHELL_MERKUR_H_
#include "shell.h"
void shell_merkur_init(void);
#endif /* SHELL_MERKUR_H_ */

View file

@ -35,7 +35,8 @@ static size_t get_index_from_uri (const char *uri)
return idx;
}
int crontab_from_string (const char *name, const char *uri, const char *s)
int crontab_from_string
(const char *name, const char *uri, const char *query, const char *s)
{
const char *err;
int res;
@ -52,7 +53,13 @@ int crontab_from_string (const char *name, const char *uri, const char *s)
}
size_t
crontab_to_string (const char *name, const char *uri, char *buf, size_t bsize)
crontab_to_string
( const char *name
, const char *uri
, const char *query
, char *buf
, size_t bsize
)
{
/* FIXME: For now we only return "valid" or "invalid" until someone
* comes up with a clever algorithm to reconstruct a crontab string

View file

@ -17,7 +17,8 @@
#include "er-coap.h"
#include "generic_resource.h"
size_t time_to_string (const char *name, const char *uri, char *buf, size_t bs)
size_t time_to_string
(const char *name, const char *uri, const char *query, char *buf, size_t bs)
{
struct xtimeval tv;
struct xtm tm;

View file

@ -21,7 +21,8 @@
#include "er-coap.h"
#include "generic_resource.h"
int timestamp_from_string (const char *name, const char *uri, const char *s)
int timestamp_from_string
(const char *name, const char *uri, const char *query, const char *s)
{
struct xtimeval tv;
// FIXME: Platform has no strtoll (long long)?
@ -31,7 +32,13 @@ int timestamp_from_string (const char *name, const char *uri, const char *s)
}
size_t
timestamp_to_string (const char *name, const char *uri, char *buf, size_t bsize)
timestamp_to_string
( const char *name
, const char *uri
, const char *query
, char *buf
, size_t bsize
)
{
struct xtimeval tv;
xgettimeofday (&tv, NULL);

View file

@ -17,14 +17,21 @@
#include "er-coap.h"
#include "generic_resource.h"
int timezone_from_string (const char *name, const char *uri, const char *s)
int timezone_from_string
(const char *name, const char *uri, const char *query, const char *s)
{
set_tz (s);
return 0;
}
size_t
timezone_to_string (const char *name, const char *uri, char *buf, size_t bsize)
timezone_to_string
( const char *name
, const char *uri
, const char *query
, char *buf
, size_t bsize
)
{
if (get_tz (buf, bsize) == NULL) {
*buf = '\0';

1
apps/tinydtls Submodule

@ -0,0 +1 @@
Subproject commit e95b02584a0041817da67c8c01f2a197d0c26915

View file

@ -410,6 +410,7 @@ parse_tag(void)
switch_majorstate(s.lastmajorstate);
break;
case TAG_BODY:
do_word();
s.majorstate = s.lastmajorstate = MAJORSTATE_BODY;
break;
case TAG_IMG:

View file

@ -155,10 +155,13 @@ make_tcp_stats(void *arg)
{
struct uip_conn *conn;
struct httpd_state *s = (struct httpd_state *)arg;
#if NETSTACK_CONF_WITH_IPV6
char buf[48];
#endif
conn = &uip_conns[s->u.count];
#if NETSTACK_CONF_WITH_IPV6
char buf[48];
httpd_sprint_ip6(conn->ripaddr, buf);
return snprintf((char *)uip_appdata, uip_mss(),
"<tr align=\"center\"><td>%d</td><td>%s:%u</td><td>%s</td><td>%u</td><td>%u</td><td>%c %c</td></tr>\r\n",
@ -249,8 +252,9 @@ extern uip_ds6_netif_t uip_ds6_if;
static unsigned short
make_addresses(void *p)
{
uint8_t i,j=0;
uint16_t numprinted;
uint8_t i, j = 0;
uint16_t numprinted;
numprinted = httpd_snprintf((char *)uip_appdata, uip_mss(),httpd_cgi_addrh);
for (i=0; i<UIP_DS6_ADDR_NB;i++) {
if (uip_ds6_if.addr_list[i].isused) {
@ -277,7 +281,7 @@ PT_THREAD(addresses(struct httpd_state *s, char *ptr))
static unsigned short
make_neighbors(void *p)
{
uint8_t i,j=0;
uint8_t j=0;
uint16_t numprinted;
numprinted = httpd_snprintf((char *)uip_appdata, uip_mss(),httpd_cgi_addrh);
uip_ds6_nbr_t *nbr;
@ -309,7 +313,7 @@ make_routes(void *p)
static const char httpd_cgi_rtes1[] HTTPD_STRING_ATTR = "(%u (via ";
static const char httpd_cgi_rtes2[] HTTPD_STRING_ATTR = ") %lus<br>";
static const char httpd_cgi_rtes3[] HTTPD_STRING_ATTR = ")<br>";
uint8_t i,j=0;
uint8_t j=0;
uint16_t numprinted;
uip_ds6_route_t *r;
@ -320,7 +324,7 @@ make_routes(void *p)
j++;
numprinted += httpd_cgi_sprint_ip6(r->ipaddr, uip_appdata + numprinted);
numprinted += httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_rtes1, r->length);
numprinted += httpd_cgi_sprint_ip6(uip_ds6_route_nexthop(r), uip_appdata + numprinted);
numprinted += httpd_cgi_sprint_ip6(*(uip_ds6_route_nexthop(r)), uip_appdata + numprinted);
if(r->state.lifetime < 3600) {
numprinted += httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_rtes2, r->state.lifetime);
} else {

View file

@ -1309,7 +1309,6 @@ cfs_coffee_configure_log(const char *filename, unsigned log_size,
return 0;
}
/*---------------------------------------------------------------------------*/
#if COFFEE_IO_SEMANTICS
int
cfs_coffee_set_io_semantics(int fd, unsigned flags)
{
@ -1321,7 +1320,6 @@ cfs_coffee_set_io_semantics(int fd, unsigned flags)
return 0;
}
#endif
/*---------------------------------------------------------------------------*/
int
cfs_coffee_format(void)

View file

@ -36,6 +36,7 @@
#include <dirent.h>
#include <string.h>
#define CFS_IMPL 1
#include "cfs/cfs.h"
struct cfs_posix_dir {

View file

@ -40,6 +40,7 @@
#include <unistd.h>
#endif
#define CFS_IMPL 1
#include "cfs/cfs.h"
/*---------------------------------------------------------------------------*/

View file

@ -148,13 +148,6 @@
#endif /* NBR_TABLE_FIND_REMOVABLE */
#endif /* UIP_CONF_IPV6_RPL */
/* RPL_CONF_MOP specifies the RPL mode of operation that will be
* advertised by the RPL root. Possible values: RPL_MOP_NO_DOWNWARD_ROUTES,
* RPL_MOP_NON_STORING, RPL_MOP_STORING_NO_MULTICAST, RPL_MOP_STORING_MULTICAST */
#ifndef RPL_CONF_MOP
#define RPL_CONF_MOP RPL_MOP_STORING_NO_MULTICAST
#endif /* RPL_CONF_MOP */
/* UIP_CONF_MAX_ROUTES specifies the maximum number of routes that each
node will be able to handle. */
#ifndef UIP_CONF_MAX_ROUTES
@ -211,7 +204,7 @@
#define UIP_CONF_ND6_SEND_RA (NETSTACK_CONF_WITH_IPV6 && !UIP_CONF_IPV6_RPL)
#endif /* UIP_CONF_ND6_SEND_RA */
/* UIP_CONF_ND6_SEND_NA enables standard IPv6 Neighbor Discovery Protocol.
/* UIP_CONF_ND6_SEND_NS enables standard IPv6 Neighbor Discovery Protocol.
We enable it by default when IPv6 is used without RPL.
With RPL, the neighbor cache (link-local IPv6 <-> MAC address mapping)
is fed whenever receiving DIO and DAO messages. This is always sufficient
@ -221,9 +214,15 @@
neighbor to us is weak, if DIO transmissions are suppressed (Trickle
timer) or if the neighbor chooses not to transmit DIOs because it is
a leaf node or for any reason. */
#ifndef UIP_CONF_ND6_SEND_NS
#define UIP_CONF_ND6_SEND_NS (NETSTACK_CONF_WITH_IPV6 && !UIP_CONF_IPV6_RPL)
#endif /* UIP_CONF_ND6_SEND_NS */
/* UIP_CONF_ND6_SEND_NA allows to still comply with NDP even if the host does
not perform NUD or DAD processes. By default it is activated so the host
can still communicate with a full NDP peer. */
#ifndef UIP_CONF_ND6_SEND_NA
#define UIP_CONF_ND6_SEND_NA (NETSTACK_CONF_WITH_IPV6 && !UIP_CONF_IPV6_RPL)
#endif /* UIP_CONF_ND6_SEND_NA */
#define UIP_CONF_ND6_SEND_NA (NETSTACK_CONF_WITH_IPV6)
#endif /* UIP_CONF_ND6_SEND_NS */
/*---------------------------------------------------------------------------*/
/* 6lowpan configuration options.

View file

@ -47,6 +47,8 @@
#define IGNORE_CHAR(c) (c == 0x0d)
#define END 0x0a
//#define IGNORE_CHAR(c) (c == 0x0a)
//#define END 0x0d
static struct ringbuf rxbuf;
static uint8_t rxbuf_data[BUFSIZE];

View file

@ -81,7 +81,7 @@ enum {
*/
static uint8_t state = STATE_TWOPACKETS;
static uint16_t begin, end;
static uint16_t begin, next_free;
static uint8_t rxbuf[RX_BUFSIZE];
static uint16_t pkt_end; /* SLIP_END tracker. */
@ -107,9 +107,6 @@ slip_send(void)
ptr = &uip_buf[UIP_LLH_LEN];
for(i = 0; i < uip_len; ++i) {
if(i == UIP_TCPIP_HLEN) {
ptr = (uint8_t *)uip_appdata;
}
c = *ptr++;
if(c == SLIP_END) {
slip_arch_writeb(SLIP_ESC);
@ -153,7 +150,7 @@ slip_write(const void *_ptr, int len)
static void
rxbuf_init(void)
{
begin = end = pkt_end = 0;
begin = next_free = pkt_end = 0;
state = STATE_OK;
}
/*---------------------------------------------------------------------------*/
@ -161,10 +158,11 @@ rxbuf_init(void)
static uint16_t
slip_poll_handler(uint8_t *outbuf, uint16_t blen)
{
#ifdef SLIP_CONF_MICROSOFT_CHAT
/* This is a hack and won't work across buffer edge! */
if(rxbuf[begin] == 'C') {
int i;
if(begin < end && (end - begin) >= 6
if(begin < next_free && (next_free - begin) >= 6
&& memcmp(&rxbuf[begin], "CLIENT", 6) == 0) {
state = STATE_TWOPACKETS; /* Interrupts do nothing. */
memset(&rxbuf[begin], 0x0, 6);
@ -177,12 +175,14 @@ slip_poll_handler(uint8_t *outbuf, uint16_t blen)
return 0;
}
}
#endif /* SLIP_CONF_MICROSOFT_CHAT */
#ifdef SLIP_CONF_ANSWER_MAC_REQUEST
else if(rxbuf[begin] == '?') {
/* Used by tapslip6 to request mac for auto configure */
int i, j;
char* hexchar = "0123456789abcdef";
if(begin < end && (end - begin) >= 2
if(begin < next_free && (next_free - begin) >= 2
&& rxbuf[begin + 1] == 'M') {
state = STATE_TWOPACKETS; /* Interrupts do nothing. */
rxbuf[begin] = 0;
@ -210,37 +210,109 @@ slip_poll_handler(uint8_t *outbuf, uint16_t blen)
*/
if(begin != pkt_end) {
uint16_t len;
uint16_t cur_next_free;
uint16_t cur_ptr;
int esc = 0;
if(begin < pkt_end) {
len = pkt_end - begin;
if(len > blen) {
len = 0;
} else {
memcpy(outbuf, &rxbuf[begin], len);
uint16_t i;
len = 0;
for(i = begin; i < pkt_end; ++i) {
if(len > blen) {
len = 0;
break;
}
if (esc) {
if(rxbuf[i] == SLIP_ESC_ESC) {
outbuf[len] = SLIP_ESC;
len++;
} else if(rxbuf[i] == SLIP_ESC_END) {
outbuf[len] = SLIP_END;
len++;
}
esc = 0;
} else if(rxbuf[i] == SLIP_ESC) {
esc = 1;
} else {
outbuf[len] = rxbuf[i];
len++;
}
}
} else {
len = (RX_BUFSIZE - begin) + (pkt_end - 0);
if(len > blen) {
len = 0;
} else {
unsigned i;
for(i = begin; i < RX_BUFSIZE; i++) {
*outbuf++ = rxbuf[i];
}
for(i = 0; i < pkt_end; i++) {
*outbuf++ = rxbuf[i];
}
uint16_t i;
len = 0;
for(i = begin; i < RX_BUFSIZE; ++i) {
if(len > blen) {
len = 0;
break;
}
if (esc) {
if(rxbuf[i] == SLIP_ESC_ESC) {
outbuf[len] = SLIP_ESC;
len++;
} else if(rxbuf[i] == SLIP_ESC_END) {
outbuf[len] = SLIP_END;
len++;
}
esc = 0;
} else if(rxbuf[i] == SLIP_ESC) {
esc = 1;
} else {
outbuf[len] = rxbuf[i];
len++;
}
}
for(i = 0; i < pkt_end; ++i) {
if(len > blen) {
len = 0;
break;
}
if (esc) {
if(rxbuf[i] == SLIP_ESC_ESC) {
outbuf[len] = SLIP_ESC;
len++;
} else if(rxbuf[i] == SLIP_ESC_END) {
outbuf[len] = SLIP_END;
len++;
}
esc = 0;
} else if(rxbuf[i] == SLIP_ESC) {
esc = 1;
} else {
outbuf[len] = rxbuf[i];
len++;
}
}
}
/* Remove data from buffer together with the copied packet. */
begin = pkt_end;
if(state == STATE_TWOPACKETS) {
pkt_end = end;
state = STATE_OK; /* Assume no bytes where lost! */
/* One more packet is buffered, need to be polled again! */
process_poll(&slip_process);
pkt_end = pkt_end + 1;
if(pkt_end == RX_BUFSIZE) {
pkt_end = 0;
}
if(pkt_end != next_free) {
cur_next_free = next_free;
cur_ptr = pkt_end;
while(cur_ptr != cur_next_free) {
if(rxbuf[cur_ptr] == SLIP_END) {
uint16_t tmp_begin = pkt_end;
pkt_end = cur_ptr;
begin = tmp_begin;
/* One more packet is buffered, need to be polled again! */
process_poll(&slip_process);
break;
}
cur_ptr++;
if(cur_ptr == RX_BUFSIZE) {
cur_ptr = 0;
}
}
if(cur_ptr == cur_next_free) {
/* no more pending full packet found */
begin = pkt_end;
}
} else {
begin = pkt_end;
}
return len;
}
@ -316,77 +388,71 @@ PROCESS_THREAD(slip_process, ev, data)
int
slip_input_byte(unsigned char c)
{
uint16_t cur_end;
switch(state) {
case STATE_RUBBISH:
if(c == SLIP_END) {
state = STATE_OK;
}
return 0;
case STATE_TWOPACKETS: /* Two packets are already buffered! */
return 0;
case STATE_ESC:
if(c == SLIP_ESC_END) {
c = SLIP_END;
} else if(c == SLIP_ESC_ESC) {
c = SLIP_ESC;
} else {
if(c != SLIP_ESC_END && c != SLIP_ESC_ESC) {
state = STATE_RUBBISH;
SLIP_STATISTICS(slip_rubbish++);
end = pkt_end; /* remove rubbish */
next_free = pkt_end; /* remove rubbish */
return 0;
}
state = STATE_OK;
break;
}
case STATE_OK:
if(c == SLIP_ESC) {
state = STATE_ESC;
return 0;
} else if(c == SLIP_END) {
/*
* We have a new packet, possibly of zero length.
*
* There may already be one packet buffered.
*/
if(end != pkt_end) { /* Non zero length. */
if(begin == pkt_end) { /* None buffered. */
pkt_end = end;
} else {
state = STATE_TWOPACKETS;
SLIP_STATISTICS(slip_twopackets++);
}
process_poll(&slip_process);
return 1;
}
return 0;
}
break;
if(c == SLIP_ESC) {
state = STATE_ESC;
}
/* add_char: */
{
unsigned next;
next = end + 1;
if(next == RX_BUFSIZE) {
next = 0;
}
if(next == begin) { /* rxbuf is full */
state = STATE_RUBBISH;
SLIP_STATISTICS(slip_overflow++);
end = pkt_end; /* remove rubbish */
return 0;
}
rxbuf[end] = c;
end = next;
cur_end = next_free;
next_free = next_free + 1;
if(next_free == RX_BUFSIZE) {
next_free = 0;
}
if(next_free == begin) { /* rxbuf is full */
state = STATE_RUBBISH;
SLIP_STATISTICS(slip_overflow++);
next_free = pkt_end; /* remove rubbish */
return 0;
}
rxbuf[cur_end] = c;
#ifdef SLIP_CONF_MICROSOFT_CHAT
/* There could be a separate poll routine for this. */
if(c == 'T' && rxbuf[begin] == 'C') {
process_poll(&slip_process);
return 1;
}
#endif /* SLIP_CONF_MICROSOFT_CHAT */
if(c == SLIP_END) {
/*
* We have a new packet, possibly of zero length.
*
* There may already be one packet buffered.
*/
if(cur_end != pkt_end) { /* Non zero length. */
if(begin == pkt_end) { /* None buffered. */
pkt_end = cur_end;
} else {
SLIP_STATISTICS(slip_twopackets++);
}
process_poll(&slip_process);
return 1;
} else {
/* Empty packet, reset the pointer */
next_free = cur_end;
}
return 0;
}
return 0;
}

View file

@ -83,7 +83,7 @@ ringbufindex_peek_put(const struct ringbufindex *r)
if(((r->put_ptr - r->get_ptr) & r->mask) == r->mask) {
return -1;
}
return (r->put_ptr + 1) & r->mask;
return r->put_ptr;
}
/* Remove the first element and return its index */
int
@ -118,7 +118,7 @@ ringbufindex_peek_get(const struct ringbufindex *r)
first one. If there are no bytes left, we return -1.
*/
if(((r->put_ptr - r->get_ptr) & r->mask) > 0) {
return (r->get_ptr + 1) & r->mask;
return r->get_ptr;
} else {
return -1;
}

View file

@ -48,25 +48,72 @@ struct ringbufindex {
uint8_t put_ptr, get_ptr;
};
/* Initialize a ring buffer. The size must be a power of two */
/**
* \brief Initialize a ring buffer. The size must be a power of two
* \param r Pointer to ringbufindex
* \param size Size of ring buffer
*/
void ringbufindex_init(struct ringbufindex *r, uint8_t size);
/* Put one element to the ring buffer */
/**
* \brief Put one element to the ring buffer
* \param r Pointer to ringbufindex
* \retval 0 Failure; the ring buffer is full
* \retval 1 Success; an element is added
*/
int ringbufindex_put(struct ringbufindex *r);
/* Check if there is space to put an element.
* Return the index where the next element is to be added */
/**
* \brief Check if there is space to put an element.
* \param r Pinter to ringbufindex
* \retval >= 0 The index where the next element is to be added.
* \retval -1 Failure; the ring buffer is full
*/
int ringbufindex_peek_put(const struct ringbufindex *r);
/* Remove the first element and return its index */
/**
* \brief Remove the first element and return its index
* \param r Pinter to ringbufindex
* \retval >= 0 The index of the first element
* \retval -1 No element in the ring buffer
*/
int ringbufindex_get(struct ringbufindex *r);
/* Return the index of the first element
* (which will be removed if calling ringbufindex_peek) */
/**
* \brief Return the index of the first element which will be removed if calling
* ringbufindex_get.
* \param r Pinter to ringbufindex
* \retval >= 0 The index of the first element
* \retval -1 No element in the ring buffer
*/
int ringbufindex_peek_get(const struct ringbufindex *r);
/* Return the ring buffer size */
/**
* \brief Return the ring buffer size
* \param r Pinter to ringbufindex
* \return The size of the ring buffer
*/
int ringbufindex_size(const struct ringbufindex *r);
/* Return the number of elements currently in the ring buffer */
/**
* \brief Return the number of elements currently in the ring buffer.
* \param r Pinter to ringbufindex
* \return The number of elements in the ring buffer
*/
int ringbufindex_elements(const struct ringbufindex *r);
/* Is the ring buffer full? */
/**
* \brief Is the ring buffer full?
* \retval 0 Not full
* \retval 1 Full
*/
int ringbufindex_full(const struct ringbufindex *r);
/* Is the ring buffer empty? */
/**
* \brief Is the ring buffer empty?
* \retval 0 Not empty
* \retval 1 Empty
*/
int ringbufindex_empty(const struct ringbufindex *r);
#endif /* __RINGBUFINDEX_H__ */

View file

@ -130,7 +130,7 @@ typedef uint16_t settings_length_t;
#define SETTINGS_KEY_RDC_INDEX TCC('R','D') /*!< RDC index, uint8_t */
#define SETTINGS_KEY_CHANNEL_MASK TCC('C','M') /*!< Channel mask, uint16_t */
#define SETTINGS_KEY_MAC_CONF TCC('M','C') /*!< MAC Layer Config, uint8_t */
/*****************************************************************************/
// MARK: - Constants

View file

@ -35,6 +35,10 @@
#include <string.h>
#define printf(...)
static uip_ip6addr_t ip64_prefix = {{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xff, 0xff, 0, 0, 0, 0}};
static uint8_t ip64_prefix_len = 96;
/*---------------------------------------------------------------------------*/
void
ip64_addr_copy4(uip_ip4addr_t *dest, const uip_ip4addr_t *src)
@ -56,20 +60,7 @@ ip64_addr_4to6(const uip_ip4addr_t *ipv4addr,
addresses. It returns 0 if it failed to convert the address and
non-zero if it could successfully convert the address. */
/* The IPv4 address is encoded as an IPv6-encoded IPv4 address in
the ::ffff:0000/24 prefix.*/
ipv6addr->u8[0] = 0;
ipv6addr->u8[1] = 0;
ipv6addr->u8[2] = 0;
ipv6addr->u8[3] = 0;
ipv6addr->u8[4] = 0;
ipv6addr->u8[5] = 0;
ipv6addr->u8[6] = 0;
ipv6addr->u8[7] = 0;
ipv6addr->u8[8] = 0;
ipv6addr->u8[9] = 0;
ipv6addr->u8[10] = 0xff;
ipv6addr->u8[11] = 0xff;
uip_ipaddr_copy(ipv6addr, &ip64_prefix);
ipv6addr->u8[12] = ipv4addr->u8[0];
ipv6addr->u8[13] = ipv4addr->u8[1];
ipv6addr->u8[14] = ipv4addr->u8[2];
@ -90,21 +81,7 @@ ip64_addr_6to4(const uip_ip6addr_t *ipv6addr,
returns 0 if it failed to convert the address and non-zero if it
could successfully convert the address. */
/* If the IPv6 address is an IPv6-encoded
IPv4 address (i.e. in the ::ffff:0/8 prefix), we simply use the
IPv4 addresses directly. */
if(ipv6addr->u8[0] == 0 &&
ipv6addr->u8[1] == 0 &&
ipv6addr->u8[2] == 0 &&
ipv6addr->u8[3] == 0 &&
ipv6addr->u8[4] == 0 &&
ipv6addr->u8[5] == 0 &&
ipv6addr->u8[6] == 0 &&
ipv6addr->u8[7] == 0 &&
ipv6addr->u8[8] == 0 &&
ipv6addr->u8[9] == 0 &&
ipv6addr->u8[10] == 0xff &&
ipv6addr->u8[11] == 0xff) {
if(ip64_addr_is_ip64(ipv6addr)) {
ipv4addr->u8[0] = ipv6addr->u8[12];
ipv4addr->u8[1] = ipv6addr->u8[13];
ipv4addr->u8[2] = ipv6addr->u8[14];
@ -121,3 +98,16 @@ ip64_addr_6to4(const uip_ip6addr_t *ipv6addr,
return 0;
}
/*---------------------------------------------------------------------------*/
int
ip64_addr_is_ip64(const uip_ip6addr_t *ipv6addr)
{
return uip_ipaddr_prefixcmp(ipv6addr, &ip64_prefix, ip64_prefix_len);
}
/*---------------------------------------------------------------------------*/
void
ip64_addr_set_prefix(const uip_ip6addr_t *prefix, uint8_t prefix_len)
{
uip_ipaddr_copy(&ip64_prefix, prefix);
ip64_prefix_len = prefix_len;
}
/*---------------------------------------------------------------------------*/

View file

@ -58,6 +58,9 @@ int ip64_addr_6to4(const uip_ip6addr_t *ipv6addr,
int ip64_addr_4to6(const uip_ip4addr_t *ipv4addr,
uip_ip6addr_t *ipv6addr);
int ip64_addr_is_ip64(const uip_ip6addr_t *ipv6addr);
void ip64_addr_set_prefix(const uip_ip6addr_t *prefix, uint8_t prefix_len);
#endif /* IP64_ADDR_H */

View file

@ -1094,7 +1094,7 @@ resolv_set_hostname(const char *hostname)
/* Add the .local suffix if it isn't already there */
if(strlen(resolv_hostname) < 7 ||
strcasecmp(resolv_hostname + strlen(resolv_hostname) - 6, ".local") != 0) {
strncat(resolv_hostname, ".local", RESOLV_CONF_MAX_DOMAIN_NAME_SIZE);
strncat(resolv_hostname, ".local", RESOLV_CONF_MAX_DOMAIN_NAME_SIZE - strlen(resolv_hostname));
}
PRINTF("resolver: hostname changed to \"%s\"\n", resolv_hostname);
@ -1248,8 +1248,8 @@ remove_trailing_dots(const char *name) {
static char dns_name_without_dots[RESOLV_CONF_MAX_DOMAIN_NAME_SIZE + 1];
size_t len = strlen(name);
if(name[len - 1] == '.') {
strncpy(dns_name_without_dots, name, sizeof(dns_name_without_dots));
if(len && name[len - 1] == '.') {
strncpy(dns_name_without_dots, name, RESOLV_CONF_MAX_DOMAIN_NAME_SIZE);
while(len && (dns_name_without_dots[len - 1] == '.')) {
dns_name_without_dots[--len] = 0;
}
@ -1309,7 +1309,7 @@ resolv_query(const char *name)
memset(nameptr, 0, sizeof(*nameptr));
strncpy(nameptr->name, name, sizeof(nameptr->name));
strncpy(nameptr->name, name, sizeof(nameptr->name) - 1);
nameptr->state = STATE_NEW;
nameptr->seqno = seqno;
++seqno;
@ -1479,7 +1479,7 @@ resolv_found(char *name, uip_ipaddr_t * ipaddr)
}
/* Re-add the .local suffix */
strncat(resolv_hostname, ".local", RESOLV_CONF_MAX_DOMAIN_NAME_SIZE);
strncat(resolv_hostname, ".local", RESOLV_CONF_MAX_DOMAIN_NAME_SIZE - strlen(resolv_hostname));
start_name_collision_check(CLOCK_SECOND * 5);
} else if(mdns_state == MDNS_STATE_READY) {

View file

@ -102,9 +102,6 @@ slipdev_send(void)
ptr = &uip_buf[UIP_LLH_LEN];
for(i = 0; i < uip_len; ++i) {
if(i == UIP_TCPIP_HLEN) {
ptr = (uint8_t *)uip_appdata;
}
c = *ptr++;
switch(c) {
case SLIP_END:

View file

@ -29,6 +29,9 @@
*
*/
#define DEBUG DEBUG_NONE
#include "net/ip/uip-debug.h"
#include "contiki.h"
#include "sys/cc.h"
#include "contiki-net.h"
@ -37,10 +40,8 @@
#include "tcp-socket.h"
#include <stdio.h>
#include <string.h>
static void relisten(struct tcp_socket *s);
LIST(socketlist);
@ -80,7 +81,7 @@ acked(struct tcp_socket *s)
s->output_data_maxlen - s->output_data_send_nxt);
}
if(s->output_data_len < s->output_data_send_nxt) {
printf("tcp: acked assertion failed s->output_data_len (%d) < s->output_data_send_nxt (%d)\n",
PRINTF("tcp: acked assertion failed s->output_data_len (%d) < s->output_data_send_nxt (%d)\n",
s->output_data_len,
s->output_data_send_nxt);
tcp_markconn(uip_conn, NULL);
@ -121,7 +122,7 @@ newdata(struct tcp_socket *s)
bytesleft = 0;
}
if(bytesleft > 0) {
printf("tcp: newdata, bytesleft > 0 (%d) not implemented\n", bytesleft);
PRINTF("tcp: newdata, bytesleft > 0 (%d) not implemented\n", bytesleft);
}
dataptr += copylen;
len -= copylen;
@ -356,6 +357,8 @@ tcp_socket_send(struct tcp_socket *s,
s->output_senddata_len = s->output_data_len;
}
tcpip_poll_tcp(s->c);
return len;
}
/*---------------------------------------------------------------------------*/
@ -398,3 +401,9 @@ tcp_socket_max_sendlen(struct tcp_socket *s)
return s->output_data_maxlen - s->output_data_len;
}
/*---------------------------------------------------------------------------*/
int
tcp_socket_queuelen(struct tcp_socket *s)
{
return s->output_data_len;
}
/*---------------------------------------------------------------------------*/

View file

@ -284,4 +284,16 @@ int tcp_socket_unregister(struct tcp_socket *s);
*/
int tcp_socket_max_sendlen(struct tcp_socket *s);
/**
* \brief The number of bytes waiting to be sent
* \param s A pointer to a TCP socket
* \return The number of bytes that have not yet been acknowledged by the receiver.
*
* This function queries the TCP socket and returns the
* number of bytes that are currently not yet known to
* have been successfully received by the receiver.
*
*/
int tcp_socket_queuelen(struct tcp_socket *s);
#endif /* TCP_SOCKET_H */

View file

@ -548,6 +548,15 @@ tcpip_ipv6_output(void)
return;
}
#if UIP_CONF_IPV6_RPL
if(!rpl_update_header()) {
/* Packet can not be forwarded */
PRINTF("tcpip_ipv6_output: RPL header update error\n");
uip_clear_buf();
return;
}
#endif /* UIP_CONF_IPV6_RPL */
if(!uip_is_addr_mcast(&UIP_IP_BUF->destipaddr)) {
/* Next hop determination */
@ -651,15 +660,9 @@ tcpip_ipv6_output(void)
/* End of next hop determination */
#if UIP_CONF_IPV6_RPL
if(!rpl_finalize_header(nexthop)) {
uip_clear_buf();
return;
}
#endif /* UIP_CONF_IPV6_RPL */
nbr = uip_ds6_nbr_lookup(nexthop);
if(nbr == NULL) {
#if UIP_ND6_SEND_NA
#if UIP_ND6_SEND_NS
if((nbr = uip_ds6_nbr_add(nexthop, NULL, 0, NBR_INCOMPLETE, NBR_TABLE_REASON_IPV6_ND, NULL)) == NULL) {
uip_clear_buf();
PRINTF("tcpip_ipv6_output: failed to add neighbor to cache\n");
@ -688,13 +691,13 @@ tcpip_ipv6_output(void)
nbr->nscount = 1;
/* Send the first NS try from here (multicast destination IP address). */
}
#else /* UIP_ND6_SEND_NA */
#else /* UIP_ND6_SEND_NS */
PRINTF("tcpip_ipv6_output: neighbor not in cache\n");
uip_len = 0;
return;
#endif /* UIP_ND6_SEND_NA */
#endif /* UIP_ND6_SEND_NS */
} else {
#if UIP_ND6_SEND_NA
#if UIP_ND6_SEND_NS
if(nbr->state == NBR_INCOMPLETE) {
PRINTF("tcpip_ipv6_output: nbr cache entry incomplete\n");
#if UIP_CONF_IPV6_QUEUE_PKT
@ -716,7 +719,7 @@ tcpip_ipv6_output(void)
nbr->nscount = 0;
PRINTF("tcpip_ipv6_output: nbr cache entry stale moving to delay\n");
}
#endif /* UIP_ND6_SEND_NA */
#endif /* UIP_ND6_SEND_NS */
tcpip_output(uip_ds6_nbr_get_ll(nbr));

4
core/net/ip/uip-debug.c Normal file → Executable file
View file

@ -56,7 +56,7 @@ uip_debug_ipaddr_print(const uip_ipaddr_t *addr)
#if NETSTACK_CONF_WITH_IPV6
if(ip64_addr_is_ipv4_mapped_addr(addr)) {
/*
* Printing IPv4-mapped addresses is done according to RFC 3513 [1]
* Printing IPv4-mapped addresses is done according to RFC 4291 [1]
*
* "An alternative form that is sometimes more
* convenient when dealing with a mixed environment
@ -67,7 +67,7 @@ uip_debug_ipaddr_print(const uip_ipaddr_t *addr)
* low-order 8-bit pieces of the address (standard
* IPv4 representation)."
*
* [1] https://tools.ietf.org/html/rfc3513#page-5
* [1] https://tools.ietf.org/html/rfc4291#page-4
*/
PRINTA("::FFFF:%u.%u.%u.%u", addr->u8[12], addr->u8[13], addr->u8[14], addr->u8[15]);
} else {

28
core/net/ip/uip.h Normal file → Executable file
View file

@ -490,26 +490,8 @@ void uip_reass_over(void);
*
* The uip_aligned_buf array is used to hold incoming and outgoing
* packets. The device driver should place incoming data into this
* buffer. When sending data, the device driver should read the link
* level headers and the TCP/IP headers from this buffer. The size of
* the link level headers is configured by the UIP_LLH_LEN define.
*
* \note The application data need not be placed in this buffer, so
* the device driver must read it from the place pointed to by the
* uip_appdata pointer as illustrated by the following example:
\code
void
devicedriver_send(void)
{
hwsend(&uip_buf[0], UIP_LLH_LEN);
if(uip_len <= UIP_LLH_LEN + UIP_TCPIP_HLEN) {
hwsend(&uip_buf[UIP_LLH_LEN], uip_len - UIP_LLH_LEN);
} else {
hwsend(&uip_buf[UIP_LLH_LEN], UIP_TCPIP_HLEN);
hwsend(uip_appdata, uip_len - UIP_TCPIP_HLEN - UIP_LLH_LEN);
}
}
\endcode
* buffer. When sending data, the device driver should read the
* outgoing data from this buffer.
*/
typedef union {
@ -2012,7 +1994,7 @@ CCIF extern uip_lladdr_t uip_lladdr;
(((a)->u8[15]) == 0x02))
/**
* \brief is addr (a) a link local unicast address, see RFC3513
* \brief is addr (a) a link local unicast address, see RFC 4291
* i.e. is (a) on prefix FE80::/10
* a is of type uip_ipaddr_t*
*/
@ -2036,7 +2018,7 @@ CCIF extern uip_lladdr_t uip_lladdr;
} while(0)
/**
* \brief is addr (a) a solicited node multicast address, see RFC3513
* \brief is addr (a) a solicited node multicast address, see RFC 4291
* a is of type uip_ipaddr_t*
*/
#define uip_is_addr_solicited_node(a) \
@ -2097,7 +2079,7 @@ CCIF extern uip_lladdr_t uip_lladdr;
#endif /*UIP_CONF_LL_802154*/
/**
* \brief is address a multicast address, see RFC 3513
* \brief is address a multicast address, see RFC 4291
* a is of type uip_ipaddr_t*
* */
#define uip_is_addr_mcast(a) \

View file

@ -120,10 +120,6 @@ uint16_t uip_ipchksum(void);
* The TCP checksum is the Internet checksum of data contents of the
* TCP segment, and a pseudo-header as defined in RFC793.
*
* \note The uip_appdata pointer that points to the packet data may
* point anywhere in memory, so it is not possible to simply calculate
* the Internet checksum of the contents of the uip_buf buffer.
*
* \return The TCP checksum of the TCP segment in uip_buf and pointed
* to by uip_appdata.
*/

View file

@ -163,7 +163,6 @@ create_msg(CC_REGISTER_ARG struct dhcp_msg *m)
memset(&m->chaddr[s.mac_len], 0, sizeof(m->chaddr) - s.mac_len);
memset(m->sname, 0, sizeof(m->sname));
strcpy((char *)m->sname, "Thingsquare");
memset(m->file, 0, sizeof(m->file));

View file

@ -39,6 +39,9 @@
#include <stdio.h>
#define DEBUG DEBUG_NONE
#include "net/ip/uip-debug.h"
PROCESS(ip64_ipv4_dhcp_process, "IPv4 DHCP");
uip_ipaddr_t uip_hostaddr; /* Needed because it is referenced by dhcpc.c */
@ -48,7 +51,7 @@ uip_ipaddr_t uip_hostaddr; /* Needed because it is referenced by dhcpc.c */
void
ip64_ipv4_dhcp_init(void)
{
printf("Starting DHCPv4\n");
printf("IP64: Starting DHCPv4\n");
process_start(&ip64_ipv4_dhcp_process, NULL);
}
/*---------------------------------------------------------------------------*/
@ -58,10 +61,10 @@ PROCESS_THREAD(ip64_ipv4_dhcp_process, ev, data)
ip64_dhcpc_init(&ip64_eth_addr, sizeof(ip64_eth_addr));
printf("Inited\n");
PRINTF("IP64: Inited\n");
ip64_dhcpc_request();
printf("Requested\n");
PRINTF("IP64: Requested\n");
while(1) {
PROCESS_WAIT_EVENT();
@ -78,15 +81,22 @@ void
ip64_dhcpc_configured(const struct ip64_dhcpc_state *s)
{
uip_ip6addr_t ip6dnsaddr;
printf("DHCP Configured with %d.%d.%d.%d\n",
PRINTF("IP64: DHCP Configured with %d.%d.%d.%d\n",
s->ipaddr.u8[0], s->ipaddr.u8[1],
s->ipaddr.u8[2], s->ipaddr.u8[3]);
ip64_set_hostaddr((uip_ip4addr_t *)&s->ipaddr);
ip64_set_netmask((uip_ip4addr_t *)&s->netmask);
ip64_set_draddr((uip_ip4addr_t *)&s->default_router);
ip64_addr_4to6((uip_ip4addr_t *)&s->dnsaddr, &ip6dnsaddr);
// mdns_conf(&ip6dnsaddr);
if(!uip_ip4addr_cmp((uip_ip4addr_t *)&s->dnsaddr, &uip_all_zeroes_addr)) {
/* Note: Currently we assume only one DNS server */
uip_ipaddr_t * dns = uip_nameserver_get(0);
/* Only update DNS entry if it is empty or already IPv4 */
if(uip_is_addr_unspecified(dns) || ip64_addr_is_ip64(dns)) {
ip64_addr_4to6((uip_ip4addr_t *)&s->dnsaddr, &ip6dnsaddr);
uip_nameserver_update(&ip6dnsaddr, uip_ntohs(s->lease_time[0])*65536ul + uip_ntohs(s->lease_time[1]));
}
}
}
/*---------------------------------------------------------------------------*/
void

View file

@ -7,8 +7,14 @@ What does it do
These files, alongside some core modifications, add support for IPv6 multicast
to contiki's uIPv6 engine.
Currently, two modes are supported:
Currently, three modes are supported:
* 'Enhanced Stateless Multicast RPL Forwarding' (ESMRF)
ESMRF is an enhanced version of the SMRF engine with the aim
of resolving the sending limitation of SMRF to allow any node
within the DODAG to send multicast traffic up and down the RPL tree.
ESMRF is documented here:
http://dl.acm.org/citation.cfm?id=2753479
* 'Stateless Multicast RPL Forwarding' (SMRF)
RPL in MOP 3 handles group management as per the RPL docs,
SMRF is a lightweight engine which handles datagram forwarding.

View file

@ -162,7 +162,7 @@ struct uip_mcast6_driver {
#define UIP_MCAST6 smrf_driver
#elif UIP_MCAST6_ENGINE == UIP_MCAST6_ENGINE_ESMRF
#define RPL_CONF_MULTICAST 1
#define RPL_WITH_MULTICAST 1
#define UIP_MCAST6 esmrf_driver
#else

View file

@ -88,19 +88,23 @@ uip_ds6_nbr_add(const uip_ipaddr_t *ipaddr, const uip_lladdr_t *lladdr,
, reason, data);
if(nbr) {
uip_ipaddr_copy(&nbr->ipaddr, ipaddr);
#if UIP_ND6_SEND_NA || UIP_ND6_SEND_RA || !UIP_CONF_ROUTER
#if UIP_ND6_SEND_RA || !UIP_CONF_ROUTER
nbr->isrouter = isrouter;
#endif /* UIP_ND6_SEND_NA || UIP_ND6_SEND_RA || !UIP_CONF_ROUTER */
#endif /* UIP_ND6_SEND_RA || !UIP_CONF_ROUTER */
nbr->state = state;
#if UIP_CONF_IPV6_QUEUE_PKT
uip_packetqueue_new(&nbr->packethandle);
#endif /* UIP_CONF_IPV6_QUEUE_PKT */
#if UIP_ND6_SEND_NA
/* timers are set separately, for now we put them in expired state */
stimer_set(&nbr->reachable, 0);
#if UIP_ND6_SEND_NS
if(nbr->state == NBR_REACHABLE) {
stimer_set(&nbr->reachable, UIP_ND6_REACHABLE_TIME / 1000);
} else {
/* We set the timer in expired state */
stimer_set(&nbr->reachable, 0);
}
stimer_set(&nbr->sendns, 0);
nbr->nscount = 0;
#endif /* UIP_ND6_SEND_NA */
#endif /* UIP_ND6_SEND_NS */
PRINTF("Adding neighbor with ip addr ");
PRINT6ADDR(ipaddr);
PRINTF(" link addr ");
@ -241,7 +245,7 @@ uip_ds6_link_neighbor_callback(int status, int numtx)
#endif /* UIP_DS6_LL_NUD */
}
#if UIP_ND6_SEND_NA
#if UIP_ND6_SEND_NS
/*---------------------------------------------------------------------------*/
/** Periodic processing on neighbors */
void
@ -322,6 +326,18 @@ uip_ds6_neighbor_periodic(void)
}
}
/*---------------------------------------------------------------------------*/
void
uip_ds6_nbr_refresh_reachable_state(const uip_ipaddr_t *ipaddr)
{
uip_ds6_nbr_t *nbr;
nbr = uip_ds6_nbr_lookup(ipaddr);
if(nbr != NULL) {
nbr->state = NBR_REACHABLE;
nbr->nscount = 0;
stimer_set(&nbr->reachable, UIP_ND6_REACHABLE_TIME / 1000);
}
}
/*---------------------------------------------------------------------------*/
uip_ds6_nbr_t *
uip_ds6_get_least_lifetime_neighbor(void)
{
@ -340,6 +356,6 @@ uip_ds6_get_least_lifetime_neighbor(void)
}
return nbr_expiring;
}
#endif /* UIP_ND6_SEND_NA */
#endif /* UIP_ND6_SEND_NS */
/*---------------------------------------------------------------------------*/
/** @} */

View file

@ -50,8 +50,6 @@
#include "net/nbr-table.h"
#include "sys/stimer.h"
#include "net/ipv6/uip-ds6.h"
#include "net/nbr-table.h"
#if UIP_CONF_IPV6_QUEUE_PKT
#include "net/ip/uip-packetqueue.h"
#endif /*UIP_CONF_QUEUE_PKT */
@ -71,11 +69,11 @@ typedef struct uip_ds6_nbr {
uip_ipaddr_t ipaddr;
uint8_t isrouter;
uint8_t state;
#if UIP_ND6_SEND_NA || UIP_ND6_SEND_RA
#if UIP_ND6_SEND_NS || UIP_ND6_SEND_RA
struct stimer reachable;
struct stimer sendns;
uint8_t nscount;
#endif /* UIP_ND6_SEND_NA || UIP_ND6_SEND_RA */
#endif /* UIP_ND6_SEND_NS || UIP_ND6_SEND_RA */
#if UIP_CONF_IPV6_QUEUE_PKT
struct uip_packetqueue_handle packethandle;
#define UIP_DS6_NBR_PACKET_LIFETIME CLOCK_SECOND * 4
@ -100,6 +98,17 @@ void uip_ds6_link_neighbor_callback(int status, int numtx);
void uip_ds6_neighbor_periodic(void);
int uip_ds6_nbr_num(void);
#if UIP_ND6_SEND_NS
/**
* \brief Refresh the reachable state of a neighbor. This function
* may be called when a node receives an IPv6 message that confirms the
* reachability of a neighbor.
* \param ipaddr pointer to the IPv6 address whose neighbor reachability state
* should be refreshed.
*/
void uip_ds6_nbr_refresh_reachable_state(const uip_ipaddr_t *ipaddr);
#endif /* UIP_ND6_SEND_NS */
/**
* \brief
* This searches inside the neighbor table for the neighbor that is about to

View file

@ -573,6 +573,12 @@ uip_ds6_route_rm_by_nexthop(uip_ipaddr_t *nexthop)
}
/*---------------------------------------------------------------------------*/
uip_ds6_defrt_t *
uip_ds6_defrt_head(void)
{
return list_head(defaultrouterlist);
}
/*---------------------------------------------------------------------------*/
uip_ds6_defrt_t *
uip_ds6_defrt_add(uip_ipaddr_t *ipaddr, unsigned long interval)
{
uip_ds6_defrt_t *d;

View file

@ -82,14 +82,10 @@ void uip_ds6_notification_rm(struct uip_ds6_notification *n);
#endif
/* Routing table */
#ifndef UIP_CONF_MAX_ROUTES
#ifdef UIP_CONF_DS6_ROUTE_NBU
#define UIP_DS6_ROUTE_NB UIP_CONF_DS6_ROUTE_NBU
#else /* UIP_CONF_DS6_ROUTE_NBU */
#define UIP_DS6_ROUTE_NB 4
#endif /* UIP_CONF_DS6_ROUTE_NBU */
#else /* UIP_CONF_MAX_ROUTES */
#ifdef UIP_CONF_MAX_ROUTES
#define UIP_DS6_ROUTE_NB UIP_CONF_MAX_ROUTES
#else /* UIP_CONF_MAX_ROUTES */
#define UIP_DS6_ROUTE_NB 4
#endif /* UIP_CONF_MAX_ROUTES */
/** \brief define some additional RPL related route state and
@ -181,6 +177,7 @@ typedef struct uip_ds6_defrt {
/** \name Default router list basic routines */
/** @{ */
uip_ds6_defrt_t *uip_ds6_defrt_head(void);
uip_ds6_defrt_t *uip_ds6_defrt_add(uip_ipaddr_t *ipaddr,
unsigned long interval);
void uip_ds6_defrt_rm(uip_ds6_defrt_t *defrt);

View file

@ -187,9 +187,9 @@ uip_ds6_periodic(void)
}
#endif /* !UIP_CONF_ROUTER */
#if UIP_ND6_SEND_NA
#if UIP_ND6_SEND_NS
uip_ds6_neighbor_periodic();
#endif /* UIP_ND6_SEND_RA */
#endif /* UIP_ND6_SEND_NS */
#if UIP_CONF_ROUTER && UIP_ND6_SEND_RA
/* Periodic RA sending */

View file

@ -56,6 +56,8 @@
* - the number of elements requested by the user in contiki configuration (name suffixed by _NBU)
* - the number of elements assigned by the system (name suffixed by _NBS)
* - the total number of elements is the sum (name suffixed by _NB)
* The routing table definitions can be found in uip-ds6-route.h
* The Neighbor cache definitions can be found in nbr-table.h
*/
/* Default router list */

View file

@ -160,11 +160,6 @@ echo_request_input(void)
uip_ext_len = 0;
}
/* Insert RPL extension headers */
#if UIP_CONF_IPV6_RPL
rpl_insert_header();
#endif /* UIP_CONF_IPV6_RPL */
/* Below is important for the correctness of UIP_ICMP_BUF and the
* checksum
*/
@ -260,10 +255,6 @@ uip_icmp6_error_output(uint8_t type, uint8_t code, uint32_t param) {
UIP_ICMP_BUF->icmpchksum = 0;
UIP_ICMP_BUF->icmpchksum = ~uip_icmp6chksum();
#if UIP_CONF_IPV6_RPL
rpl_insert_header();
#endif /* UIP_CONF_IPV6_RPL */
UIP_STAT(++uip_stat.icmp.sent);
PRINTF("Sending ICMPv6 ERROR message type %d code %d to ", type, code);
@ -301,9 +292,6 @@ uip_icmp6_send(const uip_ipaddr_t *dest, int type, int code, int payload_len)
UIP_STAT(++uip_stat.icmp.sent);
UIP_STAT(++uip_stat.ip.sent);
#if UIP_CONF_IPV6_RPL
rpl_insert_header();
#endif /* UIP_CONF_IPV6_RPL */
tcpip_ipv6_output();
}
/*---------------------------------------------------------------------------*/

View file

@ -116,13 +116,16 @@ void uip_log(char *msg);
#define UIP_ND6_OPT_RDNSS_BUF ((uip_nd6_opt_dns *)&uip_buf[uip_l2_l3_icmp_hdr_len + nd6_opt_offset])
/** @} */
#if UIP_ND6_SEND_NA || UIP_ND6_SEND_RA || !UIP_CONF_ROUTER
#if UIP_ND6_SEND_NS || UIP_ND6_SEND_NA || UIP_ND6_SEND_RA || !UIP_CONF_ROUTER
static uint8_t nd6_opt_offset; /** Offset from the end of the icmpv6 header to the option in uip_buf*/
static uint8_t *nd6_opt_llao; /** Pointer to llao option in uip_buf */
static uip_ds6_nbr_t *nbr; /** Pointer to a nbr cache entry*/
static uip_ds6_defrt_t *defrt; /** Pointer to a router list entry */
static uip_ds6_addr_t *addr; /** Pointer to an interface address */
#endif /* UIP_ND6_SEND_NA || UIP_ND6_SEND_RA || !UIP_CONF_ROUTER */
#endif /* UIP_ND6_SEND_NS || UIP_ND6_SEND_NA || UIP_ND6_SEND_RA || !UIP_CONF_ROUTER */
#if UIP_ND6_SEND_NS || UIP_ND6_SEND_RA || !UIP_CONF_ROUTER
static uip_ds6_defrt_t *defrt; /** Pointer to a router list entry */
#endif /* UIP_ND6_SEND_NS || UIP_ND6_SEND_RA || !UIP_CONF_ROUTER */
#if !UIP_CONF_ROUTER // TBD see if we move it to ra_input
static uip_nd6_opt_prefix_info *nd6_opt_prefix_info; /** Pointer to prefix information option in uip_buf */
@ -157,7 +160,27 @@ create_llao(uint8_t *llao, uint8_t type) {
}
/*------------------------------------------------------------------*/
/**
* Neighbor Solicitation Processing
*
* The NS can be received in 3 cases (procedures):
* - sender is performing DAD (ip src = unspecified, no SLLAO option)
* - sender is performing NUD (ip dst = unicast)
* - sender is performing address resolution (ip dest = solicited node mcast
* address)
*
* We do:
* - if the tgt belongs to me, reply, otherwise ignore
* - if i was performing DAD for the same address, two cases:
* -- I already sent a NS, hence I win
* -- I did not send a NS yet, hence I lose
*
* If we need to send a NA in response (i.e. the NS was done for NUD, or
* address resolution, or DAD and there is a conflict), we do it in this
* function: set src, dst, tgt address in the three cases, then for all cases
* set the rest, including SLLAO
*
*/
#if UIP_ND6_SEND_NA
static void
ns_input(void)
@ -238,9 +261,9 @@ ns_input(void)
addr = uip_ds6_addr_lookup(&UIP_ND6_NS_BUF->tgtipaddr);
if(addr != NULL) {
#if UIP_ND6_DEF_MAXDADNS > 0
if(uip_is_addr_unspecified(&UIP_IP_BUF->srcipaddr)) {
/* DAD CASE */
#if UIP_ND6_DEF_MAXDADNS > 0
#if UIP_CONF_IPV6_CHECKS
if(!uip_is_addr_solicited_node(&UIP_IP_BUF->destipaddr)) {
PRINTF("NS received is bad\n");
@ -258,9 +281,7 @@ ns_input(void)
goto discard;
}
#else /* UIP_ND6_DEF_MAXDADNS > 0 */
if(uip_is_addr_unspecified(&UIP_IP_BUF->srcipaddr)) {
/* DAD CASE */
goto discard;
goto discard; /* DAD CASE */
#endif /* UIP_ND6_DEF_MAXDADNS > 0 */
}
#if UIP_CONF_IPV6_CHECKS
@ -348,6 +369,7 @@ discard:
/*------------------------------------------------------------------*/
#if UIP_ND6_SEND_NS
void
uip_nd6_ns_output(uip_ipaddr_t * src, uip_ipaddr_t * dest, uip_ipaddr_t * tgt)
{
@ -410,7 +432,9 @@ uip_nd6_ns_output(uip_ipaddr_t * src, uip_ipaddr_t * dest, uip_ipaddr_t * tgt)
PRINTF("\n");
return;
}
#if UIP_ND6_SEND_NA
#endif /* UIP_ND6_SEND_NS */
#if UIP_ND6_SEND_NS
/*------------------------------------------------------------------*/
/**
* Neighbor Advertisement Processing
@ -522,14 +546,11 @@ na_input(void)
goto discard;
}
if(is_solicited) {
nbr->state = NBR_REACHABLE;
nbr->nscount = 0;
/* reachable time is stored in ms */
stimer_set(&(nbr->reachable), uip_ds6_if.reachable_time / 1000);
} else {
/* Note: No need to refresh the state of the nbr here.
* It has already been refreshed upon receiving the unicast IPv6 ND packet.
* See: uip_ds6_nbr_refresh_reachable_state()
*/
if(!is_solicited) {
nbr->state = NBR_STALE;
}
nbr->isrouter = is_router;
@ -552,11 +573,10 @@ na_input(void)
goto discard;
}
}
if(is_solicited) {
nbr->state = NBR_REACHABLE;
/* reachable time is stored in ms */
stimer_set(&(nbr->reachable), uip_ds6_if.reachable_time / 1000);
}
/* Note: No need to refresh the state of the nbr here.
* It has already been refreshed upon receiving the unicast IPv6 ND packet.
* See: uip_ds6_nbr_refresh_reachable_state()
*/
}
}
if(nbr->isrouter && !is_router) {
@ -589,7 +609,7 @@ discard:
uip_clear_buf();
return;
}
#endif /* UIP_ND6_SEND_NA */
#endif /* UIP_ND6_SEND_NS */
#if UIP_CONF_ROUTER
#if UIP_ND6_SEND_RA
@ -662,7 +682,8 @@ rs_input(void)
}
if(memcmp(&nd6_opt_llao[UIP_ND6_OPT_DATA_OFFSET],
lladdr, UIP_LLADDR_LEN) != 0) {
uip_ds6_nbr_t nbr_data = *nbr;
uip_ds6_nbr_t nbr_data;
nbr_data = *nbr;
uip_ds6_nbr_rm(nbr);
nbr = uip_ds6_nbr_add(&UIP_IP_BUF->srcipaddr, &lladdr_aligned,
0, NBR_STALE, NBR_TABLE_REASON_IPV6_ND, NULL);
@ -1082,6 +1103,8 @@ discard:
#if UIP_ND6_SEND_NA
UIP_ICMP6_HANDLER(ns_input_handler, ICMP6_NS, UIP_ICMP6_HANDLER_CODE_ANY,
ns_input);
#endif
#if UIP_ND6_SEND_NS
UIP_ICMP6_HANDLER(na_input_handler, ICMP6_NA, UIP_ICMP6_HANDLER_CODE_ANY,
na_input);
#endif
@ -1099,19 +1122,16 @@ UIP_ICMP6_HANDLER(ra_input_handler, ICMP6_RA, UIP_ICMP6_HANDLER_CODE_ANY,
void
uip_nd6_init()
{
#if UIP_ND6_SEND_NA
/* Only handle NSs if we are prepared to send out NAs */
uip_icmp6_register_input_handler(&ns_input_handler);
/*
* Only handle NAs if we are prepared to send out NAs.
* This is perhaps logically incorrect, but this condition was present in
* uip_process and we keep it until proven wrong
*/
uip_icmp6_register_input_handler(&na_input_handler);
#endif
#if UIP_ND6_SEND_NS
/*
* Only handle NAs if we are prepared to send out NSs. */
uip_icmp6_register_input_handler(&na_input_handler);
#endif
#if UIP_CONF_ROUTER && UIP_ND6_SEND_RA
/* Only accept RS if we are a router and happy to send out RAs */

View file

@ -60,11 +60,23 @@
/** \name RFC 4861 Host constant */
/** @{ */
/** \brief Maximum router solicitation delay */
#ifndef UIP_CONF_ND6_MAX_RTR_SOLICITATION_DELAY
#define UIP_ND6_MAX_RTR_SOLICITATION_DELAY 1
#else
#define UIP_ND6_MAX_RTR_SOLICITATION_DELAY UIP_CONF_ND6_MAX_RTR_SOLICITATION_DELAY
#endif
/** \brief Router solicitation interval */
#ifndef UIP_CONF_ND6_RTR_SOLICITATION_INTERVAL
#define UIP_ND6_RTR_SOLICITATION_INTERVAL 4
#else
#define UIP_ND6_RTR_SOLICITATION_INTERVAL UIP_CONF_ND6_RTR_SOLICITATION_INTERVAL
#endif
/** \brief Maximum router solicitations */
#ifndef UIP_CONF_ND6_MAX_RTR_SOLICITATIONS
#define UIP_ND6_MAX_RTR_SOLICITATIONS 3
#else
#define UIP_ND6_MAX_RTR_SOLICITATIONS UIP_CONF_ND6_MAX_RTR_SOLICITATIONS
#endif
/** @} */
/** \name RFC 4861 Router constants */
@ -74,6 +86,11 @@
#else
#define UIP_ND6_SEND_RA UIP_CONF_ND6_SEND_RA
#endif
#ifndef UIP_CONF_ND6_SEND_NS
#define UIP_ND6_SEND_NS 1 /* enable/disable NS sending */
#else
#define UIP_ND6_SEND_NS UIP_CONF_ND6_SEND_NS
#endif
#ifndef UIP_CONF_ND6_SEND_NA
#define UIP_ND6_SEND_NA 1 /* enable/disable NA sending */
#else
@ -91,7 +108,11 @@
#endif
#define UIP_ND6_M_FLAG 0
#define UIP_ND6_O_FLAG (UIP_ND6_RA_RDNSS || UIP_ND6_RA_DNSSL)
#ifndef UIP_CONF_ROUTER_LIFETIME
#define UIP_ND6_ROUTER_LIFETIME 3 * UIP_ND6_MAX_RA_INTERVAL
#else
#define UIP_ND6_ROUTER_LIFETIME UIP_CONF_ROUTER_LIFETIME
#endif
#define UIP_ND6_MAX_INITIAL_RA_INTERVAL 16 /*seconds*/
#define UIP_ND6_MAX_INITIAL_RAS 3 /*transmissions*/
@ -109,7 +130,7 @@
#if UIP_CONF_LL_802154
#define UIP_ND6_DEF_MAXDADNS 0
#else /* UIP_CONF_LL_802154 */
#define UIP_ND6_DEF_MAXDADNS UIP_ND6_SEND_NA
#define UIP_ND6_DEF_MAXDADNS UIP_ND6_SEND_NS
#endif /* UIP_CONF_LL_802154 */
#else /* UIP_CONF_ND6_DEF_MAXDADNS */
#define UIP_ND6_DEF_MAXDADNS UIP_CONF_ND6_DEF_MAXDADNS
@ -336,30 +357,6 @@ typedef struct uip_nd6_opt_redirected_hdr {
* @{
*/
/**
* \brief Process a neighbor solicitation
*
* The NS can be received in 3 cases (procedures):
* - sender is performing DAD (ip src = unspecified, no SLLAO option)
* - sender is performing NUD (ip dst = unicast)
* - sender is performing address resolution (ip dest = solicited node mcast
* address)
*
* We do:
* - if the tgt belongs to me, reply, otherwise ignore
* - if i was performing DAD for the same address, two cases:
* -- I already sent a NS, hence I win
* -- I did not send a NS yet, hence I lose
*
* If we need to send a NA in response (i.e. the NS was done for NUD, or
* address resolution, or DAD and there is a conflict), we do it in this
* function: set src, dst, tgt address in the three cases, then for all cases
* set the rest, including SLLAO
*
*/
void
uip_nd6_ns_input(void);
/**
* \brief Send a neighbor solicitation, send a Neighbor Advertisement
* \param src pointer to the src of the NS if known
* \param dest pointer to ip address to send the NS, for DAD or ADDR Resol,

View file

@ -73,6 +73,7 @@
#include "sys/cc.h"
#include "net/ip/uip.h"
#include "net/ip/uip_arch.h"
#include "net/ip/uipopt.h"
#include "net/ipv6/uip-icmp6.h"
#include "net/ipv6/uip-nd6.h"
@ -84,6 +85,10 @@
#include "rpl/rpl-private.h"
#endif
#if UIP_ND6_SEND_NS
#include "net/ipv6/uip-ds6-nbr.h"
#endif /* UIP_ND6_SEND_NS */
#include <string.h>
/*---------------------------------------------------------------------------*/
@ -890,7 +895,7 @@ ext_hdr_options_process(void)
*/
#if UIP_CONF_IPV6_RPL
PRINTF("Processing RPL option\n");
if(rpl_verify_hbh_header(uip_ext_opt_offset)) {
if(!rpl_verify_hbh_header(uip_ext_opt_offset)) {
PRINTF("RPL Option Error: Dropping Packet\n");
return 1;
}
@ -1150,6 +1155,13 @@ uip_process(uint8_t flag)
goto drop;
}
/* Refresh neighbor state after receiving a unicast message */
#if UIP_ND6_SEND_NS
if(!uip_is_addr_mcast(&UIP_IP_BUF->destipaddr)) {
uip_ds6_nbr_refresh_reachable_state(&UIP_IP_BUF->srcipaddr);
}
#endif /* UIP_ND6_SEND_NS */
#if UIP_CONF_ROUTER
/*
* Next header field processing. In IPv6, we can have extension headers,
@ -1228,14 +1240,6 @@ uip_process(uint8_t flag)
goto send;
}
#if UIP_CONF_IPV6_RPL
if(!rpl_update_header()) {
/* Packet can not be forwarded */
PRINTF("RPL header update error\n");
goto drop;
}
#endif /* UIP_CONF_IPV6_RPL */
UIP_IP_BUF->ttl = UIP_IP_BUF->ttl - 1;
PRINTF("Forwarding packet to ");
PRINT6ADDR(&UIP_IP_BUF->destipaddr);
@ -1582,10 +1586,6 @@ uip_process(uint8_t flag)
}
#endif /* UIP_UDP_CHECKSUMS */
#if UIP_CONF_IPV6_RPL
rpl_insert_header();
#endif /* UIP_CONF_IPV6_RPL */
UIP_STAT(++uip_stat.udp.sent);
goto ip_send_nolen;
#endif /* UIP_UDP */
@ -1854,8 +1854,10 @@ uip_process(uint8_t flag)
if((UIP_TCP_BUF->flags & TCP_SYN)) {
if((uip_connr->tcpstateflags & UIP_TS_MASK) == UIP_SYN_RCVD) {
goto tcp_send_synack;
#if UIP_ACTIVE_OPEN
} else if((uip_connr->tcpstateflags & UIP_TS_MASK) == UIP_SYN_SENT) {
goto tcp_send_syn;
#endif
}
}
goto tcp_send_ack;

View file

@ -0,0 +1,347 @@
/*
* Copyright (c) 2014, Thingsquare, http://www.thingsquare.com/.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#include "websocket-http-client.h"
#include "net/ip/uiplib.h"
#include "net/ip/resolv.h"
#include "ip64-addr.h"
#include <stdio.h>
#include <string.h>
#define DEBUG DEBUG_NONE
#include "net/ip/uip-debug.h"
enum {
STATE_WAITING_FOR_HEADER,
STATE_WAITING_FOR_CONNECTED,
STATE_STEADY_STATE,
};
/*---------------------------------------------------------------------------*/
static void
send_get(struct websocket_http_client_state *s)
{
struct tcp_socket *tcps;
tcps = &s->s;
tcp_socket_send_str(tcps, "GET ");
tcp_socket_send_str(tcps, s->file);
tcp_socket_send_str(tcps, " HTTP/1.1\r\n");
tcp_socket_send_str(tcps, "Host: ");
tcp_socket_send_str(tcps, s->host);
tcp_socket_send_str(tcps, "\r\n");
if(strlen(s->header) > 0) {
tcp_socket_send_str(tcps, s->header);
}
/* The Sec-WebSocket-Key: x3JJHMbDL1EzLkh9GBhXDw== header is
supposed to be a random value, encoded as base64, that is SHA1
hashed by the server and returned in a HTTP header. This is used
to make sure that we are not seeing some cached version of this
conversation. But we have no SHA1 code by default in Contiki, so
we can't check the return value. Therefore we just use a
hardcoded value here. */
tcp_socket_send_str(tcps,
"Connection: Upgrade\r\n"
"Upgrade: websocket\r\n"
"Sec-WebSocket-Key: x3JJHMbDL1EzLkh9GBhXDw==\r\n"
"Sec-WebSocket-Version: 13\r\n"
"Sec-WebSocket-Protocol:");
tcp_socket_send_str(tcps, s->subprotocol);
tcp_socket_send_str(tcps, "\r\n");
tcp_socket_send_str(tcps, "\r\n");
PRINTF("websocket-http-client: send_get(): output buffer left %d\n", tcp_socket_max_sendlen(tcps));
}
/*---------------------------------------------------------------------------*/
static void
send_connect(struct websocket_http_client_state *s)
{
struct tcp_socket *tcps;
char buf[20];
tcps = &s->s;
tcp_socket_send_str(tcps, "CONNECT ");
tcp_socket_send_str(tcps, s->host);
tcp_socket_send_str(tcps, ":");
sprintf(buf, "%d", s->port);
tcp_socket_send_str(tcps, buf);
tcp_socket_send_str(tcps, " HTTP/1.1\r\n");
tcp_socket_send_str(tcps, "Host: ");
tcp_socket_send_str(tcps, s->host);
tcp_socket_send_str(tcps, "\r\n");
tcp_socket_send_str(tcps, "Proxy-Connection: Keep-Alive\r\n\r\n");
}
/*---------------------------------------------------------------------------*/
static void
event(struct tcp_socket *tcps, void *ptr,
tcp_socket_event_t e)
{
struct websocket_http_client_state *s = ptr;
if(e == TCP_SOCKET_CONNECTED) {
if(s->proxy_port != 0) {
send_connect(s);
} else {
send_get(s);
}
} else if(e == TCP_SOCKET_CLOSED) {
websocket_http_client_closed(s);
} else if(e == TCP_SOCKET_TIMEDOUT) {
websocket_http_client_timedout(s);
} else if(e == TCP_SOCKET_ABORTED) {
websocket_http_client_aborted(s);
} else if(e == TCP_SOCKET_DATA_SENT) {
/* We could feed this information up to the websocket.c layer, but
we currently do not do that. */
}
}
/*---------------------------------------------------------------------------*/
static int
parse_header_byte(struct websocket_http_client_state *s,
uint8_t b)
{
static const char *endmarker = "\r\n\r\n";
PT_BEGIN(&s->parse_header_pt);
/* Skip the first part of the HTTP response */
while(b != ' ') {
PT_YIELD(&s->parse_header_pt);
}
/* Skip the space that follow the first part */
PT_YIELD(&s->parse_header_pt);
/* Read the first three bytes that constistute the HTTP status
code. We store the HTTP status code as an integer in the
s->http_status field. */
s->http_status = (b - '0');
PT_YIELD(&s->parse_header_pt);
s->http_status = s->http_status * 10 + (b - '0');
PT_YIELD(&s->parse_header_pt);
s->http_status = s->http_status * 10 + (b - '0');
if((s->proxy_port != 0 && !(s->http_status == 200 || s->http_status == 101)) ||
(s->proxy_port == 0 && s->http_status != 101)) {
/* This is a websocket request, so the server should have answered
with a 101 Switching protocols response. */
PRINTF("Websocket HTTP client didn't get the 101 status code (got %d), closing connection\n",
s->http_status);
websocket_http_client_close(s);
while(1) {
PT_YIELD(&s->parse_header_pt);
}
}
/* Keep eating header bytes until we reach the end of it. The end is
indicated by the string "\r\n\r\n". We don't actually look at any
of the headers.
The s->i variable contains the number of consecutive bytes
matched. If we match the total length of the string, we stop.
*/
s->i = 0;
do {
PT_YIELD(&s->parse_header_pt);
if(b == (uint8_t)endmarker[s->i]) {
s->i++;
} else {
s->i = 0;
}
} while(s->i < strlen(endmarker));
if(s->proxy_port != 0 && s->state == STATE_WAITING_FOR_HEADER) {
send_get(s);
s->state = STATE_WAITING_FOR_CONNECTED;
} else {
s->state = STATE_STEADY_STATE;
websocket_http_client_connected(s);
}
PT_END(&s->parse_header_pt);
}
/*---------------------------------------------------------------------------*/
static int
input(struct tcp_socket *tcps, void *ptr,
const uint8_t *inputptr, int inputdatalen)
{
struct websocket_http_client_state *s = ptr;
if(s->state == STATE_WAITING_FOR_HEADER ||
s->state == STATE_WAITING_FOR_CONNECTED) {
int i;
for(i = 0; i < inputdatalen; i++) {
parse_header_byte(s, inputptr[i]);
if(s->state == STATE_STEADY_STATE) {
i++;
break;
}
}
if(i < inputdatalen && s->state == STATE_STEADY_STATE) {
websocket_http_client_datahandler(s, &inputptr[i], inputdatalen - i);
}
} else {
websocket_http_client_datahandler(s, inputptr, inputdatalen);
}
return 0; /* all data consumed */
}
/*---------------------------------------------------------------------------*/
int
websocket_http_client_register(struct websocket_http_client_state *s,
const char *host,
uint16_t port,
const char *file,
const char *subprotocol,
const char *header)
{
if(host == NULL) {
return -1;
}
strncpy(s->host, host, sizeof(s->host));
if(file == NULL) {
return -1;
}
strncpy(s->file, file, sizeof(s->file));
if(subprotocol == NULL) {
return -1;
}
strncpy(s->subprotocol, subprotocol, sizeof(s->subprotocol));
if(header == NULL) {
strncpy(s->header, "", sizeof(s->header));
} else {
strncpy(s->header, header, sizeof(s->header));
}
if(port == 0) {
s->port = 80;
} else {
s->port = port;
}
return 1;
}
/*---------------------------------------------------------------------------*/
int
websocket_http_client_get(struct websocket_http_client_state *s)
{
uip_ip4addr_t ip4addr;
uip_ip6addr_t ip6addr;
uip_ip6addr_t *addr;
uint16_t port;
PRINTF("websocket_http_client_get: connecting to %s with file %s subprotocol %s header %s\n",
s->host, s->file, s->subprotocol, s->header);
s->state = STATE_WAITING_FOR_HEADER;
if(tcp_socket_register(&s->s, s,
s->inputbuf, sizeof(s->inputbuf),
s->outputbuf, sizeof(s->outputbuf),
input, event) < 0) {
return -1;
}
port = s->port;
if(s->proxy_port != 0) {
/* The proxy address should be an IPv6 address. */
uip_ipaddr_copy(&ip6addr, &s->proxy_addr);
port = s->proxy_port;
} else if(uiplib_ip6addrconv(s->host, &ip6addr) == 0) {
/* First check if the host is an IP address. */
if(uiplib_ip4addrconv(s->host, &ip4addr) != 0) {
ip64_addr_4to6(&ip4addr, &ip6addr);
} else {
/* Try to lookup the hostname. If it fails, we initiate a hostname
lookup. */
if(resolv_lookup(s->host, &addr) != RESOLV_STATUS_CACHED) {
return -1;
}
return tcp_socket_connect(&s->s, addr, s->port);
}
}
return tcp_socket_connect(&s->s, &ip6addr, port);
}
/*---------------------------------------------------------------------------*/
int
websocket_http_client_send(struct websocket_http_client_state *s,
const uint8_t *data,
uint16_t datalen)
{
if(s->state == STATE_STEADY_STATE) {
return tcp_socket_send(&s->s, data, datalen);
}
return -1;
}
/*---------------------------------------------------------------------------*/
int
websocket_http_client_sendbuflen(struct websocket_http_client_state *s)
{
return tcp_socket_max_sendlen(&s->s);
}
/*---------------------------------------------------------------------------*/
void
websocket_http_client_close(struct websocket_http_client_state *s)
{
tcp_socket_close(&s->s);
}
/*---------------------------------------------------------------------------*/
const char *
websocket_http_client_hostname(struct websocket_http_client_state *s)
{
return s->host;
}
/*---------------------------------------------------------------------------*/
void
websocket_http_client_init(struct websocket_http_client_state *s)
{
uip_create_unspecified(&s->proxy_addr);
s->proxy_port = 0;
}
/*---------------------------------------------------------------------------*/
void
websocket_http_client_set_proxy(struct websocket_http_client_state *s,
const uip_ipaddr_t *addr, uint16_t port)
{
uip_ipaddr_copy(&s->proxy_addr, addr);
s->proxy_port = port;
}
/*---------------------------------------------------------------------------*/
int
websocket_http_client_queuelen(struct websocket_http_client_state *s)
{
return tcp_socket_queuelen(&s->s);
}
/*---------------------------------------------------------------------------*/

View file

@ -0,0 +1,123 @@
/*
* Copyright (c) 2014, Thingsquare, http://www.thingsquare.com/.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef WEBSOCKET_HTTP_CLIENT_H_
#define WEBSOCKET_HTTP_CLIENT_H_
#include "contiki.h"
#include "tcp-socket.h"
#ifdef WEBSOCKET_HTTP_CLIENT_CONF_INPUTBUFSIZE
#define WEBSOCKET_HTTP_CLIENT_INPUTBUFSIZE WEBSOCKET_HTTP_CLIENT_CONF_INPUTBUFSIZE
#else /* WEBSOCKET_HTTP_CLIENT_CONF_INPUTBUFSIZE */
#define WEBSOCKET_HTTP_CLIENT_INPUTBUFSIZE 100
#endif /* WEBSOCKET_HTTP_CLIENT_CONF_INPUTBUFSIZE */
#ifdef WEBSOCKET_HTTP_CLIENT_CONF_OUTPUTBUFSIZE
#define WEBSOCKET_HTTP_CLIENT_OUTPUTBUFSIZE WEBSOCKET_HTTP_CLIENT_CONF_OUTPUTBUFSIZE
#else /* WEBSOCKET_HTTP_CLIENT_CONF_OUTPUTBUFSIZE */
#define WEBSOCKET_HTTP_CLIENT_OUTPUTBUFSIZE 300
#endif /* WEBSOCKET_HTTP_CLIENT_CONF_OUTPUTBUFSIZE */
#ifdef WEBSOCKET_HTTP_CLIENT_CONF_MAX_HOSTLEN
#define WEBSOCKET_HTTP_CLIENT_MAX_HOSTLEN WEBSOCKET_HTTP_CLIENT_CONF_MAX_HOSTLEN
#else /* WEBSOCKET_HTTP_CLIENT_CONF_MAX_HOSTLEN */
#define WEBSOCKET_HTTP_CLIENT_MAX_HOSTLEN 32
#endif /* WEBSOCKET_HTTP_CLIENT_CONF_MAX_HOSTLEN */
#ifdef WEBSOCKET_HTTP_CLIENT_CONF_MAX_FILELEN
#define WEBSOCKET_HTTP_CLIENT_MAX_FILELEN WEBSOCKET_HTTP_CLIENT_CONF_MAX_FILELEN
#else /* WEBSOCKET_HTTP_CLIENT_CONF_MAX_FILELEN */
#define WEBSOCKET_HTTP_CLIENT_MAX_FILELEN 32
#endif /* WEBSOCKET_HTTP_CLIENT_CONF_MAX_FILELEN */
#ifdef WEBSOCKET_HTTP_CLIENT_CONF_MAX_SUBPROTOCOLLEN
#define WEBSOCKET_HTTP_CLIENT_MAX_SUBPROTOCOLLEN WEBSOCKET_HTTP_CLIENT_CONF_MAX_SUBPROTOCOLLEN
#else /* WEBSOCKET_HTTP_CLIENT_CONF_MAX_SUBPROTOCOLLEN */
#define WEBSOCKET_HTTP_CLIENT_MAX_SUBPROTOCOLLEN 24
#endif /* WEBSOCKET_HTTP_CLIENT_CONF_MAX_SUBPROTOCOLLEN */
#ifdef WEBSOCKET_HTTP_CLIENT_CONF_MAX_HEADERLEN
#define WEBSOCKET_HTTP_CLIENT_MAX_HEADERLEN WEBSOCKET_HTTP_CLIENT_CONF_MAX_HEADERLEN
#else /* WEBSOCKET_HTTP_CLIENT_CONF_MAX_HEADERLEN */
#define WEBSOCKET_HTTP_CLIENT_MAX_HEADERLEN 128
#endif /* WEBSOCKET_HTTP_CLIENT_CONF_MAX_HEADERLEN */
struct websocket_http_client_state {
struct tcp_socket s;
uint8_t inputbuf[WEBSOCKET_HTTP_CLIENT_INPUTBUFSIZE];
uint8_t outputbuf[WEBSOCKET_HTTP_CLIENT_OUTPUTBUFSIZE];
char host[WEBSOCKET_HTTP_CLIENT_MAX_HOSTLEN];
char file[WEBSOCKET_HTTP_CLIENT_MAX_FILELEN];
char subprotocol[WEBSOCKET_HTTP_CLIENT_MAX_SUBPROTOCOLLEN];
char header[WEBSOCKET_HTTP_CLIENT_MAX_HEADERLEN];
uint16_t port;
int state;
struct pt parse_header_pt;
int http_status;
int i;
uip_ipaddr_t proxy_addr;
uint16_t proxy_port;
};
void websocket_http_client_init(struct websocket_http_client_state *s);
void websocket_http_client_set_proxy(struct websocket_http_client_state *s,
const uip_ipaddr_t *addr, uint16_t port);
int websocket_http_client_register(struct websocket_http_client_state *s,
const char *host,
uint16_t port,
const char *file,
const char *subprotocol,
const char *hdr);
int websocket_http_client_get(struct websocket_http_client_state *s);
int websocket_http_client_send(struct websocket_http_client_state *s,
const uint8_t *data,
uint16_t datalen);
int websocket_http_client_sendbuflen(struct websocket_http_client_state *s);
void websocket_http_client_close(struct websocket_http_client_state *s);
const char *websocket_http_client_hostname(struct websocket_http_client_state *s);
int websocket_http_client_queuelen(struct websocket_http_client_state *s);
/* Callback functions that have to be implemented by the application
program. */
void websocket_http_client_datahandler(struct websocket_http_client_state *s,
const uint8_t *data, uint16_t len);
void websocket_http_client_connected(struct websocket_http_client_state *s);
void websocket_http_client_timedout(struct websocket_http_client_state *s);
void websocket_http_client_aborted(struct websocket_http_client_state *s);
void websocket_http_client_closed(struct websocket_http_client_state *s);
#endif /* WEBSOCKET_HTTP_CLIENT_H_ */

724
core/net/ipv6/websocket.c Normal file
View file

@ -0,0 +1,724 @@
/*
* Copyright (c) 2012, Thingsquare, http://www.thingsquare.com/.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#include <stdio.h>
#include <stddef.h>
#include <string.h>
#include "contiki-net.h"
#include "lib/petsciiconv.h"
#include "websocket.h"
PROCESS(websocket_process, "Websockets process");
#define MAX_HOSTLEN 64
#define MAX_PATHLEN 100
LIST(websocketlist);
#define WEBSOCKET_FIN_BIT 0x80
#define WEBSOCKET_OPCODE_MASK 0x0f
#define WEBSOCKET_OPCODE_CONT 0x00
#define WEBSOCKET_OPCODE_TEXT 0x01
#define WEBSOCKET_OPCODE_BIN 0x02
#define WEBSOCKET_OPCODE_CLOSE 0x08
#define WEBSOCKET_OPCODE_PING 0x09
#define WEBSOCKET_OPCODE_PONG 0x0a
#define WEBSOCKET_MASK_BIT 0x80
#define WEBSOCKET_LEN_MASK 0x7f
struct websocket_frame_hdr {
uint8_t opcode;
uint8_t len;
uint8_t extlen[4];
};
struct websocket_frame_mask {
uint8_t mask[4];
};
#define DEBUG DEBUG_NONE
#include "net/ip/uip-debug.h"
/*---------------------------------------------------------------------------*/
static int
parse_url(const char *url, char *host, uint16_t *portptr, char *path)
{
const char *urlptr;
int i;
const char *file;
uint16_t port;
if(url == NULL) {
return 0;
}
/* Don't even try to go further if the URL is empty. */
if(strlen(url) == 0) {
return 0;
}
/* See if the URL starts with http:// or ws:// and remove it. */
if(strncmp(url, "http://", strlen("http://")) == 0) {
urlptr = url + strlen("http://");
} else if(strncmp(url, "ws://", strlen("ws://")) == 0) {
urlptr = url + strlen("ws://");
} else {
urlptr = url;
}
/* Find host part of the URL. */
for(i = 0; i < MAX_HOSTLEN; ++i) {
if(*urlptr == 0 ||
*urlptr == '/' ||
*urlptr == ' ' ||
*urlptr == ':') {
if(host != NULL) {
host[i] = 0;
}
break;
}
if(host != NULL) {
host[i] = *urlptr;
}
++urlptr;
}
/* Find the port. Default is 0, which lets the underlying transport
select its default port. */
port = 0;
if(*urlptr == ':') {
port = 0;
do {
++urlptr;
if(*urlptr >= '0' && *urlptr <= '9') {
port = (10 * port) + (*urlptr - '0');
}
} while(*urlptr >= '0' &&
*urlptr <= '9');
}
if(portptr != NULL) {
*portptr = port;
}
/* Find file part of the URL. */
while(*urlptr != '/' && *urlptr != 0) {
++urlptr;
}
if(*urlptr == '/') {
file = urlptr;
} else {
file = "/";
}
if(path != NULL) {
strncpy(path, file, MAX_PATHLEN);
}
return 1;
}
/*---------------------------------------------------------------------------*/
static int
start_get(struct websocket *s)
{
if(websocket_http_client_get(&(s->s)) == 0) {
PRINTF("Out of memory error\n");
s->state = WEBSOCKET_STATE_CLOSED;
return WEBSOCKET_ERR;
} else {
PRINTF("Connecting...\n");
s->state = WEBSOCKET_STATE_HTTP_REQUEST_SENT;
return WEBSOCKET_OK;
}
return WEBSOCKET_ERR;
}
/*---------------------------------------------------------------------------*/
void
call(struct websocket *s, websocket_result_t r,
const uint8_t *data, uint16_t datalen)
{
if(s != NULL && s->callback != NULL) {
s->callback(s, r, data, datalen);
}
}
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(websocket_process, ev, data)
{
PROCESS_BEGIN();
while(1) {
PROCESS_WAIT_EVENT();
if(ev == resolv_event_found && data != NULL) {
int ret;
struct websocket *s;
const char *name = data;
/* Either found a hostname, or not. We need to go through the
list of websocketsand figure out to which connection this
reply corresponds, then either restart the HTTP get, or kill
it (if no hostname was found). */
for(s = list_head(websocketlist);
s != NULL;
s = list_item_next(s)) {
if(strcmp(name, websocket_http_client_hostname(&s->s)) == 0) {
ret = resolv_lookup(name, NULL);
if(ret == RESOLV_STATUS_CACHED) {
/* Hostname found, restart get. */
if(s->state == WEBSOCKET_STATE_DNS_REQUEST_SENT) {
PRINTF("Restarting get\n");
start_get(s);
}
} else {
if(s->state == WEBSOCKET_STATE_DNS_REQUEST_SENT) {
/* Hostname not found, kill connection. */
/* PRINTF("XXX killing connection\n");*/
call(s, WEBSOCKET_HOSTNAME_NOT_FOUND, NULL, 0);
}
}
}
}
}
}
PROCESS_END();
}
/*---------------------------------------------------------------------------*/
/* Callback function. Called from the webclient when the HTTP
* connection was abruptly aborted.
*/
void
websocket_http_client_aborted(struct websocket_http_client_state *client_state)
{
if(client_state != NULL) {
struct websocket *s = (struct websocket *)
((char *)client_state - offsetof(struct websocket, s));
PRINTF("Websocket reset\n");
s->state = WEBSOCKET_STATE_CLOSED;
call(s, WEBSOCKET_RESET, NULL, 0);
}
}
/*---------------------------------------------------------------------------*/
/* Callback function. Called from the webclient when the HTTP
* connection timed out.
*/
void
websocket_http_client_timedout(struct websocket_http_client_state *client_state)
{
if(client_state != NULL) {
struct websocket *s = (struct websocket *)
((char *)client_state - offsetof(struct websocket, s));
PRINTF("Websocket timed out\n");
s->state = WEBSOCKET_STATE_CLOSED;
call(s, WEBSOCKET_TIMEDOUT, NULL, 0);
}
}
/*---------------------------------------------------------------------------*/
/* Callback function. Called from the webclient when the HTTP
* connection was closed after a request from the "websocket_http_client_close()"
* function. .
*/
void
websocket_http_client_closed(struct websocket_http_client_state *client_state)
{
if(client_state != NULL) {
struct websocket *s = (struct websocket *)
((char *)client_state - offsetof(struct websocket, s));
PRINTF("Websocket closed.\n");
s->state = WEBSOCKET_STATE_CLOSED;
call(s, WEBSOCKET_CLOSED, NULL, 0);
}
}
/*---------------------------------------------------------------------------*/
/* Callback function. Called from the webclient when the HTTP
* connection is connected.
*/
void
websocket_http_client_connected(struct websocket_http_client_state *client_state)
{
struct websocket *s = (struct websocket *)
((char *)client_state - offsetof(struct websocket, s));
PRINTF("Websocket connected\n");
s->state = WEBSOCKET_STATE_WAITING_FOR_HEADER;
call(s, WEBSOCKET_CONNECTED, NULL, 0);
}
/*---------------------------------------------------------------------------*/
/* The websocket header may potentially be split into multiple TCP
segments. This function eats one byte each, puts it into
s->headercache, and checks whether or not the full header has been
received. */
static int
receive_header_byte(struct websocket *s, uint8_t byte)
{
int len;
int expected_len;
struct websocket_frame_hdr *hdr;
/* Take the next byte of data and place it in the header cache. */
if(s->state == WEBSOCKET_STATE_RECEIVING_HEADER) {
s->headercache[s->headercacheptr] = byte;
s->headercacheptr++;
if(s->headercacheptr >= sizeof(s->headercache)) {
/* Something bad happened: we ad read 10 bytes and had not yet
found a reasonable header, so we close the socket. */
websocket_close(s);
}
}
len = s->headercacheptr;
hdr = (struct websocket_frame_hdr *)s->headercache;
/* Check the header that we have received to see if it is long
enough. */
/* We start with expecting a length of at least two bytes (opcode +
1 length byte). */
expected_len = 2;
if(len >= expected_len) {
/* We check how many more bytes we should expect to see. The
length byte determines how many length bytes are included in
the header. */
if((hdr->len & WEBSOCKET_LEN_MASK) == 126) {
expected_len += 2;
} else if((hdr->len & WEBSOCKET_LEN_MASK) == 127) {
expected_len += 4;
}
/* If the option has the mask bit set, we should expect to see 4
mask bytes at the end of the header. */
if((hdr->len & WEBSOCKET_MASK_BIT ) != 0) {
expected_len += 4;
}
/* Now we know how long our header if expected to be. If it is
this long, we are done and we set the state to reflect this. */
if(len == expected_len) {
s->state = WEBSOCKET_STATE_HEADER_RECEIVED;
return 1;
}
}
return 0;
}
/*---------------------------------------------------------------------------*/
/* Callback function. Called from the webclient module when HTTP data
* has arrived.
*/
void
websocket_http_client_datahandler(struct websocket_http_client_state *client_state,
const uint8_t *data, uint16_t datalen)
{
struct websocket *s = (struct websocket *)
((char *)client_state - offsetof(struct websocket, s));
struct websocket_frame_hdr *hdr;
struct websocket_frame_mask *maskptr;
if(data == NULL) {
call(s, WEBSOCKET_CLOSED, NULL, 0);
} else {
/* This function is a state machine that does different things
depending on the state. If we are waiting for header (the
default state), we change to the RECEIVING_HEADER state when we
get the first byte. If we are receiving header, we put all
bytes we have into a header buffer until the full header has
been received. If we have received the header, we parse it. If
we have received and parsed the header, we are ready to receive
data. Finally, if there is data left in the incoming packet, we
repeat the process. */
if(s->state == WEBSOCKET_STATE_WAITING_FOR_HEADER) {
s->state = WEBSOCKET_STATE_RECEIVING_HEADER;
s->headercacheptr = 0;
}
if(s->state == WEBSOCKET_STATE_RECEIVING_HEADER) {
while(datalen > 0 && s->state == WEBSOCKET_STATE_RECEIVING_HEADER) {
receive_header_byte(s, data[0]);
data++;
datalen--;
}
}
if(s->state == WEBSOCKET_STATE_HEADER_RECEIVED) {
/* If this is the start of an incoming websocket data frame, we
decode the header and check if we should act on in. If not, we
pipe the data to the application through a callback handler. If
data arrives in multiple packets, it is up to the application to
put it back together again. */
/* The websocket header is at the start of the incoming data. */
hdr = (struct websocket_frame_hdr *)s->headercache;
/* The s->left field holds the length of the application data
* chunk that we are about to receive. */
s->len = s->left = 0;
/* The s->mask field holds the bitmask of the data chunk, if
* any. */
memset(s->mask, 0, sizeof(s->mask));
/* We first read out the length of the application data
chunk. The length may be encoded over multiple bytes. If the
length is >= 126 bytes, it is encoded as two or more
bytes. The first length field determines if it is in 2 or 4
bytes. We also keep track of where the bitmask is held - its
place also differs depending on how the length is encoded. */
maskptr = (struct websocket_frame_mask *)hdr->extlen;
if((hdr->len & WEBSOCKET_LEN_MASK) < 126) {
s->len = s->left = hdr->len & WEBSOCKET_LEN_MASK;
} else if(hdr->len == 126) {
s->len = s->left = (hdr->extlen[0] << 8) + hdr->extlen[1];
maskptr = (struct websocket_frame_mask *)&hdr->extlen[2];
} else if(hdr->len == 127) {
s->len = s->left = ((uint32_t)hdr->extlen[0] << 24) +
((uint32_t)hdr->extlen[1] << 16) +
((uint32_t)hdr->extlen[2] << 8) +
hdr->extlen[3];
maskptr = (struct websocket_frame_mask *)&hdr->extlen[4];
}
/* Set user_data to point to the first byte of application data.
See if the application data chunk is masked or not. If it is,
we copy the bitmask into the s->mask field. */
if((hdr->len & WEBSOCKET_MASK_BIT) == 0) {
/* PRINTF("No mask\n");*/
} else {
memcpy(s->mask, &maskptr->mask, sizeof(s->mask));
/* PRINTF("There was a mask, %02x %02x %02x %02x\n",
s->mask[0], s->mask[1], s->mask[2], s->mask[3]);*/
}
/* Remember the opcode of the application chunk, put it in the
* s->opcode field. */
s->opcode = hdr->opcode & WEBSOCKET_OPCODE_MASK;
if(s->opcode == WEBSOCKET_OPCODE_PING) {
/* If the opcode is ping, we change the opcode to a pong, and
* send the data back. */
hdr->opcode = (hdr->opcode & (~WEBSOCKET_OPCODE_MASK)) |
WEBSOCKET_OPCODE_PONG;
websocket_http_client_send(&s->s, (const uint8_t*)hdr, 2);
if(s->left > 0) {
websocket_http_client_send(&s->s, (const uint8_t*)data, s->left);
}
PRINTF("Got ping\n");
call(s, WEBSOCKET_PINGED, NULL, 0);
s->state = WEBSOCKET_STATE_WAITING_FOR_HEADER;
} else if(s->opcode == WEBSOCKET_OPCODE_PONG) {
/* If the opcode is pong, we call the application to let it
know we got a pong. */
PRINTF("Got pong\n");
call(s, WEBSOCKET_PONG_RECEIVED, NULL, 0);
s->state = WEBSOCKET_STATE_WAITING_FOR_HEADER;
} else if(s->opcode == WEBSOCKET_OPCODE_CLOSE) {
/* If the opcode is a close, we send a close frame back. */
hdr->opcode = (hdr->opcode & (~WEBSOCKET_OPCODE_MASK)) |
WEBSOCKET_OPCODE_CLOSE;
websocket_http_client_send(&s->s, (const uint8_t*)hdr, 2);
if(s->left > 0) {
websocket_http_client_send(&s->s, (const uint8_t*)data, s->left);
}
PRINTF("websocket: got close, sending close\n");
s->state = WEBSOCKET_STATE_WAITING_FOR_HEADER;
websocket_http_client_close(&s->s);
} else if(s->opcode == WEBSOCKET_OPCODE_BIN ||
s->opcode == WEBSOCKET_OPCODE_TEXT) {
/* If the opcode is bin or text, and there is application
* layer data in the packet, we call the application to
* process it. */
if(s->left > 0) {
s->state = WEBSOCKET_STATE_RECEIVING_DATA;
if(datalen > 0) {
int len;
len = MIN(s->left, datalen);
/* XXX todo: mask if needed. */
call(s, WEBSOCKET_DATA, data, len);
data += len;
s->left -= len;
datalen -= len;
}
}
}
if(s->left == 0) {
call(s, WEBSOCKET_DATA_RECEIVED, NULL, s->len);
s->state = WEBSOCKET_STATE_WAITING_FOR_HEADER;
/* Need to keep parsing the incoming data to check for more
frames, if the incoming datalen is > than s->left. */
if(datalen > 0) {
PRINTF("XXX 1 again\n");
websocket_http_client_datahandler(client_state,
data, datalen);
}
}
} else if(s->state == WEBSOCKET_STATE_RECEIVING_DATA) {
/* XXX todo: mask if needed. */
/* PRINTF("Calling with s->left %d datalen %d\n",
s->left, datalen);*/
if(datalen > 0) {
if(datalen < s->left) {
call(s, WEBSOCKET_DATA, data, datalen);
s->left -= datalen;
data += datalen;
datalen = 0;
} else {
call(s, WEBSOCKET_DATA, data, s->left);
data += s->left;
datalen -= s->left;
s->left = 0;
}
}
if(s->left == 0) {
call(s, WEBSOCKET_DATA_RECEIVED, NULL, s->len);
s->state = WEBSOCKET_STATE_WAITING_FOR_HEADER;
/* Need to keep parsing the incoming data to check for more
frames, if the incoming datalen is > than len. */
if(datalen > 0) {
PRINTF("XXX 2 again (datalen %d s->left %d)\n", datalen, (int)s->left);
websocket_http_client_datahandler(client_state,
data, datalen);
}
}
}
}
}
/*---------------------------------------------------------------------------*/
static void
init(void)
{
static uint8_t inited = 0;
if(!inited) {
process_start(&websocket_process, NULL);
list_init(websocketlist);
inited = 1;
}
}
/*---------------------------------------------------------------------------*/
void
websocket_init(struct websocket *s)
{
init();
websocket_http_client_init(&s->s);
}
/*---------------------------------------------------------------------------*/
void
websocket_set_proxy(struct websocket *s,
const uip_ipaddr_t *addr, uint16_t port)
{
websocket_http_client_set_proxy(&s->s, addr, port);
}
/*---------------------------------------------------------------------------*/
websocket_result_t
websocket_open(struct websocket *s, const char *url,
const char *subprotocol, const char *hdr,
websocket_callback c)
{
int ret;
char host[MAX_HOSTLEN + 1] = {0};
char path[MAX_PATHLEN + 1] = {0};
uint16_t port;
uip_ipaddr_t addr;
init();
if(s == NULL) {
return WEBSOCKET_ERR;
}
if(s->state != WEBSOCKET_STATE_CLOSED) {
PRINTF("websocket_open: closing websocket before opening it again.\n");
websocket_close(s);
}
s->callback = c;
if(parse_url(url, host, &port, path)) {
list_add(websocketlist, s);
websocket_http_client_register(&s->s, host, port, path, subprotocol, hdr);
/* First check if the host is an IP address. */
if(uiplib_ip4addrconv(host, (uip_ip4addr_t *)&addr) == 0 &&
uiplib_ip6addrconv(host, (uip_ip6addr_t *)&addr) == 0) {
/* Try to lookup the hostname. If it fails, we initiate a hostname
lookup and print out an informative message on the
statusbar. */
ret = resolv_lookup(host, NULL);
if(ret != RESOLV_STATUS_CACHED) {
resolv_query(host);
s->state = WEBSOCKET_STATE_DNS_REQUEST_SENT;
PRINTF("Resolving host...\n");
return WEBSOCKET_OK;
}
}
PROCESS_CONTEXT_BEGIN(&websocket_process);
ret = start_get(s);
PROCESS_CONTEXT_END();
return ret;
}
return -1;
}
/*---------------------------------------------------------------------------*/
void
websocket_close(struct websocket *s)
{
websocket_http_client_close(&s->s);
s->state = WEBSOCKET_STATE_CLOSED;
}
/*---------------------------------------------------------------------------*/
static int
send_data(struct websocket *s, const void *data,
uint16_t datalen, uint8_t data_type_opcode)
{
uint8_t buf[WEBSOCKET_MAX_MSGLEN + 4 + 4]; /* The extra + 4 + 4 here
comes from the size of
the websocket framing
header. */
struct websocket_frame_hdr *hdr;
struct websocket_frame_mask *mask;
PRINTF("websocket send data len %d %.*s\n", datalen, datalen, (char *)data);
if(s->state == WEBSOCKET_STATE_CLOSED ||
s->state == WEBSOCKET_STATE_DNS_REQUEST_SENT ||
s->state == WEBSOCKET_STATE_HTTP_REQUEST_SENT) {
/* Trying to send data on a non-connected websocket. */
PRINTF("websocket send fail: not connected\n");
return -1;
}
/* We need to have 4 + 4 additional bytes for the websocket framing
header. */
if(4 + 4 + datalen > websocket_http_client_sendbuflen(&s->s)) {
PRINTF("websocket: too few bytes left (%d left, %d needed)\n",
websocket_http_client_sendbuflen(&s->s),
4 + 4 + datalen);
return -1;
}
if(datalen > sizeof(buf) - 4 - 4) {
PRINTF("websocket: trying to send too large data chunk %d > %d\n",
datalen, sizeof(buf) - 4 - 4);
return -1;
}
hdr = (struct websocket_frame_hdr *)&buf[0];
hdr->opcode = WEBSOCKET_FIN_BIT | data_type_opcode;
/* If the datalen is larger than 125 bytes, we need to send the data
length as two bytes. If the data length would be larger than 64k,
we should send the length as 4 bytes, but since we specify the
datalen as an unsigned 16-bit int, we do not handle the 64k case
here. */
if(datalen > 125) {
/* Data from client must always have the mask bit set, and a data
mask sent right after the header. */
hdr->len = 126 | WEBSOCKET_MASK_BIT;
hdr->extlen[0] = datalen >> 8;
hdr->extlen[1] = datalen & 0xff;
mask = (struct websocket_frame_mask *)&buf[4];
mask->mask[0] =
mask->mask[1] =
mask->mask[2] =
mask->mask[3] = 0;
memcpy(&buf[8], data, datalen);
return websocket_http_client_send(&s->s, buf, 8 + datalen);
} else {
/* Data from client must always have the mask bit set, and a data
mask sent right after the header. */
hdr->len = datalen | WEBSOCKET_MASK_BIT;
mask = (struct websocket_frame_mask *)&buf[2];
mask->mask[0] =
mask->mask[1] =
mask->mask[2] =
mask->mask[3] = 0;
memcpy(&buf[6], data, datalen);
return websocket_http_client_send(&s->s, buf, 6 + datalen);
}
return -1;
}
/*---------------------------------------------------------------------------*/
int
websocket_send_str(struct websocket *s, const char *str)
{
return send_data(s, str, strlen(str), WEBSOCKET_OPCODE_TEXT);
}
/*---------------------------------------------------------------------------*/
int
websocket_send(struct websocket *s, const uint8_t *data,
uint16_t datalen)
{
return send_data(s, data, datalen, WEBSOCKET_OPCODE_BIN);
}
/*---------------------------------------------------------------------------*/
int
websocket_ping(struct websocket *s)
{
uint8_t buf[sizeof(struct websocket_frame_hdr) +
sizeof(struct websocket_frame_mask)];
struct websocket_frame_hdr *hdr;
struct websocket_frame_mask *mask;
/* We need 2 + 4 additional bytes for the websocket framing
header. */
if(2 + 4 > websocket_http_client_sendbuflen(&s->s)) {
return -1;
}
hdr = (struct websocket_frame_hdr *)&buf[0];
mask = (struct websocket_frame_mask *)&buf[2];
hdr->opcode = WEBSOCKET_FIN_BIT | WEBSOCKET_OPCODE_PING;
/* Data from client must always have the mask bit set, and a data
mask sent right after the header. */
hdr->len = 0 | WEBSOCKET_MASK_BIT;
/* XXX: We just set a dummy mask of 0 for now and hope that this
works. */
mask->mask[0] =
mask->mask[1] =
mask->mask[2] =
mask->mask[3] = 0;
websocket_http_client_send(&s->s, buf, 2 + 4);
return 1;
}
/*---------------------------------------------------------------------------*/
int
websocket_queuelen(struct websocket *s)
{
return websocket_http_client_queuelen(&s->s);
}
/*---------------------------------------------------------------------------*/

113
core/net/ipv6/websocket.h Normal file
View file

@ -0,0 +1,113 @@
/*
* Copyright (c) 2012, Thingsquare, http://www.thingsquare.com/.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef WEBSOCKET_H
#define WEBSOCKET_H
#include "websocket-http-client.h"
typedef enum {
WEBSOCKET_ERR = 0,
WEBSOCKET_OK = 1,
WEBSOCKET_IN_PROGRESS = 2,
WEBSOCKET_HOSTNAME_NOT_FOUND = 3,
WEBSOCKET_CONNECTED = 4,
WEBSOCKET_DATA = 5,
WEBSOCKET_RESET = 6,
WEBSOCKET_TIMEDOUT = 7,
WEBSOCKET_CLOSED = 8,
WEBSOCKET_PINGED = 9,
WEBSOCKET_DATA_RECEIVED = 10,
WEBSOCKET_PONG_RECEIVED = 11,
} websocket_result_t;
struct websocket;
typedef void (* websocket_callback)(struct websocket *s,
websocket_result_t result,
const uint8_t *data,
uint16_t datalen);
#ifdef WEBSOCKET_CONF_MAX_MSGLEN
#define WEBSOCKET_MAX_MSGLEN WEBSOCKET_CONF_MAX_MSGLEN
#else /* WEBSOCKET_CONF_MAX_MSGLEN */
#define WEBSOCKET_MAX_MSGLEN 200
#endif /* WEBSOCKET_CONF_MAX_MSGLEN */
struct websocket {
struct websocket *next; /* Must be first. */
struct websocket_http_client_state s;
websocket_callback callback;
uint8_t mask[4];
uint32_t left, len;
uint8_t opcode;
uint8_t state;
uint8_t headercacheptr;
uint8_t headercache[10]; /* The maximum websocket header + mask is 6
+ 4 bytes long */
};
enum {
WEBSOCKET_STATE_CLOSED = 0,
WEBSOCKET_STATE_DNS_REQUEST_SENT = 1,
WEBSOCKET_STATE_HTTP_REQUEST_SENT = 2,
WEBSOCKET_STATE_WAITING_FOR_HEADER = 3,
WEBSOCKET_STATE_RECEIVING_HEADER = 4,
WEBSOCKET_STATE_HEADER_RECEIVED = 5,
WEBSOCKET_STATE_RECEIVING_DATA = 6,
};
void websocket_init(struct websocket *s);
void websocket_set_proxy(struct websocket *s,
const uip_ipaddr_t *addr, uint16_t port);
websocket_result_t websocket_open(struct websocket *s,
const char *url,
const char *subprotocol,
const char *hdr,
websocket_callback c);
int websocket_send(struct websocket *s,
const uint8_t *data, uint16_t datalen);
int websocket_send_str(struct websocket *s,
const char *strptr);
void websocket_close(struct websocket *s);
int websocket_ping(struct websocket *s);
int websocket_queuelen(struct websocket *s);
#endif /* WEBSOCKET_H */

View file

@ -51,7 +51,7 @@
/* Maximum value for the freshness counter */
#define FRESHNESS_MAX 16
/* Statistics with no update in FRESHNESS_EXPIRATION_TIMEOUT is not fresh */
#define FRESHNESS_EXPIRATION_TIME (10 * 60 * CLOCK_SECOND)
#define FRESHNESS_EXPIRATION_TIME (10 * 60 * (clock_time_t)CLOCK_SECOND)
/* EWMA (exponential moving average) used to maintain statistics over time */
#define EWMA_SCALE 100
@ -206,6 +206,6 @@ void
link_stats_init(void)
{
nbr_table_register(link_stats, NULL);
ctimer_set(&periodic_timer, 60 * CLOCK_SECOND * FRESHNESS_HALF_LIFE,
ctimer_set(&periodic_timer, 60 * (clock_time_t)CLOCK_SECOND * FRESHNESS_HALF_LIFE,
periodic, NULL);
}

View file

@ -52,6 +52,9 @@ const linkaddr_t linkaddr_null = { { 0, 0 } };
#if LINKADDR_SIZE == 8
const linkaddr_t linkaddr_null = { { 0, 0, 0, 0, 0, 0, 0, 0 } };
#endif /*LINKADDR_SIZE == 8*/
#if LINKADDR_SIZE == 6
const linkaddr_t linkaddr_null = { { 0, 0, 0, 0, 0, 0 } };
#endif /*LINKADDR_SIZE == 6*/
#endif /*LINKADDR_SIZE == 2*/

View file

@ -207,13 +207,13 @@ static int we_are_receiving_burst = 0;
#define INTER_PACKET_INTERVAL RTIMER_ARCH_SECOND / 2500
#endif
/* AFTER_ACK_DETECTECT_WAIT_TIME is the time to wait after a potential
/* AFTER_ACK_DETECTED_WAIT_TIME is the time to wait after a potential
ACK packet has been detected until we can read it out from the
radio. */
#ifdef CONTIKIMAC_CONF_AFTER_ACK_DETECTECT_WAIT_TIME
#define AFTER_ACK_DETECTECT_WAIT_TIME CONTIKIMAC_CONF_AFTER_ACK_DETECTECT_WAIT_TIME
#ifdef CONTIKIMAC_CONF_AFTER_ACK_DETECTED_WAIT_TIME
#define AFTER_ACK_DETECTED_WAIT_TIME CONTIKIMAC_CONF_AFTER_ACK_DETECTED_WAIT_TIME
#else
#define AFTER_ACK_DETECTECT_WAIT_TIME RTIMER_ARCH_SECOND / 1500
#define AFTER_ACK_DETECTED_WAIT_TIME RTIMER_ARCH_SECOND / 1500
#endif
/* MAX_PHASE_STROBE_TIME is the time that we transmit repeated packets
@ -289,9 +289,15 @@ off(void)
}
}
/*---------------------------------------------------------------------------*/
static volatile rtimer_clock_t cycle_start;
static void powercycle_wrapper(struct rtimer *t, void *ptr);
static char powercycle(struct rtimer *t, void *ptr);
/*---------------------------------------------------------------------------*/
static volatile rtimer_clock_t cycle_start;
#if SYNC_CYCLE_STARTS
static volatile rtimer_clock_t sync_cycle_start;
static volatile uint8_t sync_cycle_phase;
#endif
/*---------------------------------------------------------------------------*/
static void
schedule_powercycle(struct rtimer *t, rtimer_clock_t time)
{
@ -340,7 +346,7 @@ powercycle_turn_radio_off(void)
#if CONTIKIMAC_CONF_COMPOWER
uint8_t was_on = radio_is_on;
#endif /* CONTIKIMAC_CONF_COMPOWER */
if(we_are_sending == 0 && we_are_receiving_burst == 0) {
off();
#if CONTIKIMAC_CONF_COMPOWER
@ -367,13 +373,34 @@ powercycle_wrapper(struct rtimer *t, void *ptr)
powercycle(t, ptr);
}
/*---------------------------------------------------------------------------*/
static void
advance_cycle_start(void)
{
#if SYNC_CYCLE_STARTS
/* Compute cycle start when RTIMER_ARCH_SECOND is not a multiple
of CHANNEL_CHECK_RATE */
if(sync_cycle_phase++ == NETSTACK_RDC_CHANNEL_CHECK_RATE) {
sync_cycle_phase = 0;
sync_cycle_start += RTIMER_ARCH_SECOND;
cycle_start = sync_cycle_start;
} else if( (RTIMER_ARCH_SECOND * NETSTACK_RDC_CHANNEL_CHECK_RATE) > 65535) {
uint32_t phase_time = sync_cycle_phase*RTIMER_ARCH_SECOND;
cycle_start = sync_cycle_start + phase_time/NETSTACK_RDC_CHANNEL_CHECK_RATE;
} else {
unsigned phase_time = sync_cycle_phase*RTIMER_ARCH_SECOND;
cycle_start = sync_cycle_start + phase_time/NETSTACK_RDC_CHANNEL_CHECK_RATE;
}
#endif
cycle_start += CYCLE_TIME;
}
/*---------------------------------------------------------------------------*/
static char
powercycle(struct rtimer *t, void *ptr)
{
#if SYNC_CYCLE_STARTS
static volatile rtimer_clock_t sync_cycle_start;
static volatile uint8_t sync_cycle_phase;
#endif
PT_BEGIN(&pt);
@ -387,24 +414,6 @@ powercycle(struct rtimer *t, void *ptr)
static uint8_t packet_seen;
static uint8_t count;
#if SYNC_CYCLE_STARTS
/* Compute cycle start when RTIMER_ARCH_SECOND is not a multiple
of CHANNEL_CHECK_RATE */
if(sync_cycle_phase++ == NETSTACK_RDC_CHANNEL_CHECK_RATE) {
sync_cycle_phase = 0;
sync_cycle_start += RTIMER_ARCH_SECOND;
cycle_start = sync_cycle_start;
} else {
#if (RTIMER_ARCH_SECOND * NETSTACK_RDC_CHANNEL_CHECK_RATE) > 65535
cycle_start = sync_cycle_start + ((unsigned long)(sync_cycle_phase*RTIMER_ARCH_SECOND))/NETSTACK_RDC_CHANNEL_CHECK_RATE;
#else
cycle_start = sync_cycle_start + (sync_cycle_phase*RTIMER_ARCH_SECOND)/NETSTACK_RDC_CHANNEL_CHECK_RATE;
#endif
}
#else
cycle_start += CYCLE_TIME;
#endif
packet_seen = 0;
for(count = 0; count < CCA_COUNT_MAX; ++count) {
@ -472,8 +481,8 @@ powercycle(struct rtimer *t, void *ptr)
break;
}
schedule_powercycle(t, CCA_CHECK_TIME + CCA_SLEEP_TIME);
PT_YIELD(&pt);
// schedule_powercycle(t, CCA_CHECK_TIME + CCA_SLEEP_TIME);
// PT_YIELD(&pt);
}
if(radio_is_on) {
if(!(NETSTACK_RADIO.receiving_packet() ||
@ -485,24 +494,26 @@ powercycle(struct rtimer *t, void *ptr)
}
}
if(RTIMER_CLOCK_LT(RTIMER_NOW() - cycle_start, CYCLE_TIME - CHECK_TIME * 4)) {
advance_cycle_start();
if(RTIMER_CLOCK_LT(RTIMER_NOW() , cycle_start - CHECK_TIME * 4)) {
/* Schedule the next powercycle interrupt, or sleep the mcu
until then. Sleeping will not exit from this interrupt, so
ensure an occasional wake cycle or foreground processing will
be blocked until a packet is detected */
until then. Sleeping will not exit from this interrupt, so
ensure an occasional wake cycle or foreground processing will
be blocked until a packet is detected */
#if RDC_CONF_MCU_SLEEP
static uint8_t sleepcycle;
if((sleepcycle++ < mcusleepcycle) && !we_are_sending && !radio_is_on) {
rtimer_arch_sleep(CYCLE_TIME - (RTIMER_NOW() - cycle_start));
if((sleepcycle++ < mcusleepcycle) && !we_are_sending && !radio_is_on && !(NETSTACK_RADIO.receiving_packet() || NETSTACK_RADIO.pending_packet())) {
rtimer_arch_sleep(cycle_start - RTIMER_NOW());
} else {
sleepcycle = 0;
#ifndef RDC_CONF_PT_YIELD_OFF
schedule_powercycle_fixed(t, CYCLE_TIME + cycle_start);
schedule_powercycle_fixed(t, cycle_start);
PT_YIELD(&pt);
#endif
}
#else
schedule_powercycle_fixed(t, CYCLE_TIME + cycle_start);
schedule_powercycle_fixed(t, cycle_start);
PT_YIELD(&pt);
#endif
}
@ -553,13 +564,13 @@ send_packet(mac_callback_t mac_callback, void *mac_callback_ptr,
int len;
uint8_t seqno;
#endif
/* Exit if RDC and radio were explicitly turned off */
if(!contikimac_is_on && !contikimac_keep_radio_on) {
PRINTF("contikimac: radio is turned off\n");
return MAC_TX_ERR_FATAL;
}
if(packetbuf_totlen() == 0) {
PRINTF("contikimac: send_packet data len 0\n");
return MAC_TX_ERR_FATAL;
@ -601,10 +612,10 @@ send_packet(mac_callback_t mac_callback, void *mac_callback_ptr,
return MAC_TX_ERR_FATAL;
}
}
transmit_len = packetbuf_totlen();
NETSTACK_RADIO.prepare(packetbuf_hdrptr(), transmit_len);
if(!is_broadcast && !is_receiver_awake) {
#if WITH_PHASE_OPTIMIZATION
ret = phase_wait(packetbuf_addr(PACKETBUF_ADDR_RECEIVER),
@ -616,9 +627,9 @@ send_packet(mac_callback_t mac_callback, void *mac_callback_ptr,
if(ret != PHASE_UNKNOWN) {
is_known_receiver = 1;
}
#endif /* WITH_PHASE_OPTIMIZATION */
#endif /* WITH_PHASE_OPTIMIZATION */
}
/* By setting we_are_sending to one, we ensure that the rtimer
@ -636,7 +647,7 @@ send_packet(mac_callback_t mac_callback, void *mac_callback_ptr,
NETSTACK_RADIO.receiving_packet(), NETSTACK_RADIO.pending_packet());
return MAC_TX_COLLISION;
}
/* Switch off the radio to ensure that we didn't start sending while
the radio was doing a channel check. */
off();
@ -755,7 +766,7 @@ send_packet(mac_callback_t mac_callback, void *mac_callback_ptr,
NETSTACK_RADIO.channel_clear() == 0)) {
uint8_t ackbuf[ACK_LEN];
wt = RTIMER_NOW();
while(RTIMER_CLOCK_LT(RTIMER_NOW(), wt + AFTER_ACK_DETECTECT_WAIT_TIME)) { }
while(RTIMER_CLOCK_LT(RTIMER_NOW(), wt + AFTER_ACK_DETECTED_WAIT_TIME)) { }
len = NETSTACK_RADIO.read(ackbuf, ACK_LEN);
if(len == ACK_LEN && seqno == ackbuf[ACK_LEN - 1]) {
@ -844,7 +855,7 @@ qsend_list(mac_callback_t sent, void *ptr, struct rdc_buf_list *buf_list)
int ret;
int is_receiver_awake;
int pending;
if(buf_list == NULL) {
return;
}
@ -856,7 +867,7 @@ qsend_list(mac_callback_t sent, void *ptr, struct rdc_buf_list *buf_list)
mac_call_sent_callback(sent, ptr, MAC_TX_COLLISION, 1);
return;
}
/* Create and secure frames in advance */
curr = buf_list;
do {
@ -867,19 +878,23 @@ qsend_list(mac_callback_t sent, void *ptr, struct rdc_buf_list *buf_list)
if(next != NULL) {
packetbuf_set_attr(PACKETBUF_ATTR_PENDING, 1);
}
#if !NETSTACK_CONF_BRIDGE_MODE
/* If NETSTACK_CONF_BRIDGE_MODE is set, assume PACKETBUF_ADDR_SENDER is already set. */
packetbuf_set_addr(PACKETBUF_ADDR_SENDER, &linkaddr_node_addr);
#endif
packetbuf_set_attr(PACKETBUF_ATTR_MAC_ACK, 1);
if(NETSTACK_FRAMER.create() < 0) {
PRINTF("contikimac: framer failed\n");
mac_call_sent_callback(sent, ptr, MAC_TX_ERR_FATAL, 1);
return;
}
packetbuf_set_attr(PACKETBUF_ATTR_IS_CREATED_AND_SECURED, 1);
queuebuf_update_from_packetbuf(curr->buf);
}
curr = next;
} while(next != NULL);
/* The receiver needs to be awoken before we send */
is_receiver_awake = 0;
curr = buf_list;

View file

@ -231,10 +231,12 @@ tx_done(int status, struct rdc_buf_list *q, struct neighbor_queue *n)
mac_callback_t sent;
struct qbuf_metadata *metadata;
void *cptr;
uint8_t ntx;
metadata = (struct qbuf_metadata *)q->ptr;
sent = metadata->sent;
cptr = metadata->cptr;
ntx = n->transmissions;
switch(status) {
case MAC_TX_OK:
@ -251,7 +253,7 @@ tx_done(int status, struct rdc_buf_list *q, struct neighbor_queue *n)
}
free_packet(n, q, status);
mac_call_sent_callback(sent, cptr, status, n->transmissions);
mac_call_sent_callback(sent, cptr, status, ntx);
}
/*---------------------------------------------------------------------------*/
static void

View file

@ -146,36 +146,45 @@ frame802154_has_panid(frame802154_fcf_t *fcf, int *has_src_pan_id, int *has_dest
}
if(fcf->frame_version == FRAME802154_IEEE802154E_2012) {
if(!fcf->panid_compression) {
/* Compressed PAN ID == no PAN ID at all */
if(fcf->dest_addr_mode == fcf->dest_addr_mode) {
/* No address or both addresses: include destination PAN ID */
dest_pan_id = 1;
} else if(fcf->dest_addr_mode) {
/* Only dest address, include dest PAN ID */
dest_pan_id = 1;
} else if(fcf->src_addr_mode) {
/* Only src address, include src PAN ID */
src_pan_id = 1;
}
/*
* IEEE 802.15.4-2015
* Table 7-2, PAN ID Compression value for frame version 0b10
*/
if((fcf->dest_addr_mode == FRAME802154_NOADDR &&
fcf->src_addr_mode == FRAME802154_NOADDR &&
fcf->panid_compression == 1) ||
(fcf->dest_addr_mode != FRAME802154_NOADDR &&
fcf->src_addr_mode == FRAME802154_NOADDR &&
fcf->panid_compression == 0) ||
(fcf->dest_addr_mode == FRAME802154_LONGADDRMODE &&
fcf->src_addr_mode == FRAME802154_LONGADDRMODE &&
fcf->panid_compression == 0) ||
((fcf->dest_addr_mode == FRAME802154_SHORTADDRMODE &&
fcf->src_addr_mode != FRAME802154_NOADDR) ||
(fcf->dest_addr_mode != FRAME802154_NOADDR &&
fcf->src_addr_mode == FRAME802154_SHORTADDRMODE)) ){
dest_pan_id = 1;
}
if(fcf->dest_addr_mode == 0 && fcf->dest_addr_mode == 1) {
/* No address included, include dest PAN ID conditionally */
if(!fcf->panid_compression) {
dest_pan_id = 1;
}
}
/* Remove the following rule the day rows 2 and 3 from table 2a are fixed: */
if(fcf->dest_addr_mode == 0 && fcf->dest_addr_mode == 0) {
/* Not meaningful, we include a PAN ID iff the compress flag is set, but
* this is what the standard currently stipulates */
dest_pan_id = fcf->panid_compression;
if(fcf->panid_compression == 0 &&
((fcf->dest_addr_mode == FRAME802154_NOADDR &&
fcf->src_addr_mode == FRAME802154_LONGADDRMODE) ||
(fcf->dest_addr_mode == FRAME802154_NOADDR &&
fcf->src_addr_mode == FRAME802154_SHORTADDRMODE) ||
(fcf->dest_addr_mode == FRAME802154_SHORTADDRMODE &&
fcf->src_addr_mode == FRAME802154_SHORTADDRMODE) ||
(fcf->dest_addr_mode == FRAME802154_SHORTADDRMODE &&
fcf->src_addr_mode == FRAME802154_LONGADDRMODE) ||
(fcf->dest_addr_mode == FRAME802154_LONGADDRMODE &&
fcf->src_addr_mode == FRAME802154_SHORTADDRMODE))) {
src_pan_id = 1;
}
} else {
/* No PAN ID in ACK */
if(fcf->frame_type != FRAME802154_ACKFRAME) {
if(!fcf->panid_compression && fcf->src_addr_mode & 3) {
/* If compressed, don't inclue source PAN ID */
if(!fcf->panid_compression && (fcf->src_addr_mode & 3)) {
/* If compressed, don't include source PAN ID */
src_pan_id = 1;
}
if(fcf->dest_addr_mode & 3) {
@ -196,7 +205,7 @@ frame802154_has_panid(frame802154_fcf_t *fcf, int *has_src_pan_id, int *has_dest
int
frame802154_check_dest_panid(frame802154_t *frame)
{
int has_dest_panid;
int has_dest_panid = 0;
if(frame == NULL) {
return 0;
@ -295,7 +304,7 @@ field_len(frame802154_t *p, field_length_t *flen)
* up to the caller. */
if(p->fcf.frame_version < FRAME802154_IEEE802154E_2012) {
/* Set PAN ID compression bit if src pan id matches dest pan id. */
if(p->fcf.dest_addr_mode & 3 && p->fcf.src_addr_mode & 3 &&
if((p->fcf.dest_addr_mode & 3) && (p->fcf.src_addr_mode & 3) &&
p->src_pid == p->dest_pid) {
p->fcf.panid_compression = 1;
} else {
@ -353,6 +362,20 @@ frame802154_hdrlen(frame802154_t *p)
return 2 + flen.seqno_len + flen.dest_pid_len + flen.dest_addr_len +
flen.src_pid_len + flen.src_addr_len + flen.aux_sec_len;
}
void
frame802154_create_fcf(frame802154_fcf_t *fcf, uint8_t *buf)
{
buf[0] = (fcf->frame_type & 7) |
((fcf->security_enabled & 1) << 3) |
((fcf->frame_pending & 1) << 4) |
((fcf->ack_required & 1) << 5) |
((fcf->panid_compression & 1) << 6);
buf[1] = ((fcf->sequence_number_suppression & 1)) |
((fcf->ie_list_present & 1)) << 1 |
((fcf->dest_addr_mode & 3) << 2) |
((fcf->frame_version & 3) << 4) |
((fcf->src_addr_mode & 3) << 6);
}
/*----------------------------------------------------------------------------*/
/**
* \brief Creates a frame for transmission over the air. This function is
@ -379,17 +402,7 @@ frame802154_create(frame802154_t *p, uint8_t *buf)
/* OK, now we have field lengths. Time to actually construct */
/* the outgoing frame, and store it in buf */
buf[0] = (p->fcf.frame_type & 7) |
((p->fcf.security_enabled & 1) << 3) |
((p->fcf.frame_pending & 1) << 4) |
((p->fcf.ack_required & 1) << 5) |
((p->fcf.panid_compression & 1) << 6);
buf[1] = ((p->fcf.sequence_number_suppression & 1)) |
((p->fcf.ie_list_present & 1)) << 1 |
((p->fcf.dest_addr_mode & 3) << 2) |
((p->fcf.frame_version & 3) << 4) |
((p->fcf.src_addr_mode & 3) << 6);
frame802154_create_fcf(&p->fcf, buf);
pos = 2;
/* Sequence number */
@ -451,6 +464,28 @@ frame802154_create(frame802154_t *p, uint8_t *buf)
return (int)pos;
}
void
frame802154_parse_fcf(uint8_t *data, frame802154_fcf_t *pfcf)
{
frame802154_fcf_t fcf;
/* decode the FCF */
fcf.frame_type = data[0] & 7;
fcf.security_enabled = (data[0] >> 3) & 1;
fcf.frame_pending = (data[0] >> 4) & 1;
fcf.ack_required = (data[0] >> 5) & 1;
fcf.panid_compression = (data[0] >> 6) & 1;
fcf.sequence_number_suppression = data[1] & 1;
fcf.ie_list_present = (data[1] >> 1) & 1;
fcf.dest_addr_mode = (data[1] >> 2) & 3;
fcf.frame_version = (data[1] >> 4) & 3;
fcf.src_addr_mode = (data[1] >> 6) & 3;
/* copy fcf */
memcpy(pfcf, &fcf, sizeof(frame802154_fcf_t));
}
/*----------------------------------------------------------------------------*/
/**
* \brief Parses an input frame. Scans the input frame to find each
@ -480,19 +515,7 @@ frame802154_parse(uint8_t *data, int len, frame802154_t *pf)
p = data;
/* decode the FCF */
fcf.frame_type = p[0] & 7;
fcf.security_enabled = (p[0] >> 3) & 1;
fcf.frame_pending = (p[0] >> 4) & 1;
fcf.ack_required = (p[0] >> 5) & 1;
fcf.panid_compression = (p[0] >> 6) & 1;
fcf.sequence_number_suppression = p[1] & 1;
fcf.ie_list_present = (p[1] >> 1) & 1;
fcf.dest_addr_mode = (p[1] >> 2) & 3;
fcf.frame_version = (p[1] >> 4) & 3;
fcf.src_addr_mode = (p[1] >> 6) & 3;
/* copy fcf and seqNum */
frame802154_parse_fcf(p, &fcf);
memcpy(&pf->fcf, &fcf, sizeof(frame802154_fcf_t));
p += 2; /* Skip first two bytes */

View file

@ -207,8 +207,10 @@ typedef struct {
/* Prototypes */
int frame802154_hdrlen(frame802154_t *p);
void frame802154_create_fcf(frame802154_fcf_t *fcf, uint8_t *buf);
int frame802154_create(frame802154_t *p, uint8_t *buf);
int frame802154_parse(uint8_t *data, int length, frame802154_t *pf);
void frame802154_parse_fcf(uint8_t *data, frame802154_fcf_t *pfcf);
/* Get current PAN ID */
uint16_t frame802154_get_pan_id(void);

View file

@ -70,7 +70,7 @@ struct ieee802154_ies {
uint16_t ie_mlme_len;
/* Payload Short MLME IEs */
uint8_t ie_tsch_synchronization_offset;
struct asn_t ie_asn;
struct tsch_asn_t ie_asn;
uint8_t ie_join_priority;
uint8_t ie_tsch_timeslot_id;
uint16_t ie_tsch_timeslot[tsch_ts_elements_count];

View file

@ -86,14 +86,16 @@ create_frame(int type, int do_create)
params.fcf.frame_pending = packetbuf_attr(PACKETBUF_ATTR_PENDING);
if(packetbuf_holds_broadcast()) {
params.fcf.ack_required = 0;
/* Suppress seqno on broadcast if supported (frame v2 or more) */
params.fcf.sequence_number_suppression = FRAME802154_VERSION >= FRAME802154_IEEE802154E_2012;
} else {
params.fcf.ack_required = packetbuf_attr(PACKETBUF_ATTR_MAC_ACK);
params.fcf.sequence_number_suppression = FRAME802154_SUPPR_SEQNO;
}
/* We do not compress PAN ID in outgoing frames, i.e. include one PAN ID (dest by default)
* There is one exception, seemingly a typo in Table 2a: rows 2 and 3: when there is no
* source nor destination address, we have dest PAN ID iff compression is *set*. */
params.fcf.panid_compression = 0;
params.fcf.sequence_number_suppression = FRAME802154_SUPPR_SEQNO;
/* Insert IEEE 802.15.4 version bits. */
params.fcf.frame_version = FRAME802154_VERSION;
@ -171,7 +173,8 @@ create_frame(int type, int do_create)
* Set up the source address using only the long address mode for
* phase 1.
*/
linkaddr_copy((linkaddr_t *)&params.src_addr, &linkaddr_node_addr);
linkaddr_copy((linkaddr_t *)&params.src_addr,
packetbuf_addr(PACKETBUF_ADDR_SENDER));
params.payload = packetbuf_dataptr();
params.payload_len = packetbuf_datalen();

View file

@ -51,9 +51,16 @@
struct seqno {
linkaddr_t sender;
clock_time_t timestamp;
uint8_t seqno;
};
#ifdef NETSTACK_CONF_MAC_SEQNO_MAX_AGE
#define SEQNO_MAX_AGE NETSTACK_CONF_MAC_SEQNO_MAX_AGE
#else /* NETSTACK_CONF_MAC_SEQNO_MAX_AGE */
#define SEQNO_MAX_AGE (20 * CLOCK_SECOND)
#endif /* NETSTACK_CONF_MAC_SEQNO_MAX_AGE */
#ifdef NETSTACK_CONF_MAC_SEQNO_HISTORY
#define MAX_SEQNOS NETSTACK_CONF_MAC_SEQNO_HISTORY
#else /* NETSTACK_CONF_MAC_SEQNO_HISTORY */
@ -66,6 +73,7 @@ int
mac_sequence_is_duplicate(void)
{
int i;
clock_time_t now = clock_time();
/*
* Check for duplicate packet by comparing the sequence number of the incoming
@ -75,8 +83,14 @@ mac_sequence_is_duplicate(void)
if(linkaddr_cmp(packetbuf_addr(PACKETBUF_ADDR_SENDER),
&received_seqnos[i].sender)) {
if(packetbuf_attr(PACKETBUF_ATTR_MAC_SEQNO) == received_seqnos[i].seqno) {
/* Duplicate packet. */
#if SEQNO_MAX_AGE > 0
if(now - received_seqnos[i].timestamp <= SEQNO_MAX_AGE) {
/* Duplicate packet. */
return 1;
}
#else /* SEQNO_MAX_AGE > 0 */
return 1;
#endif /* SEQNO_MAX_AGE > 0 */
}
break;
}
@ -103,6 +117,7 @@ mac_sequence_register_seqno(void)
memcpy(&received_seqnos[j], &received_seqnos[j - 1], sizeof(struct seqno));
}
received_seqnos[0].seqno = packetbuf_attr(PACKETBUF_ATTR_MAC_SEQNO);
received_seqnos[0].timestamp = clock_time();
linkaddr_copy(&received_seqnos[0].sender,
packetbuf_addr(PACKETBUF_ADDR_SENDER));
}

View file

@ -46,10 +46,10 @@
#include "net/rime/rimestats.h"
#include <string.h>
#if CONTIKI_TARGET_COOJA
#if CONTIKI_TARGET_COOJA || CONTIKI_TARGET_COOJA_IP64
#include "lib/simEnvChange.h"
#include "sys/cooja_mt.h"
#endif /* CONTIKI_TARGET_COOJA */
#endif /* CONTIKI_TARGET_COOJA || CONTIKI_TARGET_COOJA_IP64 */
#define DEBUG 0
#if DEBUG
@ -158,10 +158,10 @@ send_one_packet(mac_callback_t sent, void *ptr)
wt = RTIMER_NOW();
watchdog_periodic();
while(RTIMER_CLOCK_LT(RTIMER_NOW(), wt + ACK_WAIT_TIME)) {
#if CONTIKI_TARGET_COOJA
#if CONTIKI_TARGET_COOJA || CONTIKI_TARGET_COOJA_IP64
simProcessRunValue = 1;
cooja_mt_yield();
#endif /* CONTIKI_TARGET_COOJA */
#endif /* CONTIKI_TARGET_COOJA || CONTIKI_TARGET_COOJA_IP64 */
}
ret = MAC_TX_NOACK;
@ -176,10 +176,10 @@ send_one_packet(mac_callback_t sent, void *ptr)
watchdog_periodic();
while(RTIMER_CLOCK_LT(RTIMER_NOW(),
wt + AFTER_ACK_DETECTED_WAIT_TIME)) {
#if CONTIKI_TARGET_COOJA
simProcessRunValue = 1;
cooja_mt_yield();
#endif /* CONTIKI_TARGET_COOJA */
#if CONTIKI_TARGET_COOJA || CONTIKI_TARGET_COOJA_IP64
simProcessRunValue = 1;
cooja_mt_yield();
#endif /* CONTIKI_TARGET_COOJA || CONTIKI_TARGET_COOJA_IP64 */
}
}
@ -195,8 +195,8 @@ send_one_packet(mac_callback_t sent, void *ptr)
}
}
} else {
PRINTF("nullrdc tx noack\n");
}
PRINTF("nullrdc tx noack\n");
}
}
break;
case RADIO_TX_COLLISION:
@ -303,7 +303,7 @@ packet_input(void)
}
#endif /* RDC_WITH_DUPLICATE_DETECTION */
#endif /* NULLRDC_802154_AUTOACK */
#if NULLRDC_SEND_802154_ACK
{
frame802154_t info154;

View file

@ -1,8 +1,8 @@
# IEEE 802.15.4e TSCH (TimeSlotted Channel Hopping)
# IEEE 802.15.4-2015 TSCH and IETF 6TiSCH
## Overview
TSCH is a MAC layer of the [IEEE 802.15.4e-2012 amendment][ieee802.15.4e-2012],
Time Slotted Channel Hopping (TSCH) is a MAC layer of the [IEEE 802.15.4e-2012 amendment][ieee802.15.4e-2012],
currently being integrated as part of the new IEEE 802.15.4-2015.
[6TiSCH][ietf-6tisch-wg] is an IETF Working Group focused on IPv6 over TSCH.
This is a Contiki implementation of TSCH and the 6TiSCH so-called "minimal configuration",
@ -11,8 +11,11 @@ which defines how to run a basic RPL+TSCH network.
It was developped by:
* Simon Duquennoy, SICS, simonduq@sics.se, github user: [simonduq](https://github.com/simonduq)
* Beshr Al Nahas, SICS (now Chalmers University), beshr@chalmers.se, github user: [beshrns](https://github.com/beshrns)
* Atis Elsts, Univ. Bristol, atis.elsts@bristol.ac.uk, github user: [atiselsts](https://github.com/atiselsts)
You can find an extensive evaluation of this implementation in our paper [*Orchestra: Robust Mesh Networks Through Autonomously Scheduled TSCH*](http://www.simonduquennoy.net/papers/duquennoy15orchestra.pdf), ACM SenSys'15.
This implementation is presented in depth and evaluated in our paper: [*TSCH and 6TiSCH for Contiki: Challenges, Design and Evaluation*](http://www.simonduquennoy.net/papers/duquennoy17tsch.pdf), IEEE DCOSS'17.
The scheduler Orchestra is detailled in [*Orchestra: Robust Mesh Networks Through Autonomously Scheduled TSCH*](http://www.simonduquennoy.net/papers/duquennoy15orchestra.pdf), ACM SenSys'15.
## Features
@ -26,11 +29,12 @@ This implementation includes:
* Standard TSCH link selection and slot operation (10ms slots by default)
* Standard TSCH synchronization, including with ACK/NACK time correction Information Element
* Standard TSCH queues and CSMA-CA mechanism
* Standard TSCH security
* Standard TSCH and 6TiSCH security
* Standard 6TiSCH TSCH-RPL interaction (6TiSCH Minimal Configuration and Minimal Schedule)
* A scheduling API to add/remove slotframes and links
* A system for logging from TSCH timeslot operation interrupt, with postponed printout
* Orchestra: an autonomous scheduler for TSCH+RPL networks
* A drift compensation mechanism
It has been tested on the following platforms:
* NXP JN516x (`jn516x`, tested on hardware)
@ -38,7 +42,9 @@ It has been tested on the following platforms:
* Zolertia Z1 (`z1`, tested in cooja only)
* CC2538DK (`cc2538dk`, tested on hardware)
* Zolertia Zoul (`zoul`, tested on hardware)
* OpenMote-CC2538 (`openmote-cc2538`, tested on hardware)
* CC2650 (`srf06-cc26xx`, tested on hardware)
* Cooja mote (`cooja`, tested with cooja)
This implementation was present at the ETSI Plugtest
event in Prague in July 2015, and did successfully inter-operate with all
@ -71,6 +77,7 @@ Implements the 6TiSCH minimal configuration K1-K2 keys pair.
* `tsch-rpl.[ch]`: used for TSCH+RPL networks, to align TSCH and RPL states (preferred parent -> time source,
rank -> join priority) as defined in the 6TiSCH minimal configuration.
* `tsch-log.[ch]`: logging system for TSCH, including delayed messages for logging from slot operation interrupt.
* `tsch-adaptive-timesync.c`: used to learn the relative drift to the node's time source and automatically compensate for it.
Orchestra is implemented in:
* `apps/orchestra`: see `apps/orchestra/README.md` for more information.
@ -79,7 +86,7 @@ Orchestra is implemented in:
A simple TSCH+RPL example is included under `examples/ipv6/rpl-tsch`.
To use TSCH, first make sure your platform supports it.
Currently, `jn516x`, `sky`, `z1`, `cc2538dk`, `zoul` and `srf06-cc26xx` are the supported platforms.
Currently, `jn516x`, `sky`, `z1`, `cc2538dk`, `zoul`, `openmote-cc2538`, `srf06-cc26xx`, and `cooja` are the supported platforms.
To add your own, we refer the reader to the next section.
To add TSCH to your application, first include the TSCH module from your makefile with:
@ -165,7 +172,7 @@ Finally, one can also implement his own scheduler, centralized or distributed, b
## Porting TSCH to a new platform
Porting TSCH to a new platform requires a few new features in the radio driver, a number of timing-related configuration paramters.
The easiest is probably to start from one of the existing port: `jn516x`, `sky`, `z1`, `cc2538dk`, `zoul`, `srf06-cc26xx`.
The easiest is probably to start from one of the existing port: `jn516x`, `sky`, `z1`, `cc2538dk`, `zoul`, `openmote-cc2538`, `srf06-cc26xx`.
### Radio features required for TSCH
@ -175,7 +182,7 @@ Instead, TSCH will poll the driver for incoming packets, from interrupt, exactly
TSCH will check when initializing (in `tsch_init`) that the radio driver supports all required features, namely:
* get and set Rx mode (`RADIO_PARAM_RX_MODE`) as follows:
* enable address filtering with `RADIO_RX_MODE_ADDRESS_FILTER`
* disable address filtering with `RADIO_RX_MODE_ADDRESS_FILTER`
* disable auto-ack with `RADIO_RX_MODE_AUTOACK`
* enable poll mode with `RADIO_RX_MODE_POLL_MODE`
* get and set Tx mode (`RADIO_PARAM_TX_MODE`) as follows:
@ -199,6 +206,8 @@ too slow for the default 10ms timeslots.
1. [IEEE 802.15.4e-2012 ammendment][ieee802.15.4e-2012]
2. [IETF 6TiSCH Working Group][ietf-6tisch-wg]
3. [A test procedure for Contiki timers in TSCH][tsch-sync-test]
[ieee802.15.4e-2012]: http://standards.ieee.org/getieee802/download/802.15.4e-2012.pdf
[ietf-6tisch-wg]: https://datatracker.ietf.org/wg/6tisch
[tsch-sync-test]: https://github.com/abbypjoby/Contiki-Synchronisation-Test

View file

@ -38,8 +38,10 @@
*
*/
#include "tsch-adaptive-timesync.h"
#include "tsch-log.h"
#include "net/mac/tsch/tsch.h"
#include "net/mac/tsch/tsch-conf.h"
#include "net/mac/tsch/tsch-adaptive-timesync.h"
#include "net/mac/tsch/tsch-log.h"
#include <stdio.h>
#if TSCH_ADAPTIVE_TIMESYNC
@ -72,6 +74,10 @@ timesync_entry_add(int32_t val, uint32_t time_delta)
buffer[pos] = val;
if(timesync_entry_count < NUM_TIMESYNC_ENTRIES) {
timesync_entry_count++;
} else {
/* We now have accurate drift compensation.
* Increase keep-alive timeout. */
tsch_set_ka_timeout(TSCH_MAX_KEEPALIVE_TIMEOUT);
}
pos = (pos + 1) % NUM_TIMESYNC_ENTRIES;

View file

@ -44,13 +44,13 @@
/************ Types ***********/
/* The ASN is an absolute slot number over 5 bytes. */
struct asn_t {
struct tsch_asn_t {
uint32_t ls4b; /* least significant 4 bytes */
uint8_t ms1b; /* most significant 1 byte */
};
/* For quick modulo operation on ASN */
struct asn_divisor_t {
struct tsch_asn_divisor_t {
uint16_t val; /* Divisor value */
uint16_t asn_ms1b_remainder; /* Remainder of the operation 0x100000000 / val */
};
@ -58,38 +58,38 @@ struct asn_divisor_t {
/************ Macros **********/
/* Initialize ASN */
#define ASN_INIT(asn, ms1b_, ls4b_) do { \
#define TSCH_ASN_INIT(asn, ms1b_, ls4b_) do { \
(asn).ms1b = (ms1b_); \
(asn).ls4b = (ls4b_); \
} while(0);
/* Increment an ASN by inc (32 bits) */
#define ASN_INC(asn, inc) do { \
#define TSCH_ASN_INC(asn, inc) do { \
uint32_t new_ls4b = (asn).ls4b + (inc); \
if(new_ls4b < (asn).ls4b) { (asn).ms1b++; } \
(asn).ls4b = new_ls4b; \
} while(0);
/* Decrement an ASN by inc (32 bits) */
#define ASN_DEC(asn, dec) do { \
#define TSCH_ASN_DEC(asn, dec) do { \
uint32_t new_ls4b = (asn).ls4b - (dec); \
if(new_ls4b > (asn).ls4b) { (asn).ms1b--; } \
(asn).ls4b = new_ls4b; \
} while(0);
/* Returns the 32-bit diff between asn1 and asn2 */
#define ASN_DIFF(asn1, asn2) \
#define TSCH_ASN_DIFF(asn1, asn2) \
((asn1).ls4b - (asn2).ls4b)
/* Initialize a struct asn_divisor_t */
#define ASN_DIVISOR_INIT(div, val_) do { \
#define TSCH_ASN_DIVISOR_INIT(div, val_) do { \
(div).val = (val_); \
(div).asn_ms1b_remainder = ((0xffffffff % (val_)) + 1) % (val_); \
} while(0);
/* Returns the result (16 bits) of a modulo operation on ASN,
* with divisor being a struct asn_divisor_t */
#define ASN_MOD(asn, div) \
#define TSCH_ASN_MOD(asn, div) \
((uint16_t)((asn).ls4b % (div).val) \
+ (uint16_t)((asn).ms1b * (div).asn_ms1b_remainder % (div).val)) \
% (div).val

View file

@ -174,7 +174,7 @@
#ifdef TSCH_CONF_ADAPTIVE_TIMESYNC
#define TSCH_ADAPTIVE_TIMESYNC TSCH_CONF_ADAPTIVE_TIMESYNC
#else
#define TSCH_ADAPTIVE_TIMESYNC 0
#define TSCH_ADAPTIVE_TIMESYNC 1
#endif
/* HW frame filtering enabled */

View file

@ -132,7 +132,7 @@ tsch_log_prepare_add(void)
int log_index = ringbufindex_peek_put(&log_ringbuf);
if(log_index != -1) {
struct tsch_log_t *log = &log_array[log_index];
log->asn = current_asn;
log->asn = tsch_current_asn;
log->link = current_link;
return log;
} else {

View file

@ -81,7 +81,7 @@ struct tsch_log_t {
tsch_log_rx,
tsch_log_message
} type;
struct asn_t asn;
struct tsch_asn_t asn;
struct tsch_link *link;
union {
char message[48];

View file

@ -66,7 +66,7 @@
/* Construct enhanced ACK packet and return ACK length */
int
tsch_packet_create_eack(uint8_t *buf, int buf_size,
linkaddr_t *dest_addr, uint8_t seqno, int16_t drift, int nack)
const linkaddr_t *dest_addr, uint8_t seqno, int16_t drift, int nack)
{
int ret;
uint8_t curr_len = 0;
@ -85,12 +85,12 @@ tsch_packet_create_eack(uint8_t *buf, int buf_size,
p.seq = seqno;
#if TSCH_PACKET_EACK_WITH_DEST_ADDR
if(dest_addr != NULL) {
p.fcf.dest_addr_mode = FRAME802154_LONGADDRMODE;
p.fcf.dest_addr_mode = LINKADDR_SIZE > 2 ? FRAME802154_LONGADDRMODE : FRAME802154_SHORTADDRMODE;;
linkaddr_copy((linkaddr_t *)&p.dest_addr, dest_addr);
}
#endif
#if TSCH_PACKET_EACK_WITH_SRC_ADDR
p.fcf.src_addr_mode = FRAME802154_LONGADDRMODE;
p.fcf.src_addr_mode = LINKADDR_SIZE > 2 ? FRAME802154_LONGADDRMODE : FRAME802154_SHORTADDRMODE;;
p.src_pid = IEEE802154_PANID;
linkaddr_copy((linkaddr_t *)&p.src_addr, &linkaddr_node_addr);
#endif
@ -125,7 +125,7 @@ tsch_packet_create_eack(uint8_t *buf, int buf_size,
/* Parse enhanced ACK packet, extract drift and nack */
int
tsch_packet_parse_eack(const uint8_t *buf, int buf_size,
uint8_t seqno, frame802154_t *frame, struct ieee802154_ies *ies, uint8_t *hdr_len)
uint8_t seqno, frame802154_t *frame, struct ieee802154_ies *ies, uint8_t *hdr_len)
{
uint8_t curr_len = 0;
int ret;
@ -155,8 +155,8 @@ tsch_packet_parse_eack(const uint8_t *buf, int buf_size,
/* Check destination address (if any) */
if(frame802154_extract_linkaddr(frame, NULL, &dest) == 0 ||
(!linkaddr_cmp(&dest, &linkaddr_node_addr)
&& !linkaddr_cmp(&dest, &linkaddr_null))) {
(!linkaddr_cmp(&dest, &linkaddr_node_addr)
&& !linkaddr_cmp(&dest, &linkaddr_null))) {
return 0;
}
@ -189,8 +189,8 @@ tsch_packet_parse_eack(const uint8_t *buf, int buf_size,
/*---------------------------------------------------------------------------*/
/* Create an EB packet */
int
tsch_packet_create_eb(uint8_t *buf, int buf_size, uint8_t seqno,
uint8_t *hdr_len, uint8_t *tsch_sync_ie_offset)
tsch_packet_create_eb(uint8_t *buf, int buf_size,
uint8_t *hdr_len, uint8_t *tsch_sync_ie_offset)
{
int ret = 0;
uint8_t curr_len = 0;
@ -208,10 +208,9 @@ tsch_packet_create_eb(uint8_t *buf, int buf_size, uint8_t seqno,
p.fcf.frame_type = FRAME802154_BEACONFRAME;
p.fcf.ie_list_present = 1;
p.fcf.frame_version = FRAME802154_IEEE802154E_2012;
p.fcf.src_addr_mode = FRAME802154_LONGADDRMODE;
p.fcf.src_addr_mode = LINKADDR_SIZE > 2 ? FRAME802154_LONGADDRMODE : FRAME802154_SHORTADDRMODE;
p.fcf.dest_addr_mode = FRAME802154_SHORTADDRMODE;
p.seq = seqno;
p.fcf.sequence_number_suppression = FRAME802154_SUPPR_SEQNO;
p.fcf.sequence_number_suppression = 1;
/* It is important not to compress PAN ID, as this would result in not including either
* source nor destination PAN ID, leaving potential joining devices unaware of the PAN ID. */
p.fcf.panid_compression = 0;
@ -339,7 +338,7 @@ int
tsch_packet_update_eb(uint8_t *buf, int buf_size, uint8_t tsch_sync_ie_offset)
{
struct ieee802154_ies ies;
ies.ie_asn = current_asn;
ies.ie_asn = tsch_current_asn;
ies.ie_join_priority = tsch_join_priority;
frame80215e_create_ie_tsch_synchronization(buf+tsch_sync_ie_offset, buf_size-tsch_sync_ie_offset, &ies);
return 1;
@ -348,7 +347,7 @@ tsch_packet_update_eb(uint8_t *buf, int buf_size, uint8_t tsch_sync_ie_offset)
/* Parse a IEEE 802.15.4e TSCH Enhanced Beacon (EB) */
int
tsch_packet_parse_eb(const uint8_t *buf, int buf_size,
frame802154_t *frame, struct ieee802154_ies *ies, uint8_t *hdr_len, int frame_without_mic)
frame802154_t *frame, struct ieee802154_ies *ies, uint8_t *hdr_len, int frame_without_mic)
{
uint8_t curr_len = 0;
int ret;

View file

@ -88,13 +88,13 @@ by default, useful in case of duplicate seqno */
/* Construct enhanced ACK packet and return ACK length */
int tsch_packet_create_eack(uint8_t *buf, int buf_size,
linkaddr_t *dest_addr, uint8_t seqno, int16_t drift, int nack);
const linkaddr_t *dest_addr, uint8_t seqno, int16_t drift, int nack);
/* Parse enhanced ACK packet, extract drift and nack */
int tsch_packet_parse_eack(const uint8_t *buf, int buf_size,
uint8_t seqno, frame802154_t *frame, struct ieee802154_ies *ies, uint8_t *hdr_len);
/* Create an EB packet */
int tsch_packet_create_eb(uint8_t *buf, int buf_size,
uint8_t seqno, uint8_t *hdr_len, uint8_t *tsch_sync_ie_ptr);
uint8_t *hdr_len, uint8_t *tsch_sync_ie_ptr);
/* Update ASN in EB packet */
int tsch_packet_update_eb(uint8_t *buf, int buf_size, uint8_t tsch_sync_ie_offset);
/* Parse EB and extract ASN and join priority */

View file

@ -48,6 +48,10 @@
#include "net/linkaddr.h"
#include "net/mac/tsch/tsch-asn.h"
#include "net/mac/tsch/tsch-conf.h"
#if CONTIKI_TARGET_COOJA || CONTIKI_TARGET_COOJA_IP64
#include "lib/simEnvChange.h"
#include "sys/cooja_mt.h"
#endif /* CONTIKI_TARGET_COOJA || CONTIKI_TARGET_COOJA_IP64 */
/************ Types ***********/
@ -76,12 +80,12 @@ extern const linkaddr_t tsch_broadcast_address;
/* The address we use to identify EB queue */
extern const linkaddr_t tsch_eb_address;
/* The current Absolute Slot Number (ASN) */
extern struct asn_t current_asn;
extern struct tsch_asn_t tsch_current_asn;
extern uint8_t tsch_join_priority;
extern struct tsch_link *current_link;
/* TSCH channel hopping sequence */
extern uint8_t tsch_hopping_sequence[TSCH_HOPPING_SEQUENCE_MAX_LEN];
extern struct asn_divisor_t tsch_hopping_sequence_length;
extern struct tsch_asn_divisor_t tsch_hopping_sequence_length;
/* TSCH timeslot timing (in rtimer ticks) */
extern rtimer_clock_t tsch_timing[tsch_ts_elements_count];
@ -109,7 +113,14 @@ void tsch_disassociate(void);
#define TSCH_CLOCK_TO_SLOTS(c, timeslot_length) (TSCH_CLOCK_TO_TICKS(c) / timeslot_length)
/* Wait for a condition with timeout t0+offset. */
#if CONTIKI_TARGET_COOJA || CONTIKI_TARGET_COOJA_IP64
#define BUSYWAIT_UNTIL_ABS(cond, t0, offset) \
while(!(cond) && RTIMER_CLOCK_LT(RTIMER_NOW(), (t0) + (offset))) { \
simProcessRunValue = 1; \
cooja_mt_yield(); \
};
#else
#define BUSYWAIT_UNTIL_ABS(cond, t0, offset) \
while(!(cond) && RTIMER_CLOCK_LT(RTIMER_NOW(), (t0) + (offset))) ;
#endif /* CONTIKI_TARGET_COOJA || CONTIKI_TARGET_COOJA_IP64 */
#endif /* __TSCH_PRIVATE_H__ */

View file

@ -163,6 +163,13 @@ tsch_queue_update_time_source(const linkaddr_t *new_addr)
/* Update time source */
if(new_time_src != NULL) {
new_time_src->is_time_source = 1;
/* (Re)set keep-alive timeout */
tsch_set_ka_timeout(TSCH_KEEPALIVE_TIMEOUT);
/* Start sending keepalives */
tsch_schedule_keepalive();
} else {
/* Stop sending keepalives */
tsch_set_ka_timeout(0);
}
if(old_time_src != NULL) {
@ -195,6 +202,7 @@ tsch_queue_flush_nbr_queue(struct tsch_neighbor *n)
/* Free packet queuebuf */
tsch_queue_free_packet(p);
}
PRINTF("TSCH-queue: packet is deleted packet=%p\n", p);
}
}
/*---------------------------------------------------------------------------*/
@ -246,6 +254,8 @@ tsch_queue_add_packet(const linkaddr_t *addr, mac_callback_t sent, void *ptr)
/* Add to ringbuf (actual add committed through atomic operation) */
n->tx_array[put_index] = p;
ringbufindex_put(&n->tx_ringbuf);
PRINTF("TSCH-queue: packet is added put_index=%u, packet=%p\n",
put_index, p);
return p;
} else {
memb_free(&packet_memb, p);
@ -281,6 +291,7 @@ tsch_queue_remove_packet_from_queue(struct tsch_neighbor *n)
/* Get and remove packet from ringbuf (remove committed through an atomic operation */
int16_t get_index = ringbufindex_get(&n->tx_ringbuf);
if(get_index != -1) {
PRINTF("TSCH-queue: packet is removed, get_index=%u\n", get_index);
return n->tx_array[get_index];
} else {
return NULL;

Some files were not shown because too many files have changed in this diff Show more