Browse Source

Initialized repository. Anonymized Files.

master
PHENOM 10 months ago
commit
33cd05cb5c

+ 64
- 0
.gitignore View File

@@ -0,0 +1,64 @@
# Prerequisites
*.d

# Object files
*.o
*.ko
*.obj
*.elf

# Linker output
*.ilk
*.map
*.exp

# Precompiled Headers
*.gch
*.pch

# Libraries
*.lib
*.a
*.la
*.lo

# Shared objects (inc. Windows DLLs)
*.dll
*.so
*.so.*
*.dylib

# Executables
*.exe
*.out
*.app
*.i*86
*.x86_64
*.hex

# Debug files
*.dSYM/
*.su
*.idb
*.pdb

# Kernel Module Compile Results
*.mod*
*.cmd
.tmp_versions/
modules.order
Module.symvers
Mkfile.old
dkms.conf

#Custom directories
.vs/
**/.settings/
**/obj_cc2530dk/

#Custom files
*.cc2530dk
*.lk
*.mem
*.directory
*.banks

+ 38
- 0
AT_Commands.md View File

@@ -0,0 +1,38 @@
# AT Commandset

### General

| Command | Parameters | Description | Result |
| ------- | ---------- | -------------------------------------------- | ------ |
| AT | - | Returns "OK" for testing communication | OK |
| AT+RST | - | Resets the device | OK |
| AT+HELP | - | Prints a help-page of all available commands | OK |

### IEEE 802.15.4 Radio settings

| Command | Parameters | Range | Description | Result |
| -------- | ---------- | ---------- | ------------------------------------------------------------ | ------------------- |
| AT+TXPWR | [TX_POWER] | 5 to 28 | Sets or shows the current TX_Power. | [TX_POWER]<br />OK |
| AT+CH | [CHANNEL] | 11 to 26 | Sets or shows the current RF channel. | [CHANNEL]<br />OK |
| AT+PID | [PAN_ID] | 0 to 65535 | Sets or shows the current pan_id. | [PAN_ID]<br />OK |
| AT+RSSI | - | - | Returns the current received signal strength indicator (RSSI) | {RSSI}<br />OK/FAIL |

### Operation Commands

| Command | Parameters | Range | Description | Result |
| ------- | ------------------------------------- | ----------------------------------------------- | ------------------------------- | ------- |
| AT+SEND | [IPV6_ADRESS]<br />[PORT]<br />[DATA] | IPV6_ADRESS<br />0 to 65535<br />256 bytes long | Sends UDP Data to a destination | OK/FAIL |

Note: When using the AT+SEND command. It will always send data to the first address and port destination. Needs to be revised, also whitespaces act as parameter when providing data. It will also create a Socket which listens on this connection and should output received data.

### IPv6 Commands

| Command | Parameters | Range | Description | Result |
| -------- | ---------- | ----- | -------------------------- | ------- |
| AT+LOCIP | - | - | Shows the local unicast IP | OK/FAIL |

### Debugging (Only available if AT_DEBUG=1 is defined in project-conf.h)

| Command | Parameters | Range | Description | Result |
| ------- | ---------- | ----------------- | ----------------------- | ------- |
| AT+TEST | [ANYTHING] | Max. 8 parameters | Returns every Parameter | OK/FAIL |

+ 21
- 0
LICENSE View File

@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2018 Steven B., Tobias K.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

+ 42
- 0
Notes.md View File

@@ -0,0 +1,42 @@
### Contiki get Started:



##### Using Contiki OS for development (We're using version 3.0, since 2.6 doesn't have compatibility for the CC2531 USB drivers and 2.7 has a bug that crashes the controller when utilizing IPv6)

1. Get the [latest Contiki Image](https://sourceforge.net/projects/contiki/files/Instant%20Contiki/)
2. [Get Started](http://contiki-os.org/start.html)
3. [Contiki CC2531 example](https://github.com/contiki-os/contiki/blob/master/examples/cc2530dk/cc2531-usb-demo/cc2531-usb-demo.c)

#### Resources

1. [How to flash with Contiki-2.7](https://stackoverflow.com/questions/20277203/contiki-and-cc2531-usb-dongle)
2. [CC2531 Dongle and Contiki](https://e2e.ti.com/support/wireless_connectivity/zigbee_6lowpan_802-15-4_mac/f/158/t/214272?CC2531-USB-Dongle-and-Contiki)
3. [Contiki Documentation](http://contiki.sourceforge.net/docs/2.6/index.html)
4. [Registerdefinitions for CC253x used on Contiki](http://contiki.sourceforge.net/docs/2.6/a00693_source.html)
5. [CC253x User's Guide](http://www.ti.com/lit/ug/swru191f/swru191f.pdf)
6. [How to build the 8051 SDCC Toolchain manually](https://github.com/contiki-os/contiki/wiki/8051-Requirements)
7. [Contiki Network Stack](https://anrg.usc.edu/contiki/index.php/Network_Stack)
8. [Contiki RPL UDP](http://anrg.usc.edu/contiki/index.php/RPL_UDP)

#### Important files to look into (Contiki OS 3.0)

**Main configuration**

- core/contiki-default-conf.h - Default configuration that get's loaded in Contiki
- platform/cc2530dk/contiki-conf.h - Platform specific configuration that get's loaded in Contiki

**Networking**

- core/net/netstack.h - The networking stack interface of Contiki
- core/net/dev/radio.h - Low-level radio interface for Contiki
- core/net/ip/uip.h - Basic IP communication in Contiki
- cpu/cc253x/dev/cc2530-rf.h - Low-level radio driver for the platform

**USB Communication**

- platform/cc2530dk/usb-serial.h - The serial USB Driver for the platform

**Platform-specific**

- platform/cc2530dk/contiki-main.c - Initialization routines for the platform (Setting up drivers, etc.)

BIN
Presentation.pdf View File


+ 326
- 0
README.md View File

@@ -0,0 +1,326 @@
# CC2531 Serial->USB AT-Command Terminal with 6LoWPAN Connectivity

## Goal of this project

The goal is to implement an AT-Command-set styled (See [Hayes command set](https://en.wikipedia.org/wiki/Hayes_command_set)) Firmware on the Texas Instruments [CC2531 USB Evaluation Module Kit](http://www.ti.com/tool/cc2531emk). The built-in USB interface should be recognized as an USB<-> Serial Converter Chip and AT-Commands can then be send via an serial terminal connection. The CC2531 should act as a Node in an 6LoWPAN Network connected to different Nodes and to an EDGE-Router to the Internet like shown below.

![6LoWPAN Network](http://processors.wiki.ti.com/images/8/8c/20979_6LowPan_mesh.jpg)

## Prerequisites

You need the following Soft- and Hardware in order to use this project.

###### Software

- [VirtualBox](https://www.virtualbox.org) - An x86/ AMD64 Virtualization Software
- The [Instant Contiki OS Image Version 2.7](https://sourceforge.net/projects/contiki/files/Instant%20Contiki/Instant%20Contiki%202.7/InstantContiki2.7.zip/download) - Used as development base for this project
- [Texas Instruments SmartRF-Flash Programmer](http://www.ti.com/tool/flash-programmer) (**Requires Registration**) - Software used to flash firmware onto the CC2531 chip

###### Hardware

- [Texas Instruments CC2531 USB Evaluation Module Kit](http://www.ti.com/tool/cc2531emk) - The USB Evaluation Kit

- [CC-Debugger](http://www.ti.com/tool/CC-DEBUGGER) - Programmer and Debugger Hardware

## Building Process

[Contiki OS 2.7](http://contiki-os.org) is being used as an embedded operating System running on the CC2531 System-on-Chip. In order to build this project you need to:

1. Download the [Instant Contiki OS Image Version 2.7](https://sourceforge.net/projects/contiki/files/Instant%20Contiki/Instant%20Contiki%202.7/InstantContiki2.7.zip/download)
2. Unpack the Files
3. Mount the Disk Image in VirtualBox or VMWare Player and setup an shared folder for sharing files between Host and Guest Machine
4. Start the Virtual Machine
5. Log-In with with the password user

*You can also Reefer to [here](http://contiki-os.org/start.html) for these steps*

6. Execute `sudo nano /etc/environment` in an Terminal and add these two lines at the end and replace

- `<ABSOLUTE_CONTIKI_PATH>` with the absolute path where the contiki folder is located, **without / slash at the end.** Example: `CONTIKI_PATH="/home/user/contiki"`
- `<ABSOLUTE_SDCC_PATH>` with the absolute path where the sdcc folder is located, **without / slash at the end.** Example: `SDCC_PATH="/usr/local/share/sdcc"`

```bash
CONTIKI_PATH="<ABSOLUTE_CONTIKI_PATH>"
SDCC_PATH="<ABSOLUTE_SDCC_PATH>"
```

7. Logoff and Login again

8. Open up a Terminal and enter

```bash
git clone https://github.com/BlkPingu/zigPAN
cd ./zigPAN/src
make
```

After finishing the `make` command you should have an .hex file in the ./src folder that you can move to your shared folder and then flash onto the CC2531 Chip.


## Building the 8051 SDCC Toolchain manually

This guide lists the packages required before you can build/use Contiki's 8051-based ports.

Information on this page has been tested on Ubuntu and on Mac OS X. Things should work on Cygwin but may require some tweaking.

This guide is a clone of the [guide on GitHub](https://github.com/g-oikonomou/contiki-sensinode/wiki/Prepare-your-System guide on GitHub). In cases where you see conflicting information, this page here wins.

### Required Software

Make sure you have the following installed:

* gcc
* g++
* flex
* bison
* [Boost C++ Libraries](http://www.boost.org/ ) (package libboost-graph-dev in the ubuntu archive)
* Python**2** (Note: Python3 will not work with banked builds)
* [srecord](http://srecord.sourceforge.net/)

### OS X specific

* If you want to run border routers on Mac OS X, you will also need [TunTap](http://tuntaposx.sourceforge.net/)
* Do yourself a favour and start by installing [homebrew](http://mxcl.github.com/homebrew/) if you don't have it.
* You should be able to `brew install srecord`. At the time of writing, this command would result in boost getting installed as well so two birds with one stone.
* If you want to build srecord from source, you may need to install [GNU libtool](http://www.gnu.org/software/libtool/). An easy way to do it is via homebrew.

This is what happens if you try to compile srecord with the Apple libtool:

```bash
make
libtool --mode=compile --tag=CXX g++ \
-g -O2 -I. -c srec_cat/arglex3.cc -o \
srec_cat/arglex3.lo
libtool: unknown option character `-' in: --mode=compile
Usage: libtool -static [-] file [...][-filelist listfile[,dirname]] [-arch_only arch][-sacLT]
Usage: libtool -dynamic [-] file [...][-filelist listfile[,dirname]] [-arch_only arch][-o output]
[-install_name name][-compatibility_version #] [-current_version #][-seg1addr 0x#] [-segs_read_only_addr 0x#]
[-segs_read_write_addr 0x#][-seg_addr_table ] [-seg_addr_table_filename <file_system_path>]
[-all_load][-noall_load]
make: *** [srec_cat/arglex3.lo] Error 1
```

Try this:

```bash
libtool -V
Apple Inc. version cctools-822
```

If you install GNU libtool via homebrew, it will be prefixed with a 'g':

```bash
glibtool --version
libtool (GNU libtool) 2.4.2
Written by Gordon Matzigkeit gord@gnu.ai.mit.edu, 1996

Copyright (C) 2011 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
```

Change srecord's build system to use glibtool instead of libtool and you are sorted.

* Homebrew is also an easy way to install libboost

```bash
brew install boost
```


### Build your Toolchain (SDCC)

In order to compile contiki, you need a version of the SDCC compiler. Unfortunately, the binary packages don't contain all the libraries we need so you will have to compile SDCC from sources.

Before anything else, make sure you don't have a pre-installed version from the Ubuntu archive!

SDCC supports various device types. You can compile it with support for all of them or only some. The port of interest to us is the mcs51. Disabling all other ports will make the compile considerably faster.

`Recent Tested SDCC revisions: 9092`

* Download a recommended revision from the SDCC svn (replace [rev] with one of the numbers above):

```bash
svn co -r [rev] svn://svn.code.sf.net/p/sdcc/code/trunk/sdcc
```

SDCC revisions between 7102 and 8719 suffer from a [bug](http://sourceforge.net/p/sdcc/bugs/1986/) and can't build banked firmware. Make sure you are not using one of those revisions. If you are getting the error below, this is most probably the cause and you need to rebuild SDCC:

```bash
srec_cat -disable_sequence_warnings border-router.banked-hex -intel -crop 0x18000 0x1FFFF -offset -65536 -o bank1.hex -intel
srec_cat -disable_sequence_warnings border-router.banked-hex -intel -crop 0x28000 0x2FFFF -offset -98304 -o bank2.hex -intel
srec_cat -disable_sequence_warnings border-router.banked-hex -intel -crop 0x38000 0x3FFFF -offset -131072 -o bank3.hex -intel
srec_cat -disable_sequence_warnings border-router.banked-hex -intel -crop 0x48000 0x4FFFF -offset -163840 -o bank4.hex -intel
srec_cat -disable_sequence_warnings border-router.banked-hex -intel -crop 0x00000 0x07FFF -o home.ihx -intel
srec_cat home.ihx -intel bank1.hex -intel bank2.hex -intel bank3.hex -intel bank4.hex -intel -o border-router.hex -intel
srec_cat: bank1.hex: 1: file contains no data
make: *** [border-router.hex] Error 1
rm border-router.flags border-router.banked-hex
obj_cc2530dk/border-router.app.rel
```

* cd into the extracted directory. This will be called `sdcc`

* Now you need to hack sdcc's build system a bit, in order to get correct library versions.

- Edit `device/lib/incl.mk`. We need model-huge and model-large libraries. To instruct the build system to build model-huge libraries, find this line:
`MODELS = small medium large`
Add `huge`. You may remove `small` and `medium` if you only use SDCC for contiki, but make sure you keep `large`. So your new line may end up looking like this
`MODELS = small large huge`

- Edit `device/lib/Makefile.in`. Find this line:
`TARGETS += models small-mcs51-stack-auto`
Replace it with this
`TARGETS += models model-mcs51-stack-auto`

* Run this:

```bash
./configure --disable-werror --disable-gbz80-port --disable-z80-port --disable-ds390-port --disable-ds400-port --disable-pic14-port --disable-pic16-port --disable-hc08-port --disable-r2k-port --disable-z180-port --disable-sdcdb --disable-ucsim
```

- If you don't have root access you will probably want to change the installation directory. You can do that with the `--prefix=dir` option of the `./configure` stage.
- If you get any errors about missing packages, fix them.

* `make`

* `make install` as root or with sudo

You now have a working compiler and libraries. The SDCC executable might be outside the PATH, depending where you installed it. Try running `sdcc -v` and see if it's in the PATH. If not, add it. If SDCC is in the PATH and you have compiled excluding unused ports, `sdcc -v` will show you something like this:

`SDCC : mcs51 3.4.1 #9092 (Oct 22 2014) (Mac OS X x86_64)`

The list of supported ports appears after the : and before the version number. If you build everything this message will be a lot longer.



## First attempt by using the Sensinode SDCC Banked Tool-Chain and [Free-RTOS](https://www.freertos.org)

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

### Prerequisites

What things you need to install the software and how to install them

```
Give examples
```

### Installing

#### Linux Requirements

Requirements:

● gcc, glibc, make, tar, textutils, grep, find

● sdcc version 2.7.0 or later with large-stack-auto library and banking

SDCC package from Sensinode (with banking support). Does not work for applications larger than 64 kb of ROM.

● minicom (or other serial port terminal program)

● rpm for microcontroller tool installation

● doxygen for rebuilding NanoStack references

● a USB port + FTDI USB drivers (part of the standard Linux kernel)



The distribution package names depend on your distribution.

A binary install requires only the serial interface from the above mentioned list and in addition to that it

requires rpm in Fedora Core (or other rpm based) systems.

The installation of the nRouted daemon requires root privileges. It is possible to install the nRouted not as

a system daemon that is started automatically when the system starts but rather as an ordinary program. In

such case the process does not require root privileges but it still requires that the user must have access to

the serial device (e.g. /dev/ttyUSB0).

#### Linux Installation

The PC software CD contains the NanoStack tools packaged for selected Linux distributions. Supported

distributions are Fedora Core 4 and later.

In Fedora Core the tool binaries are installed by issuing the command:

`cd <CD-ROM root>`

`cd toolchains/linux/rpm`

`rpm -Uvh *.rpm`

This installs the SDCC compiler and libraries. Try that SDCC works by typing sdcc and then asx8051 on

the command line. You may need to make sybolic links to sdcc on some systems if the NanoStack makefile

can not find sdcc or asx8051. These are created like:

`su -`

`cd /usr/bin/`

`ln -s sdcc-sdcc sdcc`

`ln -s sdcc-asx8051 asx8051`

To install NanoStack the source package is extracted from the CD to a directory where the user has

permissions to create new files and subdirectories. Then the Makefile should be able to handle the rest. For

example:

Copy the NanoStack directory from the CD-ROM to your working directory.

`cd <working directory>`

`cp -R /<CD-ROM path>/NanoStack/NanoStack-v1.0.3/ .`

`You can now test that NanoStack builds properly like this:`

`cd <working directory>/NanoStack-v1.0.3/Examples/nano_skeleton`

`make`

You should see the build process complete without errors and a nano_skeleton.hex file appear in the same

directory.



A step by step series of examples that tell you have to get a development env running

Say what the step will be

```
Give the example
```

And repeat

```
until finished
```

End with an example of getting some data out of the system or using it for a little demo

## Authors

* **Tobias K.**
* **Steven B.**

## License

This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details

## Acknowledgments

* https://github.com/g-oikonomou/contiki-sensinode
* https://github.com/mitshell/CC2531


+ 109
- 0
src/.cproject View File

@@ -0,0 +1,109 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
<storageModule moduleId="org.eclipse.cdt.core.settings">
<cconfiguration id="0.1993509435">
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="0.1993509435" moduleId="org.eclipse.cdt.core.settings" name="Default">
<externalSettings/>
<extensions>
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.VCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
</extensions>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<configuration artifactName="${ProjName}" buildProperties="" description="" id="0.1993509435" name="Default" parent="org.eclipse.cdt.build.core.prefbase.cfg">
<folderInfo id="0.1993509435." name="/" resourcePath="">
<toolChain id="org.eclipse.cdt.build.core.prefbase.toolchain.613996399" name="No ToolChain" resourceTypeBasedDiscovery="false" superClass="org.eclipse.cdt.build.core.prefbase.toolchain">
<targetPlatform id="org.eclipse.cdt.build.core.prefbase.toolchain.613996399.1183782779" name=""/>
<builder id="org.eclipse.cdt.build.core.settings.default.builder.1853435714" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="Gnu Make Builder" superClass="org.eclipse.cdt.build.core.settings.default.builder">
<outputEntries>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="outputPath" name=""/>
</outputEntries>
</builder>
<tool id="org.eclipse.cdt.build.core.settings.holder.libs.1195013986" name="holder for library settings" superClass="org.eclipse.cdt.build.core.settings.holder.libs"/>
<tool id="org.eclipse.cdt.build.core.settings.holder.1870949263" name="Assembly" superClass="org.eclipse.cdt.build.core.settings.holder">
<option id="org.eclipse.cdt.build.core.settings.holder.symbols.1083721850" name="Symbols" superClass="org.eclipse.cdt.build.core.settings.holder.symbols"/>
<option id="org.eclipse.cdt.build.core.settings.holder.incpaths.1060602575" name="Include Paths" superClass="org.eclipse.cdt.build.core.settings.holder.incpaths" valueType="includePath"/>
<inputType id="org.eclipse.cdt.build.core.settings.holder.inType.1160432783" languageId="org.eclipse.cdt.core.assembly" languageName="Assembly" sourceContentType="org.eclipse.cdt.core.asmSource" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>
</tool>
<tool id="org.eclipse.cdt.build.core.settings.holder.247176761" name="GNU C++" superClass="org.eclipse.cdt.build.core.settings.holder">
<option id="org.eclipse.cdt.build.core.settings.holder.symbols.2076525826" name="Symbols" superClass="org.eclipse.cdt.build.core.settings.holder.symbols" valueType="definedSymbols">
<listOptionValue builtIn="false" value="MODELS_CONF_CC2531_USB_STICK=1"/>
<listOptionValue builtIn="false" value="HAVE_BANKING=1"/>
<listOptionValue builtIn="false" value="NETSTACK_CONF_RADIO=cc2530_rf_driver"/>
<listOptionValue builtIn="false" value="NETSTACK_CONF_FRAMER=framer_802154"/>
<listOptionValue builtIn="false" value="NETSTACK_CONF_NETWORK=sicslowpan_driver"/>
<listOptionValue builtIn="false" value="UIP_CONF_IPV6=1"/>
<listOptionValue builtIn="false" value="DEBUG=1"/>
<listOptionValue builtIn="false" value="UIP_CONF_RPL=1"/>
<listOptionValue builtIn="false" value="NETSTACK_CONF_RDC=nullrdc_driver"/>
<listOptionValue builtIn="false" value="NETSTACK_CONF_MAC=csma_driver"/>
<listOptionValue builtIn="false" value="AT_DEBUG"/>
</option>
<option id="org.eclipse.cdt.build.core.settings.holder.incpaths.2119391488" name="Include Paths" superClass="org.eclipse.cdt.build.core.settings.holder.incpaths" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${env_var:CONTIKI_PATH}/core&quot;"/>
<listOptionValue builtIn="false" value="&quot;${env_var:SDCC_PATH}/include&quot;"/>
<listOptionValue builtIn="false" value="&quot;${env_var:CONTIKI_PATH}/cpu/cc253x&quot;"/>
<listOptionValue builtIn="false" value="&quot;${env_var:CONTIKI_PATH}/platform/cc2530dk&quot;"/>
</option>
<inputType id="org.eclipse.cdt.build.core.settings.holder.inType.1221678185" languageId="org.eclipse.cdt.core.g++" languageName="GNU C++" sourceContentType="org.eclipse.cdt.core.cxxSource,org.eclipse.cdt.core.cxxHeader" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>
</tool>
<tool id="org.eclipse.cdt.build.core.settings.holder.1561825531" name="GNU C" superClass="org.eclipse.cdt.build.core.settings.holder">
<option id="org.eclipse.cdt.build.core.settings.holder.incpaths.2115466619" name="Include Paths" superClass="org.eclipse.cdt.build.core.settings.holder.incpaths" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${env_var:CONTIKI_PATH}/core&quot;"/>
<listOptionValue builtIn="false" value="&quot;${env_var:SDCC_PATH}/include&quot;"/>
<listOptionValue builtIn="false" value="&quot;${env_var:CONTIKI_PATH}/cpu/cc253x&quot;"/>
<listOptionValue builtIn="false" value="&quot;${env_var:CONTIKI_PATH}/platform/cc2530dk&quot;"/>
</option>
<option id="org.eclipse.cdt.build.core.settings.holder.symbols.111507244" name="Symbols" superClass="org.eclipse.cdt.build.core.settings.holder.symbols" valueType="definedSymbols">
<listOptionValue builtIn="false" value="MODELS_CONF_CC2531_USB_STICK=1"/>
<listOptionValue builtIn="false" value="HAVE_BANKING=1"/>
<listOptionValue builtIn="false" value="NETSTACK_CONF_RADIO=cc2530_rf_driver"/>
<listOptionValue builtIn="false" value="NETSTACK_CONF_FRAMER=framer_802154"/>
<listOptionValue builtIn="false" value="NETSTACK_CONF_NETWORK=sicslowpan_driver"/>
<listOptionValue builtIn="false" value="UIP_CONF_IPV6=1"/>
<listOptionValue builtIn="false" value="DEBUG=1"/>
<listOptionValue builtIn="false" value="UIP_CONF_RPL=1"/>
<listOptionValue builtIn="false" value="NETSTACK_CONF_RDC=nullrdc_driver"/>
<listOptionValue builtIn="false" value="NETSTACK_CONF_MAC=csma_driver"/>
<listOptionValue builtIn="false" value="AT_DEBUG"/>
</option>
<inputType id="org.eclipse.cdt.build.core.settings.holder.inType.1203978506" languageId="org.eclipse.cdt.core.gcc" languageName="GNU C" sourceContentType="org.eclipse.cdt.core.cSource,org.eclipse.cdt.core.cHeader" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>
</tool>
</toolChain>
</folderInfo>
</configuration>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
</cconfiguration>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<project id="CC2531 AT Command Terminal.null.1594911976" name="CC2531 AT Command Terminal"/>
</storageModule>
<storageModule moduleId="scannerConfiguration">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
<scannerConfigBuildInfo instanceId="0.1993509435">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
</scannerConfigBuildInfo>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
<storageModule moduleId="refreshScope" versionNumber="2">
<configuration configurationName="Default">
<resource resourceType="PROJECT" workspacePath="/CC2531 AT Command Terminal"/>
</configuration>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.make.core.buildtargets"/>
<storageModule moduleId="org.eclipse.cdt.internal.ui.text.commentOwnerProjectMappings">
<doc-comment-owner id="org.eclipse.cdt.ui.doxygen">
<path value=""/>
</doc-comment-owner>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.language.mapping">
<project-mappings>
<file-mapping configuration="0.1993509435" language="org.eclipse.cdt.core.gcc" path="obj_cc2530dk/atCommand.h"/>
</project-mappings>
</storageModule>
</cproject>

+ 27
- 0
src/.project View File

@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>CC2531 AT Command Terminal</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
<triggers>clean,full,incremental,</triggers>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
<triggers>full,incremental,</triggers>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.cdt.core.cnature</nature>
<nature>org.eclipse.cdt.core.ccnature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
</natures>
</projectDescription>

+ 10
- 0
src/Makefile View File

@@ -0,0 +1,10 @@
CONTIKI =${CONTIKI_PATH}
CONTIKI_PROJECT = cc2531-6lowpan-at-terminal
PROJECTDIRS += at at/executors
PROJECT_SOURCEFILES += at.c help.c reset.c test.c rssi.c txpwr.c ch.c pid.c send.c locip.c
DEFINES+= PROJECT_CONF_H=\"project-conf.h\"
all: $(CONTIKI_PROJECT)



include $(CONTIKI)/Makefile.include

+ 1
- 0
src/Makefile.target View File

@@ -0,0 +1 @@
TARGET = cc2530dk

+ 174
- 0
src/at/at.c View File

@@ -0,0 +1,174 @@
/*
* at.c
*
* Created on: 10.06.2018
* Author: steven
*/

#include <stdint.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include <stdio.h>

#include "contiki.h"
#include "debug.h"
#include "executors/executors.h"
#include "at.h"

uint8_t op_mode= 0;
char* AT_DELIMITER = "+ ";
char* AT_OK = "OK\n";
char* AT_FAIL = "FAI\nL";
char* AT = "AT";

PROCESS(at_process, "at_process");
extern process_event_t serial_line_event_message;
process_event_t serial_non_at_event_message;

//AT Command registry
at_command commands[]= {
#ifdef AT_DEBUG
{
"TEST",
"Paramter test",
&test_exec
},
#endif
{
"RST",
"Resets the device",
&reset_exec
},
{
"RSSI",
"Returns the current Radio signal strength indicator (RSSI)",
&rssi_exec

},
{
"TXPWR",
"[POWER(-28 TO 5)]Returns or sets the TXPower",
&txpwr_exec
},
{
"PID",
"[PID(0-65535)] Returns or sets the PAN_ID",
&pid_exec
},
{
"CH",
"[CHANNEL(11-26)] Returns or sets the Channel",
&ch_exec
},
{
"SEND",
"Sends UDP packet data to an IPv6 address",
&send_exec
},
{
"LOCIP",
"Shows you the current local unicast IP",
&locip_exec
},
{
"HELP",
"Prints out this help",
&help_exec
},
{
NULL
}
};

at_command* fetch_command(char *string) {
uint8_t i;
for(i=0;i<(sizeof(commands)/sizeof(at_command));i++) {
if(strcmp(string,commands[i].cmd_name)==0) {
return &commands[i];
}
}
return NULL;
}

at_command* get_commands() {
return commands;
}

bool is_at(char* string) {
if (strncmp(string, AT, strlen(AT)) == 0) {
return true;
}
return false;
}

void fetch_parameters(char *token, char** parameters) {
uint8_t param_count=0;

while (token!=NULL && param_count < MAX_PARAM_COUNT) {
parameters[param_count]=(char *)malloc(strlen(token) +1);
parameters[param_count]=token;
token=strtok(NULL, AT_DELIMITER);
param_count++;
}
parameters[param_count]=NULL;
}

bool parse_at(char* string) {
char *command_name=NULL;
char *parameters[MAX_PARAM_COUNT];
uint8_t i=0;
at_command* at_command_struc;

//Check if first 2 letters start with AT
if (is_at(string)) {

//Parse command name and parameters
char *token = strtok(string+strlen(AT), AT_DELIMITER);
command_name=token;
token=strtok(NULL, AT_DELIMITER); //Artificial push to remove the name
fetch_parameters(token, parameters);

//Is AT+?
if(command_name!=NULL) {

//Check through the AT_Command registry
at_command_struc = fetch_command(command_name);
if(at_command_struc!=NULL) {
if(at_command_struc->executor(parameters)) {
printf(AT_OK);
}
else{
printf(AT_FAIL);
}
return true;
}

//Not a valid AT Command
printf("\"%s\" is not a valid AT-Command", command_name);
return true;
}
else{
//AT only is a test command
printf(AT_OK);
return true;
}
}
return false;
}

//Main AT Command process
PROCESS_THREAD(at_process, ev, data) {
PROCESS_BEGIN();
serial_non_at_event_message = process_alloc_event(); //Allocate new global event to the process manager
while (1) {
PROCESS_WAIT_EVENT();
if (ev == serial_line_event_message) {
if(!(parse_at((char *) data))) {
//Pass through serial_line_event_message if non-at-command was received via serial_non_at_event_message
process_post(PROCESS_BROADCAST, serial_non_at_event_message, data);
}
}
}
PROCESS_END();
}

+ 35
- 0
src/at/at.h View File

@@ -0,0 +1,35 @@

/*
* at.h
*
* Created on: 10.06.2018
* Author: steven
*/

#ifndef ATPARSER_H_
#define ATPARSER_H_

#include <stdbool.h>
#include "contiki.h"

#define MAX_PARAM_COUNT 8
#define AT_TYPE_NULL 0
#define AT_TYPE_INT 1
#define AT_TYPE_STRING 2
#define AT_TYPE_IPV6 3

extern process_event_t serial_non_at_event_message; //Used for passing thru non-at commands to other processes
extern char* AT_OK;
extern char* AT;

typedef struct {
char* cmd_name;
char* description;
bool (*executor)(char **);
} at_command;

at_command* get_commands();

PROCESS_NAME(at_process); //Process handle

#endif /* ATPARSER_H_ */

+ 36
- 0
src/at/executors/ch.c View File

@@ -0,0 +1,36 @@
/*
* ch.c
*
* Created on: 24.06.2018
* Author: steven
*/


#include <stdbool.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

#include "executors.h"
#include "../at.h"
#include "debug.h"
#include "net/netstack.h"
#include "dev/radio.h"

bool ch_exec (char ** parameters) {
radio_value_t channel;
if(parameters[0] != NULL) {
channel = atoi(parameters[0]);
if(NETSTACK_RADIO.set_value(RADIO_PARAM_CHANNEL, channel) == RADIO_RESULT_OK) {
printf("Set Channel to: %d\n", channel);
return true;
}
}
else{
if(NETSTACK_RADIO.get_value(RADIO_PARAM_CHANNEL, &channel)==RADIO_RESULT_OK) {
printf("%d\n", channel);
return true;
}
}
return false;
}

+ 23
- 0
src/at/executors/executors.h View File

@@ -0,0 +1,23 @@
/*
* executor.h
*
* Created on: 12.06.2018
* Author: steven
*/

#ifndef AT_EXECUTORS_EXECUTORS_H_
#define AT_EXECUTORS_EXECUTORS_H_
#include <stdbool.h>
#include <string.h>

bool help_exec(char ** parameters);
bool reset_exec(char ** parameters);
bool test_exec(char ** parameters);
bool rssi_exec(char ** parameters);
bool txpwr_exec(char ** parameters);
bool pid_exec (char ** parameters);
bool ch_exec (char ** parameters);
bool send_exec (char ** parameters);
bool locip_exec (char ** parameters);

#endif /* AT_EXECUTORS_EXECUTORS_H_ */

+ 28
- 0
src/at/executors/help.c View File

@@ -0,0 +1,28 @@
/*
* help.c
*
* Created on: 12.06.2018
* Author: steven
*/

#include <stdbool.h>
#include <string.h>
#include <stdio.h>

#include "executors.h"
#include "../at.h"
#include "debug.h"
#include "net/netstack.h"
bool help_exec(char ** parameters) {
uint8_t i=0;
at_command* commands;

printf("AT command help:\n");
commands=get_commands();

while(commands[i].cmd_name!=NULL) {
printf("%s+%s: %s \n", AT, commands[i].cmd_name, commands[i].description);
i++;
}
return true;
}

+ 43
- 0
src/at/executors/locip.c View File

@@ -0,0 +1,43 @@
/*
* send.c
*
* Created on: 27.06.2018
* Author: steven
*/
#include <stdbool.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
#include <string.h>

#include "executors.h"
#include "../at.h"
#include "debug.h"
#include "net/ip/uip-debug.h"
#include "net/ip/uip.h"
#include "net/ipv6/uip-ds6.h"
#include <contiki-net.h>

uip_ds6_addr_t *local_ip_addr;
uip_ip6addr_t addr;

//Retrieves Local Unicast Link address
bool locip_exec (char ** parameters) {

//Add Unicast IP for testing
#ifdef AT_DEBUG
if(strcmp(parameters[0], "1")==0) {
uip_ip6addr(&addr, 0x1111,0x2222,0x3333,0x4444,0x5555,0x6666,0x7777,0x8888);
uip_ds6_addr_add(&addr, 0, ADDR_MANUAL);
printf("Added IP: 1111:2222:3333:4444:5555:x6666:x7777:8888");
}
#endif
local_ip_addr = uip_ds6_get_link_local(ADDR_PREFERRED);
if(local_ip_addr!=NULL) {
uip_debug_ipaddr_print(&local_ip_addr->ipaddr);
putchar('\n');
return true;
}
return false;
return true;
}

+ 33
- 0
src/at/executors/pid.c View File

@@ -0,0 +1,33 @@
/*
* pid.c
*
* Created on: 24.06.2018
* Author: steven
*/
#include <stdbool.h>
#include <stdlib.h>
#include <stdio.h>

#include "executors.h"
#include "../at.h"
#include "debug.h"
#include "net/netstack.h"
#include "dev/radio.h"

bool pid_exec (char ** parameters) {
radio_value_t pan_id;
if(parameters[0] != NULL) {
pan_id = atoi(parameters[0]);
if(NETSTACK_RADIO.set_value(RADIO_PARAM_PAN_ID, pan_id) == RADIO_RESULT_OK) {
printf("Set PAN_ID to: 0x%X\n", pan_id);
return true;
}
}
else{
if(NETSTACK_RADIO.get_value(RADIO_PARAM_PAN_ID, &pan_id)==RADIO_RESULT_OK) {
printf("0x%X\n", pan_id);
return true;
}
}
return false;
}

+ 21
- 0
src/at/executors/reset.c View File

@@ -0,0 +1,21 @@
/*
* reset.c
*
* Created on: 12.06.2018
* Author: steven
*/

#include <stdbool.h>
#include <string.h>
#include <stdio.h>

#include "../at.h"
#include "debug.h"
#include "executors.h"
#include "dev/watchdog.h"

bool reset_exec(char ** parameters) {
printf(AT_OK);
watchdog_reboot();
return true; //Never reached anyway
}

+ 22
- 0
src/at/executors/rssi.c View File

@@ -0,0 +1,22 @@
#include <stdbool.h>
#include <string.h>

#include "executors.h"
#include "../at.h"
#include "debug.h"
#include "net/netstack.h"
#include "dev/radio.h"

bool rssi_exec(char ** parameters) {
radio_value_t val;
if(NETSTACK_RADIO.get_value(RADIO_PARAM_POWER_MODE, &val)==RADIO_RESULT_OK) {
if(val==RADIO_POWER_MODE_ON) {
if(NETSTACK_RADIO.get_value(RADIO_PARAM_RSSI, &val)==RADIO_RESULT_OK) {
putdec(val);
putchar('\n');
return true;
}
}
}
return false;
}

+ 111
- 0
src/at/executors/send.c View File

@@ -0,0 +1,111 @@
/*
* send.c
*
* Created on: 24.06.2018
* Author: steven
*/
#include <stdbool.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
#include <string.h>

#include "executors.h"
#include "../at.h"
#include "debug.h"
#include "net/ip/uip-debug.h"
#include "net/ip/uip.h"
#include "net/ipv6/uip-ds6.h"
#include <contiki-net.h>

bool udp_connection_active=false;
struct simple_udp_connection udp_connection;
uip_ip6addr_t target_ip;

uint16_t convertHexStrToWord(char* string) {
uint16_t retval=0;
uint8_t byte=0;
while(*string) {
byte = *string++;

if(byte >= 'a' && byte<= 'f') byte= byte - 'a' + 10;
else if(byte >= 'A' && byte<= 'F') byte= byte - 'A' + 10;
else if(byte >= '0' && byte<= '9') byte= byte - '0';
retval = (retval << 4) | (byte & 0xF);
}

return retval;
}

void parseIPv6String(char * string) {
uint8_t i=1;
uint16_t octets[8];

char * token = strtok(string, ":");
octets[0]=convertHexStrToWord(token); //First token call

for(i=1;i<8 && token!=NULL;i++) {
token = strtok(NULL, ":");
octets[i]=convertHexStrToWord(token);
}

uip_ip6addr(&target_ip, octets[0], octets[1], octets[2], octets[3], octets[4], octets[5], octets[6], octets[7]);
}

void udp_callback(struct simple_udp_connection *c,const uip_ipaddr_t *source_addr,uint16_t source_port,const uip_ipaddr_t *dest_addr,uint16_t dest_port,const uint8_t *data, uint16_t datalen) {
uint16_t i=0;
printf("Received UDP Data:\n");
printf("Source IP: ");
uip_debug_ipaddr_print(source_addr);
putchar('\n');
printf("Source Port: %hu\n", source_port);
printf("Destination IP: ");
uip_debug_ipaddr_print(dest_addr);
putchar('\n');
printf("Destination Port: %hu\n", dest_port);
printf("Data Length: %hu byte(s)\n", datalen);
printf("Data Contents: ");
for(i=0;i<datalen;i++) {
putchar(data[i]);
}
printf("\nEnd of Data\n");
}

bool send_exec (char ** parameters) {
uint16_t i=0;
uint16_t localPort=atoi(parameters[1]);
uint16_t destPort=atoi(parameters[2]);
parseIPv6String(parameters[0]);

//Register new connection if first called
if(!udp_connection_active) {
if(simple_udp_register(&udp_connection, localPort, NULL , destPort, &udp_callback)) {
//Register success
#ifdef AT_DEBUG
printf("UDP_Register OK!\n");
#endif
udp_connection_active=true;
}
else{
//On Register fail
#ifdef AT_DEBUG
printf("UDP_Register Fail!\n");
#endif
return false;
}
}
#ifdef AT_DEBUG
else{
printf("UDP_Connection already set up and ready for transfer.\n");
}
#endif

//Send data
simple_udp_sendto(&udp_connection, parameters[3], strlen(parameters[3]) + 1, &target_ip);
#ifdef AT_DEBUG
printf("Sent \"%s\" with size %zu to ", parameters[3], strlen(parameters[3]) + 1);
uip_debug_ipaddr_print(&target_ip);
printf(" to Port %hu from Port %hu\n", localPort, destPort);
#endif
return true;
}

+ 71
- 0
src/at/executors/sendTCP(unsupported).c View File

@@ -0,0 +1,71 @@
/*
* send.c
*
* Created on: 24.06.2018
* Author: steven
*/


#include <stdbool.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>

#include "executors.h"
#include "../at.h"
#include "debug.h"

#include <contiki-net.h>

#define INPUT_DATABUF_LEN 256
#define OUTPUT_DATABUF_LEN 256

struct tcp_socket tcp_sock;

uint8_t* input_databuffer;
uint8_t* output_databuffer;
uip_ip6addr_t test_ip;

int data_callback(struct tcp_socket *s, void *ptr,const uint8_t *input_data_ptr, int input_data_len) {
printf("Data Callback!\n");
//Print Received Data
return 0;
}

void event_callback(struct tcp_socket *s, void *ptr, tcp_socket_event_t event) {
printf("Event Callback!\n");
//Print Event
}

bool send_exec (char ** parameters) {
//MALLOC! Needs freeing
input_databuffer = (uint8_t*) malloc(INPUT_DATABUF_LEN * (sizeof(uint8_t)));
output_databuffer = (uint8_t*) malloc(OUTPUT_DATABUF_LEN * (sizeof(uint8_t)));


uip_ip6addr(&test_ip, 0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF);

if(tcp_socket_register(&tcp_sock, NULL, input_databuffer, INPUT_DATABUF_LEN, output_databuffer, OUTPUT_DATABUF_LEN, &data_callback, &event_callback)==1) {
printf("Socket Register ok\n");
if(tcp_socket_connect(&tcp_sock, &test_ip, 80)==1) {
printf("Socket Connect ok\n");
if(tcp_socket_send(&tcp_sock, "Hello World!", 13)!=-1) {
printf("Socket Send ok\n");
return true;
}
else{
printf("Socket Send failure\n");
}
}
else {
printf("Socket Connect failure\n");
}
}
else{
printf("Socket couldn't get registered!\n");
return false;
}
printf("Unregistering Socket\n");
tcp_socket_unregister(&tcp_sock);
return false;
}

+ 27
- 0
src/at/executors/test.c View File

@@ -0,0 +1,27 @@
/*
* test.c
*
* Created on: 12.06.2018
* Author: steven
*/

#include <stdbool.h>
#include <stdint.h>
#include <string.h>
#include <stdio.h>

#include "../at.h"
#include "debug.h"
#include "executors.h"

bool test_exec(char ** parameters) {
uint8_t i=0;
putstring("Executor Params:\n");
while(parameters[i]!=NULL) {
putdec(i);
putstring(": ");
printf(parameters[i]);
i++;
}
return true;
}

+ 60
- 0
src/at/executors/txpwr.c View File

@@ -0,0 +1,60 @@
/*
* txpwr.c
*
* Created on: 12.06.2018
* Author: steven
*/

/**
* Allowed TX_Power states
static const output_config_t output_power[] = {
{ 5, 0xF5 }, // 4.5
{ 3, 0xE5 }, // 2.5
{ 1, 0xD5 },
{ 0, 0xC5 }, // -0.5
{ -1, 0xB5 }, // -1.5
{ -3, 0xA5 },
{ -4, 0x95 },
{ -6, 0x85 },
{ -8, 0x75 },
{-10, 0x65 },
{-12, 0x55 },
{-14, 0x45 },
{-16, 0x35 },
{-18, 0x25 },
{-20, 0x15 },
{-22, 0x05 },
{-28, 0x05 }, // TXCTRL must be set to 0x09
};
**/

#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

#include "../at.h"
#include "debug.h"
#include "executors.h"

#include "net/netstack.h"

bool txpwr_exec(char ** parameters) {
radio_value_t txpower;
if (parameters[0] != NULL) {
txpower = atoi(parameters[0]);
if (NETSTACK_RADIO.set_value(RADIO_PARAM_TXPOWER, txpower)
== RADIO_RESULT_OK) {
printf("Set TXPOWER to: %d\n", txpower);
return true;
}
}
else{
if(NETSTACK_RADIO.get_value(RADIO_PARAM_TXPOWER, &txpower)==RADIO_RESULT_OK) {
printf("%d\n", txpower);
return true;
}
}
return false;
}

+ 40
- 0
src/cc2531-6lowpan-at-terminal.c View File

@@ -0,0 +1,40 @@
/**
* \file
* An AT-style serial terminal to connect to 6LoWPAN networks
* See at/at.h for commands
* \author
* Tobias K.
* Steven B.
*/
//Process for doing something. In this case blinking LEDs and outputting non-at-commands.
//The main AT_Process is happening via at/at_process.c

#include <stdio.h>

#include "contiki.h"
#include "dev/leds.h"
#include "debug.h"
#include "at/at.h"

static struct etimer et;
extern process_event_t serial_non_at_event_message;

PROCESS(cc2531_6lowpan_at_terminal_process, "cc2531 AT Terminal");
AUTOSTART_PROCESSES(&cc2531_6lowpan_at_terminal_process, &at_process); // @suppress("Unused variable declaration in file scope")

PROCESS_THREAD(cc2531_6lowpan_at_terminal_process, ev, data) {
PROCESS_BEGIN();

etimer_set(&et, CLOCK_SECOND/4);

while (1) {
PROCESS_WAIT_EVENT();
if (ev == PROCESS_EVENT_TIMER) {
leds_blink();
etimer_reset(&et);
} else if (ev == serial_non_at_event_message) {
printf("Received non AT-Command: %s\n", data);
}
}
PROCESS_END();
}

+ 13
- 0
src/project-conf.h View File

@@ -0,0 +1,13 @@
/*
* contiki-conf.h
*
* Created on: 24.06.2018
* Author: steven
*/
#define MODELS_CONF_CC2531_USB_STICK 1 //We use the USB Variant of the CC2530
#define AT_DEBUG 1 //Used for debugging the AT Driver
#define IEEE802154_CONF_PANID 0xDEAD //Sets the 16 bit PAN_ID
#define CC2530_RF_CONF_CHANNEL 25 //Sets the RF Channel
#define NETSTACK_CONF_WITH_IPV6 1 //#Set's the Netstack to use the IPv6 driver
#define CC2531_CONF_B2_REBOOTS 1 //Reboot the processor when B2 is pressed
#define SERIAL_LINE_CONF_BUFSIZE 256 //Provide a slightly bigger Serial Buffer, since there are some issues with an 128 byte buffer

Loading…
Cancel
Save