Revision 1790 branches/wireless/code/projects/libwireless/wireless_send.c

View differences:

wireless_send.c
395 395
      } else {
396 396
        // remove packet
397 397
        WL_DEBUG_PRINT_P("|remove packet");
398
        num = val+len;
398
        if (val+len >= PACKET_BUFFER_SIZE)
399
          num = val+len-PACKET_BUFFER_SIZE;
400
        else
401
          num = val+len;
399 402
        val = (val<2)?PACKET_BUFFER_SIZE+val-2:val-2;
400
        if (num >= PACKET_BUFFER_SIZE)
401
          num -= PACKET_BUFFER_SIZE;
402 403
        while(num != send_buf_last) {
403 404
          if (send_buf_add(&val,send_buf_get(&num)) != WL_SUCCESS)
404 405
            return; // error
......
437 438
        }
438 439
      } else {
439 440
        // check attempts on packet
440
        num = val+len-1; // set to end of packet
441
        if (num >= PACKET_BUFFER_SIZE)
442
          num -= PACKET_BUFFER_SIZE;
441
        if (val+len-1 >= PACKET_BUFFER_SIZE)
442
          num = val+len-1-PACKET_BUFFER_SIZE;
443
        else
444
          num = val+len-1; // set to end of packet
443 445
        if (send_buf[num] < NUM_RETRIES) {
444 446
          val = (val<2)?PACKET_BUFFER_SIZE+val-2:val-2; // set to start of this packet
445 447
          // retry sending
446 448
          send_buf[num]++; // increment retries
449
          send_buf[val+1] = nextframe; // reset frame number
450
          nextframe = (nextframe == 0xFF)?1:nextframe+1; // increment frame number
451
          
447 452
          val = (val==0)?PACKET_BUFFER_SIZE-1:val-1; // go back one byte
448 453
          if (xbee_send_header(len+1) != WL_SUCCESS) {
449 454
            WL_DEBUG_PRINT_P("Error sending packet from ackhandle function\r\n");

Also available in: Unified diff