static int _ss_send_attributes_payload(struct ss_device *dev)
{
   if (!dev->connected)
      return 0;

   _ss_build_attributes_payload(dev);

   return USB_WriteCtrlMsgAsync(dev->fd,
         USB_REQTYPE_INTERFACE_SET,
         USB_REQ_SETREPORT,
         (USB_REPTYPE_OUTPUT<<8) | 0x01,
         0x0,
         sizeof(_ss_attributes_payload),
         _ss_attributes_payload,
         NULL, NULL);  
}
Esempio n. 2
0
static s32 __USB_CtrlMsgTimeout(usbstorage_handle *dev, u8 bmRequestType, u8 bmRequest, u16 wValue, u16 wIndex, u16 wLength, void *rpData)
{
	s32 retval;

	dev->retval = USBSTORAGE_PROCESSING;
	retval = USB_WriteCtrlMsgAsync(dev->usb_fd, bmRequestType, bmRequest, wValue, wIndex, wLength, rpData, __usb_blkmsg_cb, (void *)dev);
	if(retval < 0) return retval;

	__usb_settimeout(dev, usbtimeout);

	do {
		retval = dev->retval;
		if(retval!=USBSTORAGE_PROCESSING) break;
		else LWP_ThreadSleep(__usbstorage_waitq);
	} while(retval==USBSTORAGE_PROCESSING);

	return retval;
}
int ss_get_mac(struct ss_device *dev, uint8_t *mac)
{
   uint8_t ATTRIBUTE_ALIGN(32) msg[8];
   int ret = USB_WriteCtrlMsgAsync(dev->fd,
         USB_REQTYPE_INTERFACE_GET,
         USB_REQ_GETREPORT,
         (USB_REPTYPE_FEATURE<<8) | 0xf5,
         0,
         sizeof(msg),
         msg,
         NULL, NULL);

   mac[0] = msg[2];
   mac[1] = msg[3];
   mac[2] = msg[4];
   mac[3] = msg[5];
   mac[4] = msg[6];
   mac[5] = msg[7];
   return ret;
}
   mac[1] = msg[3];
   mac[2] = msg[4];
   mac[3] = msg[5];
   mac[4] = msg[6];
   mac[5] = msg[7];
   return ret;
}

int ss_set_mac(struct ss_device *dev, const uint8_t *mac)
{
   uint8_t ATTRIBUTE_ALIGN(32) msg[] = {0x01, 0x00, mac[0], mac[1],
      mac[2], mac[3], mac[4], mac[5]};
   int ret = USB_WriteCtrlMsgAsync(dev->fd,
         USB_REQTYPE_INTERFACE_SET,
         USB_REQ_SETREPORT,
         (USB_REPTYPE_FEATURE<<8) | 0xf5,
         0,
         sizeof(msg),
         msg,
         NULL, NULL);
   return ret;
}


static int _ss_read(struct ss_device *dev)
{
   return USB_WriteCtrlMsgAsync(
         dev->fd,
         USB_REQTYPE_INTERFACE_GET,
         USB_REQ_GETREPORT,
         (USB_REPTYPE_INPUT<<8) | 0x01,
         0x0,