Merge pull request #382 from OlegHahm/transceiver_return
transceiver return signed values for sending
This commit is contained in:
commit
2cdfc5b585
@ -60,9 +60,9 @@ void nativenet_set_monitor(uint8_t mode);
|
|||||||
* Send a packet
|
* Send a packet
|
||||||
*
|
*
|
||||||
* @param packet a radio 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
|
* Set transceiver address
|
||||||
|
|||||||
@ -107,16 +107,12 @@ radio_address_t nativenet_get_address()
|
|||||||
return _native_net_addr;
|
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;
|
packet->src = _native_net_addr;
|
||||||
DEBUG("nativenet_send: Sending packet of length %"PRIu16" from %"PRIu16" to %"PRIu16"\n", packet->length, packet->src, packet->dst);
|
DEBUG("nativenet_send: Sending packet of length %"PRIu16" from %"PRIu16" to %"PRIu16"\n", packet->length, packet->src, packet->dst);
|
||||||
|
|
||||||
if (send_buf(packet) == -1) {
|
return send_buf(packet);
|
||||||
warnx("nativenet_send: error sending packet");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void nativenet_switch_to_rx()
|
void nativenet_switch_to_rx()
|
||||||
|
|||||||
@ -54,6 +54,7 @@ int16_t at86rf231_send(at86rf231_packet_t *packet)
|
|||||||
|
|
||||||
// transmit packet
|
// transmit packet
|
||||||
at86rf231_xmit(pkt, packet->length);
|
at86rf231_xmit(pkt, packet->length);
|
||||||
|
return packet->length;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void at86rf231_xmit(uint8_t *data, uint8_t length)
|
static void at86rf231_xmit(uint8_t *data, uint8_t length)
|
||||||
|
|||||||
@ -29,7 +29,7 @@
|
|||||||
|
|
||||||
//#include <board.h>
|
//#include <board.h>
|
||||||
|
|
||||||
uint8_t cc110x_send(cc110x_packet_t *packet)
|
int8_t cc110x_send(cc110x_packet_t *packet)
|
||||||
{
|
{
|
||||||
volatile uint32_t abort_count;
|
volatile uint32_t abort_count;
|
||||||
uint8_t size;
|
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) */
|
/* Go to mode after TX (CONST_RX -> RX, WOR -> WOR) */
|
||||||
cc110x_switch_to_rx();
|
cc110x_switch_to_rx();
|
||||||
|
|
||||||
return true;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -121,7 +121,7 @@ void cc110x_init(int transceiver_pid);
|
|||||||
|
|
||||||
void cc110x_rx_handler(void);
|
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);
|
uint8_t cc110x_get_buffer_pos(void);
|
||||||
|
|
||||||
|
|||||||
@ -116,7 +116,7 @@ static void receive_nativenet_packet(radio_packet_t *trans_p);
|
|||||||
#ifdef MODULE_AT86RF231
|
#ifdef MODULE_AT86RF231
|
||||||
void receive_at86rf231_packet(radio_packet_t *trans_p);
|
void receive_at86rf231_packet(radio_packet_t *trans_p);
|
||||||
#endif
|
#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 get_channel(transceiver_type_t t);
|
||||||
static int16_t set_channel(transceiver_type_t t, void *channel);
|
static int16_t set_channel(transceiver_type_t t, void *channel);
|
||||||
static int16_t get_address(transceiver_type_t t);
|
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 t The transceiver device
|
||||||
* @param pkt Generic pointer to the packet
|
* @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;
|
int8_t res = -1;
|
||||||
#ifdef MODULE_CC110X
|
|
||||||
int snd_ret;
|
|
||||||
#endif
|
|
||||||
radio_packet_t p = *((radio_packet_t *)pkt);
|
radio_packet_t p = *((radio_packet_t *)pkt);
|
||||||
|
|
||||||
#ifdef MODULE_CC110X_NG
|
#ifdef MODULE_CC110X_NG
|
||||||
@ -617,13 +614,8 @@ static uint8_t send_packet(transceiver_type_t t, void *pkt)
|
|||||||
#elif MODULE_CC110X
|
#elif MODULE_CC110X
|
||||||
memcpy(cc1100_pkt, p.data, p.length);
|
memcpy(cc1100_pkt, p.data, p.length);
|
||||||
|
|
||||||
if ((snd_ret = cc1100_send_csmaca(p.dst, 4, 0, (char *) cc1100_pkt, p.length)) < 0) {
|
res = cc1100_send_csmaca(p.dst, 4, 0, (char *) cc1100_pkt, p.length);
|
||||||
DEBUG("transceiver: snd_ret (%u) = %i\n", p.length, snd_ret);
|
DEBUG("transceiver: snd_ret (%u) = %i\n", p.length, snd_ret);
|
||||||
res = 0;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
res = 1;
|
|
||||||
}
|
|
||||||
#else
|
#else
|
||||||
puts("Unknown transceiver");
|
puts("Unknown transceiver");
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user