Modificacion de https://mbed.org/cookbook/RFID-Tweeter para soporte de un tag no enlistado y registro del mismo mediante twiter

Dependencies:   EthernetNetIf HTTPClient_ToBeRemoved mbed

Committer:
sherckuith
Date:
Sun Oct 28 04:49:16 2012 +0000
Revision:
0:8df845fb13c7
Modificacion de https://mbed.org/cookbook/RFID-Tweeter para soporte de un tag no valido y registro en twiter.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
sherckuith 0:8df845fb13c7 1 /* mbed ID12 RFID Library
sherckuith 0:8df845fb13c7 2 * Copyright (c) 2007-2010, sford, http://mbed.org
sherckuith 0:8df845fb13c7 3 *
sherckuith 0:8df845fb13c7 4 * Permission is hereby granted, free of charge, to any person obtaining a copy
sherckuith 0:8df845fb13c7 5 * of this software and associated documentation files (the "Software"), to deal
sherckuith 0:8df845fb13c7 6 * in the Software without restriction, including without limitation the rights
sherckuith 0:8df845fb13c7 7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
sherckuith 0:8df845fb13c7 8 * copies of the Software, and to permit persons to whom the Software is
sherckuith 0:8df845fb13c7 9 * furnished to do so, subject to the following conditions:
sherckuith 0:8df845fb13c7 10 *
sherckuith 0:8df845fb13c7 11 * The above copyright notice and this permission notice shall be included in
sherckuith 0:8df845fb13c7 12 * all copies or substantial portions of the Software.
sherckuith 0:8df845fb13c7 13 *
sherckuith 0:8df845fb13c7 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
sherckuith 0:8df845fb13c7 15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
sherckuith 0:8df845fb13c7 16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
sherckuith 0:8df845fb13c7 17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
sherckuith 0:8df845fb13c7 18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
sherckuith 0:8df845fb13c7 19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
sherckuith 0:8df845fb13c7 20 * THE SOFTWARE.
sherckuith 0:8df845fb13c7 21 */
sherckuith 0:8df845fb13c7 22
sherckuith 0:8df845fb13c7 23 #include "ID12RFID.h"
sherckuith 0:8df845fb13c7 24
sherckuith 0:8df845fb13c7 25 #include "mbed.h"
sherckuith 0:8df845fb13c7 26
sherckuith 0:8df845fb13c7 27 ID12RFID::ID12RFID(PinName rx)
sherckuith 0:8df845fb13c7 28 : _rfid(NC, rx) {
sherckuith 0:8df845fb13c7 29 }
sherckuith 0:8df845fb13c7 30
sherckuith 0:8df845fb13c7 31 int ID12RFID::readable() {
sherckuith 0:8df845fb13c7 32 return _rfid.readable();
sherckuith 0:8df845fb13c7 33 }
sherckuith 0:8df845fb13c7 34
sherckuith 0:8df845fb13c7 35 int ID12RFID::read() {
sherckuith 0:8df845fb13c7 36 while (_rfid.getc() != 2);
sherckuith 0:8df845fb13c7 37
sherckuith 0:8df845fb13c7 38 int v = 0;
sherckuith 0:8df845fb13c7 39 _rfid.getc(); // drop 1st 2 bytes - we actually only read the lower 32-bits of the code
sherckuith 0:8df845fb13c7 40 _rfid.getc();
sherckuith 0:8df845fb13c7 41
sherckuith 0:8df845fb13c7 42 for (int i=7; i>=0; i--) {
sherckuith 0:8df845fb13c7 43 char c = _rfid.getc(); // a ascii hex char
sherckuith 0:8df845fb13c7 44 int part = c - '0';
sherckuith 0:8df845fb13c7 45 v |= part << (i * 4);
sherckuith 0:8df845fb13c7 46 }
sherckuith 0:8df845fb13c7 47
sherckuith 0:8df845fb13c7 48 for (int i=0; i<5; i++) {
sherckuith 0:8df845fb13c7 49 _rfid.getc();
sherckuith 0:8df845fb13c7 50 }
sherckuith 0:8df845fb13c7 51
sherckuith 0:8df845fb13c7 52 return v;
sherckuith 0:8df845fb13c7 53 }