1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

Merge pull request #7851 from kYc0o/fix_sx127x_misc

drivers/sx127x: Fix misc variable types and lengths
This commit is contained in:
Francisco Acosta 2017-10-26 16:01:54 +02:00 committed by GitHub
commit 1baece5039
4 changed files with 17 additions and 9 deletions

View File

@ -208,7 +208,7 @@ enum {
*/
typedef struct {
uint16_t preamble_len; /**< Length of preamble header */
uint8_t power; /**< Signal power */
int8_t power; /**< Signal power */
uint8_t bandwidth; /**< Signal bandwidth */
uint8_t datarate; /**< Spreading factor rate, e.g datarate */
uint8_t coderate; /**< Error coding rate */
@ -616,7 +616,7 @@ uint8_t sx127x_get_tx_power(const sx127x_t *dev);
* @param[in] dev The sx127x device descriptor
* @param[in] power The TX power
*/
void sx127x_set_tx_power(sx127x_t *dev, uint8_t power);
void sx127x_set_tx_power(sx127x_t *dev, int8_t power);
/**
* @brief Gets the SX127X preamble length

View File

@ -731,7 +731,7 @@ uint8_t sx127x_get_tx_power(const sx127x_t *dev)
return dev->settings.lora.power;
}
void sx127x_set_tx_power(sx127x_t *dev, uint8_t power)
void sx127x_set_tx_power(sx127x_t *dev, int8_t power)
{
DEBUG("[DEBUG] Set power: %d\n", power);

View File

@ -441,9 +441,9 @@ static int _set(netdev_t *netdev, netopt_t opt, const void *val, size_t len)
return sizeof(uint32_t);
case NETOPT_TX_POWER:
assert(len <= sizeof(uint8_t));
sx127x_set_tx_power(dev, *((const uint8_t*) val));
return sizeof(uint16_t);
assert(len <= sizeof(int8_t));
sx127x_set_tx_power(dev, *((const int8_t*) val));
return sizeof(int8_t);
case NETOPT_FIXED_HEADER:
assert(len <= sizeof(netopt_enable_t));
@ -471,7 +471,7 @@ static uint8_t _get_tx_len(const struct iovec *vector, unsigned count)
{
uint8_t len = 0;
for (int i=0 ; i < count ; i++) {
for (unsigned i = 0 ; i < count ; i++) {
len += vector[i].iov_len;
}
@ -694,4 +694,4 @@ void _on_dio3_irq(void *arg)
puts("sx127x_on_dio3: Unknown modem");
break;
}
}
}

View File

@ -117,6 +117,9 @@ int lora_setup_cmd(int argc, char **argv) {
int random_cmd(int argc, char **argv)
{
(void)argc;
(void)argv;
printf("random: number from sx127x: %u\n",
(unsigned int) sx127x_random((sx127x_t*) netdev));
@ -218,7 +221,7 @@ int send_cmd(int argc, char **argv)
return -1;
}
printf("sending \"%s\" payload (%d bytes)\n",
printf("sending \"%s\" payload (%zd bytes)\n",
argv[1], strlen(argv[1]) + 1);
struct iovec vec[1];
@ -233,6 +236,9 @@ int send_cmd(int argc, char **argv)
int listen_cmd(int argc, char **argv)
{
(void)argc;
(void)argv;
/* Switch to continuous listen mode */
netdev->driver->set(netdev, NETOPT_SINGLE_RECEIVE, false, sizeof(uint8_t));
sx127x_set_rx(&sx127x);
@ -325,6 +331,8 @@ static void _event_cb(netdev_t *dev, netdev_event_t event)
void *_recv_thread(void *arg)
{
(void)arg;
static msg_t _msg_q[SX127X_LORA_MSG_QUEUE];
msg_init_queue(_msg_q, SX127X_LORA_MSG_QUEUE);