Skip to content

openxc/AT-commander

Repository files navigation

AT Commander

The AT Commander is a C library (with an optional C++ wrapper) for controller an embedded module that uses an AT command set.

Supported AT Platforms

  • Roving Networks
    • RN-41
    • RN-42
  • Digi
    • XBee

Firmware

There are examples in this repository for a few platforms that you can flash to set the baud rate of an attached RN-42:

  • Arduino / chipKIT
  • LPC17xx

C API Example

For a full working example on the Arduion platform, see the arduino directory.

A brief example:

AtCommanderConfig config;
config.platform = AT_PLATFORM_RN42;
config.write_function = write_byte
config.read_function = read_byte
config.delay_function = delay;

// Set the baud to 115200, if it's not already correct
bool baud_set = at_commander_set_baud(&config, 115200);

char device_id[20];
at_commander_get_device_id(&config, device_id, sizeof(device_id));

// Send an arbitrary "get" request:
AtCommand my_get_command = {
    request_format: "GB",
    expected_response: NULL,
    error_response: "ERR"
};

char response[25];
at_commander_get(config, &my_get_command, response, sizeof(response));

// Send an arbitrary "set" command, with arguments
AtCommand my_set_command = {
    request_format: "SR,%s",
    expected_response: "AOK",
    error_response: "ERR"
};

at_commander_set(config, &my_set_command, "Z");

C++ API Example

TODO, might look like this:

AtCommander commander(AT_PLATFORM_RN42, Serial.write, Serial.read, delay);
commander.setBaud(115200);

Testing

The library includes a test suite that uses the check C unit test library.

$ script/bootstrap.sh
$ make test

Authors

Chris Peplin cpeplin@ford.com

License

Copyright (c) 2013 Ford Motor Company

Licensed under the BSD license.

About

A C library to control a device via UART that responds to an AT command set (like an RN-42)

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages