Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Xbee 802.15.4 modem driver for Arduino #1463

Closed
wants to merge 1 commit into from
Closed

Xbee 802.15.4 modem driver for Arduino #1463

wants to merge 1 commit into from

Conversation

rousselk
Copy link
Contributor

This radio driver allows to use an XBee 802.15.4 modem with an Arduino board, using the official Arduino Wireless/SD shield (see http://arduino.cc/en/Main/ArduinoWirelessShield) for connection.

@haukepetersen
Copy link
Contributor

nice! I am just wondering: why are you not using the low-level uart driver for this? That would make the board specific part completely obsolete...

@rousselk
Copy link
Contributor Author

By "low-level UART driver", do you mean the 'sys/uart0' module?

@thomaseichinger
Copy link
Member

@rousselk I think @haukepetersen was thinking about using the drivers/include/periph/uart.h interface.

@rousselk
Copy link
Contributor Author

@thomaseichinger I didn't knew about this file...
@haukepetersen Well, it may indeed be interesting, but we will still need a board-specific part, since there are some controls for the XBee modem beyond the UART. The most important (for me at least) is the sleep control that can only be made in an asynchronous and precise manner via a separate pin (SLEEP_RQ). Since this pin is not soldered by default on the official Arduino shield, but can be soldered to any digital pin of the Arduino (with a strap), one need to be able to change this configuration...
There is also two optional /CTS and /RTS lines available for serial link regulation, as well as GPIO lines (both digital and analogic), that we can't use with drivers/periph/uart.h. My driver don't support them for now, but maybe will we find a use for them in the future...

@haukepetersen
Copy link
Contributor

@rousselk What you describe is exactly the use-case for the low-level drivers - they were created so that you do not need to have any board specific parts in any high-level driver.

Say your boards needs an UART and one additional GPIO pin for the sleep line. The driver should then be based on the UART driver as in drivers/include/periph/uart.h and also on the GPIO driver as in drivers/include/periph/gpio.h. The initialization function for the xbee driver could then look like

int xbee_init(xbee_t *xbee_dev_descr, uart_t uart, gpio_t sleep_pin);

The init function can then initialize the peripherals as it needs them - and most importantly: the driver is usable for all boards implementing the low-level drivers.

@mehlis
Copy link
Contributor

mehlis commented Jul 27, 2014

we need the abstraction here, without the abstraction this driver is not a RIOT driver....its more a Ardunio driver.

@haukepetersen
Copy link
Contributor

@mehlis What do you mean with abstraction? I would say using the RIOT low-level driver is all the abstraction we need?!

@rousselk
Copy link
Contributor Author

Well, then: here's a version using UART and GPIO drivers.
@haukepetersen I think @mehlis was speaking about the abstration given by these low-level drivers...

/*****************************************************************************/

/* UART used to communicate with XBee */
static uart_t xbee_uart_link;
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you can throw out this variable and use XBEE_UART_LINK instead throughout the driver.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it's a leftover of a previous version that I forgot to delete.

@haukepetersen
Copy link
Contributor

looks good. Should you maybe export the drivers public functions in the xbee.h file?

@rousselk
Copy link
Contributor Author

Should you maybe export the drivers public functions in the xbee.h file?

Wouldn't it be redundant with the xbee_radio_driver driver definition?

@haukepetersen
Copy link
Contributor

Sorry, you're completely right, I overlooked that one.

@rousselk
Copy link
Contributor Author

Rebased on master, and squashed into an unique commit.

.channel_is_clear = xbee_channel_clear,
.set_promiscuous_mode = xbee_set_monitor,
.in_promiscuous_mode = xbee_get_monitor
};
Copy link
Member

Choose a reason for hiding this comment

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

This is illegal in C++, as far as I know. Use parameter-less initialisation instead.

Copy link
Contributor

Choose a reason for hiding this comment

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

No need to enforce C++ rules in .c files.

Copy link
Member

Choose a reason for hiding this comment

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

Even if this gets compiled with a C++ compiler?

Copy link
Contributor

Choose a reason for hiding this comment

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

We don't use a C++ compiler to compile .c files. Probably most of RIOT would be broken if you compile it with g++, because of some subtle differences between C and C++.

Copy link
Member

Choose a reason for hiding this comment

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

kk

@miri64
Copy link
Member

miri64 commented Aug 4, 2014

@rousselk did you see what's happening in #1492?


/* identifier of the GPIO pin linked to the ON/SLEEP pin (pin 13) of the XBee
module (input that gives the online or sleeping status of the module) */
#define XBEE_ON_STATUS_GPIO GPIO_UNDEFINED
Copy link
Member

Choose a reason for hiding this comment

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

With regards to #1492 this would be a struct in drivers/include/xbee.h extending net_dev_t

typedef struct {
    net_dev_type_t type;               /* set to NET_DEV_TYPE_802154 */
    net_dev_802154_driver_t *driver;   /* net_dev_802154_driver_t is a net_dev 
                                          compatible rewrite of your
                                          ieee802154_driver_t; set to fitted
                                          xbee_radio_driver_t */
    uart_t uart_link;
    gpio_t sleep_rq_gpio;
    gpio_t on_status_gpio;
} xbee_net_dev_t

and this way be configured by the user at runtime.

@rousselk
Copy link
Contributor Author

@authmillenon (Sorry for my late reply, I was absent till yesterday.)
Yes, I see the point; I am now busy with another part of the system, but I will adapt to the new architecture introduced by #1492 ASAP.

@rousselk
Copy link
Contributor Author

rousselk commented Jan 6, 2015

Closing this PR, beceause I need to rebuild my own RIOT repository...
I'll reopen it later from the new repository when I have time to fix the problems mentioned here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: network Area: Networking Platform: ARM Platform: This PR/issue effects ARM-based platforms State: WIP State: The PR is still work-in-progress and its code is not in its final presentable form yet Type: new feature The issue requests / The PR implemements a new feature for RIOT
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants