Andriy Makukha / Mbed 2 deprecated football_project_wo_output

Dependencies:   mbed

Fork of football_project by MZJ

Committer:
AntonLS
Date:
Thu Feb 11 17:47:28 2016 +0000
Revision:
67:5650f461722a
Parent:
65:7addf8506bdb
Child:
68:0c96bb3d73a7
Radio message arch like old cones. Static or Auto node IDs.  Missed ack detect. Dark alert fix. Fixes cone death.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
elmbed 18:affef3a7db2a 1 #include <RFM69.h>
elmbed 18:affef3a7db2a 2 #include <SPI.h>
elmbed 23:26f27c462976 3 #include "types.h"
elmbed 23:26f27c462976 4 #include "TA.h"
elmbed 62:9b34dc1b265d 5 #include "DataStore.hh"
AntonLS 67:5650f461722a 6 #include "Radio.hh"
elmbed 18:affef3a7db2a 7
elmbed 44:4ad6133987ed 8 #define RADIO_STARTUP_ID 99
elmbed 18:affef3a7db2a 9 #define NETWORKID 101 //the same on all nodes that talk to each other
elmbed 18:affef3a7db2a 10
elmbed 18:affef3a7db2a 11 #define FREQUENCY RF69_915MHZ
elmbed 18:affef3a7db2a 12
elmbed 18:affef3a7db2a 13 //#define IS_RFM69HW //NOTE: uncomment this ONLY for RFM69HW or RFM69HCW
elmbed 18:affef3a7db2a 14 #define ENCRYPT_KEY "EncryptKey123456" // use same 16byte encryption key for all devices on net
elmbed 18:affef3a7db2a 15 #define LED 9 // Anardino miniWireless has LEDs on D9
elmbed 18:affef3a7db2a 16 #define SERIAL_BAUD 115200
elmbed 18:affef3a7db2a 17 #define VERSION "1.0"
elmbed 18:affef3a7db2a 18
elmbed 18:affef3a7db2a 19 #define MSGBUFSIZE 64 // message buffersize, but for this demo we only use:
elmbed 18:affef3a7db2a 20 // 1-byte NODEID + 4-bytes for time + 1-byte for temp in C + 2-bytes for vcc(mV)
elmbed 18:affef3a7db2a 21
elmbed 18:affef3a7db2a 22 //RFM69::RFM69(PinName PinName mosi, PinName miso, PinName sclk,slaveSelectPin, PinName int)
elmbed 23:26f27c462976 23 RFM69 radio(P0_24,P0_23,P0_25,P0_28,P0_7);
elmbed 18:affef3a7db2a 24
elmbed 23:26f27c462976 25 static bool promiscuousMode = true; // set 'true' to sniff all packets on the same network
elmbed 44:4ad6133987ed 26 extern unsigned long millis();
elmbed 44:4ad6133987ed 27
elmbed 62:9b34dc1b265d 28 extern bool is_master;
elmbed 18:affef3a7db2a 29
elmbed 44:4ad6133987ed 30 struct node_id_mapping
elmbed 44:4ad6133987ed 31 {
elmbed 44:4ad6133987ed 32 int mac;
elmbed 44:4ad6133987ed 33 int node_id;
elmbed 44:4ad6133987ed 34 };
elmbed 18:affef3a7db2a 35
elmbed 44:4ad6133987ed 36 struct extended_message
elmbed 44:4ad6133987ed 37 {
elmbed 44:4ad6133987ed 38 Message m;
elmbed 44:4ad6133987ed 39 int mac;
elmbed 44:4ad6133987ed 40 };
elmbed 23:26f27c462976 41
AntonLS 67:5650f461722a 42 struct prev_message // maybe TODO we could have an array of NUM_CONES of these.
AntonLS 67:5650f461722a 43 {
AntonLS 67:5650f461722a 44 Message m;
AntonLS 67:5650f461722a 45 uint8_t msgid;
AntonLS 67:5650f461722a 46 };
AntonLS 67:5650f461722a 47
AntonLS 65:7addf8506bdb 48 /*
elmbed 56:dccf9b22d594 49 int get_node_id()
elmbed 56:dccf9b22d594 50 {
elmbed 56:dccf9b22d594 51 return my_node_id == RADIO_STARTUP_ID ? 0 : my_node_id;
elmbed 56:dccf9b22d594 52 }
AntonLS 65:7addf8506bdb 53 */
elmbed 56:dccf9b22d594 54
AntonLS 67:5650f461722a 55 static node_id_mapping nodes[NUM_CONES] = {0};
elmbed 44:4ad6133987ed 56 static int node_idx = 0;
elmbed 44:4ad6133987ed 57 static int my_mac = 0;
elmbed 18:affef3a7db2a 58
elmbed 18:affef3a7db2a 59 void radio_init()
elmbed 18:affef3a7db2a 60 {
elmbed 62:9b34dc1b265d 61 radio.initialize(FREQUENCY, datastore_node_id(), NETWORKID);
elmbed 23:26f27c462976 62 radio.encrypt(0);
elmbed 23:26f27c462976 63 radio.promiscuous(promiscuousMode);
elmbed 23:26f27c462976 64 }
elmbed 23:26f27c462976 65
elmbed 56:dccf9b22d594 66 /* Gets the node ID which is associated with the
elmbed 56:dccf9b22d594 67 * given mac. If no ID has been given then zero
elmbed 56:dccf9b22d594 68 * is returned.
elmbed 56:dccf9b22d594 69 *
elmbed 56:dccf9b22d594 70 * @param mac - the mac address if the cone
elmbed 56:dccf9b22d594 71 * @returns ID if found else zero
elmbed 56:dccf9b22d594 72 */
elmbed 44:4ad6133987ed 73 static int get_node_id(int mac)
elmbed 44:4ad6133987ed 74 {
elmbed 44:4ad6133987ed 75 for (int i = 0; i < node_idx; ++i)
elmbed 44:4ad6133987ed 76 {
elmbed 44:4ad6133987ed 77 if (nodes[i].mac == mac)
elmbed 44:4ad6133987ed 78 {
elmbed 44:4ad6133987ed 79 return nodes[i].node_id;
elmbed 44:4ad6133987ed 80 }
elmbed 44:4ad6133987ed 81 }
elmbed 44:4ad6133987ed 82
elmbed 44:4ad6133987ed 83 return 0;
elmbed 44:4ad6133987ed 84 }
elmbed 28:8e74ddc4f70f 85
elmbed 56:dccf9b22d594 86 /* Process a radio startup message from the master.
elmbed 56:dccf9b22d594 87 *
elmbed 56:dccf9b22d594 88 * @param em - the message from the master
elmbed 56:dccf9b22d594 89 */
elmbed 44:4ad6133987ed 90 static void slave_process(extended_message *em)
elmbed 44:4ad6133987ed 91 {
elmbed 44:4ad6133987ed 92 if (em->m.command == 'R')
elmbed 44:4ad6133987ed 93 {
elmbed 44:4ad6133987ed 94 // We have been given a node id
elmbed 62:9b34dc1b265d 95 datastore_set_node_id(em->m.value);
elmbed 44:4ad6133987ed 96
elmbed 62:9b34dc1b265d 97 if( Dbg ) writeToPhone("NID: %d\r\n", datastore_node_id());
elmbed 44:4ad6133987ed 98
elmbed 44:4ad6133987ed 99 // Now reset the radio :)
AntonLS 67:5650f461722a 100 /// promiscuousMode = false;
elmbed 44:4ad6133987ed 101 radio_init();
elmbed 44:4ad6133987ed 102 }
elmbed 44:4ad6133987ed 103 }
elmbed 44:4ad6133987ed 104
elmbed 56:dccf9b22d594 105 /* Process a radio startup message from a slave.
elmbed 56:dccf9b22d594 106 *
elmbed 56:dccf9b22d594 107 * @param m - the message from the slave
elmbed 56:dccf9b22d594 108 */
elmbed 44:4ad6133987ed 109 static void master_process(Message *m)
elmbed 44:4ad6133987ed 110 {
elmbed 44:4ad6133987ed 111 byte payload[10] = {0};
elmbed 44:4ad6133987ed 112 int node_id = 0;
elmbed 44:4ad6133987ed 113
elmbed 44:4ad6133987ed 114 if (m->command == 'S')
elmbed 44:4ad6133987ed 115 {
elmbed 44:4ad6133987ed 116 // Message from a cone requesting an ID.
elmbed 44:4ad6133987ed 117 // The payload should be part of the MAC address
elmbed 44:4ad6133987ed 118 node_id = 0;
elmbed 44:4ad6133987ed 119
elmbed 44:4ad6133987ed 120 if (node_idx == 0)
elmbed 44:4ad6133987ed 121 {
elmbed 44:4ad6133987ed 122 node_id = 2;
elmbed 44:4ad6133987ed 123 }
elmbed 44:4ad6133987ed 124 else
elmbed 44:4ad6133987ed 125 {
elmbed 44:4ad6133987ed 126 node_id = nodes[node_idx-1].node_id + 1;
elmbed 44:4ad6133987ed 127 }
elmbed 44:4ad6133987ed 128
elmbed 44:4ad6133987ed 129 int node_found = get_node_id(m->value);
elmbed 44:4ad6133987ed 130
elmbed 44:4ad6133987ed 131 if (node_found == 0)
elmbed 44:4ad6133987ed 132 {
elmbed 44:4ad6133987ed 133 nodes[node_idx].node_id = node_id;
elmbed 44:4ad6133987ed 134 nodes[node_idx++].mac = m->value;
elmbed 44:4ad6133987ed 135 }
elmbed 44:4ad6133987ed 136 else
elmbed 44:4ad6133987ed 137 {
elmbed 44:4ad6133987ed 138 node_id = node_found;
elmbed 44:4ad6133987ed 139 }
elmbed 44:4ad6133987ed 140
AntonLS 67:5650f461722a 141 // Send the cone its ID
elmbed 44:4ad6133987ed 142 extended_message em;
elmbed 44:4ad6133987ed 143 em.m.cone = 99;
elmbed 44:4ad6133987ed 144 em.m.command = 'R';
elmbed 44:4ad6133987ed 145 em.m.value = node_id;
elmbed 44:4ad6133987ed 146 em.mac = m->value;
elmbed 44:4ad6133987ed 147
elmbed 44:4ad6133987ed 148 payload[0] = (byte)em.m.command;
elmbed 44:4ad6133987ed 149
elmbed 44:4ad6133987ed 150 payload[4] = (byte)em.m.value & 255;
elmbed 44:4ad6133987ed 151 payload[3] = (byte)(em.m.value >> 8);
elmbed 44:4ad6133987ed 152 payload[2] = (byte)(em.m.value >> 16);
elmbed 44:4ad6133987ed 153 payload[1] = (byte)(em.m.value >> 24);
elmbed 44:4ad6133987ed 154
elmbed 44:4ad6133987ed 155 payload[8] = (byte)em.mac & 255;
elmbed 44:4ad6133987ed 156 payload[7] = (byte)(em.mac >> 8);
elmbed 44:4ad6133987ed 157 payload[6] = (byte)(em.mac >> 16);
elmbed 44:4ad6133987ed 158 payload[5] = (byte)(em.mac >> 24);
AntonLS 67:5650f461722a 159
AntonLS 67:5650f461722a 160 radio.send( em.m.cone, payload, sizeof(payload), false ); //// NO ACK req.
AntonLS 67:5650f461722a 161 /// radio.send(em.m.cone, payload, sizeof(payload));
elmbed 44:4ad6133987ed 162
AntonLS 52:060fdec99780 163 if( Dbg ) writeToPhone("SND: %d %d 0x%x\r\n", em.m.cone, node_id, em.mac);
elmbed 44:4ad6133987ed 164 }
elmbed 44:4ad6133987ed 165 }
elmbed 28:8e74ddc4f70f 166
AntonLS 67:5650f461722a 167 void radio_send( Message *m, bool requestACK ) ////
elmbed 23:26f27c462976 168 {
elmbed 23:26f27c462976 169 static byte payload [6] = {0};
elmbed 23:26f27c462976 170
elmbed 23:26f27c462976 171 if (m == NULL)
elmbed 23:26f27c462976 172 {
elmbed 23:26f27c462976 173 return;
elmbed 23:26f27c462976 174 }
AntonLS 67:5650f461722a 175
AntonLS 52:060fdec99780 176 //if( Dbg ) writeToPhone("SM: %c to: %d frm: %d (%d)\r\n", m->command, m->cone, NODE_ID, m->value);
AntonLS 52:060fdec99780 177
elmbed 23:26f27c462976 178 payload[0] = (byte)m->command;
elmbed 44:4ad6133987ed 179
elmbed 23:26f27c462976 180 payload[4] = (byte)m->value & 255;
elmbed 23:26f27c462976 181 payload[3] = (byte)(m->value >> 8);
elmbed 23:26f27c462976 182 payload[2] = (byte)(m->value >> 16);
elmbed 23:26f27c462976 183 payload[1] = (byte)(m->value >> 24);
AntonLS 67:5650f461722a 184
AntonLS 67:5650f461722a 185 payload[5] = (byte)++TA::msg_id; //// Msg ID, was: = (byte)'%';
AntonLS 67:5650f461722a 186
AntonLS 67:5650f461722a 187 radio.send( m->cone, payload, sizeof(payload), requestACK ); ////
AntonLS 67:5650f461722a 188 }
AntonLS 67:5650f461722a 189
AntonLS 67:5650f461722a 190 void stompage_check()
AntonLS 67:5650f461722a 191 {
AntonLS 67:5650f461722a 192 if( --radio.INCNT != 0 )
AntonLS 67:5650f461722a 193 {
AntonLS 67:5650f461722a 194 writeToPhone( "LOST MSGS: %d\r\n", radio.INCNT );
AntonLS 67:5650f461722a 195 radio.INCNT = 0;
AntonLS 67:5650f461722a 196 }
elmbed 18:affef3a7db2a 197 }
elmbed 18:affef3a7db2a 198
elmbed 23:26f27c462976 199 bool radio_receive_complete()
elmbed 23:26f27c462976 200 {
elmbed 23:26f27c462976 201 return radio.receiveDone();
elmbed 23:26f27c462976 202 }
elmbed 23:26f27c462976 203
elmbed 23:26f27c462976 204 bool radio_receive(Message *m)
elmbed 23:26f27c462976 205 {
AntonLS 67:5650f461722a 206 bool retval = false;
AntonLS 67:5650f461722a 207
AntonLS 67:5650f461722a 208 //// For msg id feature...
AntonLS 67:5650f461722a 209 static prev_message mPrev;
AntonLS 67:5650f461722a 210 static long lastMsgAt = millis();
AntonLS 67:5650f461722a 211
elmbed 44:4ad6133987ed 212 Message lm;
elmbed 44:4ad6133987ed 213 extended_message em;
AntonLS 67:5650f461722a 214
AntonLS 67:5650f461722a 215 do
elmbed 23:26f27c462976 216 {
AntonLS 67:5650f461722a 217 if( m == NULL ) break;
AntonLS 67:5650f461722a 218
AntonLS 67:5650f461722a 219 if (radio.receiveDone())
AntonLS 67:5650f461722a 220 {
AntonLS 67:5650f461722a 221 if( radio.TARGETID == datastore_node_id() ) //// Check for stompage...
AntonLS 67:5650f461722a 222 {
AntonLS 67:5650f461722a 223 stompage_check();
AntonLS 67:5650f461722a 224
AntonLS 67:5650f461722a 225 if( radio.ACK_RECEIVED )
AntonLS 67:5650f461722a 226 {
AntonLS 67:5650f461722a 227 // We've received an ACK between retries.
AntonLS 67:5650f461722a 228 retval = true;
AntonLS 67:5650f461722a 229 break;
AntonLS 67:5650f461722a 230 }
AntonLS 67:5650f461722a 231 }
AntonLS 67:5650f461722a 232 if( !get_crc_ok() ) // CRC error will be rechecked/sent from caller.
AntonLS 67:5650f461722a 233 {
AntonLS 67:5650f461722a 234 retval = true;
AntonLS 67:5650f461722a 235 break;
AntonLS 67:5650f461722a 236 }
AntonLS 67:5650f461722a 237 if( radio.DATALEN < 6 )
AntonLS 67:5650f461722a 238 {
AntonLS 67:5650f461722a 239 RA_DEBUG( "Warn: Short packet\r\n" );
AntonLS 67:5650f461722a 240 RA_DEBUG( "Warn: Data len %d\r\n", radio.DATALEN );
AntonLS 67:5650f461722a 241 RA_DEBUG( "Warn: Cmd %c, Frm %d\r\n", radio.DATA[0], radio.SENDERID );
AntonLS 67:5650f461722a 242 break;
AntonLS 67:5650f461722a 243 }
AntonLS 67:5650f461722a 244
AntonLS 67:5650f461722a 245 lm.cone = radio.SENDERID;
AntonLS 67:5650f461722a 246 lm.command = radio.DATA[0];
AntonLS 67:5650f461722a 247
AntonLS 67:5650f461722a 248 lm.value = ((int)radio.DATA[1] << 24);
AntonLS 67:5650f461722a 249 lm.value |= ((int)radio.DATA[2] << 16);
AntonLS 67:5650f461722a 250 lm.value |= (((int)radio.DATA[3]) << 8);
AntonLS 67:5650f461722a 251 lm.value |= (radio.DATA[4]);
AntonLS 67:5650f461722a 252
AntonLS 67:5650f461722a 253 if (is_master && lm.command == 'S')
AntonLS 67:5650f461722a 254 {
AntonLS 67:5650f461722a 255 // Don't pass on radio startup messages
AntonLS 67:5650f461722a 256 master_process(&lm);
AntonLS 67:5650f461722a 257 break;
AntonLS 67:5650f461722a 258 }
AntonLS 67:5650f461722a 259 else if (!is_master && (NODE_ID == 99) && radio.TARGETID == RADIO_STARTUP_ID) //// NODE_ID check allows not using auto node IDs
AntonLS 67:5650f461722a 260 {
AntonLS 67:5650f461722a 261 em.mac = (int)radio.DATA[8] & 0xff;
AntonLS 67:5650f461722a 262 em.mac |= (int)radio.DATA[7] << 8;
AntonLS 67:5650f461722a 263 em.mac |= (int)radio.DATA[6] << 16;
AntonLS 67:5650f461722a 264 em.mac |= (int)radio.DATA[5] << 24;
elmbed 44:4ad6133987ed 265
AntonLS 67:5650f461722a 266 if( Dbg ) writeToPhone("RP: 0x%x\r\n", em.mac);
elmbed 44:4ad6133987ed 267
AntonLS 67:5650f461722a 268 if (em.mac != my_mac)
AntonLS 67:5650f461722a 269 {
AntonLS 67:5650f461722a 270 if( Dbg ) writeToPhone("DM 0x%x\r\n", em.mac);
AntonLS 67:5650f461722a 271 break; // This message was meant for someone else
AntonLS 67:5650f461722a 272 }
elmbed 44:4ad6133987ed 273
AntonLS 67:5650f461722a 274 memcpy(&em.m, &lm, sizeof(Message));
AntonLS 67:5650f461722a 275 slave_process(&em);
AntonLS 67:5650f461722a 276 }
AntonLS 67:5650f461722a 277 else if (radio.TARGETID == datastore_node_id())
AntonLS 67:5650f461722a 278 {
AntonLS 67:5650f461722a 279 memcpy(m, &lm, sizeof(Message));
AntonLS 67:5650f461722a 280
AntonLS 67:5650f461722a 281 //// Check if sender missed an ACK (Got duplicate of last msg, so ignore dup.)
AntonLS 67:5650f461722a 282 if( (millis() -lastMsgAt < 100) && //// Only consider as dup if w/in 100ms of prev.
AntonLS 67:5650f461722a 283 (mPrev.m.cone == m->cone) &&
AntonLS 67:5650f461722a 284 (mPrev.msgid == radio.DATA[5]) )
AntonLS 67:5650f461722a 285 { //// ASS-U-ME [for now] last msg is from same cone.
AntonLS 67:5650f461722a 286 RA_DEBUG( "Ignored dup cmd\r\n" );
AntonLS 67:5650f461722a 287 radio_send_ack();
AntonLS 67:5650f461722a 288 break;
AntonLS 67:5650f461722a 289 }
AntonLS 32:64e5d7340d82 290
AntonLS 67:5650f461722a 291 memcpy( &mPrev.m, m, sizeof( Message ) ); ////
AntonLS 67:5650f461722a 292 mPrev.msgid = radio.DATA[5]; ////
AntonLS 67:5650f461722a 293 lastMsgAt = millis(); ////
AntonLS 67:5650f461722a 294
AntonLS 67:5650f461722a 295 if( Dbg ) writeToPhone("GM: %d %c %d\r\n", radio.SENDERID, m->command, m->value);
AntonLS 67:5650f461722a 296 retval = true;
AntonLS 67:5650f461722a 297 }
AntonLS 67:5650f461722a 298 }
AntonLS 67:5650f461722a 299
AntonLS 67:5650f461722a 300 } while( false );
AntonLS 67:5650f461722a 301
AntonLS 67:5650f461722a 302 if( retval )
AntonLS 67:5650f461722a 303 {
AntonLS 67:5650f461722a 304 if( get_crc_ok() )
AntonLS 67:5650f461722a 305 RA_DEBUG( "M: %c %d r:%d\r\n", m->command, m->value, get_rssi() );
AntonLS 67:5650f461722a 306 if( get_fifo_ov() )
AntonLS 67:5650f461722a 307 RA_DEBUG( "Radio FIFO Overflow\r\n" );
elmbed 23:26f27c462976 308 }
AntonLS 67:5650f461722a 309
AntonLS 67:5650f461722a 310 return retval;
elmbed 23:26f27c462976 311 }
elmbed 23:26f27c462976 312
AntonLS 67:5650f461722a 313 void radio_send_ack() ////
AntonLS 67:5650f461722a 314 {
AntonLS 67:5650f461722a 315 radio.sendACK( "K", 1 );
AntonLS 67:5650f461722a 316 }
AntonLS 67:5650f461722a 317
AntonLS 67:5650f461722a 318 bool radio_ack_received( int cone )
elmbed 23:26f27c462976 319 {
AntonLS 67:5650f461722a 320 bool retval = radio.ACKReceived(cone);
AntonLS 67:5650f461722a 321
AntonLS 67:5650f461722a 322 if( retval && (radio.TARGETID == datastore_node_id()) )
AntonLS 67:5650f461722a 323 {
AntonLS 67:5650f461722a 324 stompage_check();
AntonLS 67:5650f461722a 325 }
AntonLS 67:5650f461722a 326
AntonLS 67:5650f461722a 327 return retval;
elmbed 23:26f27c462976 328 }
elmbed 23:26f27c462976 329
elmbed 56:dccf9b22d594 330 /* This is only needed for the slave cones, the master
elmbed 56:dccf9b22d594 331 * cone will just return.
elmbed 56:dccf9b22d594 332 *
elmbed 56:dccf9b22d594 333 * If the slave cone doesn't have a valid node ID send out
elmbed 56:dccf9b22d594 334 * the node ID request message to the master cone.
elmbed 56:dccf9b22d594 335 *
elmbed 56:dccf9b22d594 336 * @param mac - the mac address for this cone (currently the first two bytes)
elmbed 56:dccf9b22d594 337 */
elmbed 44:4ad6133987ed 338 void radio_loop(int mac)
elmbed 18:affef3a7db2a 339 {
elmbed 44:4ad6133987ed 340 static unsigned long last_send = 0L;
elmbed 44:4ad6133987ed 341 unsigned long current = millis();
elmbed 44:4ad6133987ed 342 Message m;
elmbed 44:4ad6133987ed 343
elmbed 44:4ad6133987ed 344 if (my_mac == 0)
elmbed 44:4ad6133987ed 345 {
AntonLS 67:5650f461722a 346 my_mac = mac;
elmbed 44:4ad6133987ed 347 }
elmbed 44:4ad6133987ed 348
elmbed 44:4ad6133987ed 349 if (is_master)
elmbed 44:4ad6133987ed 350 {
elmbed 44:4ad6133987ed 351 return; // Only needed for slave cones
elmbed 44:4ad6133987ed 352 }
AntonLS 67:5650f461722a 353
elmbed 62:9b34dc1b265d 354 if (datastore_node_id() != RADIO_STARTUP_ID && current - last_send > 1000L)
elmbed 44:4ad6133987ed 355 {
elmbed 62:9b34dc1b265d 356 if( Dbg ) writeToPhone("NID: %d\r\n", datastore_node_id());
elmbed 44:4ad6133987ed 357 last_send = current;
elmbed 44:4ad6133987ed 358 }
elmbed 44:4ad6133987ed 359
elmbed 44:4ad6133987ed 360 // Send out an i'm here message
elmbed 62:9b34dc1b265d 361 if (datastore_node_id() != RADIO_STARTUP_ID || current - last_send < 1000L)
elmbed 44:4ad6133987ed 362 {
elmbed 44:4ad6133987ed 363 return;
elmbed 44:4ad6133987ed 364 }
elmbed 44:4ad6133987ed 365
elmbed 44:4ad6133987ed 366 m.command = 'S';
elmbed 44:4ad6133987ed 367 m.cone = 1;
elmbed 44:4ad6133987ed 368 m.value = my_mac;
elmbed 44:4ad6133987ed 369
AntonLS 52:060fdec99780 370 if( Dbg ) writeToPhone("SNM\r\n");
elmbed 44:4ad6133987ed 371
elmbed 44:4ad6133987ed 372 last_send = current;
elmbed 44:4ad6133987ed 373
AntonLS 67:5650f461722a 374 radio_send( &m, false ); ////
AntonLS 67:5650f461722a 375 /// radio_send(&m);
AntonLS 67:5650f461722a 376 }
AntonLS 67:5650f461722a 377
AntonLS 67:5650f461722a 378
AntonLS 67:5650f461722a 379
AntonLS 67:5650f461722a 380 int16_t get_rssi()
AntonLS 67:5650f461722a 381 {
AntonLS 67:5650f461722a 382 return radio.RSSI;
elmbed 18:affef3a7db2a 383 }
elmbed 23:26f27c462976 384
AntonLS 67:5650f461722a 385 bool get_crc_ok()
AntonLS 67:5650f461722a 386 {
AntonLS 67:5650f461722a 387 return radio.CRCOK;
AntonLS 67:5650f461722a 388 }
AntonLS 67:5650f461722a 389
AntonLS 67:5650f461722a 390 bool get_fifo_ov()
AntonLS 67:5650f461722a 391 {
AntonLS 67:5650f461722a 392 return radio.FIFOV;
AntonLS 67:5650f461722a 393 }
AntonLS 67:5650f461722a 394
AntonLS 67:5650f461722a 395 // for debugging
AntonLS 67:5650f461722a 396 void read_all_regs()
AntonLS 67:5650f461722a 397 {
AntonLS 67:5650f461722a 398 radio.readAllRegs();
AntonLS 67:5650f461722a 399 }
AntonLS 67:5650f461722a 400