I currently have my connectport x2d programmed to receive a frame and then reply to the sender of the frame. The x2 receives every packet completely fine and then supposedly replies to the sender but my sender never gets the frame. Here is my code:
import sys, os
import time
import xbee
from socket import *
# ConnectPort's address
addr = "0013a20040c042dd"
# Create the socket, datagram mode, proprietary transport:
sd = socket(AF_XBEE, SOCK_DGRAM, XBS_PROT_TRANSPORT)
# Bind to endpoint 0xe8 (232):
sd.bind(("", 0xe8, 0, 0))
while 1:
# Block until a single frame is received, up to 72 bytes:
payload, src_addr = sd.recvfrom(8192)
# If packet was commission
if payload.startswith("\xff\xfe"):
# Send ConnectPort Address and current time
newPayload = addr + ";" + time.strftime("%Y-%m-%d %H:%M:%S")
print newPayload, src_addr
print sd.sendto(newPayload, 0, src_addr)
I followed the example xbee_echo.py then just added some logic.
The output of the code:
#> python dpdsrv.py
Launching Python application 'test.py' ...
0013a20040c042dd;2015-01-08 15:20:55
('[00:13:a2:00:40:ac:6f:23]!', 232, 49413, 149, 194, 0)
36
Any help would be great. Thanks!