cancel
Showing results for 
Search instead for 
Did you mean: 

Send 20 bytes payload with p2p-Service

ABabi.1
Associate II

Hello all,

I want to modify the p2p-Service for sending 20 bytes payload instead of only 2 bytes by default.

The only one I did, is changing the notification-characteristic in the file "p2p_stm.c" like this:

 COPY_P2P_NOTIFY_UUID(uuid16.Char_UUID_128);
    aci_gatt_add_char(aPeerToPeerContext.PeerToPeerSvcHdle,
                      UUID_TYPE_128, &uuid16,
                      20,
                      CHAR_PROP_NOTIFY,
                      ATTR_PERMISSION_NONE,
                      GATT_NOTIFY_ATTRIBUTE_WRITE, /* gattEvtMask */
                      10, /* encryKeySize */
                      1, /* isVariable: 1 */
                      &(aPeerToPeerContext.P2PNotifyServerToClientCharHdle));
 

There, I have only changed the payload in line 4 from 2 to 20. Are there any further modifications in the code in any file neccessary, for doing what I want? This is my typedef struct in "p2p_server_app.c":

 typedef struct{
    uint8_t             Device_Led_Selection;
    uint8_t             Led1;
 }P2P_LedCharValue_t;
 
typedef struct{
    uint8_t             Device_Selection;
    uint8_t             Button_State;
 
   uint8_t		Value_X_Axis_H;
   uint8_t		Value_X_Axis_L;
   uint8_t		Value_Y_Axis_H;
   uint8_t		Value_Y_Axis_L;
   uint8_t		Value_Z_Axis_H;
   uint8_t		Value_Z_Axis_L;
   uint32_t	Timestamp;
    
 }P2P_ButtonCharValue_t;
 
 
typedef struct
{
  uint8_t                            Notification_Status;
  P2P_LedCharValue_t    LedControl;
  uint16_t			   Parameter;
  P2P_ButtonCharValue_t     Acceleration;
  uint16_t                          ConnectionHandle;
} P2P_Button_LED_App_Context_t;

As you will see, I´m send acceleration data for 3 axis and also trying to send a 32bit timestamp in microseconds. And sending the acceleration data works very well, but the timestamp not. The timestamp will be send only approximately each 15 second, it seems like. This is how I send the data:

void calculate_timestamp(void){
 
	uint8_t time_micro32_1 = time_micro32 & 0xFF;
	uint8_t time_micro32_2 = (time_micro32 >> 8) & 0xFF;
	uint8_t time_micro32_3 = (time_micro32 >> 16) & 0xFF;
	uint8_t time_micro32_4 = (time_micro32 >> 24) & 0xFF;
 
   	P2P_Server_App_Context.Acceleration.Timestamp = time_micro32_1; 
   	P2P_Server_App_Context.Acceleration.Timestamp = time_micro32_2; 
	P2P_Server_App_Context.Acceleration.Timestamp = time_micro32_3;
        P2P_Server_App_Context.Acceleration.Timestamp = time_micro32_4;
}
 
void get_acceleration(void){
 
		    P2P_Server_App_Context.Acceleration.Value_X_Axis_H = sendbuf[0];
		    P2P_Server_App_Context.Acceleration.Value_X_Axis_L = sendbuf[1];
 
		    P2P_Server_App_Context.Acceleration.Value_Y_Axis_H = sendbuf[2];
		    P2P_Server_App_Context.Acceleration.Value_Y_Axis_L = sendbuf[3];
 
		    P2P_Server_App_Context.Acceleration.Value_Z_Axis_H = sendbuf[4];
		    P2P_Server_App_Context.Acceleration.Value_Z_Axis_L = sendbuf[5];

I call the methods get_acceleration() and calculate_timestamp() in each run.

Any idea why sending the timestamp not works? Is it the payload like I thought, or is can there be an another reason?

Thank you...

1 ACCEPTED SOLUTION

Accepted Solutions

You write the timestamp value 4 times, finally with a value of micro seconds divided by roughly 16,000​,000

It is a 32-bit value, just set once with time_micro32 and be done.​

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

View solution in original post

3 REPLIES 3

How would setting the same variable 4 times work?​

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
ABabi.1
Associate II

Can you explain that further, please?

You write the timestamp value 4 times, finally with a value of micro seconds divided by roughly 16,000​,000

It is a 32-bit value, just set once with time_micro32 and be done.​

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..