examples of simple peripheral/central ble transmission nrf52 series

I am very familiar with PICs and some atmega stuff, just graduated university ee and the project I am working on requires transmitting very small amounts of data continuously via ble protocol. Actually transmitting real time gyroscope data. Nrf modules seemed the easiest/cheapest for our purpose and decided we would most likely end up going with someones 52 series module. I have been playing around awhile with the nordic 52 development board however I am finding the learning curve fairly steep with zephyr. I can do basic stuff, gpio, pwm, interrupts etc but am struggling with bluetooth. Would it be possible to get an example of a central device and peripheral device with a custom service and characteristic 128, that simply sends or receives 24 or more bits of data at a time.   I'm really trying to learn this and just feel myself lost, thanks.  I have been through many of the peripheral and central zephyr examples.

Parents
  • Hi,

    Yes, you may keep this ticket open if you would like so for follow up questions which are related to the topic in this ticket. If you have new questions, I will of course try to reply and answer to them, but I would recommend to create new tickets for unique questions and cases.

    And also yes, I would say this type of ticket is something that is perfect as a public ticket as there are very likely more out there with the same questions and in the same situation, so go ahead and convert it if you're comfortable with that!

    Kind regards,
    Andreas

  • after much experimenting I seem to be getting this error from the second example. 

  • ////this is .h
    
    #include <zephyr.h>
    #include <logging/log.h>
    
    #include <bluetooth/bluetooth.h>
    #include <bluetooth/uuid.h>
    #include <bluetooth/gatt.h>
    #include <bluetooth/hci.h>
    
    #define MY_SERVICE_UUID 0xd4, 0x86, 0x48, 0x24, 0x54, 0xB3, 0x43, 0xA1, \
    			            0xBC, 0x20, 0x97, 0x8F, 0xC3, 0x76, 0xC2, 0x75
    
    #define RX_CHARACTERISTIC_UUID  0xA6, 0xE8, 0xC4, 0x60, 0x7E, 0xAA, 0x41, 0x6B, \
    			                    0x95, 0xD4, 0x9D, 0xCC, 0x08, 0x4F, 0xCF, 0x6A
    
    #define TX_CHARACTERISTIC_UUID  0xED, 0xAA, 0x20, 0x11, 0x92, 0xE7, 0x43, 0x5A, \
    			                    0xAA, 0xE9, 0x94, 0x43, 0x35, 0x6A, 0xD4, 0xD3
    
    /** @brief Callback type for when new data is received. */
    typedef void (*data_rx_cb_t)(uint8_t *data, uint8_t length);
    
    /** @brief Callback struct used by the my_service Service. */
    struct my_service_cb 
    {
    	/** Data received callback. */
    	data_rx_cb_t    data_rx_cb;
    };
    
    int my_service_init(void);
    
    void my_service_send(struct bt_conn *conn, const uint8_t *data, uint16_t len);
    
    
    
    

Reply
  • ////this is .h
    
    #include <zephyr.h>
    #include <logging/log.h>
    
    #include <bluetooth/bluetooth.h>
    #include <bluetooth/uuid.h>
    #include <bluetooth/gatt.h>
    #include <bluetooth/hci.h>
    
    #define MY_SERVICE_UUID 0xd4, 0x86, 0x48, 0x24, 0x54, 0xB3, 0x43, 0xA1, \
    			            0xBC, 0x20, 0x97, 0x8F, 0xC3, 0x76, 0xC2, 0x75
    
    #define RX_CHARACTERISTIC_UUID  0xA6, 0xE8, 0xC4, 0x60, 0x7E, 0xAA, 0x41, 0x6B, \
    			                    0x95, 0xD4, 0x9D, 0xCC, 0x08, 0x4F, 0xCF, 0x6A
    
    #define TX_CHARACTERISTIC_UUID  0xED, 0xAA, 0x20, 0x11, 0x92, 0xE7, 0x43, 0x5A, \
    			                    0xAA, 0xE9, 0x94, 0x43, 0x35, 0x6A, 0xD4, 0xD3
    
    /** @brief Callback type for when new data is received. */
    typedef void (*data_rx_cb_t)(uint8_t *data, uint8_t length);
    
    /** @brief Callback struct used by the my_service Service. */
    struct my_service_cb 
    {
    	/** Data received callback. */
    	data_rx_cb_t    data_rx_cb;
    };
    
    int my_service_init(void);
    
    void my_service_send(struct bt_conn *conn, const uint8_t *data, uint16_t len);
    
    
    
    

Children
No Data
Related