aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Peach <mrpeach@users.sourceforge.net>2011-11-17 18:31:42 +0000
committerMartin Peach <mrpeach@users.sourceforge.net>2011-11-17 18:31:42 +0000
commit4f75b8c09abfc7fd4c0739c4cfdcf3d6c9c0a1f0 (patch)
tree5754ad530dd7fd632cfcad823c7bd6c75f75000c
parent73266bf5538e2f65d716cfc33259ed585ea19a51 (diff)
Added remote command response packet handler, fixed some signed/unsigned warnings. Help patch is a bit better but still needs organizing.
svn path=/trunk/externals/mrpeach/; revision=15788
-rw-r--r--xbee/packxbee-help.pd1105
-rw-r--r--xbee/packxbee.c22
-rw-r--r--xbee/unpackxbee.c124
3 files changed, 687 insertions, 564 deletions
diff --git a/xbee/packxbee-help.pd b/xbee/packxbee-help.pd
index 2949d19..b1fdd3a 100644
--- a/xbee/packxbee-help.pd
+++ b/xbee/packxbee-help.pd
@@ -1,521 +1,584 @@
-#N canvas 502 3 994 313 10;
-#X declare -lib mrpeach;
-#X msg 80 53 AT DH 0x0013A200;
-#X text 193 52 set upper 32 bits of destination address;
-#X msg 103 76 AT DL 0x407694DB;
-#X msg 128 101 AT MY;
-#X text 80 9 get upper 32 bits of destination address;
-#X text 97 31 get loweer 32 bits of destination address;
-#X msg 37 10 AT DH;
-#X msg 60 33 AT DL;
-#X msg 148 121 AT MP;
-#X text 171 99 get our 16-bit address (Read Only);
-#X msg 171 144 AT NC;
-#X text 210 141 get number of remaining children (Read Only);
-#X msg 193 166 AT SH;
-#X text 232 163 get serial number high 32 bits (Read Only);
-#X text 253 184 get serial number low 32 bits (Read Only);
-#X msg 214 187 AT SL;
-#X msg 234 207 AT NI diddley;
-#X text 321 204 set node identifier string;
-#X msg 254 227 AT NI;
-#X text 299 225 get node identifier string;
-#X text 527 50 prefix hexadecimal parameters with 0x;
-#X msg 274 247 AT NP;
-#X text 319 245 get maximum payload;
-#X msg 294 267 AT DD;
-#X text 336 264 get device type identifier;
-#X text 191 119 get endpoint parent's 16-bit address (Read Only);
-#X msg 328 301 AT CH;
-#X text 366 300 get operating channel;
-#X msg 348 321 AT ID;
-#X text 386 320 get 64-bit PAN ID;
-#X text 529 342 set 64-bit PAN ID;
-#X msg 390 363 AT ID 0x0;
-#X text 458 362 set coordinator chosen 64-bit PAN ID;
-#X msg 370 343 AT ID 0xFEEAFEEBFEECFEED;
-#X text 210 74 set lower 32 bits of destination address;
-#X msg 412 385 AT OP;
-#X text 455 383 get operating 64-bit PAN ID;
-#X msg 432 405 AT NH;
-#X msg 452 425 AT NH 0xFF;
-#X text 528 443 set maximum unicast hops (float arg);
-#X text 525 423 set maximum unicast hops (symbol arg);
-#X text 475 403 get maximum unicast hops (no arg);
-#X msg 492 465 AT BH;
-#X text 535 463 get maximum broadcastcast hops (no arg);
-#X text 585 483 set maximum broadcast hops (symbol arg);
-#X msg 512 485 AT BH 0x1E;
-#X msg 532 505 AT BH 3;
-#X text 585 502 set maximum broadcast hops (float arg);
-#X msg 552 525 AT OI;
-#X text 595 523 get operating 16-bit PAN ID;
-#X msg 472 445 AT NH 2;
-#X msg 573 546 AT NT;
-#X text 616 544 get node discovery timeout;
-#X text 662 564 set node discovery timeout;
-#X msg 593 566 AT NT 0xFF;
-#X msg 613 586 AT NO;
-#X msg 633 606 AT NO 3;
-#X text 656 584 get node discovery options;
-#X text 684 604 set node discovery options;
-#X msg 654 627 AT SC;
-#X msg 673 646 AT SC 0xFFFF;
-#X text 697 625 get scan channel bitmask;
-#X text 754 645 set scan channels;
-#X msg 692 665 AT SD;
-#X msg 711 684 AT SD 3;
-#X text 735 663 get scan duration;
-#X text 762 683 set scan duration;
-#X text 66 300 get zigbee stack profile;
-#X text 94 320 set zigbee stack profile;
-#X msg 28 301 AT ZS;
-#X msg 47 320 AT ZS 0;
-#X msg 68 341 AT NJ;
-#X msg 88 361 AT NJ 0xFF;
-#X text 106 340 get node join time;
-#X text 161 360 set node join time;
-#X obj 412 700 s topackxbee;
-#X obj 583 690 r topackxbee;
-#X msg 108 381 AT JV;
-#X text 146 380 get channel verification;
-#X text 181 400 set channel verification;
-#X msg 128 401 AT JV 1;
-#X obj 237 720 comport 23 9600;
-#X text 203 437 get power level;
-#X msg 165 438 AT PL;
-#X msg 185 458 AT PM;
-#X text 223 457 get power mode;
-#X msg 205 478 AT DB;
-#X msg 225 498 AT PP;
-#X text 263 497 get peak power dBm;
-#X text 243 477 get received signal strength -dBm;
-#X text 283 517 get API mode;
-#X msg 245 518 AT AP;
-#X msg 325 598 AT AO;
-#X text 363 597 get API options;
-#X msg 345 618 AT BD;
-#X text 383 617 get interface data rate;
-#X msg 365 638 AT NB;
-#X text 403 637 get interface parity;
-#X msg 385 658 AT SB;
-#X text 423 657 get interface stop bits;
-#X msg 405 678 AT RO;
-#X text 443 677 get packetization timeout;
-#X obj 1082 736 s topackxbee;
-#X msg 954 593 AT D7;
-#X msg 936 575 AT D6;
-#X msg 708 347 AT IR;
-#X text 746 346 get IO sample rate;
-#X msg 728 367 AT IC;
-#X text 766 366 get IO digital change detection;
-#X msg 748 387 AT P0;
-#X text 786 386 get PWM0 function;
-#X msg 768 407 AT P1;
-#X text 806 406 get PWM1 function;
-#X msg 788 427 AT P2;
-#X text 826 426 get PWM2 function;
-#X msg 808 447 AT P3;
-#X text 846 446 get PWM3 function;
-#X msg 828 467 AT D0;
-#X text 872 466 get AD0/DIO0 function;
-#X msg 846 485 AT D1;
-#X msg 864 503 AT D2;
-#X text 908 502 get AD2/DIO2 function;
-#X text 890 484 get AD1/DIO1 function;
-#X msg 882 521 AT D3;
-#X msg 900 539 AT D4;
-#X msg 918 557 AT D5;
-#X text 926 520 get AD3/DIO3 function;
-#X text 944 538 get DIO4 function;
-#X text 962 556 get DIO5 function;
-#X text 974 574 get DIO6 configuration;
-#X text 992 592 get DIO7 configuration;
-#X msg 972 611 AT D8;
-#X text 1010 610 get DIO8 configuration;
-#X msg 991 630 AT LT;
-#X text 1026 628 get Associate LED blink time 10ms;
-#X msg 1009 648 AT PR;
-#X text 1044 646 get pullup resistors;
-#X text 1067 664 get supply voltage 1200/1024mV;
-#X msg 1028 667 AT %V;
-#X msg 1048 687 AT V+;
-#X text 1087 684 get supply voltage threshold 1200/1024mV;
-#X msg 1068 707 AT TP;
-#X text 1107 704 get temperature C;
-#X obj 1277 662 s topackxbee;
-#X msg 979 349 AT VR;
-#X text 1018 346 get firmware version;
-#X msg 999 369 AT HV;
-#X text 1038 366 get hardware version;
-#X msg 1019 389 AT AI;
-#X text 1058 386 get association indication;
-#X msg 1039 409 AT CC;
-#X text 1078 406 get AT command sequence character;
-#X msg 1069 439 AT ND;
-#X text 1108 436 node discover;
-#X text 1187 457 resolve destination node;
-#X msg 1089 459 AT DN jellybaby;
-#X msg 1109 479 AT IS;
-#X msg 1129 499 AT 1S;
-#X text 1157 477 force sample;
-#X text 1167 497 force xbee sample;
-#X msg 143 705 devices;
-#X msg 11 546 API 1;
-#X msg 33 568 API 2;
-#X obj 86 636 s topackxbee;
-#X text 50 545 set API mode 1;
-#X text 74 569 set API mode 2 (escaped characters);
-#X text 55 583 mode 2 is the default setting;
-#X text 314 537 set API mode;
-#X msg 265 538 AT AP 1;
-#X text 334 557 set API mode;
-#X msg 285 558 AT AP 2;
-#X msg 1162 532 AT AC;
-#X text 1202 530 apply changes;
-#X msg 1182 552 AT WR;
-#X text 1222 550 write parameters to non-volatile memory;
-#X msg 1202 572 AT RE;
-#X text 1242 570 restore defaults;
-#X msg 1222 592 AT FR;
-#X text 1262 590 software reset;
-#X msg 1242 612 AT NR;
-#X text 1282 610 network reset;
-#X msg 1262 632 AT CB 1;
-#X text 1312 630 commisioning pushbutton;
-#X text 1115 515 ***DANGEROUS***;
-#X text 14 704 list available ports;
-#X obj 792 320 s topackxbee;
-#X text 640 79 queue set interface data rate;
-#X msg 566 79 ATQ BD 7;
-#X msg 184 652 baud 115200;
-#X msg 208 676 baud 9600;
-#X text 660 99 queue set interface data rate;
-#X msg 586 99 ATQ BD 3;
-#X msg 150 750 verbosity \$1;
-#X obj 96 735 hradio 15 1 0 3 empty empty verbosity 0 -8 0 10 -4034
--1 -1 0;
-#X msg 713 226 verbosity \$1;
-#X obj 659 211 hradio 15 1 0 3 empty empty verbosity 0 -8 0 10 -4034
--1 -1 0;
-#X msg 656 169 TX 0x0013A200406ADE1E 0x79D6 0 0 64;
-#X obj 237 739 t f f;
-#X obj 237 793 print data;
-#N canvas 4 353 1019 577 status 1;
-#X obj 73 16 inlet;
-#X floatatom 184 218 5 0 0 0 - - -;
-#X obj 264 97 print unpack5;
-#X obj 73 50 route AT_Command_Response;
-#X obj 73 82 list split 3;
-#X obj 184 142 route ND;
-#X obj 184 120 list trim;
-#X symbolatom 201 234 7 0 0 0 - - -;
-#X symbolatom 219 251 17 0 0 0 - - -;
-#X obj 73 120 unpack 0 0 0;
-#X floatatom 73 144 5 0 0 0 - - -;
-#X floatatom 107 164 5 0 0 0 - - -;
-#X floatatom 142 184 5 0 0 0 - - -;
-#X text -1 144 packet type;
-#X text 39 164 packet ID;
-#X text 64 183 data length;
-#X text 71 215 AT command status;
-#X text 155 233 addr16;
-#X text 175 249 addr64;
-#X obj 428 65 route ZigBee_Transmit_Status;
-#X floatatom 428 105 5 0 0 0 - - -;
-#X floatatom 449 123 5 0 0 0 - - -;
-#X text 354 105 packet type;
-#X text 381 123 packet ID;
-#X symbolatom 470 140 7 0 0 0 - - -;
-#X text 427 139 addr16;
-#X floatatom 533 192 5 0 0 0 - - -;
-#X floatatom 512 175 5 0 0 0 - - -;
-#X floatatom 491 158 5 0 0 0 - - -;
-#X text 360 156 transmit retry count;
-#X text 411 173 delivery status;
-#X text 427 190 discovery status;
-#X symbolatom 236 268 32 0 0 0 - - -;
-#X symbolatom 254 286 7 0 0 0 - - -;
-#X symbolatom 307 339 7 0 0 0 - - -;
-#X symbolatom 325 357 7 0 0 0 - - -;
-#X obj 184 196 unpack 0 s s s s 0 0 s s;
-#X floatatom 272 304 5 0 0 0 - - -;
-#X floatatom 289 321 5 0 0 0 - - -;
-#X text 139 267 Node Identifier;
-#X text 207 285 parent;
-#X text 197 301 device type;
-#X text 209 319 source event;
-#X text 252 337 profile;
-#X text 247 355 manufacturer;
-#X obj 229 162 print unpack7;
-#X obj 428 85 unpack 0 0 s 0 0 0;
-#X obj 616 80 route ZigBee_Receive_Packet;
-#X obj 775 100 print someotherpacket;
-#X symbolatom 685 177 7 0 0 0 - - -;
-#X symbolatom 662 159 17 0 0 0 - - -;
-#X text 639 176 addr16;
-#X text 618 157 addr64;
-#X floatatom 616 123 5 0 0 0 - - -;
-#X text 542 123 packet type;
-#X floatatom 709 195 5 0 0 0 - - -;
-#X text 610 193 receive options;
-#X obj 709 245 tgl 15 0 empty empty acknowledged 17 7 0 10 -4034 -1
--1 0 1;
-#X obj 749 265 tgl 15 0 empty empty broadcast 17 7 0 10 -4034 -1 -1
-0 1;
-#X obj 789 285 tgl 15 0 empty empty encrypted 17 7 0 10 -4034 -1 -1
-0 1;
-#X obj 829 305 tgl 15 0 empty empty from_end_device 17 7 0 10 -4034
--1 -1 0 1;
-#X obj 709 209 & 1;
-#X obj 749 209 & 2;
-#X obj 789 209 & 32;
-#X obj 829 209 & 64;
-#X obj 616 101 unpack 0 0 s s 0;
-#X floatatom 639 140 5 0 0 0 - - -;
-#X text 565 140 data length;
-#X obj 511 214 select 0 2 21 33 34 35 36 37;
-#X symbolatom 511 411 32 0 0 0 - - -;
-#X msg 511 238 set success;
-#X msg 676 396 set unknown;
-#X msg 531 257 set CCA_failurs;
-#X msg 572 297 set Network_ACK_Failure;
-#X msg 552 277 set Invalid_Destination_Endpoint;
-#X msg 593 317 set Not_Joined_To_Network;
-#X msg 612 337 set Self-Addresed;
-#X msg 634 356 set Address_Not_Found;
-#X msg 655 376 set Route_Not_Found;
-#X text 408 410 delivery status:;
-#X symbolatom 532 547 32 0 0 0 - - -;
-#X msg 613 532 set unknown;
-#X obj 532 435 select 0 1 2 3;
-#X msg 532 456 set No_Discovery_Overhead;
-#X msg 552 475 set Address_Discovery;
-#X msg 573 494 set Route_Discovery;
-#X msg 593 513 set Address_And_Route_Discovery;
-#X text 428 545 discovery status:;
-#X connect 0 0 3 0;
-#X connect 3 0 4 0;
-#X connect 3 1 19 0;
-#X connect 4 0 9 0;
-#X connect 4 1 6 0;
-#X connect 4 2 2 0;
-#X connect 5 0 36 0;
-#X connect 5 1 45 0;
-#X connect 6 0 5 0;
-#X connect 9 0 10 0;
-#X connect 9 1 11 0;
-#X connect 9 2 12 0;
-#X connect 19 0 46 0;
-#X connect 19 1 47 0;
-#X connect 36 0 1 0;
-#X connect 36 1 7 0;
-#X connect 36 2 8 0;
-#X connect 36 3 32 0;
-#X connect 36 4 33 0;
-#X connect 36 5 37 0;
-#X connect 36 6 38 0;
-#X connect 36 7 34 0;
-#X connect 36 8 35 0;
-#X connect 46 0 20 0;
-#X connect 46 1 21 0;
-#X connect 46 2 24 0;
-#X connect 46 3 28 0;
-#X connect 46 4 27 0;
-#X connect 46 4 68 0;
-#X connect 46 5 26 0;
-#X connect 46 5 82 0;
-#X connect 47 0 65 0;
-#X connect 47 1 48 0;
-#X connect 55 0 61 0;
-#X connect 55 0 62 0;
-#X connect 55 0 63 0;
-#X connect 55 0 64 0;
-#X connect 61 0 57 0;
-#X connect 62 0 58 0;
-#X connect 63 0 59 0;
-#X connect 64 0 60 0;
-#X connect 65 0 53 0;
-#X connect 65 1 66 0;
-#X connect 65 2 50 0;
-#X connect 65 3 49 0;
-#X connect 65 4 55 0;
-#X connect 68 0 70 0;
-#X connect 68 1 72 0;
-#X connect 68 2 74 0;
-#X connect 68 3 73 0;
-#X connect 68 4 75 0;
-#X connect 68 5 76 0;
-#X connect 68 6 77 0;
-#X connect 68 7 78 0;
-#X connect 68 8 71 0;
-#X connect 70 0 69 0;
-#X connect 71 0 69 0;
-#X connect 72 0 69 0;
-#X connect 73 0 69 0;
-#X connect 74 0 69 0;
-#X connect 75 0 69 0;
-#X connect 76 0 69 0;
-#X connect 77 0 69 0;
-#X connect 78 0 69 0;
-#X connect 81 0 80 0;
-#X connect 82 0 83 0;
-#X connect 82 1 84 0;
-#X connect 82 2 85 0;
-#X connect 82 3 86 0;
-#X connect 82 4 81 0;
-#X connect 83 0 80 0;
-#X connect 84 0 80 0;
-#X connect 85 0 80 0;
-#X connect 86 0 80 0;
-#X restore 317 780 pd status;
-#X obj 385 754 spigot;
-#X obj 385 776 print raw;
-#X obj 418 730 tgl 15 0 empty empty print_raw 17 7 0 10 -4034 -1 -1
-0 1;
-#X obj 709 771 print packed;
-#X obj 717 754 spigot;
-#X obj 750 730 tgl 15 0 empty empty print_packed 17 7 0 10 -4034 -1
--1 0 1;
-#X obj 717 705 packxbee 2;
-#X obj 237 765 unpackxbee 2;
-#X msg 742 255 RAT 0x0013A200406ADE1E 0x79D6 0 AT SH;
-#X msg 762 275 RAT 0x0013A200406ADE1E 0x79D6 0 AT SL;
-#X msg 636 149 TX 0x0013A20040769444 0xFFFE 0 0 1 2 3 4;
-#X msg 836 196 RAT 0x0013A20040769698 0xDA23 0 AT SL;
-#X obj 412 2 import mrpeach;
-#X text 891 135 data packet: 64-bit_destination 16-bit_destination
-broadcast_radius options data;
-#X msg 617 130 TX 0x0013A20040769698 0xFFFE 0 0 136 \$1;
-#X obj 898 97 hsl 128 15 0 127 0 0 empty empty empty -2 -8 0 10 -262144
--1 -1 8100 1;
-#X obj 895 116 nbx 5 14 -1e+037 1e+037 0 0 empty empty empty 0 -8 0
-10 -262144 -1 -1 81 256;
-#X obj 931 47 metro 2000;
-#X obj 925 74 f;
-#X obj 968 74 + 1;
-#X obj 942 16 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0
-1;
-#X obj 1012 72 % 128;
-#X connect 0 0 206 0;
-#X connect 2 0 206 0;
-#X connect 3 0 206 0;
-#X connect 6 0 206 0;
-#X connect 7 0 206 0;
-#X connect 8 0 206 0;
-#X connect 10 0 206 0;
-#X connect 12 0 206 0;
-#X connect 15 0 206 0;
-#X connect 16 0 206 0;
-#X connect 18 0 206 0;
-#X connect 21 0 206 0;
-#X connect 23 0 206 0;
-#X connect 26 0 206 0;
-#X connect 28 0 206 0;
-#X connect 31 0 206 0;
-#X connect 33 0 206 0;
-#X connect 35 0 206 0;
-#X connect 37 0 206 0;
-#X connect 38 0 206 0;
-#X connect 42 0 206 0;
-#X connect 45 0 206 0;
-#X connect 46 0 206 0;
-#X connect 48 0 206 0;
-#X connect 50 0 206 0;
-#X connect 51 0 206 0;
-#X connect 54 0 206 0;
-#X connect 55 0 206 0;
-#X connect 56 0 206 0;
-#X connect 59 0 206 0;
-#X connect 60 0 206 0;
-#X connect 63 0 206 0;
-#X connect 64 0 206 0;
-#X connect 69 0 75 0;
-#X connect 70 0 75 0;
-#X connect 71 0 75 0;
-#X connect 72 0 75 0;
-#X connect 76 0 206 0;
-#X connect 77 0 75 0;
-#X connect 80 0 75 0;
-#X connect 81 0 197 0;
-#X connect 83 0 75 0;
-#X connect 84 0 75 0;
-#X connect 86 0 75 0;
-#X connect 87 0 75 0;
-#X connect 91 0 75 0;
-#X connect 92 0 75 0;
-#X connect 94 0 75 0;
-#X connect 96 0 75 0;
-#X connect 98 0 75 0;
-#X connect 100 0 75 0;
-#X connect 103 0 102 0;
-#X connect 104 0 102 0;
-#X connect 105 0 102 0;
-#X connect 107 0 102 0;
-#X connect 109 0 102 0;
-#X connect 111 0 102 0;
-#X connect 113 0 102 0;
-#X connect 115 0 102 0;
-#X connect 117 0 102 0;
-#X connect 119 0 102 0;
-#X connect 120 0 102 0;
-#X connect 123 0 102 0;
-#X connect 124 0 102 0;
-#X connect 125 0 102 0;
-#X connect 131 0 102 0;
-#X connect 133 0 102 0;
-#X connect 135 0 102 0;
-#X connect 138 0 102 0;
-#X connect 139 0 102 0;
-#X connect 141 0 102 0;
-#X connect 144 0 143 0;
-#X connect 146 0 143 0;
-#X connect 148 0 143 0;
-#X connect 150 0 143 0;
-#X connect 152 0 143 0;
-#X connect 155 0 143 0;
-#X connect 156 0 143 0;
-#X connect 157 0 143 0;
-#X connect 160 0 81 0;
-#X connect 161 0 163 0;
-#X connect 162 0 163 0;
-#X connect 168 0 75 0;
-#X connect 170 0 75 0;
-#X connect 171 0 143 0;
-#X connect 173 0 143 0;
-#X connect 175 0 143 0;
-#X connect 177 0 143 0;
-#X connect 179 0 143 0;
-#X connect 181 0 143 0;
-#X connect 187 0 185 0;
-#X connect 188 0 81 0;
-#X connect 189 0 81 0;
-#X connect 191 0 185 0;
-#X connect 192 0 207 0;
-#X connect 193 0 192 0;
-#X connect 194 0 185 0;
-#X connect 195 0 194 0;
-#X connect 196 0 185 0;
-#X connect 197 0 207 0;
-#X connect 197 1 200 0;
-#X connect 200 0 201 0;
-#X connect 202 0 200 1;
-#X connect 204 0 203 0;
-#X connect 205 0 204 1;
-#X connect 206 0 81 0;
-#X connect 206 0 204 0;
-#X connect 207 0 198 0;
-#X connect 207 1 199 0;
-#X connect 208 0 185 0;
-#X connect 209 0 185 0;
-#X connect 210 0 185 0;
-#X connect 211 0 185 0;
-#X connect 214 0 185 0;
-#X connect 215 0 216 0;
-#X connect 216 0 214 0;
-#X connect 217 0 218 0;
-#X connect 218 0 219 0;
-#X connect 218 0 215 0;
-#X connect 219 0 221 0;
-#X connect 220 0 217 0;
-#X connect 221 0 218 1;
+#N canvas 154 423 1227 436 10;
+#X declare -lib mrpeach;
+#X msg 80 53 AT DH 0x0013A200;
+#X text 193 52 set upper 32 bits of destination address;
+#X msg 103 76 AT DL 0x407694DB;
+#X msg 128 101 AT MY;
+#X text 80 9 get upper 32 bits of destination address;
+#X text 97 31 get loweer 32 bits of destination address;
+#X msg 37 10 AT DH;
+#X msg 60 33 AT DL;
+#X msg 148 121 AT MP;
+#X text 171 99 get our 16-bit address (Read Only);
+#X msg 171 144 AT NC;
+#X text 210 141 get number of remaining children (Read Only);
+#X msg 193 166 AT SH;
+#X text 232 163 get serial number high 32 bits (Read Only);
+#X text 253 184 get serial number low 32 bits (Read Only);
+#X msg 214 187 AT SL;
+#X msg 234 207 AT NI diddley;
+#X text 321 204 set node identifier string;
+#X msg 254 227 AT NI;
+#X text 299 225 get node identifier string;
+#X text 527 50 prefix hexadecimal parameters with 0x;
+#X msg 274 247 AT NP;
+#X text 319 245 get maximum payload;
+#X msg 294 267 AT DD;
+#X text 336 264 get device type identifier;
+#X text 191 119 get endpoint parent's 16-bit address (Read Only);
+#X msg 328 301 AT CH;
+#X text 366 300 get operating channel;
+#X msg 348 321 AT ID;
+#X text 386 320 get 64-bit PAN ID;
+#X text 529 342 set 64-bit PAN ID;
+#X msg 390 363 AT ID 0x0;
+#X text 458 362 set coordinator chosen 64-bit PAN ID;
+#X msg 370 343 AT ID 0xFEEAFEEBFEECFEED;
+#X text 210 74 set lower 32 bits of destination address;
+#X msg 412 385 AT OP;
+#X text 455 383 get operating 64-bit PAN ID;
+#X msg 432 405 AT NH;
+#X msg 452 425 AT NH 0xFF;
+#X text 528 443 set maximum unicast hops (float arg);
+#X text 525 423 set maximum unicast hops (symbol arg);
+#X text 475 403 get maximum unicast hops (no arg);
+#X msg 492 465 AT BH;
+#X text 535 463 get maximum broadcastcast hops (no arg);
+#X text 585 483 set maximum broadcast hops (symbol arg);
+#X msg 512 485 AT BH 0x1E;
+#X msg 532 505 AT BH 3;
+#X text 585 502 set maximum broadcast hops (float arg);
+#X msg 552 525 AT OI;
+#X text 595 523 get operating 16-bit PAN ID;
+#X msg 472 445 AT NH 2;
+#X msg 573 546 AT NT;
+#X text 616 544 get node discovery timeout;
+#X text 662 564 set node discovery timeout;
+#X msg 593 566 AT NT 0xFF;
+#X msg 613 586 AT NO;
+#X msg 633 606 AT NO 3;
+#X text 656 584 get node discovery options;
+#X text 684 604 set node discovery options;
+#X msg 654 627 AT SC;
+#X msg 673 646 AT SC 0xFFFF;
+#X text 697 625 get scan channel bitmask;
+#X text 754 645 set scan channels;
+#X msg 692 665 AT SD;
+#X msg 711 684 AT SD 3;
+#X text 735 663 get scan duration;
+#X text 762 683 set scan duration;
+#X text 66 300 get zigbee stack profile;
+#X text 94 320 set zigbee stack profile;
+#X msg 28 301 AT ZS;
+#X msg 47 320 AT ZS 0;
+#X msg 68 341 AT NJ;
+#X msg 88 361 AT NJ 0xFF;
+#X text 106 340 get node join time;
+#X text 161 360 set node join time;
+#X obj 410 700 s topackxbee;
+#X obj 614 688 r topackxbee;
+#X msg 108 381 AT JV;
+#X text 146 380 get channel verification;
+#X text 181 400 set channel verification;
+#X msg 128 401 AT JV 1;
+#X text 203 437 get power level;
+#X msg 165 438 AT PL;
+#X msg 185 458 AT PM;
+#X text 223 457 get power mode;
+#X msg 205 478 AT DB;
+#X msg 225 498 AT PP;
+#X text 263 497 get peak power dBm;
+#X text 243 477 get received signal strength -dBm;
+#X text 283 517 get API mode;
+#X msg 245 518 AT AP;
+#X msg 325 598 AT AO;
+#X text 363 597 get API options;
+#X msg 345 618 AT BD;
+#X text 383 617 get interface data rate;
+#X msg 365 638 AT NB;
+#X text 403 637 get interface parity;
+#X msg 385 658 AT SB;
+#X text 423 657 get interface stop bits;
+#X msg 405 678 AT RO;
+#X text 443 677 get packetization timeout;
+#X obj 1080 736 s topackxbee;
+#X msg 954 593 AT D7;
+#X msg 936 575 AT D6;
+#X msg 708 347 AT IR;
+#X text 746 346 get IO sample rate;
+#X msg 728 367 AT IC;
+#X text 766 366 get IO digital change detection;
+#X msg 748 387 AT P0;
+#X text 786 386 get PWM0 function;
+#X msg 768 407 AT P1;
+#X text 806 406 get PWM1 function;
+#X msg 788 427 AT P2;
+#X text 826 426 get PWM2 function;
+#X msg 808 447 AT P3;
+#X text 846 446 get PWM3 function;
+#X msg 828 467 AT D0;
+#X text 872 466 get AD0/DIO0 function;
+#X msg 846 485 AT D1;
+#X msg 864 503 AT D2;
+#X text 908 502 get AD2/DIO2 function;
+#X text 890 484 get AD1/DIO1 function;
+#X msg 882 521 AT D3;
+#X msg 900 539 AT D4;
+#X msg 918 557 AT D5;
+#X text 926 520 get AD3/DIO3 function;
+#X text 944 538 get DIO4 function;
+#X text 962 556 get DIO5 function;
+#X text 974 574 get DIO6 configuration;
+#X text 992 592 get DIO7 configuration;
+#X msg 972 611 AT D8;
+#X text 1010 610 get DIO8 configuration;
+#X msg 991 630 AT LT;
+#X text 1026 628 get Associate LED blink time 10ms;
+#X msg 1009 648 AT PR;
+#X text 1044 646 get pullup resistors;
+#X text 1067 664 get supply voltage 1200/1024mV;
+#X msg 1028 667 AT %V;
+#X msg 1048 687 AT V+;
+#X text 1087 684 get supply voltage threshold 1200/1024mV;
+#X msg 1068 707 AT TP;
+#X text 1107 704 get temperature C;
+#X obj 1275 662 s topackxbee;
+#X msg 979 349 AT VR;
+#X text 1018 346 get firmware version;
+#X msg 999 369 AT HV;
+#X text 1038 366 get hardware version;
+#X msg 1019 389 AT AI;
+#X text 1058 386 get association indication;
+#X msg 1039 409 AT CC;
+#X text 1078 406 get AT command sequence character;
+#X msg 1069 439 AT ND;
+#X text 1108 436 node discover;
+#X text 1179 459 resolve destination node;
+#X msg 1109 479 AT IS;
+#X msg 1129 499 AT 1S;
+#X text 1157 477 force sample;
+#X text 1167 497 force xbee sample;
+#X msg 143 705 devices;
+#X msg 11 546 API 1;
+#X msg 33 568 API 2;
+#X obj 84 636 s topackxbee;
+#X text 50 545 set API mode 1;
+#X text 74 569 set API mode 2 (escaped characters);
+#X text 55 583 mode 2 is the default setting;
+#X text 314 537 set API mode;
+#X msg 265 538 AT AP 1;
+#X text 334 557 set API mode;
+#X msg 285 558 AT AP 2;
+#X msg 1162 532 AT AC;
+#X text 1202 530 apply changes;
+#X msg 1182 552 AT WR;
+#X text 1222 550 write parameters to non-volatile memory;
+#X msg 1202 572 AT RE;
+#X text 1242 570 restore defaults;
+#X msg 1222 592 AT FR;
+#X text 1262 590 software reset;
+#X msg 1242 612 AT NR;
+#X text 1282 610 network reset;
+#X msg 1262 632 AT CB 1;
+#X text 1312 630 commisioning pushbutton;
+#X text 1115 515 ***DANGEROUS***;
+#X text 14 704 list available ports;
+#X obj 792 322 s topackxbee;
+#X text 640 79 queue set interface data rate;
+#X msg 566 79 ATQ BD 7;
+#X msg 183 652 baud 115200;
+#X msg 207 676 baud 9600;
+#X text 660 99 queue set interface data rate;
+#X msg 586 99 ATQ BD 3;
+#X msg 150 751 verbosity \$1;
+#X obj 96 736 hradio 15 1 0 3 empty empty verbosity 0 -8 0 10 -4034
+-1 -1 0;
+#X msg 713 226 verbosity \$1;
+#X obj 659 211 hradio 15 1 0 3 empty empty verbosity 0 -8 0 10 -4034
+-1 -1 2;
+#X msg 656 169 TX 0x0013A200406ADE1E 0x79D6 0 0 64;
+#X obj 237 742 t f f;
+#X obj 237 796 print data;
+#N canvas 43 599 1232 329 status 1;
+#X obj 73 16 inlet;
+#X floatatom 184 218 5 0 0 0 - - -;
+#X obj 254 99 print unpack5;
+#X obj 73 46 route AT_Command_Response;
+#X obj 73 82 list split 3;
+#X obj 184 142 route ND;
+#X obj 184 120 list trim;
+#X symbolatom 201 234 7 0 0 0 - - -;
+#X symbolatom 219 251 20 0 0 0 - - -;
+#X obj 73 120 unpack 0 0 0;
+#X floatatom 73 144 5 0 0 0 - - -;
+#X floatatom 107 164 5 0 0 0 - - -;
+#X floatatom 142 184 5 0 0 0 - - -;
+#X text -1 144 packet type;
+#X text 39 164 packet ID;
+#X text 64 183 data length;
+#X text 71 215 AT command status;
+#X text 155 233 addr16;
+#X text 175 249 addr64;
+#X obj 428 63 route ZigBee_Transmit_Status;
+#X floatatom 428 105 5 0 0 0 - - -;
+#X floatatom 449 123 5 0 0 0 - - -;
+#X text 354 105 packet type;
+#X text 381 123 packet ID;
+#X symbolatom 470 140 7 0 0 0 - - -;
+#X text 427 139 addr16;
+#X floatatom 533 192 5 0 0 0 - - -;
+#X floatatom 512 175 5 0 0 0 - - -;
+#X floatatom 491 158 5 0 0 0 - - -;
+#X text 360 156 transmit retry count;
+#X text 411 173 delivery status;
+#X text 427 190 discovery status;
+#X symbolatom 236 268 32 0 0 0 - - -;
+#X symbolatom 254 286 7 0 0 0 - - -;
+#X symbolatom 307 339 7 0 0 0 - - -;
+#X symbolatom 325 357 7 0 0 0 - - -;
+#X obj 184 196 unpack 0 s s s s 0 0 s s;
+#X floatatom 272 304 5 0 0 0 - - -;
+#X floatatom 289 321 5 0 0 0 - - -;
+#X text 139 267 Node Identifier;
+#X text 207 285 parent;
+#X text 197 301 device type;
+#X text 209 319 source event;
+#X text 252 337 profile;
+#X text 247 355 manufacturer;
+#X obj 428 85 unpack 0 0 s 0 0 0;
+#X obj 616 80 route ZigBee_Receive_Packet;
+#X obj 1181 114 print someotherpacket;
+#X symbolatom 685 177 7 0 0 0 - - -;
+#X symbolatom 662 159 17 0 0 0 - - -;
+#X text 639 176 addr16;
+#X text 618 157 addr64;
+#X floatatom 616 123 5 0 0 0 - - -;
+#X text 542 123 packet type;
+#X floatatom 709 195 5 0 0 0 - - -;
+#X text 610 193 receive options;
+#X obj 709 245 tgl 15 0 empty empty acknowledged 17 7 0 10 -4034 -1
+-1 0 1;
+#X obj 749 265 tgl 15 0 empty empty broadcast 17 7 0 10 -4034 -1 -1
+0 1;
+#X obj 789 285 tgl 15 0 empty empty encrypted 17 7 0 10 -4034 -1 -1
+0 1;
+#X obj 829 305 tgl 15 0 empty empty from_end_device 17 7 0 10 -4034
+-1 -1 0 1;
+#X obj 709 209 & 1;
+#X obj 749 209 & 2;
+#X obj 789 209 & 32;
+#X obj 829 209 & 64;
+#X obj 616 101 unpack 0 0 s s 0;
+#X floatatom 639 140 5 0 0 0 - - -;
+#X text 565 140 data length;
+#X obj 511 214 select 0 2 21 33 34 35 36 37;
+#X symbolatom 511 411 32 0 0 0 - - -;
+#X msg 511 238 set success;
+#X msg 676 396 set unknown;
+#X msg 531 257 set CCA_failurs;
+#X msg 572 297 set Network_ACK_Failure;
+#X msg 552 277 set Invalid_Destination_Endpoint;
+#X msg 593 317 set Not_Joined_To_Network;
+#X msg 612 337 set Self-Addresed;
+#X msg 634 356 set Address_Not_Found;
+#X msg 655 376 set Route_Not_Found;
+#X text 408 410 delivery status:;
+#X symbolatom 532 547 32 0 0 0 - - -;
+#X msg 613 532 set unknown;
+#X obj 532 435 select 0 1 2 3;
+#X msg 532 456 set No_Discovery_Overhead;
+#X msg 552 475 set Address_Discovery;
+#X msg 573 494 set Route_Discovery;
+#X msg 593 513 set Address_And_Route_Discovery;
+#X text 428 545 discovery status:;
+#X obj 936 97 route Remote_Command_Response;
+#X floatatom 936 150 5 0 0 0 - - -;
+#X floatatom 955 172 5 0 0 0 - - -;
+#X text 862 150 packet type;
+#X text 887 172 packet ID;
+#X floatatom 1053 279 5 0 0 0 - - -;
+#X symbolatom 975 212 20 0 0 0 - - -;
+#X text 931 210 addr64;
+#X symbolatom 994 193 7 0 0 0 - - -;
+#X symbolatom 1014 234 7 0 0 0 - - -;
+#X text 968 233 command;
+#X floatatom 1033 256 5 0 0 0 - - -;
+#X text 983 280 data length;
+#X text 991 256 status;
+#X obj 936 124 unpack 0 0 s s s 0 0;
+#X obj 229 162 print AT_response;
+#X text 948 192 addr16;
+#X obj 1101 160 select 0 1 2 3 4;
+#X symbolatom 1101 360 32 0 0 0 - - -;
+#X text 998 359 delivery status:;
+#X msg 1101 187 set OK;
+#X msg 1119 207 set ERROR;
+#X msg 1138 226 set Invalid_Command;
+#X msg 1157 246 set Invalid_Parameter;
+#X msg 1175 269 set Transmission_Failed;
+#X connect 0 0 3 0;
+#X connect 3 0 4 0;
+#X connect 3 1 19 0;
+#X connect 4 0 9 0;
+#X connect 4 1 6 0;
+#X connect 4 2 2 0;
+#X connect 5 0 36 0;
+#X connect 5 1 102 0;
+#X connect 6 0 5 0;
+#X connect 9 0 10 0;
+#X connect 9 1 11 0;
+#X connect 9 2 12 0;
+#X connect 19 0 45 0;
+#X connect 19 1 46 0;
+#X connect 36 0 1 0;
+#X connect 36 1 7 0;
+#X connect 36 2 8 0;
+#X connect 36 3 32 0;
+#X connect 36 4 33 0;
+#X connect 36 5 37 0;
+#X connect 36 6 38 0;
+#X connect 36 7 34 0;
+#X connect 36 8 35 0;
+#X connect 45 0 20 0;
+#X connect 45 1 21 0;
+#X connect 45 2 24 0;
+#X connect 45 3 28 0;
+#X connect 45 4 27 0;
+#X connect 45 4 67 0;
+#X connect 45 5 26 0;
+#X connect 45 5 81 0;
+#X connect 46 0 64 0;
+#X connect 46 1 87 0;
+#X connect 54 0 60 0;
+#X connect 54 0 61 0;
+#X connect 54 0 62 0;
+#X connect 54 0 63 0;
+#X connect 60 0 56 0;
+#X connect 61 0 57 0;
+#X connect 62 0 58 0;
+#X connect 63 0 59 0;
+#X connect 64 0 52 0;
+#X connect 64 1 65 0;
+#X connect 64 2 49 0;
+#X connect 64 3 48 0;
+#X connect 64 4 54 0;
+#X connect 67 0 69 0;
+#X connect 67 1 71 0;
+#X connect 67 2 73 0;
+#X connect 67 3 72 0;
+#X connect 67 4 74 0;
+#X connect 67 5 75 0;
+#X connect 67 6 76 0;
+#X connect 67 7 77 0;
+#X connect 67 8 70 0;
+#X connect 69 0 68 0;
+#X connect 70 0 68 0;
+#X connect 71 0 68 0;
+#X connect 72 0 68 0;
+#X connect 73 0 68 0;
+#X connect 74 0 68 0;
+#X connect 75 0 68 0;
+#X connect 76 0 68 0;
+#X connect 77 0 68 0;
+#X connect 80 0 79 0;
+#X connect 81 0 82 0;
+#X connect 81 1 83 0;
+#X connect 81 2 84 0;
+#X connect 81 3 85 0;
+#X connect 81 4 80 0;
+#X connect 82 0 79 0;
+#X connect 83 0 79 0;
+#X connect 84 0 79 0;
+#X connect 85 0 79 0;
+#X connect 87 0 101 0;
+#X connect 87 1 47 0;
+#X connect 101 0 88 0;
+#X connect 101 1 89 0;
+#X connect 101 2 93 0;
+#X connect 101 3 95 0;
+#X connect 101 4 96 0;
+#X connect 101 5 98 0;
+#X connect 101 5 104 0;
+#X connect 101 6 92 0;
+#X connect 104 0 107 0;
+#X connect 104 1 108 0;
+#X connect 104 2 109 0;
+#X connect 104 3 110 0;
+#X connect 104 4 111 0;
+#X connect 107 0 105 0;
+#X connect 108 0 105 0;
+#X connect 109 0 105 0;
+#X connect 110 0 105 0;
+#X connect 111 0 105 0;
+#X restore 317 783 pd status;
+#X obj 385 759 spigot;
+#X obj 385 781 print raw;
+#X obj 418 733 tgl 15 0 empty empty print_raw 17 7 0 10 -4034 -1 -1
+0 1;
+#X obj 715 780 print packed;
+#X obj 715 754 spigot;
+#X obj 748 730 tgl 15 0 empty empty print_packed 17 7 0 10 -4034 -1
+-1 0 1;
+#X obj 715 705 packxbee 2;
+#X obj 237 768 unpackxbee 2;
+#X msg 636 149 TX 0x0013A20040769444 0xFFFE 0 0 1 2 3 4;
+#X obj 412 2 import mrpeach;
+#X text 891 135 data packet: 64-bit_destination 16-bit_destination
+broadcast_radius options data;
+#X obj 898 97 hsl 128 15 0 127 0 0 empty empty empty -2 -8 0 10 -262144
+-1 -1 1900 0;
+#X obj 895 116 nbx 5 14 -1e+37 1e+37 0 0 empty empty empty 0 -8 0 10
+-262144 -1 -1 19 256;
+#X obj 895 74 f;
+#X obj 938 74 + 1;
+#X obj 1337 160 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1
+0 1;
+#X obj 982 72 % 128;
+#X obj 237 723 comport 4 9600;
+#X msg 617 130 TX 0x0013A200406BFE6C 0x51D6 0 0 136 \$1;
+#X msg 1337 273 4;
+#X msg 1356 253 5;
+#X obj 1337 209 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1
+1 1;
+#X obj 1337 230 sel 0 1;
+#X msg 777 290 RAT 0x0013A200406BFE6C 0x51D6 2 D0 \$1;
+#X obj 1337 185 metro 200;
+#X msg 753 266 RAT 0x0013A200406BFE6C 0x51D6 0 SL;
+#X msg 733 246 RAT 0x0013A200406BFE6C 0x51D6 0 SH;
+#X obj 895 32 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0
+1;
+#X obj 895 52 metro 200;
+#X text 856 220 remote AT command: 64-bit address \, 16-bit address
+\, options \, command \, parameters;
+#X text 1008 290 switch remote IO pin 0 high/low (options = 2 = apply
+changes immediately);
+#X msg 1089 459 AT DN IMCA_R1;
+#X connect 0 0 204 0;
+#X connect 2 0 204 0;
+#X connect 3 0 204 0;
+#X connect 6 0 204 0;
+#X connect 7 0 204 0;
+#X connect 8 0 204 0;
+#X connect 10 0 204 0;
+#X connect 12 0 204 0;
+#X connect 15 0 204 0;
+#X connect 16 0 204 0;
+#X connect 18 0 204 0;
+#X connect 21 0 204 0;
+#X connect 23 0 204 0;
+#X connect 26 0 204 0;
+#X connect 28 0 204 0;
+#X connect 31 0 204 0;
+#X connect 33 0 204 0;
+#X connect 35 0 204 0;
+#X connect 37 0 204 0;
+#X connect 38 0 204 0;
+#X connect 42 0 204 0;
+#X connect 45 0 204 0;
+#X connect 46 0 204 0;
+#X connect 48 0 204 0;
+#X connect 50 0 204 0;
+#X connect 51 0 204 0;
+#X connect 54 0 204 0;
+#X connect 55 0 204 0;
+#X connect 56 0 204 0;
+#X connect 59 0 204 0;
+#X connect 60 0 204 0;
+#X connect 63 0 204 0;
+#X connect 64 0 204 0;
+#X connect 69 0 75 0;
+#X connect 70 0 75 0;
+#X connect 71 0 75 0;
+#X connect 72 0 75 0;
+#X connect 76 0 204 0;
+#X connect 77 0 75 0;
+#X connect 80 0 75 0;
+#X connect 82 0 75 0;
+#X connect 83 0 75 0;
+#X connect 85 0 75 0;
+#X connect 86 0 75 0;
+#X connect 90 0 75 0;
+#X connect 91 0 75 0;
+#X connect 93 0 75 0;
+#X connect 95 0 75 0;
+#X connect 97 0 75 0;
+#X connect 99 0 75 0;
+#X connect 102 0 101 0;
+#X connect 103 0 101 0;
+#X connect 104 0 101 0;
+#X connect 106 0 101 0;
+#X connect 108 0 101 0;
+#X connect 110 0 101 0;
+#X connect 112 0 101 0;
+#X connect 114 0 101 0;
+#X connect 116 0 101 0;
+#X connect 118 0 101 0;
+#X connect 119 0 101 0;
+#X connect 122 0 101 0;
+#X connect 123 0 101 0;
+#X connect 124 0 101 0;
+#X connect 130 0 101 0;
+#X connect 132 0 101 0;
+#X connect 134 0 101 0;
+#X connect 137 0 101 0;
+#X connect 138 0 101 0;
+#X connect 140 0 101 0;
+#X connect 143 0 142 0;
+#X connect 145 0 142 0;
+#X connect 147 0 142 0;
+#X connect 149 0 142 0;
+#X connect 151 0 142 0;
+#X connect 154 0 142 0;
+#X connect 155 0 142 0;
+#X connect 158 0 215 0;
+#X connect 159 0 161 0;
+#X connect 160 0 161 0;
+#X connect 166 0 75 0;
+#X connect 168 0 75 0;
+#X connect 169 0 142 0;
+#X connect 171 0 142 0;
+#X connect 173 0 142 0;
+#X connect 175 0 142 0;
+#X connect 177 0 142 0;
+#X connect 179 0 142 0;
+#X connect 185 0 183 0;
+#X connect 186 0 215 0;
+#X connect 187 0 215 0;
+#X connect 189 0 183 0;
+#X connect 190 0 205 0;
+#X connect 191 0 190 0;
+#X connect 192 0 183 0;
+#X connect 193 0 192 0;
+#X connect 194 0 183 0;
+#X connect 195 0 205 0;
+#X connect 195 1 198 0;
+#X connect 198 0 199 0;
+#X connect 200 0 198 1;
+#X connect 202 0 201 0;
+#X connect 203 0 202 1;
+#X connect 204 0 202 0;
+#X connect 204 0 215 0;
+#X connect 205 0 196 0;
+#X connect 205 1 197 0;
+#X connect 206 0 183 0;
+#X connect 209 0 210 0;
+#X connect 210 0 216 0;
+#X connect 211 0 212 0;
+#X connect 211 0 209 0;
+#X connect 212 0 214 0;
+#X connect 213 0 222 0;
+#X connect 214 0 211 1;
+#X connect 215 0 195 0;
+#X connect 216 0 183 0;
+#X connect 217 0 221 0;
+#X connect 218 0 221 0;
+#X connect 219 0 220 0;
+#X connect 220 0 217 0;
+#X connect 220 1 218 0;
+#X connect 221 0 183 0;
+#X connect 222 0 219 0;
+#X connect 223 0 183 0;
+#X connect 224 0 183 0;
+#X connect 225 0 226 0;
+#X connect 226 0 211 0;
+#X connect 229 0 142 0;
diff --git a/xbee/packxbee.c b/xbee/packxbee.c
index 2355896..33a0201 100644
--- a/xbee/packxbee.c
+++ b/xbee/packxbee.c
@@ -46,7 +46,7 @@ static void *packxbee_new(t_floatarg f)
x->x_listout = outlet_new(&x->x_obj, &s_list);
if (1 == f) x->x_api_mode = 1;
else x->x_api_mode = 2; /* default to escaped mode */
- x->x_verbosity = 2; /* debug level */
+ x->x_verbosity = 0; /* debug level */
for(i = 0; i < MAX_XBEE_PACKET_LENGTH; ++i) x->x_outbuf[i].a_type = A_FLOAT; /* init output atoms as floats */
}
return (x);
@@ -135,9 +135,9 @@ static void packxbee_TX(t_packxbee *x, t_symbol *s, int argc, t_atom *argv)
return;
}
#ifdef _MSC_VER
- if (x->x_verbosity > 0) post ("packxbee_TX: dest64:0x%016I64X", dest64);
+ if (x->x_verbosity > 1) post ("packxbee_TX: dest64:0x%016I64X", dest64);
#else
- if (x->x_verbosity > 0) post ("packxbee_TX: dest64:0x%016LX", dest64);
+ if (x->x_verbosity > 1) post ("packxbee_TX: dest64:0x%016LX", dest64);
#endif
/* second arg is dest16 also a symbol starting with "0x" */
if (argv[1].a_type != A_SYMBOL)
@@ -156,7 +156,7 @@ static void packxbee_TX(t_packxbee *x, t_symbol *s, int argc, t_atom *argv)
error("packxbee_TX: second argument is not a hex string");
return;
}
- if (x->x_verbosity > 0) post ("packxbee_TX: dest16: 0x%X", dest16);
+ if (x->x_verbosity > 1) post ("packxbee_TX: dest16: 0x%X", dest16);
/* broadcast radius is a single byte as a float */
if (argv[2].a_type != A_FLOAT)
{
@@ -164,7 +164,7 @@ static void packxbee_TX(t_packxbee *x, t_symbol *s, int argc, t_atom *argv)
return;
}
f = argv[2].a_w.w_float;
- if (x->x_verbosity > 0) post("packxbee_TX float parameter %f", f);
+ if (x->x_verbosity > 1) post("packxbee_TX float parameter %f", f);
d = ((unsigned int)f)&0x0FF;
if (f != d)
{
@@ -172,7 +172,7 @@ static void packxbee_TX(t_packxbee *x, t_symbol *s, int argc, t_atom *argv)
return;
}
else broadcast_radius = d;
- if (x->x_verbosity > 0) post("packxbee_TX: broadcast_radius: %d", d);
+ if (x->x_verbosity > 1) post("packxbee_TX: broadcast_radius: %d", d);
/* options is a single byte as a float */
if (argv[3].a_type != A_FLOAT)
@@ -181,7 +181,7 @@ static void packxbee_TX(t_packxbee *x, t_symbol *s, int argc, t_atom *argv)
return;
}
f = argv[3].a_w.w_float;
- if (x->x_verbosity > 0) post("packxbee_TX float parameter %f", f);
+ if (x->x_verbosity > 1) post("packxbee_TX float parameter %f", f);
d = ((unsigned int)f)&0x0FF;
if (f != d)
{
@@ -189,7 +189,7 @@ static void packxbee_TX(t_packxbee *x, t_symbol *s, int argc, t_atom *argv)
return;
}
else options = d;
- if (x->x_verbosity > 0) post("packxbee_TX: options: %d", d);
+ if (x->x_verbosity > 1) post("packxbee_TX: options: %d", d);
x->x_frameType = ZigBee_Transmit_Request;/* because we're building a queued AT frame */
floatstring[0] = XFRAME; /* as usual */
@@ -234,7 +234,7 @@ static void packxbee_TX(t_packxbee *x, t_symbol *s, int argc, t_atom *argv)
if (A_FLOAT == argv[k].a_type)
{
f = argv[k].a_w.w_float;
- if (x->x_verbosity > 0) post("packxbee_TX float parameter %f", f);
+ if (x->x_verbosity > 1) post("packxbee_TX float parameter %f", f);
d = ((unsigned int)f)&0x0FF;
if (f != d)
{
@@ -246,7 +246,7 @@ static void packxbee_TX(t_packxbee *x, t_symbol *s, int argc, t_atom *argv)
}
else if (A_SYMBOL == argv[k].a_type)
{
- if (x->x_verbosity > 0) post("packxbee_TX symbol parameter %s", argv[k].a_w.w_symbol->s_name);
+ if (x->x_verbosity > 1) post("packxbee_TX symbol parameter %s", argv[k].a_w.w_symbol->s_name);
j = i;
i += sprintf((char *)&floatstring[i], "%s", argv[k].a_w.w_symbol->s_name);
for (;j < i; ++j) checksum -= floatstring[j];
@@ -307,7 +307,6 @@ static void packxbee_pack_remote_frame(t_packxbee *x, t_symbol *s, int argc, t_a
unsigned char floatstring[256]; /* longer than the longest hex number with each character escaped plus the header and checksum overhead */
int length = 0;
unsigned char c, digits;
- long param;
t_float f;
unsigned long long dest64;
@@ -529,7 +528,6 @@ static void packxbee_pack_frame(t_packxbee *x, t_symbol *s, int argc, t_atom *ar
unsigned char floatstring[256]; /* longer than the longest hex number with each character escaped plus the header and checksum overhead */
int length = 0;
unsigned char c, digits;
- long param;
t_float f;
if (x->x_verbosity > 0) post("packxbee_AT s is %s, argc is %d", s->s_name, argc);
diff --git a/xbee/unpackxbee.c b/xbee/unpackxbee.c
index 2e43c57..b8b5900 100644
--- a/xbee/unpackxbee.c
+++ b/xbee/unpackxbee.c
@@ -23,7 +23,7 @@ typedef struct _unpackxbee
unsigned int x_frame_length;
int x_verbosity;
unsigned char x_message[MAX_XBEE_PACKET_LENGTH];
- int x_message_index;
+ unsigned int x_message_index;
int x_escaped;
t_atom x_outbuf[MAX_XBEE_PACKET_LENGTH];
t_atom x_statusbuf[32]; /* some number bigger than we will ever reach */
@@ -48,7 +48,7 @@ static void *unpackxbee_new(t_floatarg f)
if (1 == f) x->x_api_mode = 1;
else x->x_api_mode = 2; /* default to escaped mode */
- x->x_verbosity = 2; /* debug level */
+ x->x_verbosity = 0; /* debug level */
for(i = 0; i < MAX_XBEE_PACKET_LENGTH; ++i) x->x_outbuf[i].a_type = A_FLOAT; /* init output atoms as floats */
}
return (x);
@@ -70,7 +70,7 @@ int unpackxbee_add(t_unpackxbee *x, unsigned char d)
{
if (XFRAME == d)
{
- if (x->x_verbosity > 1) post ("frame start");
+ if (x->x_verbosity > 0) post ("frame start");
x->x_message_index = 0;
x->x_frame_length = 0;
x->x_frame_type = 0;
@@ -92,17 +92,17 @@ int unpackxbee_add(t_unpackxbee *x, unsigned char d)
if (LENGTH_LSB_INDEX == x->x_message_index) /* length is a bigendian pair */
{
x->x_frame_length = (x->x_message[LENGTH_MSB_INDEX]<<8) + d;
- if (x->x_verbosity > 1) post ("frame length %d", x->x_frame_length);
+ if (x->x_verbosity > 0) post ("frame length %d", x->x_frame_length);
}
else if (FRAME_TYPE_INDEX == x->x_message_index)
{
x->x_frame_type = d;
- if (x->x_verbosity > 1) post ("frame type 0x%02X", x->x_frame_type);
+ if (x->x_verbosity > 0) post ("frame type 0x%02X", x->x_frame_type);
}
else if (FRAME_ID_INDEX == x->x_message_index)
{ /* this is part of the payload and may not be valid in some frame types */
x->x_frame_ID = d;
- if (x->x_verbosity > 1) post ("frame ID %d", x->x_frame_ID);
+ if (x->x_verbosity > 0) post ("frame ID %d", x->x_frame_ID);
}
x->x_message[x->x_message_index++] = d; /* add the unescaped character to the output list */
return 1;
@@ -121,14 +121,14 @@ static void unpackxbee_input(t_unpackxbee *x, t_symbol *s, int argc, t_atom *arg
unsigned long long addr64;
unsigned int addr16;
- if (x->x_verbosity > 1) post("unpackxbee_input: s is %s, argc is %d", s->s_name, argc);
+ if (x->x_verbosity > 0) post("unpackxbee_input: s is %s, argc is %d", s->s_name, argc);
for (i = 0; i < argc; ++i)
{
if (A_FLOAT == argv[i].a_type)
{
f = argv[i].a_w.w_float;
d = ((unsigned int)f)&0x0FF;
- if (x->x_verbosity > 1) post("unpackxbee_input: argv[%d] is %f int is %d", i, f, d);
+ if (x->x_verbosity > 0) post("unpackxbee_input: argv[%d] is %f int is %d", i, f, d);
if (f != d)
{
post ("unpackxbee_input not a positive integer from 0 to 255");
@@ -141,7 +141,7 @@ static void unpackxbee_input(t_unpackxbee *x, t_symbol *s, int argc, t_atom *arg
if ((x->x_frame_length > 0)&&(x->x_frame_length + 4 == x->x_message_index))
{ /* end of frame reached */
k = x->x_frame_length+4; /* total packet length is payload + 1 start 2 length 1 checksum*/
- if(x->x_verbosity > 1)
+ if(x->x_verbosity > 0)
{
post("frame end");
for (j = 0; j < k; ++j)
@@ -160,7 +160,7 @@ static void unpackxbee_input(t_unpackxbee *x, t_symbol *s, int argc, t_atom *arg
post("unpackxbee: wrong checksum; dropping packet");
return;
}
- if(x->x_verbosity > 1) post("unpackxbee checksum %d [0x%02X]", checksum, checksum);
+ if(x->x_verbosity > 0) post("unpackxbee checksum %d [0x%02X]", checksum, checksum);
switch(x->x_frame_type)
{
case AT_Command:
@@ -230,7 +230,7 @@ static void unpackxbee_input(t_unpackxbee *x, t_symbol *s, int argc, t_atom *arg
||(AT_Command_Queue_Parameter_Value == x->x_frame_type)
)
{
- if (x->x_verbosity > 1)
+ if (x->x_verbosity > 0)
post("AT_Command_Response AT_Command AT_Command_Queue_Parameter_Value statuslength %d", statuslength);
SETFLOAT(&x->x_statusbuf[statuslength], x->x_frame_ID);
statuslength++;
@@ -257,8 +257,8 @@ buf[6]: 68 [0x44] D
buf[7]: 0 [0x00] status
*/
addr16 = (x->x_message[8]<<8) + x->x_message[9];
- sprintf(floatstring, "0x%X", addr16);
- SETSYMBOL(&x->x_statusbuf[statuslength], gensym(floatstring));
+ sprintf((char *)floatstring, "0x%X", addr16);
+ SETSYMBOL(&x->x_statusbuf[statuslength], gensym((char *)floatstring));
statuslength++;
/*
buf[8]: 121 [0x79] MY
@@ -282,11 +282,11 @@ buf[9]: 214 [0xD6]
addr64 <<= 8;
addr64 |= x->x_message[17];
#ifdef _MSC_VER
- sprintf(floatstring, "0x%016I64X", addr64);
+ sprintf((char *)floatstring, "0x%016I64X", addr64);
#else
- sprintf(floatstring, "0x%016LX", addr64);
+ sprintf((char *)floatstring, "0x%016LX", addr64);
#endif
- SETSYMBOL(&x->x_statusbuf[statuslength], gensym(floatstring)); /* addr64 */
+ SETSYMBOL(&x->x_statusbuf[statuslength], gensym((char *)floatstring)); /* addr64 */
statuslength++;
/*
buf[10]: 0 [0x00] SH
@@ -307,16 +307,16 @@ buf[17]: 30 [0x1E]
break;/* Node Identifier should be a null-terminated ascii string */
}
}
- SETSYMBOL(&x->x_statusbuf[statuslength], gensym(floatstring)); /* Node Identifier */
+ SETSYMBOL(&x->x_statusbuf[statuslength], gensym((char *)floatstring)); /* Node Identifier */
statuslength++;
/*
buf[18]: 32 [0x20] NI
buf[19]: 0 [0x00]
*/
addr16 = (x->x_message[i]<<8) + x->x_message[i+1];
- sprintf(floatstring, "0x%X", addr16);
+ sprintf((char *)floatstring, "0x%X", addr16);
i += 2;
- SETSYMBOL(&x->x_statusbuf[statuslength], gensym(floatstring)); /* parent addr16 */
+ SETSYMBOL(&x->x_statusbuf[statuslength], gensym((char *)floatstring)); /* parent addr16 */
statuslength++;
/*
buf[20]: 255 [0xFF] parent
@@ -334,17 +334,17 @@ buf[23]: 0 [0x00] source event
*/
addr16 = x->x_message[i++]<<8;
addr16 |= x->x_message[i++];
- sprintf(floatstring, "0x%X", addr16);
- SETSYMBOL(&x->x_statusbuf[statuslength], gensym(floatstring)); /* Profile ID */
+ sprintf((char *)floatstring, "0x%X", addr16);
+ SETSYMBOL(&x->x_statusbuf[statuslength], gensym((char *)floatstring)); /* Profile ID */
statuslength++;
/*
buf[24]: 193 [0xC1] Profile ID
buf[25]: 5 [0x05]
*/
addr16 = (x->x_message[i]<<8) + x->x_message[i+1];
- sprintf(floatstring, "0x%X", addr16);
+ sprintf((char *)floatstring, "0x%X", addr16);
i += 2;
- SETSYMBOL(&x->x_statusbuf[statuslength], gensym(floatstring)); /* Manufacturer ID */
+ SETSYMBOL(&x->x_statusbuf[statuslength], gensym((char *)floatstring)); /* Manufacturer ID */
statuslength++;
/*
buf[26]: 16 [0x10] Manufacturer ID
@@ -361,9 +361,71 @@ buf[28]: 36 [0x24] checksum
payloadstart = 8;
}
}
+/* RAT */
+ if (Remote_Command_Response == x->x_frame_type)
+ {
+ if (x->x_verbosity > 0)
+ post("Remote_Command_Response statuslength %d", statuslength);
+ SETFLOAT(&x->x_statusbuf[statuslength], x->x_frame_ID);
+ statuslength++;
+/*
+buf[0]: 126 [0x7E] packet start
+buf[1]: 0 [0x00] Length MSB
+
+buf[2]: 25 [0x19] Length LSB
+buf[3]: 151 [0x97] remote response frame type
+buf[4]: 5 [0x05] packet ID
+buf[5-12]: 0 [0x00] 64-bit source (remote) address
+buf[13-14]: 68 [0x44] 16-bit source address
+buf[15-16]: AT command
+buf[17]: status
+buf[18...] data
+*/
+
+ addr64 = x->x_message[5];
+ addr64 <<= 8;
+ addr64 |= x->x_message[6];
+ addr64 <<= 8;
+ addr64 |= x->x_message[7];
+ addr64 <<= 8;
+ addr64 |= x->x_message[8];
+ addr64 <<= 8;
+ addr64 |= x->x_message[9];
+ addr64 <<= 8;
+ addr64 |= x->x_message[10];
+ addr64 <<= 8;
+ addr64 |= x->x_message[11];
+ addr64 <<= 8;
+ addr64 |= x->x_message[12];
+#ifdef _MSC_VER
+ sprintf((char *)floatstring, "0x%016I64X", addr64);
+#else
+ sprintf((char *)floatstring, "0x%016LX", addr64);
+#endif
+ SETSYMBOL(&x->x_statusbuf[statuslength], gensym((char *)floatstring)); /* addr64 */
+ statuslength++;
+
+ addr16 = (x->x_message[13]<<8) + x->x_message[14];
+ sprintf((char *)floatstring, "0x%X", addr16);
+ SETSYMBOL(&x->x_statusbuf[statuslength], gensym((char *)floatstring));
+ statuslength++;
+ atbuf[0] = x->x_message[15]; /* the remote AT command string */
+ atbuf[1] = x->x_message[16];
+ atbuf[2] = '\0';
+ SETSYMBOL(&x->x_statusbuf[statuslength], gensym(atbuf));
+ statuslength++;
+
+ SETFLOAT(&x->x_statusbuf[statuslength], x->x_message[17]);/* AT command status */
+ statuslength++;
+ /* data doesn't include 1byte frame type 1byte ID 8byte addr64 2byte addr16 2byte AT command 1byte status = 15bytes */
+ SETFLOAT(&x->x_statusbuf[statuslength], x->x_frame_length-15);
+ statuslength++;
+ payloadstart = 18;
+ }
+/* RAT */
else if (ZigBee_Transmit_Status == x->x_frame_type)
{
- if (x->x_verbosity > 1)
+ if (x->x_verbosity > 0)
post("ZigBee_Transmit_Status statuslength %d", statuslength);
SETFLOAT(&x->x_statusbuf[statuslength], x->x_frame_ID);
statuslength++;
@@ -380,7 +442,7 @@ buf[28]: 36 [0x24] checksum
}
else if (ZigBee_Receive_Packet == x->x_frame_type)
{
- if (x->x_verbosity > 1)
+ if (x->x_verbosity > 0)
post("ZigBee_Receive_Packet statuslength %d", statuslength);
/* data doesn't include 1byte frametype, 8byte addr64, 2byte addr16, 1byte options = 12bytes*/
SETFLOAT(&x->x_statusbuf[statuslength], x->x_frame_length-12);
@@ -404,17 +466,17 @@ buf[28]: 36 [0x24] checksum
addr64 <<= 8;
addr64 |= x->x_message[i++];
#ifdef _MSC_VER
- sprintf(floatstring, "0x%016I64X", addr64);
+ sprintf((char *)floatstring, "0x%016I64X", addr64);
#else
- sprintf(floatstring, "0x%016LX", addr64);
+ sprintf((char *)floatstring, "0x%016LX", addr64);
#endif
- SETSYMBOL(&x->x_statusbuf[statuslength], gensym(floatstring)); /* addr64 */
+ SETSYMBOL(&x->x_statusbuf[statuslength], gensym((char *)floatstring)); /* addr64 */
statuslength++;
/* 16-bit source address */
addr16 = x->x_message[i++]<<8;
addr16 |= x->x_message[i++];
- sprintf(floatstring, "0x%X", addr16);
- SETSYMBOL(&x->x_statusbuf[statuslength], gensym(floatstring)); /* addr16 */
+ sprintf((char *)floatstring, "0x%X", addr16);
+ SETSYMBOL(&x->x_statusbuf[statuslength], gensym((char *)floatstring)); /* addr16 */
statuslength++;
/* receive options byte */
SETFLOAT(&x->x_statusbuf[statuslength], x->x_message[i++]);/* 1 2 32 64 */
@@ -424,7 +486,7 @@ buf[28]: 36 [0x24] checksum
}
else
{
- if (x->x_verbosity > 1)
+ if (x->x_verbosity > 0)
post("some other packet statuslength %d", statuslength);
SETFLOAT(&x->x_statusbuf[statuslength], x->x_frame_ID);/* may not be valid */
statuslength++;