project for nrf51822 qfab

Dependencies:   eddystone_URL mbed

Fork of eddystone_URL by vo dung

Files at this revision

API Documentation at this revision

Comitter:
tridung141196
Date:
Thu Nov 23 15:38:48 2017 +0000
Parent:
4:2386637c9c7c
Commit message:
ibeacon

Changed in this revision

TB6612FNG/TB6612.cpp Show diff for this revision Revisions of this file
TB6612FNG/TB6612.h Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 2386637c9c7c -r 267bdacf5508 TB6612FNG/TB6612.cpp
--- a/TB6612FNG/TB6612.cpp	Thu Nov 23 08:46:00 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,71 +0,0 @@
-/* wallbot mini Library
- *
- * wallbotmini.cpp
- *
- * Copyright (c) 2010-2013 jksoft
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-
-#include "TB6612.h"
-
-// TB6612 Class Constructor
-TB6612::TB6612(PinName pwm, PinName fwd, PinName rev):
-        _pwm(pwm), _fwd(fwd), _rev(rev) {
-
-    _fwd = 0;
-    _rev = 0;
-    _pwm = 0.0;
-    stat = 0;
-    _pwm.period(0.001);
-    
-}
-
-// Speed Control
-//  arg
-//   float speed -1.0 - 0.0 - 1.0
-float TB6612::speed(float speed) {
-    
-    
-    
-    if( speed > 0.0 )
-    {
-        if( speed > 0.7)    speed = 0.7;
-        _pwm = speed;
-        _fwd = 1;
-        _rev = 0;
-        stat = 1;
-    }
-    else if( speed < 0.0 )
-    {
-        if( speed < -0.7)    speed = -0.7;
-        _pwm = -speed;
-        _fwd = 0;
-        _rev = 1;
-        stat = -1;
-    }
-    else
-    {
-        _fwd = 1;
-        _rev = 1;
-        stat = 0;
-    }
-    return speed==0 ? 0 : speed > 0 ? 1 : -1;
-}
\ No newline at end of file
diff -r 2386637c9c7c -r 267bdacf5508 TB6612FNG/TB6612.h
--- a/TB6612FNG/TB6612.h	Thu Nov 23 08:46:00 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,92 +0,0 @@
-/* mbed TB6612FNG Library
- *
- * TB6612.h
- *
- * Copyright (c) 2010-2013 jksoft
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-#ifndef MBED_TB6612_H
-#define MBED_TB6612_H
-
-#include "mbed.h"
-
-/** TB6612FNG  Library
- *
- * Example:
- * @code
- * // Drive the Motor
-
-#include "mbed.h"
-#include "TB6612.h"
-
-TB6612 motor(p21,p5,p6);    // PWMA,AIN1,AIN2
- 
-int main() {
-
-    motor = 0.0;        // Motor stopped.
-
-    while(1)
-    {
-        motor = 0.5;    // Motor forward.
-        wait(2.0);
-        motor = -0.5;   // Motor reversal.
-        wait(2.0);
-    }
- }
-
- * @endcode
- */
-
-class TB6612 {
-    // Public functions
-public:
-    /** Create a TB6612 connected to the specified pins.
-     * @param pwm A PwmOut pin, driving the H-bridge enable line to control the speed.(PwmOutに対応したポートを指定します。)
-     * @param fwd A DigitalOut, set high when the motor should go forward.(DigitalOutに対応したポートを指定します。)
-     * @param rev A DigitalOut, set high when the motor should go backwards.(DigitalOutに対応したポートを指定します。)
-     */
-    TB6612(PinName pwm, PinName fwd, PinName rev);
-    /** Directly control the speed and direction of the motor
-     *
-     * @param speed A normalised number -1.0 - 1.0 represents the full range.
-     * @return return the stopped state or direction of rotation.
-     */
-    float speed(float speed);
-    /** A operator shorthand for speed()
-     *
-     */ 
-    void operator= ( float value )
-    {
-        speed(value);
-    }
-    operator int()
-    {
-        return(stat);
-    }
-    
-protected:
-    PwmOut _pwm;
-    DigitalOut _fwd;
-    DigitalOut _rev;
-    int stat;
-};
-
-#endif
diff -r 2386637c9c7c -r 267bdacf5508 main.cpp
--- a/main.cpp	Thu Nov 23 08:46:00 2017 +0000
+++ b/main.cpp	Thu Nov 23 15:38:48 2017 +0000
@@ -2,40 +2,26 @@
 #include "BLEDevice.h"
 
 BLEDevice  ble;
-static const uint16_t uuid16_list[]        = {0x00A0};
 const static uint8_t beaconPayload_url[] = {
-    0xaa,
-    0xfe,
- 
-    // URL
- 
-    0x10, // Frame Type
-    0x20, // Ranging Data
-    0x02, // URL Scheme (http:// = 0x02)
- 
-    'i',
-    'o',
-    't',
-    'm',
-    'a',
-    'k',
-    'e',
-    'r',
-    '.',
-    'v',
-    'n',
+                            0x4C, 0x00, //ID Company
+                            0x02,       //Type
+                            0x15,       //Length of data
+                            0xE2, 0x0A, 0x39, 0xF4, 0x73, 0xF5, 0x4B, 0xC4, //UUID
+                            0xA1, 0x2F, 0x17, 0xD1, 0xAD, 0x07, 0xA9, 0x61, //
+                            0x04, 0x62, //Major
+                            0x0D, 0x10, //Mirnor
+                            0xC8,       //Txpower 
+                            
+
 };
 int main(void)
 {
     ble.init();
-    ble.accumulateAdvertisingPayload(GapAdvertisingData::BREDR_NOT_SUPPORTED|GapAdvertisingData::LE_GENERAL_DISCOVERABLE);
- 
-    ble.accumulateAdvertisingPayload(GapAdvertisingData::COMPLETE_LIST_16BIT_SERVICE_IDS, (uint8_t *)uuid16_list, sizeof(uuid16_list));
- 
-    //ble.accumulateAdvertisingPayload(GapAdvertisingData::SERVICE_DATA,beaconPayload_uid, sizeof(beaconPayload_uid));
-    ble.accumulateAdvertisingPayload(GapAdvertisingData::SERVICE_DATA,beaconPayload_url, sizeof(beaconPayload_url));
-    //ble.accumulateAdvertisingPayload(GapAdvertisingData::SERVICE_DATA,beaconPayload_tlm, sizeof(beaconPayload_tlm));
- 
+    
+    ble.accumulateAdvertisingPayload(GapAdvertisingData::BREDR_NOT_SUPPORTED | GapAdvertisingData::LE_GENERAL_DISCOVERABLE );
+    
+    ble.accumulateAdvertisingPayload(GapAdvertisingData::MANUFACTURER_SPECIFIC_DATA, beaconPayload_url, sizeof(beaconPayload_url));
+    
     ble.setAdvertisingType(GapAdvertisingParams::ADV_NON_CONNECTABLE_UNDIRECTED);
  
     ble.setAdvertisingInterval(160);