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

Merge pull request #382 from OlegHahm/transceiver_return

transceiver return signed values for sending
This commit is contained in:
Oleg Hahm 2013-12-18 09:33:32 -08:00
commit 2cdfc5b585
6 changed files with 14 additions and 25 deletions

View File

@ -60,9 +60,9 @@ void nativenet_set_monitor(uint8_t mode);
* Send a packet
*
* @param packet a radio packet
* @return 1 on success, 0 otherwise
* @return -1 if the operation failed, 0 otherwise
*/
uint8_t nativenet_send(radio_packet_t *packet);
int8_t nativenet_send(radio_packet_t *packet);
/**
* Set transceiver address

View File

@ -107,16 +107,12 @@ radio_address_t nativenet_get_address()
return _native_net_addr;
}
uint8_t nativenet_send(radio_packet_t *packet)
int8_t nativenet_send(radio_packet_t *packet)
{
packet->src = _native_net_addr;
DEBUG("nativenet_send: Sending packet of length %"PRIu16" from %"PRIu16" to %"PRIu16"\n", packet->length, packet->src, packet->dst);
if (send_buf(packet) == -1) {
warnx("nativenet_send: error sending packet");
return 0;
}
return true;
return send_buf(packet);
}
void nativenet_switch_to_rx()

View File

@ -54,6 +54,7 @@ int16_t at86rf231_send(at86rf231_packet_t *packet)
// transmit packet
at86rf231_xmit(pkt, packet->length);
return packet->length;
}
static void at86rf231_xmit(uint8_t *data, uint8_t length)

View File

@ -29,7 +29,7 @@
//#include <board.h>
uint8_t cc110x_send(cc110x_packet_t *packet)
int8_t cc110x_send(cc110x_packet_t *packet)
{
volatile uint32_t abort_count;
uint8_t size;
@ -96,6 +96,6 @@ uint8_t cc110x_send(cc110x_packet_t *packet)
/* Go to mode after TX (CONST_RX -> RX, WOR -> WOR) */
cc110x_switch_to_rx();
return true;
return size;
}

View File

@ -121,7 +121,7 @@ void cc110x_init(int transceiver_pid);
void cc110x_rx_handler(void);
uint8_t cc110x_send(cc110x_packet_t *pkt);
int8_t cc110x_send(cc110x_packet_t *pkt);
uint8_t cc110x_get_buffer_pos(void);

View File

@ -116,7 +116,7 @@ static void receive_nativenet_packet(radio_packet_t *trans_p);
#ifdef MODULE_AT86RF231
void receive_at86rf231_packet(radio_packet_t *trans_p);
#endif
static uint8_t send_packet(transceiver_type_t t, void *pkt);
static int8_t send_packet(transceiver_type_t t, void *pkt);
static int16_t get_channel(transceiver_type_t t);
static int16_t set_channel(transceiver_type_t t, void *channel);
static int16_t get_address(transceiver_type_t t);
@ -580,14 +580,11 @@ void receive_at86rf231_packet(radio_packet_t *trans_p) {
* @param t The transceiver device
* @param pkt Generic pointer to the packet
*
* @return 1 on success, 0 otherwise
* @return A negative value if operation failed, 0 or the number of bytes sent otherwise.
*/
static uint8_t send_packet(transceiver_type_t t, void *pkt)
static int8_t send_packet(transceiver_type_t t, void *pkt)
{
uint8_t res = 0;
#ifdef MODULE_CC110X
int snd_ret;
#endif
int8_t res = -1;
radio_packet_t p = *((radio_packet_t *)pkt);
#ifdef MODULE_CC110X_NG
@ -617,13 +614,8 @@ static uint8_t send_packet(transceiver_type_t t, void *pkt)
#elif MODULE_CC110X
memcpy(cc1100_pkt, p.data, p.length);
if ((snd_ret = cc1100_send_csmaca(p.dst, 4, 0, (char *) cc1100_pkt, p.length)) < 0) {
DEBUG("transceiver: snd_ret (%u) = %i\n", p.length, snd_ret);
res = 0;
}
else {
res = 1;
}
res = cc1100_send_csmaca(p.dst, 4, 0, (char *) cc1100_pkt, p.length);
DEBUG("transceiver: snd_ret (%u) = %i\n", p.length, snd_ret);
#else
puts("Unknown transceiver");
#endif